From: Martino Fontana tinozzo123@gmail.com
--- dlls/dinput/device.c | 10 +++++++++- dlls/dinput/device_private.h | 1 + dlls/dinput/keyboard.c | 15 +++++++++++++++ dlls/dinput/tests/device8.c | 6 ------ 4 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c index 9a9b559902a..6ea4ef5ef79 100644 --- a/dlls/dinput/device.c +++ b/dlls/dinput/device.c @@ -812,6 +812,7 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con case (DWORD_PTR)DIPROP_LOGICALRANGE: case (DWORD_PTR)DIPROP_PHYSICALRANGE: case (DWORD_PTR)DIPROP_APPDATA: + case (DWORD_PTR)DIPROP_SCANCODE: if (impl->dinput->dwVersion < 0x0800) return DIERR_UNSUPPORTED; break; } @@ -885,10 +886,10 @@ static HRESULT check_property( struct dinput_device *impl, const GUID *guid, con break;
case (DWORD_PTR)DIPROP_KEYNAME: + case (DWORD_PTR)DIPROP_SCANCODE: if (header->dwHow == DIPH_DEVICE) return DIERR_INVALIDPARAM; break;
- case (DWORD_PTR)DIPROP_SCANCODE: case (DWORD_PTR)DIPROP_APPDATA: if (header->dwHow == DIPH_DEVICE) return DIERR_UNSUPPORTED; break; @@ -1061,6 +1062,12 @@ static BOOL get_object_property( struct dinput_device *device, UINT index, struc value->uData = properties->app_data; return DIENUM_STOP; } + case (DWORD_PTR)DIPROP_SCANCODE: + { + DIPROPDWORD *value = (DIPROPDWORD *)params->header; + value->dwData = properties->scan_code; + return DI_OK; + } }
return DIENUM_STOP; @@ -1097,6 +1104,7 @@ static HRESULT dinput_device_get_property( IDirectInputDevice8W *iface, const GU case (DWORD_PTR)DIPROP_KEYNAME: case (DWORD_PTR)DIPROP_CALIBRATIONMODE: case (DWORD_PTR)DIPROP_APPDATA: + case (DWORD_PTR)DIPROP_SCANCODE: hr = impl->vtbl->enum_objects( iface, &filter, object_mask, get_object_property, ¶ms ); if (FAILED(hr)) return hr; if (hr == DIENUM_CONTINUE) return DIERR_NOTFOUND; diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h index feeade7def6..fa791f08a9d 100644 --- a/dlls/dinput/device_private.h +++ b/dlls/dinput/device_private.h @@ -69,6 +69,7 @@ struct object_properties UINT_PTR app_data; DWORD calibration_mode; DWORD granularity; + DWORD scan_code; };
enum device_status diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c index cbcbf94f0f6..8ec9dd47150 100644 --- a/dlls/dinput/keyboard.c +++ b/dlls/dinput/keyboard.c @@ -187,7 +187,10 @@ HRESULT keyboard_enum_device( DWORD type, DWORD flags, DIDEVICEINSTANCEW *instan
HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirectInputDevice8W **out ) { + DIDEVICEOBJECTINSTANCEW instance; struct keyboard *impl; + DWORD i, index, dik; + BYTE subtype; HRESULT hr;
TRACE( "dinput %p, guid %s, out %p.\n", dinput, debugstr_guid( guid ), out ); @@ -204,9 +207,21 @@ HRESULT keyboard_create_device( struct dinput *dinput, const GUID *guid, IDirect impl->base.caps.dwFirmwareRevision = 100; impl->base.caps.dwHardwareRevision = 100; if (dinput->dwVersion >= 0x0800) impl->base.use_raw_input = TRUE; + subtype = GET_DIDEVICE_SUBTYPE( impl->base.instance.dwDevType );
if (FAILED(hr = dinput_device_init_device_format( &impl->base.IDirectInputDevice8W_iface ))) goto failed;
+ for (i = 0, index = 0; i < 512; ++i) + { + if (!GetKeyNameTextW( i << 16, instance.tszName, ARRAY_SIZE(instance.tszName) )) continue; + if (!(dik = map_dik_code( i, 0, subtype, impl->base.dinput->dwVersion ))) continue; + + if (dik == DIK_NUMLOCK) impl->base.object_properties[index++].scan_code = 0x451de1; + else if (dik == DIK_PAUSE) impl->base.object_properties[index++].scan_code = 0x45; + else if (dik < 0x80) impl->base.object_properties[index++].scan_code = dik; + else impl->base.object_properties[index++].scan_code = (dik - 0x80) << 8 | 0x00e0; + } + *out = &impl->base.IDirectInputDevice8W_iface; return DI_OK;
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c index 0f7a2b6532d..85c0b79d70e 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device8.c @@ -1325,7 +1325,6 @@ static void test_sys_mouse( DWORD version ) hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr ); hr = IDirectInputDevice8_GetProperty( device, DIPROP_SCANCODE, &prop_dword.diph ); - todo_wine_if( version >= 0x800 ) ok( hr == (version < 0x800 ? DIERR_UNSUPPORTED : DIERR_INVALIDPARAM), "GetProperty DIPROP_SCANCODE returned %#lx\n", hr );
@@ -2370,9 +2369,7 @@ static void test_dik_codes( IDirectInputDevice8W *device, HANDLE event, HWND hwn ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_SCANCODE returned %#lx\n", hr ); else { - todo_wine ok( hr == DI_OK, "GetProperty DIPROP_SCANCODE returned %#lx\n", hr ); - todo_wine ok( prop_dword.dwData == scan, "got %#lx expected %#x\n", prop_dword.dwData, scan ); }
@@ -2490,9 +2487,7 @@ static void test_scan_codes( IDirectInputDevice8W *device, HANDLE event, HWND hw ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_SCANCODE returned %#lx\n", hr ); else { - todo_wine ok( hr == DI_OK, "GetProperty DIPROP_SCANCODE returned %#lx\n", hr ); - todo_wine ok( prop_dword.dwData == map[j].result, "got %#lx expected %#lx\n", prop_dword.dwData, map[j].result ); } @@ -2833,7 +2828,6 @@ static void test_sys_keyboard( DWORD version ) hr = IDirectInputDevice8_GetProperty( device, DIPROP_GRANULARITY, &prop_dword.diph ); ok( hr == DIERR_UNSUPPORTED, "GetProperty DIPROP_GRANULARITY returned %#lx\n", hr ); hr = IDirectInputDevice8_GetProperty( device, DIPROP_SCANCODE, &prop_dword.diph ); - todo_wine_if( version >= 0x800 ) ok( hr == (version < 0x800 ? DIERR_UNSUPPORTED : DIERR_INVALIDPARAM), "GetProperty DIPROP_SCANCODE returned %#lx\n", hr );