-- v2: joy.cpl: Use the DIJOYSTATE2 user data format to support more buttons. joy.cpl: Improve the DInput button display with many buttons. joy.cpl: Refresh the DInput button display on device change. joy.cpl: Process messages while waiting for the input threads.
From: Rémi Bernon rbernon@codeweavers.com
Instead of interrupting the wait on any message. --- dlls/joy.cpl/dinput.c | 11 ++++++++++- dlls/joy.cpl/xinput.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index 521634ff7da..9762dd4b435 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -792,7 +792,16 @@ INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM case PSN_RESET: case PSN_KILLACTIVE: SetEvent( thread_stop ); - MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, 0 ); + /* wait for the input thread to stop, processing any WM_USER message from it */ + while (MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, QS_ALLINPUT )) + { + MSG msg; + while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } + } CloseHandle( state_event ); CloseHandle( thread_stop ); CloseHandle( thread ); diff --git a/dlls/joy.cpl/xinput.c b/dlls/joy.cpl/xinput.c index 757b99fa333..8459ab0be42 100644 --- a/dlls/joy.cpl/xinput.c +++ b/dlls/joy.cpl/xinput.c @@ -428,7 +428,16 @@ extern INT_PTR CALLBACK test_xi_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, case PSN_RESET: case PSN_KILLACTIVE: SetEvent( thread_stop ); - MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, 0 ); + /* wait for the input thread to stop, processing any WM_USER message from it */ + while (MsgWaitForMultipleObjects( 1, &thread, FALSE, INFINITE, QS_ALLINPUT )) + { + MSG msg; + while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) + { + TranslateMessage( &msg ); + DispatchMessageW( &msg ); + } + } CloseHandle( thread_stop ); CloseHandle( thread ); dialog_hwnd = 0;
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/dinput.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index 9762dd4b435..b19e4cf7000 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -564,6 +564,7 @@ LRESULT CALLBACK test_di_buttons_window_proc( HWND hwnd, UINT msg, WPARAM wparam hdc = BeginPaint( hwnd, &paint );
GetClientRect( hwnd, &rect ); + FillRect( hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1) );
size = (rect.right - rect.left - space) / step; offs = (rect.right - rect.left - step * size - space) / 2; @@ -762,6 +763,8 @@ INT_PTR CALLBACK test_di_dialog_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM
SendDlgItemMessageW( hwnd, IDC_DI_EFFECTS, LB_SETCURSEL, 0, 0 ); handle_di_effects_change( hwnd ); + + update_device_views( hwnd ); break;
case MAKEWPARAM( IDC_DI_EFFECTS, LBN_SELCHANGE ):
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/dinput.c | 10 ++++++---- dlls/joy.cpl/joy.rc | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index b19e4cf7000..77bf6df2e2f 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -417,7 +417,8 @@ static void draw_button_view( HDC hdc, RECT rect, BOOL set, const WCHAR *name ) SelectObject( hdc, GetStockObject( DC_BRUSH ) ); SelectObject( hdc, GetStockObject( DC_PEN ) );
- Ellipse( hdc, rect.left, rect.top, rect.right, rect.bottom ); + if (rect.right - rect.left < 16) Rectangle( hdc, rect.left, rect.top, rect.right, rect.bottom ); + else Ellipse( hdc, rect.left, rect.top, rect.right, rect.bottom );
color = SetTextColor( hdc, GetSysColor( set ? COLOR_HIGHLIGHTTEXT : COLOR_WINDOWTEXT ) ); font = SelectObject( hdc, GetStockObject( ANSI_VAR_FONT ) ); @@ -559,7 +560,7 @@ LRESULT CALLBACK test_di_buttons_window_proc( HWND hwnd, UINT msg, WPARAM wparam }
if (caps.dwButtons <= 48) step = 16; - else step = 32; + else step = 24;
hdc = BeginPaint( hwnd, &paint );
@@ -579,7 +580,8 @@ LRESULT CALLBACK test_di_buttons_window_proc( HWND hwnd, UINT msg, WPARAM wparam for (j = 0; j < step && i < caps.dwButtons; j++, i++) { WCHAR buffer[3]; - swprintf( buffer, ARRAY_SIZE(buffer), L"%d", i ); + if (step == 24) swprintf( buffer, ARRAY_SIZE(buffer), L"%02x", i ); + else swprintf( buffer, ARRAY_SIZE(buffer), L"%d", i ); draw_button_view( hdc, rect, state.rgbButtons[i], buffer ); OffsetRect( &rect, size, 0 ); } @@ -675,7 +677,7 @@ static void create_device_views( HWND hwnd ) GetClientRect( parent, &rect ); rect.top += 10;
- margin = (rect.bottom - rect.top) * 10 / 100; + margin = (rect.bottom - rect.top) * 5 / 100; InflateRect( &rect, -margin, -margin );
CreateWindowW( L"JoyCplDInputButtons", NULL, WS_CHILD | WS_VISIBLE, rect.left, rect.top, diff --git a/dlls/joy.cpl/joy.rc b/dlls/joy.cpl/joy.rc index 08f6fa12e0c..76d8bb401e4 100644 --- a/dlls/joy.cpl/joy.rc +++ b/dlls/joy.cpl/joy.rc @@ -57,9 +57,9 @@ FONT 8, "Ms Shell Dlg" COMBOBOX IDC_DI_DEVICES, 15, 10, 291, 60, CBS_DROPDOWNLIST | CBS_HASSTRINGS GROUPBOX "Axes", IDC_DI_AXES, 15, 30, 214, 60 GROUPBOX "POVs", IDC_DI_POVS, 246, 30, 60, 60 - GROUPBOX "Buttons", IDC_DI_BUTTONS, 15, 100, 291, 70 - LTEXT "Force Feedback Effect", IDC_STATIC, 15, 180, 291, 10 - LISTBOX IDC_DI_EFFECTS, 15, 190, 291, 70, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY + GROUPBOX "Buttons", IDC_DI_BUTTONS, 15, 100, 291, 86 + LTEXT "Force Feedback Effect", IDC_STATIC, 15, 196, 291, 10 + LISTBOX IDC_DI_EFFECTS, 15, 206, 291, 54, WS_TABSTOP | WS_VSCROLL | LBS_NOTIFY LTEXT "Press any button in the controller to activate the chosen effect. The effect direction can be changed with the controller axis.", IDC_STATIC, 15, 260, 291, 25 }
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/joy.cpl/dinput.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/joy.cpl/dinput.c b/dlls/joy.cpl/dinput.c index 77bf6df2e2f..55919340023 100644 --- a/dlls/joy.cpl/dinput.c +++ b/dlls/joy.cpl/dinput.c @@ -236,7 +236,7 @@ static BOOL CALLBACK enum_devices( const DIDEVICEINSTANCEW *instance, void *cont if (!(entry = calloc( 1, sizeof(*entry) ))) return DIENUM_STOP;
IDirectInput8_CreateDevice( dinput, &instance->guidInstance, &entry->device, NULL ); - IDirectInputDevice8_SetDataFormat( entry->device, &c_dfDIJoystick ); + IDirectInputDevice8_SetDataFormat( entry->device, &c_dfDIJoystick2 ); IDirectInputDevice8_GetCapabilities( entry->device, &caps );
list_add_tail( &devices, &entry->entry ); @@ -266,7 +266,7 @@ static DWORD WINAPI input_thread( void *param ) while (WaitForMultipleObjects( 2, events, FALSE, INFINITE ) != 0) { IDirectInputEffect *effect; - DIJOYSTATE state = {0}; + DIJOYSTATE2 state = {0}; unsigned int i;
SendMessageW( dialog_hwnd, WM_USER, 0, 0 ); @@ -437,7 +437,7 @@ LRESULT CALLBACK test_di_axes_window_proc( HWND hwnd, UINT msg, WPARAM wparam, L { DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; IDirectInputDevice8W *device; - DIJOYSTATE state = {0}; + DIJOYSTATE2 state = {0}; RECT rect, tmp_rect; PAINTSTRUCT paint; HDC hdc; @@ -503,7 +503,7 @@ LRESULT CALLBACK test_di_povs_window_proc( HWND hwnd, UINT msg, WPARAM wparam, L { DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; IDirectInputDevice8W *device; - DIJOYSTATE state = {0}; + DIJOYSTATE2 state = {0}; PAINTSTRUCT paint; RECT rect; HDC hdc; @@ -547,7 +547,7 @@ LRESULT CALLBACK test_di_buttons_window_proc( HWND hwnd, UINT msg, WPARAM wparam DIDEVCAPS caps = {.dwSize = sizeof(DIDEVCAPS)}; UINT i, j, offs, size, step, space = 2; IDirectInputDevice8W *device; - DIJOYSTATE state = {0}; + DIJOYSTATE2 state = {0}; PAINTSTRUCT paint; RECT rect; HDC hdc;