Skip to content

Commit

Permalink
Merge branch 'libretro:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ComradeEcho authored Aug 4, 2021
2 parents 62f29bd + 49632bb commit 96705f2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 76 deletions.
86 changes: 30 additions & 56 deletions gfx/common/win32_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand Down Expand Up @@ -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)
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down
30 changes: 11 additions & 19 deletions libretro-db/rmsgpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,24 +398,24 @@ 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;

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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion menu/menu_explore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 96705f2

Please sign in to comment.