support all keyboard keys

origin
ob1kenewb 23 years ago
parent 9c57577783
commit 0c2b175eaa

@ -16,15 +16,16 @@ void keybinput_new (_keybinput *ki) {
int keybinput_loop (_keybinput *ki, SDL_Event *event) { int keybinput_loop (_keybinput *ki, SDL_Event *event) {
int key = 0; int key = 0, keyu = 0;
ki->changed = 0; ki->changed = 0;
if (event->type == SDL_KEYUP) if (event->type == SDL_KEYUP)
keybinput_oldkey = 0; keybinput_oldkey = 0;
if (event->type == SDL_KEYDOWN && keybinput_oldkey != event->key.keysym.sym) { if (event->type == SDL_KEYDOWN && keybinput_oldkey != event->key.keysym.sym) {
key = keybinput_oldkey = event->key.keysym.sym; key = keybinput_oldkey = event->key.keysym.sym;
keyu = event->key.keysym.unicode;
if (key == 8) { // BACKSPACE if (key == 8) { // BACKSPACE
if (ki->curpos > 0) { if (ki->curpos > 0) {
@ -33,7 +34,7 @@ int keybinput_loop (_keybinput *ki, SDL_Event *event) {
ki->changed = 1; ki->changed = 1;
} }
} }
else if (key >= ' ' && key <= 'z') { else if ((keyu >= 32 && keyu <= 126) || (keyu >= 128 && keyu <= 255)) { // International keyboard support
if (ki->curpos < 255) { if (ki->curpos < 255) {
ki->text[ki->curpos++] = event->key.keysym.unicode; ki->text[ki->curpos++] = event->key.keysym.unicode;
ki->text[ki->curpos] = 0; ki->text[ki->curpos] = 0;

@ -1,4 +1,4 @@
/* $Id: menu.c,v 1.4 2003/05/04 19:23:00 ob1kenewb Exp $ */ /* $Id: menu.c,v 1.5 2003/05/04 21:00:30 ob1kenewb Exp $ */
/* menu's for the game */ /* menu's for the game */
#include <SDL.h> #include <SDL.h>
@ -250,8 +250,8 @@ menu_get_text (char *title, char *text, int len)
keypressed = 1; keypressed = 1;
} }
for (i = ' '; i <= 'z'; i++) for (i = ' '; i <= 255; i++)
if (!keypressed && keys[i] && event.type == SDL_KEYDOWN) { if (i != 127 && !keypressed && keys[i] && event.type == SDL_KEYDOWN) {
if (t[curpos] == 0) if (t[curpos] == 0)
t[curpos + 1] = 0; t[curpos + 1] = 0;
t[curpos] = event.key.keysym.unicode; t[curpos] = event.key.keysym.unicode;

Loading…
Cancel
Save