commit 51b9c699b8a54e0a99fe63fd68c02ee4d066adbe
parent 87507f7f033cd9effe0df8ed80700c43be6310c2
Author: neauoire <aliceffekt@gmail.com>
Date: Mon, 27 Dec 2021 13:37:37 -0800
Mini fix to controller button order
Diffstat:
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/devices/controller.c b/src/devices/controller.c
@@ -16,21 +16,25 @@ WITH REGARD TO THIS SOFTWARE.
void
controller_down(Device *d, Uint8 mask)
{
- d->dat[2] |= mask;
- uxn_eval(d->u, d->vector);
+ if(mask) {
+ d->dat[2] |= mask;
+ uxn_eval(d->u, d->vector);
+ }
}
void
controller_up(Device *d, Uint8 mask)
{
- d->dat[2] &= (~mask);
- uxn_eval(d->u, d->vector);
+ if(mask) {
+ d->dat[2] &= (~mask);
+ uxn_eval(d->u, d->vector);
+ }
}
void
controller_key(Device *d, Uint8 key)
{
- if(!key) {
+ if(key) {
d->dat[3] = key;
uxn_eval(d->u, d->vector);
d->dat[3] = 0x00;
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -505,14 +505,17 @@ run(Uxn *u)
clamp(event.motion.x - PAD, 0, ppu.width - 1),
clamp(event.motion.y - PAD, 0, ppu.height - 1));
/* Controller */
- else if(event.type == SDL_KEYDOWN) {
- controller_down(devctrl, get_button(&event));
- controller_key(devctrl, get_key(&event));
- do_shortcut(u, &event);
+ else if(event.type == SDL_KEYDOWN || event.type == SDL_TEXTINPUT) {
+ if(event.type == SDL_TEXTINPUT)
+ controller_key(devctrl, event.text.text[0]);
+ else if(get_key(&event))
+ controller_key(devctrl, get_key(&event));
+ else if(get_button(&event)) {
+ controller_down(devctrl, get_button(&event));
+ do_shortcut(u, &event);
+ }
} else if(event.type == SDL_KEYUP)
controller_up(devctrl, get_button(&event));
- else if(event.type == SDL_TEXTINPUT)
- controller_key(devctrl, event.text.text[0]);
else if(event.type == SDL_JOYBUTTONDOWN)
controller_down(devctrl, get_button_joystick(&event));
else if(event.type == SDL_JOYBUTTONUP)