Skip to content

Commit

Permalink
WINRAW: Invert mouse order (#17376)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos authored Jan 10, 2025
1 parent 95dd1d8 commit 17e9aab
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions input/drivers/winraw_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt)
char name[256];
UINT name_size = sizeof(name);

name[0] = '\0';
name[0] = '\0';

for (i = 0; i < mouse_cnt; ++i)
{
UINT r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME,
name, &name_size);
if (r == (UINT)-1 || r == 0)
name[0] = '\0';
name[0] = '\0';

if (name[0])
{
Expand All @@ -146,7 +146,7 @@ static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt)
if (hhid != INVALID_HANDLE_VALUE)
{
wchar_t prod_buf[128];
prod_buf[0] = '\0';
prod_buf[0] = '\0';
if (HidD_GetProductString(hhid, prod_buf, sizeof(prod_buf)))
wcstombs(name, prod_buf, sizeof(name));
}
Expand All @@ -158,7 +158,7 @@ static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt)

input_config_set_mouse_display_name(i, name);

RARCH_LOG("[WinRaw]: Mouse #%u: \"%s\".\n", i, name);
RARCH_LOG("[WinRaw]: Mouse #%u: \"%s\".\n", i + 1, name);
}
}

Expand Down Expand Up @@ -203,19 +203,23 @@ static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt)
}
}

*mouse_cnt = mouse_cnt_r;

/* count is already checked, so this is safe */
for (i = mouse_cnt_r = 0; i < dev_cnt; ++i)
{
if (devs[i].dwType == RIM_TYPEMOUSE)
mice_r[mouse_cnt_r++].hnd = devs[i].hDevice;
{
mouse_cnt_r++;
mice_r[*mouse_cnt - mouse_cnt_r].hnd = devs[i].hDevice;
}
}

*mice = mice_r;

winraw_log_mice_info(mice_r, mouse_cnt_r);
free(devs);

*mice = mice_r;
*mouse_cnt = mouse_cnt_r;

return true;

error:
Expand Down

0 comments on commit 17e9aab

Please sign in to comment.