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
c918234f
Commit
c918234f
authored
Nov 18, 2021
by
Rémi Bernon
Committed by
Alexandre Julliard
Nov 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Reset axis and pov values on object property change.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1ae1744c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
8 deletions
+40
-8
device.c
dlls/dinput/device.c
+39
-0
joystick_hid.c
dlls/dinput/joystick_hid.c
+1
-8
No files found.
dlls/dinput/device.c
View file @
c918234f
...
...
@@ -27,6 +27,7 @@
#include <stdarg.h>
#include <string.h>
#include <math.h>
#include "windef.h"
#include "winbase.h"
...
...
@@ -1037,6 +1038,39 @@ static BOOL CALLBACK set_object_property( const DIDEVICEOBJECTINSTANCEW *instanc
return
DIENUM_CONTINUE
;
}
static
BOOL
CALLBACK
reset_object_value
(
const
DIDEVICEOBJECTINSTANCEW
*
instance
,
void
*
context
)
{
struct
dinput_device
*
impl
=
context
;
struct
object_properties
*
properties
;
LONG
tmp
=
-
1
;
if
(
!
impl
->
object_properties
)
return
DIENUM_STOP
;
properties
=
impl
->
object_properties
+
instance
->
dwOfs
/
sizeof
(
LONG
);
if
(
instance
->
dwType
&
DIDFT_AXIS
)
{
if
(
!
properties
->
range_min
)
tmp
=
properties
->
range_max
/
2
;
else
tmp
=
round
(
(
properties
->
range_min
+
properties
->
range_max
)
/
2
.
0
);
}
*
(
LONG
*
)(
impl
->
device_state
+
instance
->
dwOfs
)
=
tmp
;
return
DIENUM_CONTINUE
;
}
static
void
reset_device_state
(
IDirectInputDevice8W
*
iface
)
{
struct
dinput_device
*
impl
=
impl_from_IDirectInputDevice8W
(
iface
);
DIPROPHEADER
filter
=
{
.
dwHeaderSize
=
sizeof
(
DIPROPHEADER
),
.
dwSize
=
sizeof
(
DIPROPHEADER
),
.
dwHow
=
DIPH_DEVICE
,
.
dwObj
=
0
,
};
impl
->
vtbl
->
enum_objects
(
iface
,
&
filter
,
DIDFT_AXIS
|
DIDFT_POV
,
reset_object_value
,
impl
);
}
static
HRESULT
WINAPI
dinput_device_SetProperty
(
IDirectInputDevice8W
*
iface
,
const
GUID
*
guid
,
const
DIPROPHEADER
*
header
)
{
...
...
@@ -1065,6 +1099,7 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
if
(
value
->
lMin
>
value
->
lMax
)
return
DIERR_INVALIDPARAM
;
hr
=
impl
->
vtbl
->
enum_objects
(
iface
,
&
filter
,
DIDFT_AXIS
,
set_object_property
,
&
params
);
if
(
FAILED
(
hr
))
return
hr
;
reset_device_state
(
iface
);
return
DI_OK
;
}
case
(
DWORD_PTR
)
DIPROP_DEADZONE
:
...
...
@@ -1075,6 +1110,7 @@ static HRESULT WINAPI dinput_device_SetProperty( IDirectInputDevice8W *iface, co
if
(
value
->
dwData
>
10000
)
return
DIERR_INVALIDPARAM
;
hr
=
impl
->
vtbl
->
enum_objects
(
iface
,
&
filter
,
DIDFT_AXIS
,
set_object_property
,
&
params
);
if
(
FAILED
(
hr
))
return
hr
;
reset_device_state
(
iface
);
return
DI_OK
;
}
case
(
DWORD_PTR
)
DIPROP_AUTOCENTER
:
...
...
@@ -1922,6 +1958,9 @@ static BOOL CALLBACK enum_objects_init( const DIDEVICEOBJECTINSTANCEW *instance,
obj_format
->
dwFlags
=
instance
->
dwFlags
;
}
if
(
impl
->
object_properties
&&
(
instance
->
dwType
&
(
DIDFT_AXIS
|
DIDFT_POV
)))
reset_object_value
(
instance
,
impl
);
format
->
dwNumObjs
++
;
return
DIENUM_CONTINUE
;
}
...
...
dlls/dinput/joystick_hid.c
View file @
c918234f
...
...
@@ -789,17 +789,10 @@ static void set_extra_caps_range( struct hid_joystick *impl, const DIDEVICEOBJEC
properties
->
range_min
=
min
;
properties
->
range_max
=
max
;
if
(
instance
->
dwType
&
DIDFT_AXIS
)
{
if
(
!
properties
->
range_min
)
tmp
=
properties
->
range_max
/
2
;
else
tmp
=
round
(
(
properties
->
range_min
+
properties
->
range_max
)
/
2
.
0
);
*
(
LONG
*
)(
impl
->
base
.
device_state
+
instance
->
dwOfs
)
=
tmp
;
}
else
if
(
instance
->
dwType
&
DIDFT_POV
)
if
(
instance
->
dwType
&
DIDFT_POV
)
{
tmp
=
properties
->
logical_max
-
properties
->
logical_min
;
if
(
tmp
>
0
)
properties
->
range_max
-=
max
/
(
tmp
+
1
);
*
(
LONG
*
)(
impl
->
base
.
device_state
+
instance
->
dwOfs
)
=
-
1
;
}
}
...
...
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