Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
wine
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexey Alyaev
wine
Commits
083d6e84
Commit
083d6e84
authored
15 years ago
by
Vitaliy Margolen
Committed by
Alexandre Julliard
15 years ago
Browse files
Options
Downloads
Patches
Plain Diff
dinput: Move setup_dinput_options into common place.
parent
1362d150
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dlls/dinput/joystick.c
+120
-0
120 additions, 0 deletions
dlls/dinput/joystick.c
dlls/dinput/joystick_linux.c
+1
-117
1 addition, 117 deletions
dlls/dinput/joystick_linux.c
dlls/dinput/joystick_private.h
+1
-0
1 addition, 0 deletions
dlls/dinput/joystick_private.h
with
122 additions
and
117 deletions
dlls/dinput/joystick.c
+
120
−
0
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
;
}
This diff is collapsed.
Click to expand it.
dlls/dinput/joystick_linux.c
+
1
−
117
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
;
...
...
This diff is collapsed.
Click to expand it.
dlls/dinput/joystick_private.h
+
1
−
0
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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment