Virtual key codes are layout dependant while direct input works with scan codes.
Using virtual key code for 'A' with AZERTY layout resulted in scan code for 'Q' being sent out, which in turn made the tests fail.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50987 Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/dinput8/tests/device.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/dlls/dinput8/tests/device.c b/dlls/dinput8/tests/device.c index 3e6da23b4ab..17deed193dd 100644 --- a/dlls/dinput8/tests/device.c +++ b/dlls/dinput8/tests/device.c @@ -91,7 +91,7 @@ static void test_device_input(IDirectInputDevice8A *lpdid, DWORD event_type, DWO ok (SUCCEEDED(hr), "Failed to acquire device hr=%08x\n", hr);
if (event_type == INPUT_KEYBOARD) - keybd_event(event, MapVirtualKeyA(event, MAPVK_VK_TO_VSC), 0, 0); + keybd_event(0, event, KEYEVENTF_SCANCODE, 0);
if (event_type == INPUT_MOUSE) mouse_event( event, 0, 0, 0, 0); @@ -307,7 +307,7 @@ static void test_appdata_property_vs_map(struct enum_data *data) hr = IDirectInputDevice8_SetProperty(data->keyboard, DIPROP_APPDATA, &(dp.diph)); ok(SUCCEEDED(hr), "IDirectInputDevice8_SetProperty failed hr=%08x\n", hr);
- test_device_input(data->keyboard, INPUT_KEYBOARD, VK_SPACE, 10); + test_device_input(data->keyboard, INPUT_KEYBOARD, DIK_SPACE, 10);
dp.diph.dwHow = DIPH_BYID; dp.diph.dwObj = DIDFT_MAKEINSTANCE(DIK_V) | DIDFT_PSHBUTTON; @@ -319,7 +319,7 @@ static void test_appdata_property_vs_map(struct enum_data *data) hr = IDirectInputDevice8_SetDataFormat(data->keyboard, &c_dfDIKeyboard); ok(SUCCEEDED(hr), "SetDataFormat failed: %08x\n", hr);
- test_device_input(data->keyboard, INPUT_KEYBOARD, VK_SPACE, -1); + test_device_input(data->keyboard, INPUT_KEYBOARD, DIK_SPACE, -1);
dp.diph.dwHow = DIPH_BYID; dp.diph.dwObj = DIDFT_MAKEINSTANCE(DIK_V) | DIDFT_PSHBUTTON; @@ -327,13 +327,13 @@ static void test_appdata_property_vs_map(struct enum_data *data) hr = IDirectInputDevice8_SetProperty(data->keyboard, DIPROP_APPDATA, &(dp.diph)); ok(SUCCEEDED(hr), "IDirectInputDevice8_SetProperty failed hr=%08x\n", hr);
- test_device_input(data->keyboard, INPUT_KEYBOARD, 'V', 11); + test_device_input(data->keyboard, INPUT_KEYBOARD, DIK_V, 11);
/* back to action map */ hr = IDirectInputDevice8_SetActionMap(data->keyboard, data->lpdiaf, NULL, 0); ok(SUCCEEDED(hr), "SetActionMap failed hr=%08x\n", hr);
- test_device_input(data->keyboard, INPUT_KEYBOARD, VK_SPACE, 2); + test_device_input(data->keyboard, INPUT_KEYBOARD, DIK_SPACE, 2); }
static void test_action_mapping(void) @@ -402,19 +402,19 @@ static void test_action_mapping(void) /* Test keyboard BuildActionMap */ test_build_action_map(data.keyboard, data.lpdiaf, DITEST_KEYBOARDSPACE, DIDFT_PSHBUTTON, DIK_SPACE); /* Test keyboard input */ - test_device_input(data.keyboard, INPUT_KEYBOARD, VK_SPACE, 2); + test_device_input(data.keyboard, INPUT_KEYBOARD, DIK_SPACE, 2);
/* setting format should reset action map */ hr = IDirectInputDevice8_SetDataFormat(data.keyboard, &c_dfDIKeyboard); ok (SUCCEEDED(hr), "IDirectInputDevice8_SetDataFormat failed: %08x\n", hr);
- test_device_input(data.keyboard, INPUT_KEYBOARD, VK_SPACE, -1); + test_device_input(data.keyboard, INPUT_KEYBOARD, DIK_SPACE, -1);
/* back to action map */ hr = IDirectInputDevice8_SetActionMap(data.keyboard, data.lpdiaf, NULL, 0); ok (SUCCEEDED(hr), "SetActionMap should succeed hr=%08x\n", hr);
- test_device_input(data.keyboard, INPUT_KEYBOARD, VK_SPACE, 2); + test_device_input(data.keyboard, INPUT_KEYBOARD, DIK_SPACE, 2);
test_appdata_property_vs_map(&data);
@@ -958,7 +958,7 @@ static void test_appdata_property(void) ok(SUCCEEDED(hr), "IDirectInputDevice8_SetProperty failed hr=%08x\n", hr);
/* the default value */ - test_device_input(di_keyboard, INPUT_KEYBOARD, 'A', -1); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_A, -1);
dp.diph.dwHow = DIPH_DEVICE; dp.diph.dwObj = 0; @@ -992,19 +992,19 @@ static void test_appdata_property(void) hr = IDirectInputDevice8_SetProperty(di_keyboard, DIPROP_APPDATA, &(dp.diph)); ok(SUCCEEDED(hr), "IDirectInputDevice8_SetProperty failed hr=%08x\n", hr);
- test_device_input(di_keyboard, INPUT_KEYBOARD, VK_SPACE, 3); - test_device_input(di_keyboard, INPUT_KEYBOARD, 'A', 4); - test_device_input(di_keyboard, INPUT_KEYBOARD, 'B', 5); - test_device_input(di_keyboard, INPUT_KEYBOARD, 'C', -1); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_SPACE, 3); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_A, 4); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_B, 5); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_C, -1);
/* setting data format resets APPDATA */ hr = IDirectInputDevice8_SetDataFormat(di_keyboard, &c_dfDIKeyboard); ok(SUCCEEDED(hr), "IDirectInputDevice8_SetDataFormat failed: %08x\n", hr);
test_device_input(di_keyboard, INPUT_KEYBOARD, VK_SPACE, -1); - test_device_input(di_keyboard, INPUT_KEYBOARD, 'A', -1); - test_device_input(di_keyboard, INPUT_KEYBOARD, 'B', -1); - test_device_input(di_keyboard, INPUT_KEYBOARD, 'C', -1); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_A, -1); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_B, -1); + test_device_input(di_keyboard, INPUT_KEYBOARD, DIK_C, -1);
DestroyWindow(hwnd); IDirectInputDevice_Release(di_keyboard);
On Wed, 26 May 2021, Arkadiusz Hiler wrote:
Virtual key codes are layout dependant while direct input works with scan codes.
Using virtual key code for 'A' with AZERTY layout resulted in scan code for 'Q' being sent out, which in turn made the tests fail.
That makes sense. Nowadays I use SetWinLocale [1] to configure the VMs locale and that changes the default & 'MUI' language, country, formats and keyboard layout.
[1] https://source.winehq.org/git/tools.git/blob/HEAD:/testbot/bin/SetWinLocale