Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
18981330
Commit
18981330
authored
Oct 13, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Oct 13, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Factor all SetActionMap wrappers together.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
30ea1876
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
128 additions
and
144 deletions
+128
-144
device.c
dlls/dinput/device.c
+123
-105
device_private.h
dlls/dinput/device_private.h
+2
-2
joystick_hid.c
dlls/dinput/joystick_hid.c
+1
-13
keyboard.c
dlls/dinput/keyboard.c
+1
-12
mouse.c
dlls/dinput/mouse.c
+1
-12
No files found.
dlls/dinput/device.c
View file @
18981330
...
...
@@ -827,111 +827,6 @@ static BOOL set_app_data(IDirectInputDeviceImpl *dev, int offset, UINT_PTR app_d
return
TRUE
;
}
HRESULT
_set_action_map
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIACTIONFORMATW
lpdiaf
,
LPCWSTR
lpszUserName
,
DWORD
dwFlags
,
LPCDIDATAFORMAT
df
)
{
IDirectInputDeviceImpl
*
This
=
impl_from_IDirectInputDevice8W
(
iface
);
DIDATAFORMAT
data_format
;
DIOBJECTDATAFORMAT
*
obj_df
=
NULL
;
DIPROPDWORD
dp
;
DIPROPRANGE
dpr
;
DIPROPSTRING
dps
;
WCHAR
username
[
MAX_PATH
];
DWORD
username_size
=
MAX_PATH
;
int
i
,
action
=
0
,
num_actions
=
0
;
unsigned
int
offset
=
0
;
ActionMap
*
action_map
;
if
(
This
->
acquired
)
return
DIERR_ACQUIRED
;
data_format
.
dwSize
=
sizeof
(
data_format
);
data_format
.
dwObjSize
=
sizeof
(
DIOBJECTDATAFORMAT
);
data_format
.
dwFlags
=
DIDF_RELAXIS
;
data_format
.
dwDataSize
=
lpdiaf
->
dwDataSize
;
/* Count the actions */
for
(
i
=
0
;
i
<
lpdiaf
->
dwNumActions
;
i
++
)
if
(
IsEqualGUID
(
&
This
->
guid
,
&
lpdiaf
->
rgoAction
[
i
].
guidInstance
))
num_actions
++
;
if
(
num_actions
==
0
)
return
DI_NOEFFECT
;
/* Construct the dataformat and actionmap */
obj_df
=
malloc
(
sizeof
(
DIOBJECTDATAFORMAT
)
*
num_actions
);
data_format
.
rgodf
=
(
LPDIOBJECTDATAFORMAT
)
obj_df
;
data_format
.
dwNumObjs
=
num_actions
;
action_map
=
malloc
(
sizeof
(
ActionMap
)
*
num_actions
);
for
(
i
=
0
;
i
<
lpdiaf
->
dwNumActions
;
i
++
)
{
if
(
IsEqualGUID
(
&
This
->
guid
,
&
lpdiaf
->
rgoAction
[
i
].
guidInstance
))
{
DWORD
inst
=
DIDFT_GETINSTANCE
(
lpdiaf
->
rgoAction
[
i
].
dwObjID
);
DWORD
type
=
DIDFT_GETTYPE
(
lpdiaf
->
rgoAction
[
i
].
dwObjID
);
LPDIOBJECTDATAFORMAT
obj
;
if
(
type
==
DIDFT_PSHBUTTON
)
type
=
DIDFT_BUTTON
;
if
(
type
==
DIDFT_RELAXIS
)
type
=
DIDFT_AXIS
;
obj
=
dataformat_to_odf_by_type
(
df
,
inst
,
type
);
memcpy
(
&
obj_df
[
action
],
obj
,
df
->
dwObjSize
);
action_map
[
action
].
uAppData
=
lpdiaf
->
rgoAction
[
i
].
uAppData
;
action_map
[
action
].
offset
=
offset
;
obj_df
[
action
].
dwOfs
=
offset
;
offset
+=
(
type
&
DIDFT_BUTTON
)
?
1
:
4
;
action
++
;
}
}
IDirectInputDevice8_SetDataFormat
(
iface
,
&
data_format
);
This
->
action_map
=
action_map
;
This
->
num_actions
=
num_actions
;
free
(
obj_df
);
/* Set the device properties according to the action format */
dpr
.
diph
.
dwSize
=
sizeof
(
DIPROPRANGE
);
dpr
.
lMin
=
lpdiaf
->
lAxisMin
;
dpr
.
lMax
=
lpdiaf
->
lAxisMax
;
dpr
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dpr
.
diph
.
dwHow
=
DIPH_DEVICE
;
IDirectInputDevice8_SetProperty
(
iface
,
DIPROP_RANGE
,
&
dpr
.
diph
);
if
(
lpdiaf
->
dwBufferSize
>
0
)
{
dp
.
diph
.
dwSize
=
sizeof
(
DIPROPDWORD
);
dp
.
dwData
=
lpdiaf
->
dwBufferSize
;
dp
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dp
.
diph
.
dwHow
=
DIPH_DEVICE
;
IDirectInputDevice8_SetProperty
(
iface
,
DIPROP_BUFFERSIZE
,
&
dp
.
diph
);
}
/* Retrieve logged user name if necessary */
if
(
lpszUserName
==
NULL
)
GetUserNameW
(
username
,
&
username_size
);
else
lstrcpynW
(
username
,
lpszUserName
,
MAX_PATH
);
dps
.
diph
.
dwSize
=
sizeof
(
dps
);
dps
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dps
.
diph
.
dwObj
=
0
;
dps
.
diph
.
dwHow
=
DIPH_DEVICE
;
if
(
dwFlags
&
DIDSAM_NOUSER
)
dps
.
wsz
[
0
]
=
'\0'
;
else
lstrcpynW
(
dps
.
wsz
,
username
,
ARRAY_SIZE
(
dps
.
wsz
));
IDirectInputDevice2WImpl_SetProperty
(
iface
,
DIPROP_USERNAME
,
&
dps
.
diph
);
/* Save the settings to disk */
save_mapping_settings
(
iface
,
lpdiaf
,
username
);
return
DI_OK
;
}
/******************************************************************************
* queue_event - add new event to the ring queue
*/
...
...
@@ -1760,6 +1655,129 @@ HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap( IDirectInputDevice8W *if
return
DI_OK
;
}
HRESULT
WINAPI
IDirectInputDevice8WImpl_SetActionMap
(
IDirectInputDevice8W
*
iface
,
DIACTIONFORMATW
*
format
,
const
WCHAR
*
username
,
DWORD
flags
)
{
IDirectInputDeviceImpl
*
impl
=
impl_from_IDirectInputDevice8W
(
iface
);
DIDATAFORMAT
data_format
;
DIOBJECTDATAFORMAT
*
obj_df
=
NULL
;
DIPROPDWORD
dp
;
DIPROPRANGE
dpr
;
DIPROPSTRING
dps
;
WCHAR
username_buf
[
MAX_PATH
];
DWORD
username_len
=
MAX_PATH
;
int
i
,
action
=
0
,
num_actions
=
0
;
unsigned
int
offset
=
0
;
const
DIDATAFORMAT
*
df
;
ActionMap
*
action_map
;
FIXME
(
"iface %p, format %p, username %s, flags %#x semi-stub!
\n
"
,
iface
,
format
,
debugstr_w
(
username
),
flags
);
if
(
!
format
)
return
DIERR_INVALIDPARAM
;
switch
(
GET_DIDEVICE_TYPE
(
impl
->
instance
.
dwDevType
))
{
case
DIDEVTYPE_KEYBOARD
:
case
DI8DEVTYPE_KEYBOARD
:
df
=
&
c_dfDIKeyboard
;
break
;
case
DIDEVTYPE_MOUSE
:
case
DI8DEVTYPE_MOUSE
:
df
=
&
c_dfDIMouse2
;
break
;
default:
df
=
impl
->
data_format
.
wine_df
;
break
;
}
if
(
impl
->
acquired
)
return
DIERR_ACQUIRED
;
data_format
.
dwSize
=
sizeof
(
data_format
);
data_format
.
dwObjSize
=
sizeof
(
DIOBJECTDATAFORMAT
);
data_format
.
dwFlags
=
DIDF_RELAXIS
;
data_format
.
dwDataSize
=
format
->
dwDataSize
;
/* Count the actions */
for
(
i
=
0
;
i
<
format
->
dwNumActions
;
i
++
)
if
(
IsEqualGUID
(
&
impl
->
guid
,
&
format
->
rgoAction
[
i
].
guidInstance
))
num_actions
++
;
if
(
num_actions
==
0
)
return
DI_NOEFFECT
;
/* Construct the dataformat and actionmap */
obj_df
=
malloc
(
sizeof
(
DIOBJECTDATAFORMAT
)
*
num_actions
);
data_format
.
rgodf
=
(
LPDIOBJECTDATAFORMAT
)
obj_df
;
data_format
.
dwNumObjs
=
num_actions
;
action_map
=
malloc
(
sizeof
(
ActionMap
)
*
num_actions
);
for
(
i
=
0
;
i
<
format
->
dwNumActions
;
i
++
)
{
if
(
IsEqualGUID
(
&
impl
->
guid
,
&
format
->
rgoAction
[
i
].
guidInstance
))
{
DWORD
inst
=
DIDFT_GETINSTANCE
(
format
->
rgoAction
[
i
].
dwObjID
);
DWORD
type
=
DIDFT_GETTYPE
(
format
->
rgoAction
[
i
].
dwObjID
);
LPDIOBJECTDATAFORMAT
obj
;
if
(
type
==
DIDFT_PSHBUTTON
)
type
=
DIDFT_BUTTON
;
if
(
type
==
DIDFT_RELAXIS
)
type
=
DIDFT_AXIS
;
obj
=
dataformat_to_odf_by_type
(
df
,
inst
,
type
);
memcpy
(
&
obj_df
[
action
],
obj
,
df
->
dwObjSize
);
action_map
[
action
].
uAppData
=
format
->
rgoAction
[
i
].
uAppData
;
action_map
[
action
].
offset
=
offset
;
obj_df
[
action
].
dwOfs
=
offset
;
offset
+=
(
type
&
DIDFT_BUTTON
)
?
1
:
4
;
action
++
;
}
}
IDirectInputDevice8_SetDataFormat
(
iface
,
&
data_format
);
impl
->
action_map
=
action_map
;
impl
->
num_actions
=
num_actions
;
free
(
obj_df
);
/* Set the device properties according to the action format */
dpr
.
diph
.
dwSize
=
sizeof
(
DIPROPRANGE
);
dpr
.
lMin
=
format
->
lAxisMin
;
dpr
.
lMax
=
format
->
lAxisMax
;
dpr
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dpr
.
diph
.
dwHow
=
DIPH_DEVICE
;
IDirectInputDevice8_SetProperty
(
iface
,
DIPROP_RANGE
,
&
dpr
.
diph
);
if
(
format
->
dwBufferSize
>
0
)
{
dp
.
diph
.
dwSize
=
sizeof
(
DIPROPDWORD
);
dp
.
dwData
=
format
->
dwBufferSize
;
dp
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dp
.
diph
.
dwHow
=
DIPH_DEVICE
;
IDirectInputDevice8_SetProperty
(
iface
,
DIPROP_BUFFERSIZE
,
&
dp
.
diph
);
}
/* Retrieve logged user name if necessary */
if
(
username
==
NULL
)
GetUserNameW
(
username_buf
,
&
username_len
);
else
lstrcpynW
(
username_buf
,
username
,
MAX_PATH
);
dps
.
diph
.
dwSize
=
sizeof
(
dps
);
dps
.
diph
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
);
dps
.
diph
.
dwObj
=
0
;
dps
.
diph
.
dwHow
=
DIPH_DEVICE
;
if
(
flags
&
DIDSAM_NOUSER
)
dps
.
wsz
[
0
]
=
'\0'
;
else
lstrcpynW
(
dps
.
wsz
,
username_buf
,
ARRAY_SIZE
(
dps
.
wsz
)
);
IDirectInputDevice2WImpl_SetProperty
(
iface
,
DIPROP_USERNAME
,
&
dps
.
diph
);
/* Save the settings to disk */
save_mapping_settings
(
iface
,
format
,
username_buf
);
return
DI_OK
;
}
HRESULT
WINAPI
IDirectInputDevice8WImpl_GetImageInfo
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIDEVICEIMAGEINFOHEADERW
lpdiDevImageInfoHeader
)
{
...
...
dlls/dinput/device_private.h
View file @
18981330
...
...
@@ -114,8 +114,6 @@ extern void _dump_OBJECTINSTANCEW(const DIDEVICEOBJECTINSTANCEW *ddoi) DECLSPEC
extern
void
_dump_DIDATAFORMAT
(
const
DIDATAFORMAT
*
df
)
DECLSPEC_HIDDEN
;
extern
const
char
*
_dump_dinput_GUID
(
const
GUID
*
guid
)
DECLSPEC_HIDDEN
;
extern
HRESULT
_set_action_map
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIACTIONFORMATW
lpdiaf
,
LPCWSTR
lpszUserName
,
DWORD
dwFlags
,
LPCDIDATAFORMAT
df
)
DECLSPEC_HIDDEN
;
/* And the stubs */
extern
HRESULT
WINAPI
IDirectInputDevice2WImpl_Acquire
(
LPDIRECTINPUTDEVICE8W
iface
)
DECLSPEC_HIDDEN
;
extern
HRESULT
WINAPI
IDirectInputDevice2WImpl_Unacquire
(
LPDIRECTINPUTDEVICE8W
iface
)
DECLSPEC_HIDDEN
;
...
...
@@ -178,6 +176,8 @@ extern HRESULT WINAPI IDirectInputDevice8WImpl_BuildActionMap(LPDIRECTINPUTDEVIC
LPDIACTIONFORMATW
lpdiaf
,
LPCWSTR
lpszUserName
,
DWORD
dwFlags
)
DECLSPEC_HIDDEN
;
extern
HRESULT
WINAPI
IDirectInputDevice8WImpl_SetActionMap
(
IDirectInputDevice8W
*
iface
,
DIACTIONFORMATW
*
format
,
const
WCHAR
*
username
,
DWORD
flags
);
extern
HRESULT
WINAPI
IDirectInputDevice8WImpl_GetImageInfo
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIDEVICEIMAGEINFOHEADERW
lpdiDevImageInfoHeader
)
DECLSPEC_HIDDEN
;
...
...
dlls/dinput/joystick_hid.c
View file @
18981330
...
...
@@ -1385,18 +1385,6 @@ static HRESULT WINAPI hid_joystick_Poll( IDirectInputDevice8W *iface )
return
hr
;
}
static
HRESULT
WINAPI
hid_joystick_SetActionMap
(
IDirectInputDevice8W
*
iface
,
DIACTIONFORMATW
*
format
,
const
WCHAR
*
username
,
DWORD
flags
)
{
struct
hid_joystick
*
impl
=
impl_from_IDirectInputDevice8W
(
iface
);
TRACE
(
"iface %p, format %p, username %s, flags %#x.
\n
"
,
iface
,
format
,
debugstr_w
(
username
),
flags
);
if
(
!
format
)
return
DIERR_INVALIDPARAM
;
return
_set_action_map
(
iface
,
format
,
username
,
flags
,
impl
->
base
.
data_format
.
wine_df
);
}
static
const
IDirectInputDevice8WVtbl
hid_joystick_vtbl
=
{
/*** IUnknown methods ***/
...
...
@@ -1434,7 +1422,7 @@ static const IDirectInputDevice8WVtbl hid_joystick_vtbl =
IDirectInputDevice7WImpl_WriteEffectToFile
,
/*** IDirectInputDevice8 methods ***/
IDirectInputDevice8WImpl_BuildActionMap
,
hid_joystick
_SetActionMap
,
IDirectInputDevice8WImpl
_SetActionMap
,
IDirectInputDevice8WImpl_GetImageInfo
,
};
...
...
dlls/dinput/keyboard.c
View file @
18981330
...
...
@@ -410,17 +410,6 @@ static HRESULT WINAPI SysKeyboardWImpl_Acquire(LPDIRECTINPUTDEVICE8W iface)
return
res
;
}
static
HRESULT
WINAPI
SysKeyboardWImpl_SetActionMap
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIACTIONFORMATW
lpdiaf
,
LPCWSTR
lpszUserName
,
DWORD
dwFlags
)
{
SysKeyboardImpl
*
This
=
impl_from_IDirectInputDevice8W
(
iface
);
FIXME
(
"(%p)->(%p,%s,%08x): semi-stub !
\n
"
,
This
,
lpdiaf
,
debugstr_w
(
lpszUserName
),
dwFlags
);
return
_set_action_map
(
iface
,
lpdiaf
,
lpszUserName
,
dwFlags
,
&
c_dfDIKeyboard
);
}
static
const
IDirectInputDevice8WVtbl
SysKeyboardWvt
=
{
IDirectInputDevice2WImpl_QueryInterface
,
...
...
@@ -453,6 +442,6 @@ static const IDirectInputDevice8WVtbl SysKeyboardWvt =
IDirectInputDevice7WImpl_EnumEffectsInFile
,
IDirectInputDevice7WImpl_WriteEffectToFile
,
IDirectInputDevice8WImpl_BuildActionMap
,
SysKeyboard
WImpl_SetActionMap
,
IDirectInputDevice8
WImpl_SetActionMap
,
IDirectInputDevice8WImpl_GetImageInfo
};
dlls/dinput/mouse.c
View file @
18981330
...
...
@@ -676,17 +676,6 @@ static HRESULT WINAPI SysMouseWImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
return
res
;
}
static
HRESULT
WINAPI
SysMouseWImpl_SetActionMap
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIACTIONFORMATW
lpdiaf
,
LPCWSTR
lpszUserName
,
DWORD
dwFlags
)
{
SysMouseImpl
*
This
=
impl_from_IDirectInputDevice8W
(
iface
);
FIXME
(
"(%p)->(%p,%s,%08x): semi-stub !
\n
"
,
This
,
lpdiaf
,
debugstr_w
(
lpszUserName
),
dwFlags
);
return
_set_action_map
(
iface
,
lpdiaf
,
lpszUserName
,
dwFlags
,
&
c_dfDIMouse2
);
}
static
const
IDirectInputDevice8WVtbl
SysMouseWvt
=
{
IDirectInputDevice2WImpl_QueryInterface
,
...
...
@@ -719,6 +708,6 @@ static const IDirectInputDevice8WVtbl SysMouseWvt =
IDirectInputDevice7WImpl_EnumEffectsInFile
,
IDirectInputDevice7WImpl_WriteEffectToFile
,
IDirectInputDevice8WImpl_BuildActionMap
,
SysMouse
WImpl_SetActionMap
,
IDirectInputDevice8
WImpl_SetActionMap
,
IDirectInputDevice8WImpl_GetImageInfo
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment