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
2cea950e
Commit
2cea950e
authored
Jul 29, 2007
by
Peter Dons Tychsen
Committed by
Alexandre Julliard
Aug 08, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: Allow the use of the standard Joystick GUID when calling CreateDevice.
parent
086a91fa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
39 deletions
+65
-39
joystick_linux.c
dlls/dinput/joystick_linux.c
+24
-11
joystick_linuxinput.c
dlls/dinput/joystick_linuxinput.c
+41
-28
No files found.
dlls/dinput/joystick_linux.c
View file @
2cea950e
...
...
@@ -159,7 +159,6 @@ static INT find_joystick_devices(void)
return
joystick_devices_count
;
}
#undef MAX_JOYSTICKS
static
BOOL
joydev_enum_deviceA
(
DWORD
dwDevType
,
DWORD
dwFlags
,
LPDIDEVICEINSTANCEA
lpddi
,
DWORD
version
,
int
id
)
{
...
...
@@ -400,7 +399,8 @@ static HRESULT setup_dinput_options(JoystickImpl * device)
return
DI_OK
;
}
static
HRESULT
alloc_device
(
REFGUID
rguid
,
const
void
*
jvt
,
IDirectInputImpl
*
dinput
,
LPDIRECTINPUTDEVICEA
*
pdev
)
static
HRESULT
alloc_device
(
REFGUID
rguid
,
const
void
*
jvt
,
IDirectInputImpl
*
dinput
,
LPDIRECTINPUTDEVICEA
*
pdev
,
unsigned
short
index
)
{
DWORD
i
;
JoystickImpl
*
newDevice
;
...
...
@@ -416,7 +416,7 @@ static HRESULT alloc_device(REFGUID rguid, const void *jvt, IDirectInputImpl *di
return
DIERR_OUTOFMEMORY
;
}
if
(
!
lstrcpynA
(
newDevice
->
dev
,
joystick_devices
[
rguid
->
Data3
],
sizeof
(
newDevice
->
dev
))
||
if
(
!
lstrcpynA
(
newDevice
->
dev
,
joystick_devices
[
index
],
sizeof
(
newDevice
->
dev
))
||
(
newDevice
->
joyfd
=
open
(
newDevice
->
dev
,
O_RDONLY
))
<
0
)
{
WARN
(
"open(%s, O_RDONLY) failed: %s
\n
"
,
newDevice
->
dev
,
strerror
(
errno
));
...
...
@@ -561,7 +561,10 @@ FAILED1:
return
hr
;
}
static
BOOL
IsJoystickGUID
(
REFGUID
guid
)
/******************************************************************************
* get_joystick_index : Get the joystick index from a given GUID
*/
static
unsigned
short
get_joystick_index
(
REFGUID
guid
)
{
GUID
wine_joystick
=
DInput_Wine_Joystick_GUID
;
GUID
dev_guid
=
*
guid
;
...
...
@@ -569,19 +572,26 @@ static BOOL IsJoystickGUID(REFGUID guid)
wine_joystick
.
Data3
=
0
;
dev_guid
.
Data3
=
0
;
return
IsEqualGUID
(
&
wine_joystick
,
&
dev_guid
);
/* for the standard joystick GUID use index 0 */
if
(
IsEqualGUID
(
&
GUID_Joystick
,
guid
))
return
0
;
/* for the wine joystick GUIDs use the index stored in Data3 */
if
(
IsEqualGUID
(
&
wine_joystick
,
&
dev_guid
))
return
guid
->
Data3
;
return
MAX_JOYSTICKS
;
}
static
HRESULT
joydev_create_deviceA
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
{
if
((
IsEqualGUID
(
&
GUID_Joystick
,
rguid
))
||
(
IsJoystickGUID
(
rguid
)))
{
unsigned
short
index
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYSTICKS
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
return
alloc_device
(
rguid
,
&
JoystickAvt
,
dinput
,
pdev
);
return
alloc_device
(
rguid
,
&
JoystickAvt
,
dinput
,
pdev
,
index
);
}
else
{
WARN
(
"no interface
\n
"
);
*
pdev
=
0
;
...
...
@@ -596,14 +606,15 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
static
HRESULT
joydev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
if
((
IsEqualGUID
(
&
GUID_Joystick
,
rguid
))
||
(
IsJoystickGUID
(
rguid
)))
{
unsigned
short
index
;
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYSTICKS
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
return
alloc_device
(
rguid
,
&
JoystickWvt
,
dinput
,
(
LPDIRECTINPUTDEVICEA
*
)
pdev
);
return
alloc_device
(
rguid
,
&
JoystickWvt
,
dinput
,
(
LPDIRECTINPUTDEVICEA
*
)
pdev
,
index
);
}
else
{
WARN
(
"no interface
\n
"
);
*
pdev
=
0
;
...
...
@@ -616,6 +627,8 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
return
DIERR_DEVICENOTREG
;
}
#undef MAX_JOYSTICKS
const
struct
dinput_device
joystick_linux_device
=
{
"Wine Linux joystick driver"
,
joydev_enum_deviceA
,
...
...
dlls/dinput/joystick_linuxinput.c
View file @
2cea950e
...
...
@@ -239,6 +239,7 @@ static void find_joydevs(void)
}
if
(
fd
!=-
1
)
{
if
((
-
1
==
ioctl
(
fd
,
EVIOCGBIT
(
0
,
sizeof
(
joydev
.
evbits
)),
joydev
.
evbits
)))
{
perror
(
"EVIOCGBIT 0"
);
close
(
fd
);
...
...
@@ -391,7 +392,7 @@ static BOOL joydev_enum_deviceW(DWORD dwDevType, DWORD dwFlags, LPDIDEVICEINSTAN
return
FALSE
;
}
static
JoystickImpl
*
alloc_device
(
REFGUID
rguid
,
const
void
*
jvt
,
IDirectInputImpl
*
dinput
,
struct
JoyDev
*
joydev
)
static
JoystickImpl
*
alloc_device
(
REFGUID
rguid
,
const
void
*
jvt
,
IDirectInputImpl
*
dinput
,
unsigned
short
index
)
{
JoystickImpl
*
newDevice
;
LPDIDATAFORMAT
df
=
NULL
;
...
...
@@ -407,7 +408,7 @@ static JoystickImpl *alloc_device(REFGUID rguid, const void *jvt, IDirectInputIm
newDevice
->
base
.
crit
.
DebugInfo
->
Spare
[
0
]
=
(
DWORD_PTR
)(
__FILE__
": JoystickImpl*->base.crit"
);
newDevice
->
joyfd
=
-
1
;
newDevice
->
base
.
dinput
=
dinput
;
newDevice
->
joydev
=
joydev
;
newDevice
->
joydev
=
&
joydevs
[
index
]
;
#ifdef HAVE_STRUCT_FF_EFFECT_DIRECTION
newDevice
->
ff_state
=
FF_STATUS_STOPPED
;
#endif
...
...
@@ -475,22 +476,39 @@ failed:
return
NULL
;
}
/******************************************************************************
* get_joystick_index : Get the joystick index from a given GUID
*/
static
unsigned
short
get_joystick_index
(
REFGUID
guid
)
{
GUID
wine_joystick
=
DInput_Wine_Joystick_Base_GUID
;
GUID
dev_guid
=
*
guid
;
wine_joystick
.
Data3
=
0
;
dev_guid
.
Data3
=
0
;
/* for the standard joystick GUID use index 0 */
if
(
IsEqualGUID
(
&
GUID_Joystick
,
guid
))
return
0
;
/* for the wine joystick GUIDs use the index stored in Data3 */
if
(
IsEqualGUID
(
&
wine_joystick
,
&
dev_guid
))
return
guid
->
Data3
-
DInput_Wine_Joystick_Base_GUID
.
Data3
;
return
MAX_JOYDEV
;
}
static
HRESULT
joydev_create_deviceA
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEA
*
pdev
)
{
int
i
;
unsigned
short
index
;
find_joydevs
();
find_joydevs
();
for
(
i
=
0
;
i
<
have_joydevs
;
i
++
)
{
if
(
IsEqualGUID
(
&
GUID_Joystick
,
rguid
)
||
IsEqualGUID
(
&
joydevs
[
i
].
guid
,
rguid
)
)
{
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYDEV
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
*
pdev
=
(
IDirectInputDeviceA
*
)
alloc_device
(
rguid
,
&
JoystickAvt
,
dinput
,
&
joydevs
[
i
]
);
IsEqualGUID
(
&
IID_IDirectInputDeviceA
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7A
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8A
,
riid
))
{
*
pdev
=
(
IDirectInputDeviceA
*
)
alloc_device
(
rguid
,
&
JoystickAvt
,
dinput
,
index
);
TRACE
(
"Creating a Joystick device (%p)
\n
"
,
*
pdev
);
if
(
*
pdev
==
0
)
{
ERR
(
"out of memory
\n
"
);
...
...
@@ -501,28 +519,24 @@ static HRESULT joydev_create_deviceA(IDirectInputImpl *dinput, REFGUID rguid, RE
return
DIERR_NOINTERFACE
;
}
}
}
return
DIERR_DEVICENOTREG
;
return
DIERR_DEVICENOTREG
;
}
static
HRESULT
joydev_create_deviceW
(
IDirectInputImpl
*
dinput
,
REFGUID
rguid
,
REFIID
riid
,
LPDIRECTINPUTDEVICEW
*
pdev
)
{
int
i
;
unsigned
short
index
;
find_joydevs
();
find_joydevs
();
for
(
i
=
0
;
i
<
have_joydevs
;
i
++
)
{
if
(
IsEqualGUID
(
&
GUID_Joystick
,
rguid
)
||
IsEqualGUID
(
&
joydevs
[
i
].
guid
,
rguid
)
)
{
if
((
index
=
get_joystick_index
(
rguid
))
<
MAX_JOYDEV
)
{
if
((
riid
==
NULL
)
||
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
*
pdev
=
(
IDirectInputDeviceW
*
)
alloc_device
(
rguid
,
&
JoystickWvt
,
dinput
,
&
joydevs
[
i
]
);
IsEqualGUID
(
&
IID_IDirectInputDeviceW
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice2W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice7W
,
riid
)
||
IsEqualGUID
(
&
IID_IDirectInputDevice8W
,
riid
))
{
*
pdev
=
(
IDirectInputDeviceW
*
)
alloc_device
(
rguid
,
&
JoystickWvt
,
dinput
,
index
);
TRACE
(
"Creating a Joystick device (%p)
\n
"
,
*
pdev
);
if
(
*
pdev
==
0
)
{
ERR
(
"out of memory
\n
"
);
...
...
@@ -533,9 +547,8 @@ static HRESULT joydev_create_deviceW(IDirectInputImpl *dinput, REFGUID rguid, RE
return
DIERR_NOINTERFACE
;
}
}
}
return
DIERR_DEVICENOTREG
;
return
DIERR_DEVICENOTREG
;
}
const
struct
dinput_device
joystick_linuxinput_device
=
{
...
...
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