From 6cc9a3f9b4a4507fef1c0358e5c0219ea63e7c7a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 13 Jun 2020 01:01:30 +0200 Subject: [PATCH] (UWP) Buildfix + uwp_input cleanups --- input/drivers/uwp_input.c | 73 ++++++++++++++++++++------------------- menu/menu_displaylist.c | 2 +- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/input/drivers/uwp_input.c b/input/drivers/uwp_input.c index 9090184a3d..7c6b97edc2 100644 --- a/input/drivers/uwp_input.c +++ b/input/drivers/uwp_input.c @@ -106,35 +106,6 @@ static void uwp_input_grab_mouse(void *data, bool state) (void)state; } -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 1; - - /* Then, process the joypad bindings */ - 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, rarch_joypad_info_t *joypad_info, const struct retro_keybind *binds, @@ -184,13 +155,36 @@ static int16_t uwp_input_state(void *data, { unsigned i; int16_t ret = 0; - for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) + if (input_uwp.keyboard_mapping_blocked) { - if (binds[port][i].valid) + for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) { - if (uwp_is_pressed( - uwp, joypad_info, binds[port], port, i)) - ret |= (1 << i); + if (binds[port][i].valid) + { + if (button_is_pressed( + uwp->joypad, joypad_info, binds[port], port, i)) + ret |= (1 << i); + else if (uwp_mouse_state(port, + binds[port][i].mbutton, false)) + ret |= (1 << i); + } + } + } + else + { + for (i = 0; i < RARCH_FIRST_CUSTOM_BIND; i++) + { + if (binds[port][i].valid) + { + if ( button_is_pressed( + uwp->joypad, joypad_info, binds[port], port, i) + || ((binds[port][i].key < RETROK_LAST) && uwp_keyboard_pressed(binds[port][i].key)) + ) + ret |= (1 << i); + else if (uwp_mouse_state(port, + binds[port][i].mbutton, false)) + ret |= (1 << i); + } } } @@ -202,9 +196,18 @@ static int16_t uwp_input_state(void *data, { if (binds[port][id].valid) { - if (uwp_is_pressed(uwp, joypad_info, + if (button_is_pressed(uwp->joypad, joypad_info, binds[port], port, id)) return 1; + else if ((binds[port][id].key < RETROK_LAST) + && uwp_keyboard_pressed(binds[port][id].key) + && ((id == RARCH_GAME_FOCUS_TOGGLE) || + !input_uwp.keyboard_mapping_blocked) + ) + return 1; + else if (uwp_mouse_state(port, + binds[port][id].mbutton, false)) + return 1; } } } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 675408f2f7..c7a092f3e5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -139,8 +139,8 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) unsigned i, count = 0; core_info_t *core_info = NULL; const char *core_path = NULL; -#if !(defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) settings_t *settings = config_get_ptr(); +#if !(defined(__WINRT__) || defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) bool kiosk_mode_enable = settings->bools.kiosk_mode_enable; #if defined(HAVE_NETWORKING) && defined(HAVE_ONLINE_UPDATER) bool menu_show_core_updater = settings->bools.menu_show_core_updater;