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
e90e7e5b
Commit
e90e7e5b
authored
Mar 09, 2009
by
Aric Stewart
Committed by
Alexandre Julliard
Mar 10, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Move joystick mapping functions to the generic part.
parent
94a5e097
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
56 deletions
+59
-56
joystick.c
dlls/dinput/joystick.c
+55
-0
joystick_linuxinput.c
dlls/dinput/joystick_linuxinput.c
+1
-56
joystick_private.h
dlls/dinput/joystick_private.h
+3
-0
No files found.
dlls/dinput/joystick.c
View file @
e90e7e5b
...
...
@@ -387,3 +387,58 @@ HRESULT WINAPI JoystickAGenericImpl_GetDeviceState(
return
DI_OK
;
}
/*
* This maps the read value (from the input event) to a value in the
* 'wanted' range.
* Notes:
* Dead zone is in % multiplied by a 100 (range 0..10000)
*/
LONG
joystick_map_axis
(
ObjProps
*
props
,
int
val
)
{
LONG
ret
;
LONG
dead_zone
=
MulDiv
(
props
->
lDeadZone
,
props
->
lDevMax
-
props
->
lDevMin
,
10000
);
LONG
dev_range
=
props
->
lDevMax
-
props
->
lDevMin
-
dead_zone
;
/* Center input */
val
-=
(
props
->
lDevMin
+
props
->
lDevMax
)
/
2
;
/* Remove dead zone */
if
(
abs
(
val
)
<=
dead_zone
/
2
)
val
=
0
;
else
val
=
val
<
0
?
val
+
dead_zone
/
2
:
val
-
dead_zone
/
2
;
/* Scale and map the value from the device range into the required range */
ret
=
MulDiv
(
val
,
props
->
lMax
-
props
->
lMin
,
dev_range
)
+
(
props
->
lMin
+
props
->
lMax
)
/
2
;
/* Clamp in case or rounding errors */
if
(
ret
>
props
->
lMax
)
ret
=
props
->
lMax
;
else
if
(
ret
<
props
->
lMin
)
ret
=
props
->
lMin
;
TRACE
(
"(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d
\n
"
,
props
->
lDevMin
,
dead_zone
,
props
->
lDevMax
,
props
->
lMin
,
props
->
lDeadZone
,
props
->
lMax
,
val
,
ret
);
return
ret
;
}
/*
* Maps POV x & y event values to a DX "clock" position:
* 0
* 31500 4500
* 27000 -1 9000
* 22500 13500
* 18000
*/
DWORD
joystick_map_pov
(
POINTL
*
p
)
{
if
(
p
->
x
>
0
)
return
p
->
y
<
0
?
4500
:
!
p
->
y
?
9000
:
13500
;
else
if
(
p
->
x
<
0
)
return
p
->
y
<
0
?
31500
:
!
p
->
y
?
27000
:
22500
;
else
return
p
->
y
<
0
?
0
:
!
p
->
y
?
-
1
:
18000
;
}
dlls/dinput/joystick_linuxinput.c
View file @
e90e7e5b
...
...
@@ -64,65 +64,10 @@
#include "dinput_private.h"
#include "device_private.h"
#include "joystick_private.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
dinput
);
/*
* Maps POV x & y event values to a DX "clock" position:
* 0
* 31500 4500
* 27000 -1 9000
* 22500 13500
* 18000
*/
DWORD
joystick_map_pov
(
POINTL
*
p
)
{
if
(
p
->
x
>
0
)
return
p
->
y
<
0
?
4500
:
!
p
->
y
?
9000
:
13500
;
else
if
(
p
->
x
<
0
)
return
p
->
y
<
0
?
31500
:
!
p
->
y
?
27000
:
22500
;
else
return
p
->
y
<
0
?
0
:
!
p
->
y
?
-
1
:
18000
;
}
/*
* This maps the read value (from the input event) to a value in the
* 'wanted' range.
* Notes:
* Dead zone is in % multiplied by a 100 (range 0..10000)
*/
LONG
joystick_map_axis
(
ObjProps
*
props
,
int
val
)
{
LONG
ret
;
LONG
dead_zone
=
MulDiv
(
props
->
lDeadZone
,
props
->
lDevMax
-
props
->
lDevMin
,
10000
);
LONG
dev_range
=
props
->
lDevMax
-
props
->
lDevMin
-
dead_zone
;
/* Center input */
val
-=
(
props
->
lDevMin
+
props
->
lDevMax
)
/
2
;
/* Remove dead zone */
if
(
abs
(
val
)
<=
dead_zone
/
2
)
val
=
0
;
else
val
=
val
<
0
?
val
+
dead_zone
/
2
:
val
-
dead_zone
/
2
;
/* Scale and map the value from the device range into the required range */
ret
=
MulDiv
(
val
,
props
->
lMax
-
props
->
lMin
,
dev_range
)
+
(
props
->
lMin
+
props
->
lMax
)
/
2
;
/* Clamp in case or rounding errors */
if
(
ret
>
props
->
lMax
)
ret
=
props
->
lMax
;
else
if
(
ret
<
props
->
lMin
)
ret
=
props
->
lMin
;
TRACE
(
"(%d <%d> %d) -> (%d <%d> %d): val=%d ret=%d
\n
"
,
props
->
lDevMin
,
dead_zone
,
props
->
lDevMax
,
props
->
lMin
,
props
->
lDeadZone
,
props
->
lMax
,
val
,
ret
);
return
ret
;
}
#ifdef HAVE_CORRECT_LINUXINPUT_H
#define EVDEVPREFIX "/dev/input/event"
...
...
dlls/dinput/joystick_private.h
View file @
e90e7e5b
...
...
@@ -46,6 +46,9 @@ typedef struct JoystickGenericImpl
joy_polldev_handler
*
joy_polldev
;
}
JoystickGenericImpl
;
LONG
joystick_map_axis
(
ObjProps
*
props
,
int
val
);
DWORD
joystick_map_pov
(
POINTL
*
p
);
HRESULT
WINAPI
JoystickWGenericImpl_GetObjectInfo
(
LPDIRECTINPUTDEVICE8W
iface
,
LPDIDEVICEOBJECTINSTANCEW
pdidoi
,
DWORD
dwObj
,
DWORD
dwHow
);
...
...
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