Clear up SDL_KEYDOWN/SDL_TEXTINPUT logic

This commit is contained in:
Andrew Alderwick 2022-01-04 01:12:03 +00:00
parent 4789d8ccef
commit 205f63cc43
1 changed files with 8 additions and 9 deletions

View File

@ -465,20 +465,19 @@ run(Uxn *u)
else if(event.type == SDL_MOUSEWHEEL) else if(event.type == SDL_MOUSEWHEEL)
mouse_scroll(devmouse, event.wheel.x, event.wheel.y); mouse_scroll(devmouse, event.wheel.x, event.wheel.y);
/* Controller */ /* Controller */
else if(event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) { else if(event.type == SDL_TEXTINPUT)
if(event.type == SDL_TEXTINPUT) controller_key(devctrl, event.text.text[0]);
controller_key(devctrl, event.text.text[0]); else if(event.type == SDL_KEYDOWN) {
else if(get_key(&event)) int ksym;
if(get_key(&event))
controller_key(devctrl, get_key(&event)); controller_key(devctrl, get_key(&event));
else if(get_button(&event)) else if(get_button(&event))
controller_down(devctrl, get_button(&event)); controller_down(devctrl, get_button(&event));
else else
do_shortcut(u, &event); do_shortcut(u, &event);
if(event.type == SDL_KEYDOWN) { ksym = event.key.keysym.sym;
int ksym = event.key.keysym.sym; if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym)
if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym) break;
break;
}
} else if(event.type == SDL_KEYUP) } else if(event.type == SDL_KEYUP)
controller_up(devctrl, get_button(&event)); controller_up(devctrl, get_button(&event));
else if(event.type == SDL_JOYAXISMOTION) { else if(event.type == SDL_JOYAXISMOTION) {