Created
July 21, 2011 21:03
-
-
Save lfzawacki/1098194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 92021ad4b2c3afd056ff8c4ecca9c18dca853189 Mon Sep 17 00:00:00 2001 | |
From: Lucas Fialho Zawacki <[email protected]> | |
Date: Thu, 21 Jul 2011 16:15:34 -0300 | |
Subject: [PATCH] dinput: Using the same function for keyboard/mouse BuildActionMap | |
--- | |
dlls/dinput/device.c | 29 +++++++++++++++++++++++++++++ | |
dlls/dinput/device_private.h | 1 + | |
dlls/dinput/keyboard.c | 26 +------------------------- | |
dlls/dinput/mouse.c | 26 ++------------------------ | |
4 files changed, 33 insertions(+), 49 deletions(-) | |
diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c | |
index 58d4e14..c2b5312 100644 | |
--- a/dlls/dinput/device.c | |
+++ b/dlls/dinput/device.c | |
@@ -598,6 +598,35 @@ DWORD semantic_to_obj_id(IDirectInputDeviceImpl* This, DWORD dwSemantic) | |
return type | (0x0000ff00 & (obj_instance << 8)); | |
} | |
+HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask) | |
+{ | |
+ IDirectInputDeviceImpl *This = impl_from_IDirectInputDevice8W(iface); | |
+ int i, has_actions = 0; | |
+ | |
+ for (i=0; i < lpdiaf->dwNumActions; i++) | |
+ { | |
+ if ((lpdiaf->rgoAction[i].dwSemantic & devMask) == devMask) | |
+ { | |
+ DWORD obj_id = semantic_to_obj_id(This, lpdiaf->rgoAction[i].dwSemantic); | |
+ | |
+ lpdiaf->rgoAction[i].dwObjID = obj_id; | |
+ lpdiaf->rgoAction[i].guidInstance = This->guid; | |
+ lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT; | |
+ has_actions = 1; | |
+ } | |
+ else if (!(dwFlags & DIDBAM_PRESERVE)) | |
+ { | |
+ /* we must clear action data belonging to other devices */ | |
+ memset(&lpdiaf->rgoAction[i].guidInstance, 0, sizeof(GUID)); | |
+ lpdiaf->rgoAction[i].dwHow = DIAH_UNMAPPED; | |
+ } | |
+ } | |
+ | |
+ if (!has_actions) return DI_NOEFFECT; | |
+ | |
+ return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags); | |
+} | |
+ | |
/****************************************************************************** | |
* queue_event - add new event to the ring queue | |
*/ | |
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h | |
index 6c061b2..7aa6690 100644 | |
--- a/dlls/dinput/device_private.h | |
+++ b/dlls/dinput/device_private.h | |
@@ -126,6 +126,7 @@ extern const char *_dump_dinput_GUID(const GUID *guid) DECLSPEC_HIDDEN; | |
extern DWORD semantic_to_obj_id(IDirectInputDeviceImpl* This, DWORD dwSemantic) DECLSPEC_HIDDEN; | |
extern LPDIOBJECTDATAFORMAT dataformat_to_odf_by_type(LPCDIDATAFORMAT df, int n, DWORD type) DECLSPEC_HIDDEN; | |
+HRESULT _build_action_map(LPDIRECTINPUTDEVICE8W iface, LPDIACTIONFORMATW lpdiaf, LPCWSTR lpszUserName, DWORD dwFlags, DWORD devMask) DECLSPEC_HIDDEN; | |
/* And the stubs */ | |
extern HRESULT WINAPI IDirectInputDevice2AImpl_Acquire(LPDIRECTINPUTDEVICE8A iface) DECLSPEC_HIDDEN; | |
diff --git a/dlls/dinput/keyboard.c b/dlls/dinput/keyboard.c | |
index 3c93bcd..0a87547 100644 | |
--- a/dlls/dinput/keyboard.c | |
+++ b/dlls/dinput/keyboard.c | |
@@ -529,33 +529,9 @@ static HRESULT WINAPI SysKeyboardWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W ifac | |
LPCWSTR lpszUserName, | |
DWORD dwFlags) | |
{ | |
- SysKeyboardImpl *This = impl_from_IDirectInputDevice8W(iface); | |
- int i, has_actions = 0; | |
- | |
FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags); | |
- for (i=0; i < lpdiaf->dwNumActions; i++) | |
- { | |
- if ((lpdiaf->rgoAction[i].dwSemantic & DIKEYBOARD_MASK) == DIKEYBOARD_MASK) | |
- { | |
- DWORD obj_id = semantic_to_obj_id(&This->base, lpdiaf->rgoAction[i].dwSemantic); | |
- | |
- lpdiaf->rgoAction[i].dwObjID = obj_id; | |
- lpdiaf->rgoAction[i].guidInstance = This->base.guid; | |
- lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT; | |
- has_actions = 1; | |
- } | |
- else if (!(dwFlags & DIDBAM_PRESERVE)) | |
- { | |
- /* we must clear action data belonging to other devices */ | |
- memset(&lpdiaf->rgoAction[i].guidInstance, 0, sizeof(GUID)); | |
- lpdiaf->rgoAction[i].dwHow = DIAH_UNMAPPED; | |
- } | |
- } | |
- | |
- if (!has_actions) return DI_NOEFFECT; | |
- | |
- return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags); | |
+ return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIKEYBOARD_MASK); | |
} | |
static HRESULT WINAPI SysKeyboardAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface, | |
diff --git a/dlls/dinput/mouse.c b/dlls/dinput/mouse.c | |
index fb724d5..9a0919a 100644 | |
--- a/dlls/dinput/mouse.c | |
+++ b/dlls/dinput/mouse.c | |
@@ -778,31 +778,9 @@ static HRESULT WINAPI SysMouseWImpl_BuildActionMap(LPDIRECTINPUTDEVICE8W iface, | |
LPCWSTR lpszUserName, | |
DWORD dwFlags) | |
{ | |
- SysMouseImpl *This = impl_from_IDirectInputDevice8W(iface); | |
- int i, has_actions = 0; | |
- | |
- for (i=0; i < lpdiaf->dwNumActions; i++) | |
- { | |
- if ((lpdiaf->rgoAction[i].dwSemantic & DIMOUSE_MASK) == DIMOUSE_MASK) | |
- { | |
- DWORD obj_id = semantic_to_obj_id(&This->base, lpdiaf->rgoAction[i].dwSemantic); | |
- | |
- lpdiaf->rgoAction[i].dwObjID = obj_id; | |
- lpdiaf->rgoAction[i].guidInstance = This->base.guid; | |
- lpdiaf->rgoAction[i].dwHow = DIAH_DEFAULT; | |
- has_actions = 1; | |
- } | |
- else if (!(dwFlags & DIDBAM_PRESERVE)) | |
- { | |
- /* we must clear action data belonging to other devices */ | |
- memset(&lpdiaf->rgoAction[i].guidInstance, 0, sizeof(GUID)); | |
- lpdiaf->rgoAction[i].dwHow = DIAH_UNMAPPED; | |
- } | |
- } | |
- | |
- if (!has_actions) return DI_NOEFFECT; | |
+ FIXME("(%p)->(%p,%s,%08x): semi-stub !\n", iface, lpdiaf, debugstr_w(lpszUserName), dwFlags); | |
- return IDirectInputDevice8WImpl_BuildActionMap(iface, lpdiaf, lpszUserName, dwFlags); | |
+ return _build_action_map(iface, lpdiaf, lpszUserName, dwFlags, DIMOUSE_MASK); | |
} | |
static HRESULT WINAPI SysMouseAImpl_BuildActionMap(LPDIRECTINPUTDEVICE8A iface, | |
-- | |
1.7.0.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment