File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -14,27 +14,34 @@ pub const fn null<T>() -> *mut T { 0 as *mut T }
14
14
pub extern "C" fn main ( ) -> ! {
15
15
unsafe {
16
16
consoleInit ( null ( ) ) ;
17
- gfxInitDefault ( ) ;
18
17
19
- printf ( "\x1b [16;16HPress PLUS to exit." . as_ptr ( ) as * const i8 ) ;
18
+ let mut k_held_old = HidControllerKeys ( 0 ) ;
19
+
20
+ printf ( "\x1b [1;1HPress PLUS to exit.\n " . as_ptr ( ) as * const i8 ) ;
21
+ printf ( "\x1b [2;1HOr any other key to see its value.\n " . as_ptr ( ) as * const i8 ) ;
20
22
21
23
while appletMainLoop ( ) {
22
24
hidScanInput ( ) ;
25
+ let k_held = HidControllerKeys ( hidKeysHeld ( HidControllerID :: CONTROLLER_P1_AUTO ) as u32 ) ;
23
26
24
- let k_down = HidControllerKeys ( hidKeysDown ( HidControllerID :: CONTROLLER_P1_AUTO ) as u32 ) ;
25
-
26
- if k_down == HidControllerKeys :: KEY_PLUS {
27
+ if k_held == HidControllerKeys :: KEY_PLUS {
27
28
break ;
28
29
}
29
30
30
- printf ( "This key is pressed: %d\n " . as_ptr ( ) as * const i8 , k_down) ;
31
+ if k_held != k_held_old {
32
+ consoleClear ( ) ;
33
+
34
+ printf ( "\x1b [1;1HPress PLUS to exit.\n " . as_ptr ( ) as * const i8 ) ;
35
+ printf ( "\x1b [2;1HOr any other key to see its value.\n " . as_ptr ( ) as * const i8 ) ;
36
+ printf ( "\x1b [3;1HThis key is currently pressed: %d\n " . as_ptr ( ) as * const i8 , k_held) ;
37
+ }
38
+
39
+ k_held_old = k_held;
31
40
32
- gfxFlushBuffers ( ) ;
33
- gfxSwapBuffers ( ) ;
34
- gfxWaitForVsync ( ) ;
41
+ consoleUpdate ( null ( ) ) ;
35
42
}
36
43
37
- gfxExit ( ) ;
44
+ consoleExit ( null ( ) ) ;
38
45
panic ! ( "Success. We shall however think on a way of exiting cleanly." ) ;
39
46
}
40
47
}
You can’t perform that action at this time.
0 commit comments