joy.cpl: Refresh the joystick device list when modified.
This will not work for legacy dinput devices because of the internal enumeration logic, but it will dynamically update the list for HID joysticks. Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
a6f7f2dcfb
commit
c496a7b3f9
|
@ -155,20 +155,7 @@ static void destroy_joysticks(struct JoystickData *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
free(data->joysticks);
|
free(data->joysticks);
|
||||||
}
|
data->joysticks = NULL;
|
||||||
|
|
||||||
static void initialize_joysticks_list(HWND hwnd, struct JoystickData *data)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_RESETCONTENT, 0, 0);
|
|
||||||
|
|
||||||
/* Add enumerated joysticks */
|
|
||||||
for (i = 0; i < data->num_joysticks; i++)
|
|
||||||
{
|
|
||||||
struct Joystick *joy = &data->joysticks[i];
|
|
||||||
SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_ADDSTRING, 0, (LPARAM) joy->instance.tszInstanceName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -233,15 +220,23 @@ static void enable_joystick(WCHAR *joy_name, BOOL enable)
|
||||||
if (appkey) RegCloseKey(appkey);
|
if (appkey) RegCloseKey(appkey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize_disabled_joysticks_list(HWND hwnd)
|
static void refresh_joystick_list(HWND hwnd, struct JoystickData *data)
|
||||||
{
|
{
|
||||||
|
struct Joystick *joy, *joy_end;
|
||||||
HKEY hkey, appkey;
|
HKEY hkey, appkey;
|
||||||
DWORD values = 0;
|
DWORD values = 0;
|
||||||
LSTATUS status;
|
LSTATUS status;
|
||||||
DWORD i;
|
DWORD i;
|
||||||
|
|
||||||
|
destroy_joysticks(data);
|
||||||
|
initialize_joysticks(data);
|
||||||
|
|
||||||
|
SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_RESETCONTENT, 0, 0);
|
||||||
SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_RESETCONTENT, 0, 0);
|
SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_RESETCONTENT, 0, 0);
|
||||||
|
|
||||||
|
for (joy = data->joysticks, joy_end = joy + data->num_joysticks; joy != joy_end; ++joy)
|
||||||
|
SendDlgItemMessageW(hwnd, IDC_JOYSTICKLIST, LB_ADDSTRING, 0, (LPARAM) joy->instance.tszInstanceName);
|
||||||
|
|
||||||
/* Search for disabled joysticks */
|
/* Search for disabled joysticks */
|
||||||
get_app_key(&hkey, &appkey);
|
get_app_key(&hkey, &appkey);
|
||||||
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, &values, NULL, NULL, NULL, NULL);
|
RegQueryInfoKeyW(hkey, NULL, NULL, NULL, NULL, NULL, NULL, &values, NULL, NULL, NULL, NULL);
|
||||||
|
@ -275,8 +270,7 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
||||||
{
|
{
|
||||||
data = (struct JoystickData*) ((PROPSHEETPAGEW*)lparam)->lParam;
|
data = (struct JoystickData*) ((PROPSHEETPAGEW*)lparam)->lParam;
|
||||||
|
|
||||||
initialize_joysticks_list(hwnd, data);
|
refresh_joystick_list(hwnd, data);
|
||||||
initialize_disabled_joysticks_list(hwnd);
|
|
||||||
|
|
||||||
EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), FALSE);
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTONENABLE), FALSE);
|
||||||
EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), FALSE);
|
EnableWindow(GetDlgItem(hwnd, IDC_BUTTONDISABLE), FALSE);
|
||||||
|
@ -298,7 +292,7 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
||||||
if (sel >= 0)
|
if (sel >= 0)
|
||||||
{
|
{
|
||||||
enable_joystick(data->joysticks[sel].instance.tszInstanceName, FALSE);
|
enable_joystick(data->joysticks[sel].instance.tszInstanceName, FALSE);
|
||||||
initialize_disabled_joysticks_list(hwnd);
|
refresh_joystick_list(hwnd, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -312,7 +306,7 @@ static INT_PTR CALLBACK list_dlgproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
||||||
WCHAR text[MAX_PATH];
|
WCHAR text[MAX_PATH];
|
||||||
SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_GETTEXT, sel, (LPARAM) text);
|
SendDlgItemMessageW(hwnd, IDC_DISABLEDLIST, LB_GETTEXT, sel, (LPARAM) text);
|
||||||
enable_joystick(text, TRUE);
|
enable_joystick(text, TRUE);
|
||||||
initialize_disabled_joysticks_list(hwnd);
|
refresh_joystick_list(hwnd, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue