libwiikeyboard : space key problem May 27, 2010 04:35PM | Registered: 16 years ago Posts: 74 |
if (KEYBOARD_Init(keyPress_cb) == 0) printf("keyboard initialised\n"); char cmd[32]; do { // Call WPAD_ScanPads each loop, this reads the latest controller states WPAD_ScanPads(); // WPAD_ButtonsDown tells us which buttons were pressed in this loop // this is a "one shot" state which will not fire again until the button has been released u32 pressed = WPAD_ButtonsDown(0); //char key = getchar(); scanf("%s", cmd);
void keyPress_cb(char sym) { if (sym == 13) putchar('\n'); //else if (sym == 32) putchar(' '); else if (sym > 32 ) putchar(sym); else if ( sym == 0x1b) quitapp = true; }
Re: libwiikeyboard : space key problem May 28, 2010 12:34AM | Registered: 15 years ago Posts: 444 |
Re: libwiikeyboard : space key problem May 28, 2010 01:26PM | Registered: 16 years ago Posts: 74 |
Re: libwiikeyboard : space key problem May 28, 2010 03:58PM | Registered: 15 years ago Posts: 379 |
Quote
String of characters. This will read subsequent characters until a whitespace is found (whitespace characters are considered to be blank, newline and tab).
Re: libwiikeyboard : space key problem May 30, 2010 03:48AM | Registered: 16 years ago Posts: 73 |
scanf("%31[0-9a-zA-Z \t]", cmd);
Re: libwiikeyboard : space key problem May 31, 2010 02:29AM | Registered: 16 years ago Posts: 74 |
Re: libwiikeyboard : space key problem June 01, 2010 05:54AM | Registered: 16 years ago Posts: 73 |
--- libwiikeyboard/keyboard.c.orig 2009-11-11 11:37:47.000000000 -0500 +++ libwiikeyboard/keyboard.c 2010-02-27 09:27:52.000000000 -0500 @@ -434,9 +434,10 @@ while (!_kbd_thread_quit) { if (((_keyBuffer.tail+1)&255) != _keyBuffer.head) { if ( KEYBOARD_GetEvent(&event)) { - if (event.type == KEYBOARD_PRESSED) { - _keyBuffer.buf[_keyBuffer.tail] = event.symbol; - _keyBuffer.tail++; + if ( (event.type == KEYBOARD_PRESSED) + && (event.symbol < 255)) { + _keyBuffer.buf[_keyBuffer.tail] = event.symbol; + _keyBuffer.tail++; } } }I added the '&& (event.symbol < 255))' part. This might not be the ideal solution, but it's what I've been using without any problems.
Re: libwiikeyboard : space key problem June 02, 2010 02:52PM | Registered: 16 years ago Posts: 74 |
char cur_input; for(i=0; i <= BUFFER_SIZE; i++) { cur_input = getc(stdin); if(cur_input != 13){ cmd = cur_input; } else{ cmd = '\0'; break; } }
Re: libwiikeyboard : space key problem June 02, 2010 04:39PM | Registered: 15 years ago Posts: 379 |
Re: libwiikeyboard : space key problem June 02, 2010 04:41PM | Registered: 16 years ago Posts: 73 |
Quote
TheDrev
Unfortunatly, With scanf or fgets I am using the AltGr key to 'submit' the input (the Return key do not submit, only add the scan code 13)
Re: libwiikeyboard : space key problem June 04, 2010 03:21AM | Registered: 16 years ago Posts: 74 |
if ( (event.type == KEYBOARD_PRESSED) && (event.symbol != 61697) && (event.symbol != 61698) ) { _keyBuffer.buf[_keyBuffer.tail] = event.symbol; _keyBuffer.tail++; }
int __scanf (const char *format, ...) { va_list arg; int done; va_start (arg, format); done = INTUSE(_IO_vfscanf) (stdin, format, arg, NULL); va_end (arg); return done; } ldbl_strong_alias (__scanf, scanf)