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;
for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++)
{
if (
if (binds[port][i].valid)
{
if (
button_is_pressed(
android->joypad, joypad_info, binds[port],
port, i)
|| android_keyboard_port_input_pressed(binds[port], i)
)
ret |= (1 << i);
android->joypad, joypad_info, binds[port],
port, i)
|| android_keyboard_port_input_pressed(binds[port], i)
)
ret |= (1 << i);
}
}
return ret;
}
else
{
if (
if (binds[port][id].valid)
{
if (
button_is_pressed(
android->joypad, joypad_info, binds[port],
port, id)
|| android_keyboard_port_input_pressed(binds[port], id)
)
return 1;
android->joypad, joypad_info, binds[port],
port, id)
|| android_keyboard_port_input_pressed(binds[port], id)
)
return 1;
}
}
break;
case RETRO_DEVICE_ANALOG:

View File

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

View File

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

View File

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