diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 8e1b31cab64..b69937344d6 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -978,8 +978,8 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd, quit = true; { uint16_t mod = 0; - unsigned keycode = 0; - unsigned keysym = (lparam >> 16) & 0xff; + unsigned keysym = (unsigned)wparam; + unsigned keycode = input_keymaps_translate_keysym_to_rk(keysym); if (GetKeyState(VK_SHIFT) & 0x80) mod |= RETROKMOD_SHIFT; @@ -994,32 +994,6 @@ static LRESULT CALLBACK wnd_proc_common_internal(HWND hwnd, if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) mod |= RETROKMOD_META; - keysym = (unsigned)wparam; - /* fix key binding issues on winraw when - * DirectInput is not available */ - switch (keysym) - { - /* Mod & Keypad handling done in winraw_callback */ - case VK_SHIFT: - case VK_CONTROL: - case VK_MENU: - case VK_INSERT: - case VK_DELETE: - case VK_HOME: - case VK_END: - case VK_PRIOR: - case VK_NEXT: - case VK_UP: - case VK_DOWN: - case VK_LEFT: - case VK_RIGHT: - case VK_CLEAR: - case VK_RETURN: - return 0; - } - - keycode = input_keymaps_translate_keysym_to_rk(keysym); - input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD); @@ -1103,22 +1077,8 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd, { uint16_t mod = 0; unsigned keycode = 0; - unsigned keysym = (lparam >> 16) & 0xff; - - if (GetKeyState(VK_SHIFT) & 0x80) - mod |= RETROKMOD_SHIFT; - if (GetKeyState(VK_CONTROL) & 0x80) - mod |= RETROKMOD_CTRL; - if (GetKeyState(VK_MENU) & 0x80) - mod |= RETROKMOD_ALT; - if (GetKeyState(VK_CAPITAL) & 0x81) - mod |= RETROKMOD_CAPSLOCK; - if (GetKeyState(VK_SCROLL) & 0x81) - mod |= RETROKMOD_SCROLLOCK; - if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) - mod |= RETROKMOD_META; + unsigned keysym = (unsigned)wparam; - keysym = (unsigned)wparam; /* fix key binding issues on winraw when * DirectInput is not available */ switch (keysym) @@ -1144,6 +1104,20 @@ static LRESULT CALLBACK wnd_proc_winraw_common_internal(HWND hwnd, keycode = input_keymaps_translate_keysym_to_rk(keysym); + if (GetKeyState(VK_SHIFT) & 0x80) + mod |= RETROKMOD_SHIFT; + if (GetKeyState(VK_CONTROL) & 0x80) + mod |= RETROKMOD_CTRL; + if (GetKeyState(VK_MENU) & 0x80) + mod |= RETROKMOD_ALT; + if (GetKeyState(VK_CAPITAL) & 0x81) + mod |= RETROKMOD_CAPSLOCK; + if (GetKeyState(VK_SCROLL) & 0x81) + mod |= RETROKMOD_SCROLLOCK; + if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) + mod |= RETROKMOD_META; + + input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD); @@ -1235,19 +1209,6 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd, unsigned keycode = 0; unsigned keysym = (lparam >> 16) & 0xff; - if (GetKeyState(VK_SHIFT) & 0x80) - mod |= RETROKMOD_SHIFT; - if (GetKeyState(VK_CONTROL) & 0x80) - mod |= RETROKMOD_CTRL; - if (GetKeyState(VK_MENU) & 0x80) - mod |= RETROKMOD_ALT; - if (GetKeyState(VK_CAPITAL) & 0x81) - mod |= RETROKMOD_CAPSLOCK; - if (GetKeyState(VK_SCROLL) & 0x81) - mod |= RETROKMOD_SCROLLOCK; - if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) - mod |= RETROKMOD_META; - /* extended keys will map to dinput if the high bit is set */ if ((lparam >> 24 & 0x1)) keysym |= 0x80; @@ -1261,6 +1222,19 @@ static LRESULT CALLBACK wnd_proc_common_dinput_internal(HWND hwnd, return 0; } + if (GetKeyState(VK_SHIFT) & 0x80) + mod |= RETROKMOD_SHIFT; + if (GetKeyState(VK_CONTROL) & 0x80) + mod |= RETROKMOD_CTRL; + if (GetKeyState(VK_MENU) & 0x80) + mod |= RETROKMOD_ALT; + if (GetKeyState(VK_CAPITAL) & 0x81) + mod |= RETROKMOD_CAPSLOCK; + if (GetKeyState(VK_SCROLL) & 0x81) + mod |= RETROKMOD_SCROLLOCK; + if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x80) + mod |= RETROKMOD_META; + input_keyboard_event(keydown, keycode, 0, mod, RETRO_DEVICE_KEYBOARD); diff --git a/libretro-db/rmsgpack.c b/libretro-db/rmsgpack.c index 98240b85700..b81fdf75369 100644 --- a/libretro-db/rmsgpack.c +++ b/libretro-db/rmsgpack.c @@ -398,7 +398,7 @@ int rmsgpack_write_uint(RFILE *fd, uint64_t value) static int read_uint(RFILE *fd, uint64_t *out, size_t size) { - uint64_t tmp; + union { uint64_t u64; uint32_t u32; uint16_t u16; uint8_t u8; } tmp; if (filestream_read(fd, &tmp, size) == -1) goto error; @@ -406,16 +406,16 @@ static int read_uint(RFILE *fd, uint64_t *out, size_t size) switch (size) { case 1: - *out = *(uint8_t *)(&tmp); + *out = tmp.u8; break; case 2: - *out = swap_if_little16((uint16_t)tmp); + *out = swap_if_little16(tmp.u16); break; case 4: - *out = swap_if_little32((uint32_t)tmp); + *out = swap_if_little32(tmp.u32); break; case 8: - *out = swap_if_little64(tmp); + *out = swap_if_little64(tmp.u64); break; } return 0; @@ -426,32 +426,24 @@ static int read_uint(RFILE *fd, uint64_t *out, size_t size) static int read_int(RFILE *fd, int64_t *out, size_t size) { - uint8_t tmp8 = 0; - uint16_t tmp16; - uint32_t tmp32; - uint64_t tmp64; + union { uint64_t u64; uint32_t u32; uint16_t u16; uint8_t u8; } tmp; - if (filestream_read(fd, &tmp64, size) == -1) + if (filestream_read(fd, &tmp, size) == -1) goto error; - (void)tmp8; - switch (size) { case 1: - *out = *((int8_t *)(&tmp64)); + *out = (int8_t)tmp.u8; break; case 2: - tmp16 = swap_if_little16((uint16_t)tmp64); - *out = *((int16_t *)(&tmp16)); + *out = (int16_t)swap_if_little16(tmp.u16); break; case 4: - tmp32 = swap_if_little32((uint32_t)tmp64); - *out = *((int32_t *)(&tmp32)); + *out = (int32_t)swap_if_little32(tmp.u32); break; case 8: - tmp64 = swap_if_little64(tmp64); - *out = *((int64_t *)(&tmp64)); + *out = (int64_t)swap_if_little64(tmp.u64); break; } return 0; diff --git a/menu/menu_explore.c b/menu/menu_explore.c index 7e55c28bb5e..fc25b26b146 100644 --- a/menu/menu_explore.c +++ b/menu/menu_explore.c @@ -596,7 +596,7 @@ static explore_state_t *explore_build_list(settings_t *settings) key_str = key->val.string.buff; if (string_is_equal(key_str, "crc")) { - switch (strlen(val->val.binary.buff)) + switch (val->val.binary.len) { case 1: crc32 = *(uint8_t*)val->val.binary.buff;