Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
083d6e84
Commit
083d6e84
authored
Aug 15, 2009
by
Vitaliy Margolen
Committed by
Alexandre Julliard
Aug 19, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Move setup_dinput_options into common place.
parent
1362d150
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
117 deletions
+122
-117
joystick.c
dlls/dinput/joystick.c
+120
-0
joystick_linux.c
dlls/dinput/joystick_linux.c
+1
-117
joystick_private.h
dlls/dinput/joystick_private.h
+1
-0
No files found.
dlls/dinput/joystick.c
View file @
083d6e84
...
...
@@ -28,6 +28,7 @@
#include "joystick_private.h"
#include "wine/debug.h"
#include "winreg.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
dinput
);
...
...
@@ -442,3 +443,122 @@ DWORD joystick_map_pov(POINTL *p)
else
return
p
->
y
<
0
?
0
:
!
p
->
y
?
-
1
:
18000
;
}
/*
* Setup the dinput options.
*/
HRESULT
setup_dinput_options
(
JoystickGenericImpl
*
This
)
{
char
buffer
[
MAX_PATH
+
16
];
HKEY
hkey
,
appkey
;
int
tokens
=
0
;
int
axis
=
0
;
int
pov
=
0
;
get_app_key
(
&
hkey
,
&
appkey
);
/* get options */
if
(
!
get_config_key
(
hkey
,
appkey
,
"DefaultDeadZone"
,
buffer
,
sizeof
(
buffer
)))
{
This
->
deadzone
=
atoi
(
buffer
);
TRACE
(
"setting default deadzone to:
\"
%s
\"
%d
\n
"
,
buffer
,
This
->
deadzone
);
}
This
->
axis_map
=
HeapAlloc
(
GetProcessHeap
(),
0
,
This
->
device_axis_count
*
sizeof
(
int
));
if
(
!
This
->
axis_map
)
return
DIERR_OUTOFMEMORY
;
if
(
!
get_config_key
(
hkey
,
appkey
,
This
->
name
,
buffer
,
sizeof
(
buffer
)))
{
static
const
char
*
axis_names
[]
=
{
"X"
,
"Y"
,
"Z"
,
"Rx"
,
"Ry"
,
"Rz"
,
"Slider1"
,
"Slider2"
,
"POV1"
,
"POV2"
,
"POV3"
,
"POV4"
};
const
char
*
delim
=
","
;
char
*
ptr
;
TRACE
(
"
\"
%s
\"
=
\"
%s
\"\n
"
,
This
->
name
,
buffer
);
if
((
ptr
=
strtok
(
buffer
,
delim
))
!=
NULL
)
{
do
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
axis_names
)
/
sizeof
(
axis_names
[
0
]);
i
++
)
{
if
(
!
strcmp
(
ptr
,
axis_names
[
i
]))
{
if
(
!
strncmp
(
ptr
,
"POV"
,
3
))
{
if
(
pov
>=
4
)
{
WARN
(
"Only 4 POVs supported - ignoring extra
\n
"
);
i
=
-
1
;
}
else
{
/* Pov takes two axes */
This
->
axis_map
[
tokens
++
]
=
i
;
pov
++
;
}
}
else
{
if
(
axis
>=
8
)
{
FIXME
(
"Only 8 Axes supported - ignoring extra
\n
"
);
i
=
-
1
;
}
else
axis
++
;
}
break
;
}
}
if
(
i
==
sizeof
(
axis_names
)
/
sizeof
(
axis_names
[
0
]))
{
ERR
(
"invalid joystick axis type:
\"
%s
\"\n
"
,
ptr
);
i
=
-
1
;
}
This
->
axis_map
[
tokens
]
=
i
;
tokens
++
;
}
while
((
ptr
=
strtok
(
NULL
,
delim
))
!=
NULL
);
if
(
tokens
!=
This
->
device_axis_count
)
{
ERR
(
"not all joystick axes mapped: %d axes(%d,%d), %d arguments
\n
"
,
This
->
device_axis_count
,
axis
,
pov
,
tokens
);
while
(
tokens
<
This
->
device_axis_count
)
{
This
->
axis_map
[
tokens
]
=
-
1
;
tokens
++
;
}
}
}
}
else
{
/* No config - set default mapping. */
for
(
tokens
=
0
;
tokens
<
This
->
device_axis_count
;
tokens
++
)
{
if
(
tokens
<
8
)
This
->
axis_map
[
tokens
]
=
axis
++
;
else
if
(
tokens
<
15
)
{
This
->
axis_map
[
tokens
++
]
=
8
+
pov
;
This
->
axis_map
[
tokens
]
=
8
+
pov
++
;
}
else
This
->
axis_map
[
tokens
]
=
-
1
;
}
}
This
->
devcaps
.
dwAxes
=
axis
;
This
->
devcaps
.
dwPOVs
=
pov
;
if
(
appkey
)
RegCloseKey
(
appkey
);
if
(
hkey
)
RegCloseKey
(
hkey
);
return
DI_OK
;
}
dlls/dinput/joystick_linux.c
View file @
083d6e84
...
...
@@ -62,7 +62,6 @@
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "winreg.h"
#include "dinput.h"
#include "dinput_private.h"
...
...
@@ -235,121 +234,6 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return
FALSE
;
}
/*
* Setup the dinput options.
*/
static
HRESULT
setup_dinput_options
(
JoystickImpl
*
device
)
{
char
buffer
[
MAX_PATH
+
16
];
HKEY
hkey
,
appkey
;
int
tokens
=
0
;
int
axis
=
0
;
int
pov
=
0
;
buffer
[
MAX_PATH
]
=
'\0'
;
get_app_key
(
&
hkey
,
&
appkey
);
/* get options */
if
(
!
get_config_key
(
hkey
,
appkey
,
"DefaultDeadZone"
,
buffer
,
MAX_PATH
))
{
device
->
generic
.
deadzone
=
atoi
(
buffer
);
TRACE
(
"setting default deadzone to:
\"
%s
\"
%d
\n
"
,
buffer
,
device
->
generic
.
deadzone
);
}
device
->
generic
.
axis_map
=
HeapAlloc
(
GetProcessHeap
(),
0
,
device
->
generic
.
device_axis_count
*
sizeof
(
int
));
if
(
!
device
->
generic
.
axis_map
)
return
DIERR_OUTOFMEMORY
;
if
(
!
get_config_key
(
hkey
,
appkey
,
device
->
generic
.
name
,
buffer
,
MAX_PATH
))
{
static
const
char
*
axis_names
[]
=
{
"X"
,
"Y"
,
"Z"
,
"Rx"
,
"Ry"
,
"Rz"
,
"Slider1"
,
"Slider2"
,
"POV1"
,
"POV2"
,
"POV3"
,
"POV4"
};
const
char
*
delim
=
","
;
char
*
ptr
;
TRACE
(
"
\"
%s
\"
=
\"
%s
\"\n
"
,
device
->
generic
.
name
,
buffer
);
if
((
ptr
=
strtok
(
buffer
,
delim
))
!=
NULL
)
{
do
{
int
i
;
for
(
i
=
0
;
i
<
sizeof
(
axis_names
)
/
sizeof
(
axis_names
[
0
]);
i
++
)
if
(
!
strcmp
(
ptr
,
axis_names
[
i
]))
{
if
(
!
strncmp
(
ptr
,
"POV"
,
3
))
{
if
(
pov
>=
4
)
{
WARN
(
"Only 4 POVs supported - ignoring extra
\n
"
);
i
=
-
1
;
}
else
{
/* Pov takes two axes */
device
->
generic
.
axis_map
[
tokens
++
]
=
i
;
pov
++
;
}
}
else
{
if
(
axis
>=
8
)
{
FIXME
(
"Only 8 Axes supported - ignoring extra
\n
"
);
i
=
-
1
;
}
else
axis
++
;
}
break
;
}
if
(
i
==
sizeof
(
axis_names
)
/
sizeof
(
axis_names
[
0
]))
{
ERR
(
"invalid joystick axis type:
\"
%s
\"\n
"
,
ptr
);
i
=
-
1
;
}
device
->
generic
.
axis_map
[
tokens
]
=
i
;
tokens
++
;
}
while
((
ptr
=
strtok
(
NULL
,
delim
))
!=
NULL
);
if
(
tokens
!=
device
->
generic
.
device_axis_count
)
{
ERR
(
"not all joystick axes mapped: %d axes(%d,%d), %d arguments
\n
"
,
device
->
generic
.
device_axis_count
,
axis
,
pov
,
tokens
);
while
(
tokens
<
device
->
generic
.
device_axis_count
)
{
device
->
generic
.
axis_map
[
tokens
]
=
-
1
;
tokens
++
;
}
}
}
}
else
{
for
(
tokens
=
0
;
tokens
<
device
->
generic
.
device_axis_count
;
tokens
++
)
{
if
(
tokens
<
8
)
device
->
generic
.
axis_map
[
tokens
]
=
axis
++
;
else
if
(
tokens
<
16
)
{
device
->
generic
.
axis_map
[
tokens
++
]
=
8
+
pov
;
device
->
generic
.
axis_map
[
tokens
]
=
8
+
pov
++
;
}
else
device
->
generic
.
axis_map
[
tokens
]
=
-
1
;
}
}
device
->
generic
.
devcaps
.
dwAxes
=
axis
;
device
->
generic
.
devcaps
.
dwPOVs
=
pov
;
if
(
appkey
)
RegCloseKey
(
appkey
);
if
(
hkey
)
RegCloseKey
(
hkey
);
return
DI_OK
;
}
static
HRESULT
alloc_device
(
REFGUID
rguid
,
const
void
*
jvt
,
IDirectInputImpl
*
dinput
,
LPDIRECTINPUTDEVICEA
*
pdev
,
unsigned
short
index
)
{
...
...
@@ -426,7 +310,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
newDevice
->
generic
.
deadzone
=
0
;
/* do any user specified configuration */
hr
=
setup_dinput_options
(
newDevice
);
hr
=
setup_dinput_options
(
&
newDevice
->
generic
);
if
(
hr
!=
DI_OK
)
goto
FAILED1
;
...
...
dlls/dinput/joystick_private.h
View file @
083d6e84
...
...
@@ -53,6 +53,7 @@ typedef struct JoystickGenericImpl
}
JoystickGenericImpl
;
LONG
joystick_map_axis
(
ObjProps
*
props
,
int
val
);
HRESULT
setup_dinput_options
(
JoystickGenericImpl
*
This
);
DWORD
joystick_map_pov
(
POINTL
*
p
);
...
...
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