Mini fix to controller button order

This commit is contained in:
neauoire 2021-12-27 13:37:37 -08:00
parent 87507f7f03
commit 51b9c699b8
2 changed files with 18 additions and 11 deletions

View File

@ -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;

View File

@ -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)