This commit is contained in:
twinaphex 2020-06-12 18:41:09 +02:00
parent 4a91b11806
commit d998f86f1f
5 changed files with 91 additions and 97 deletions

View File

@ -1434,25 +1434,31 @@ static int16_t android_input_state(void *data,
int16_t ret = 0; int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
if ( if (binds[port][i].valid)
{
if (
button_is_pressed( button_is_pressed(
android->joypad, joypad_info, binds[port], android->joypad, joypad_info, binds[port],
port, i) port, i)
|| android_keyboard_port_input_pressed(binds[port], i) || android_keyboard_port_input_pressed(binds[port], i)
) )
ret |= (1 << i); ret |= (1 << i);
}
} }
return ret; return ret;
} }
else else
{ {
if ( if (binds[port][id].valid)
{
if (
button_is_pressed( button_is_pressed(
android->joypad, joypad_info, binds[port], android->joypad, joypad_info, binds[port],
port, id) port, id)
|| android_keyboard_port_input_pressed(binds[port], id) || android_keyboard_port_input_pressed(binds[port], id)
) )
return 1; return 1;
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

View File

@ -306,36 +306,42 @@ static int16_t cocoa_input_state(void *data,
int16_t ret = 0; int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
if (button_is_pressed( if (binds[port][i].valid)
apple->joypad, {
joypad_info, binds[port], port, i)) if (button_is_pressed(
ret |= (1 << i); apple->joypad,
joypad_info, binds[port], port, i))
ret |= (1 << i);
#ifdef HAVE_MFI #ifdef HAVE_MFI
else if (button_is_pressed( else if (button_is_pressed(
apple->sec_joypad, apple->sec_joypad,
joypad_info, binds[port], port, i)) joypad_info, binds[port], port, i))
ret |= (1 << i); ret |= (1 << i);
#endif #endif
else if (apple_key_state[rarch_keysym_lut[binds[port][i].key]]) else if (apple_key_state[rarch_keysym_lut[binds[port][i].key]])
ret |= (1 << i); ret |= (1 << i);
}
} }
return ret; return ret;
} }
else else
{ {
if (button_is_pressed( if (binds[port][id].valid)
apple->joypad, {
joypad_info, binds[port], port, id)) if (button_is_pressed(
return 1; apple->joypad,
#ifdef HAVE_MFI joypad_info, binds[port], port, id))
else if (button_is_pressed(
apple->sec_joypad,
joypad_info, binds[port], port, id))
return 1;
#endif
else if (id < RARCH_BIND_LIST_END)
if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
return 1; return 1;
#ifdef HAVE_MFI
else if (button_is_pressed(
apple->sec_joypad,
joypad_info, binds[port], port, id))
return 1;
#endif
else if (id < RARCH_BIND_LIST_END)
if (apple_key_state[rarch_keysym_lut[binds[port][id].key]])
return 1;
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

View File

@ -64,9 +64,11 @@ static int16_t ctr_input_state(void *data,
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
if (binds[port][i].valid) if (binds[port][i].valid)
{
if (button_is_pressed( if (button_is_pressed(
ctr->joypad, joypad_info, binds[port], port, i)) ctr->joypad, joypad_info, binds[port], port, i))
ret |= (1 << i); ret |= (1 << i);
}
} }
return ret; return ret;
@ -74,9 +76,14 @@ static int16_t ctr_input_state(void *data,
else else
{ {
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{
if (binds[port][id].valid) if (binds[port][id].valid)
return button_is_pressed( {
ctr->joypad, joypad_info, binds[port], port, id); if (button_is_pressed(
ctr->joypad, joypad_info, binds[port], port, id))
return 1;
}
}
} }
break; break;
case RETRO_DEVICE_ANALOG: case RETRO_DEVICE_ANALOG:

View File

@ -106,37 +106,33 @@ static void uwp_input_grab_mouse(void *data, bool state)
(void)state; (void)state;
} }
static bool uwp_pressed_joypad(uwp_input_t *uwp, static int16_t uwp_is_pressed(
rarch_joypad_info_t *joypad_info, uwp_input_t *uwp,
const struct retro_keybind *binds, rarch_joypad_info_t *joypad_info,
unsigned port, unsigned id) const struct retro_keybind *binds,
unsigned port, unsigned id)
{ {
const struct retro_keybind *bind = &binds[id]; const struct retro_keybind *bind = &binds[id];
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[id].joykey != NO_BTN)
? binds[id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE)
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis;
/* First, process the keyboard bindings */ /* First, process the keyboard bindings */
if ((bind->key < RETROK_LAST) && uwp_keyboard_pressed(bind->key)) if ((bind->key < RETROK_LAST) && uwp_keyboard_pressed(bind->key))
if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_uwp.keyboard_mapping_blocked) if ((id == RARCH_GAME_FOCUS_TOGGLE) || !input_uwp.keyboard_mapping_blocked)
return true; return 1;
/* Then, process the joypad bindings */ /* Then, process the joypad bindings */
if (binds && binds[id].valid) if (uwp_mouse_state(port, bind->mbutton, false))
{ return 1;
/* Auto-binds are per joypad, not per user. */ if ((uint16_t)joykey != NO_BTN && uwp->joypad->button(
const uint64_t joykey = (binds[id].joykey != NO_BTN) joypad_info->joy_idx, (uint16_t)joykey))
? binds[id].joykey : joypad_info->auto_binds[id].joykey; return 1;
const uint32_t joyaxis = (binds[id].joyaxis != AXIS_NONE) if (((float)abs(uwp->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
? binds[id].joyaxis : joypad_info->auto_binds[id].joyaxis; return 1;
return 0;
if (uwp_mouse_state(port, bind->mbutton, false))
return true;
if ((uint16_t)joykey != NO_BTN && uwp->joypad->button(
joypad_info->joy_idx, (uint16_t)joykey))
return true;
if (((float)abs(uwp->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
return true;
}
return false;
} }
static int16_t uwp_pressed_analog(uwp_input_t *uwp, static int16_t uwp_pressed_analog(uwp_input_t *uwp,
@ -192,7 +188,7 @@ static int16_t uwp_input_state(void *data,
{ {
if (binds[port][i].valid) if (binds[port][i].valid)
{ {
if (uwp_pressed_joypad( if (uwp_is_pressed(
uwp, joypad_info, binds[port], port, i)) uwp, joypad_info, binds[port], port, i))
ret |= (1 << i); ret |= (1 << i);
} }
@ -204,9 +200,9 @@ static int16_t uwp_input_state(void *data,
{ {
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
{ {
if (binds[port][i].valid) if (binds[port][id].valid)
{ {
if (uwp_pressed_joypad(uwp, joypad_info, if (uwp_is_pressed(uwp, joypad_info,
binds[port], port, id)) binds[port], port, id))
return 1; return 1;
} }

View File

@ -303,29 +303,14 @@ static int16_t input_wl_state(void *data,
int16_t ret = 0; int16_t ret = 0;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{ {
/* Auto-binds are per joypad, not per user. */ if (binds[port][i].valid)
const uint64_t joykey = (binds[port][i].joykey != NO_BTN)
? binds[port][i].joykey : joypad_info->auto_binds[i].joykey;
const uint32_t joyaxis = (binds[port][i].joyaxis != AXIS_NONE)
? binds[port][i].joyaxis : joypad_info->auto_binds[i].joyaxis;
if (BIT_GET(wl->key_state, rarch_keysym_lut[binds[port][i].key]) )
{ {
ret |= (1 << i); if (button_is_pressed(wl->joypad, joypad_info, binds[port],
continue; port, i))
}
if (binds[port])
{
if ((uint16_t)joykey != NO_BTN && wl->joypad->button(joypad_info->joy_idx, (uint16_t)joykey))
{
ret |= (1 << i); ret |= (1 << i);
continue; else if (BIT_GET(wl->key_state,
} rarch_keysym_lut[binds[port][i].key]) )
if (((float)abs(wl->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold)
{
ret |= (1 << i); ret |= (1 << i);
continue;
}
} }
} }
@ -333,23 +318,17 @@ static int16_t input_wl_state(void *data,
} }
else else
{ {
/* Auto-binds are per joypad, not per user. */
const uint64_t joykey = (binds[port][id].joykey != NO_BTN)
? binds[port][id].joykey : joypad_info->auto_binds[id].joykey;
const uint32_t joyaxis = (binds[port][id].joyaxis != AXIS_NONE)
? binds[port][id].joyaxis : joypad_info->auto_binds[id].joyaxis;
if (id < RARCH_BIND_LIST_END) if (id < RARCH_BIND_LIST_END)
if (BIT_GET(wl->key_state,
rarch_keysym_lut[binds[port][id].key]))
return 1;
if (binds[port])
{ {
if ((uint16_t)joykey != NO_BTN && wl->joypad->button(joypad_info->joy_idx, (uint16_t)joykey)) if (binds[port][id].valid)
return 1; {
if (((float)abs(wl->joypad->axis(joypad_info->joy_idx, joyaxis)) / 0x8000) > joypad_info->axis_threshold) if (button_is_pressed(wl->joypad, joypad_info, binds[port],
return 1; port, id))
return 1;
else if (BIT_GET(wl->key_state,
rarch_keysym_lut[binds[port][id].key]))
return 1;
}
} }
} }
break; break;