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
fa5f61f5
Commit
fa5f61f5
authored
Sep 20, 2010
by
Zach Smith
Committed by
Alexandre Julliard
Sep 21, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dinput: OSX joystick driver separate device for each top level HID collection.
parent
af0c074d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
20 deletions
+103
-20
joystick_osx.c
dlls/dinput/joystick_osx.c
+103
-20
No files found.
dlls/dinput/joystick_osx.c
View file @
fa5f61f5
...
@@ -119,7 +119,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
...
@@ -119,7 +119,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dinput);
#ifdef HAVE_IOHIDMANAGERCREATE
#ifdef HAVE_IOHIDMANAGERCREATE
static
IOHIDManagerRef
gIOHIDManagerRef
=
NULL
;
static
IOHIDManagerRef
gIOHIDManagerRef
=
NULL
;
static
CFArrayRef
g
Device
s
=
NULL
;
static
CFArrayRef
g
Collection
s
=
NULL
;
typedef
struct
JoystickImpl
JoystickImpl
;
typedef
struct
JoystickImpl
JoystickImpl
;
static
const
IDirectInputDevice8AVtbl
JoystickAvt
;
static
const
IDirectInputDevice8AVtbl
JoystickAvt
;
...
@@ -194,6 +194,64 @@ static CFMutableDictionaryRef creates_osx_device_match(int usage)
...
@@ -194,6 +194,64 @@ static CFMutableDictionaryRef creates_osx_device_match(int usage)
return
result
;
return
result
;
}
}
static
CFIndex
find_top_level
(
IOHIDDeviceRef
tIOHIDDeviceRef
,
CFArrayRef
topLevels
)
{
CFArrayRef
gElementCFArrayRef
;
CFIndex
numTops
=
0
;
if
(
!
tIOHIDDeviceRef
)
return
0
;
gElementCFArrayRef
=
IOHIDDeviceCopyMatchingElements
(
tIOHIDDeviceRef
,
NULL
,
0
);
if
(
gElementCFArrayRef
)
{
CFIndex
idx
,
cnt
=
CFArrayGetCount
(
gElementCFArrayRef
);
for
(
idx
=
0
;
idx
<
cnt
;
idx
++
)
{
IOHIDElementRef
tIOHIDElementRef
=
(
IOHIDElementRef
)
CFArrayGetValueAtIndex
(
gElementCFArrayRef
,
idx
);
int
eleType
=
IOHIDElementGetType
(
tIOHIDElementRef
);
/* Check for top-level gaming device collections */
if
(
eleType
==
kIOHIDElementTypeCollection
&&
IOHIDElementGetParent
(
tIOHIDElementRef
)
==
0
)
{
int
tUsagePage
=
IOHIDElementGetUsagePage
(
tIOHIDElementRef
);
int
tUsage
=
IOHIDElementGetUsage
(
tIOHIDElementRef
);
if
(
tUsagePage
==
kHIDPage_GenericDesktop
&&
(
tUsage
==
kHIDUsage_GD_Joystick
||
tUsage
==
kHIDUsage_GD_GamePad
))
{
CFArrayAppendValue
((
CFMutableArrayRef
)
topLevels
,
tIOHIDElementRef
);
numTops
++
;
}
}
}
}
return
numTops
;
}
static
void
get_element_children
(
IOHIDElementRef
tElement
,
CFArrayRef
childElements
)
{
CFIndex
idx
,
cnt
;
CFArrayRef
tElementChildrenArray
=
IOHIDElementGetChildren
(
tElement
);
cnt
=
CFArrayGetCount
(
tElementChildrenArray
);
if
(
cnt
<
1
)
return
;
/* Either add the element to the array or grab its children */
for
(
idx
=
0
;
idx
<
cnt
;
idx
++
)
{
IOHIDElementRef
tChildElementRef
;
tChildElementRef
=
(
IOHIDElementRef
)
CFArrayGetValueAtIndex
(
tElementChildrenArray
,
idx
);
if
(
IOHIDElementGetType
(
tChildElementRef
)
==
kIOHIDElementTypeCollection
)
get_element_children
(
tChildElementRef
,
childElements
);
else
CFArrayAppendValue
((
CFMutableArrayRef
)
childElements
,
tChildElementRef
);
}
}
static
int
find_osx_devices
(
void
)
static
int
find_osx_devices
(
void
)
{
{
IOReturn
tIOReturn
;
IOReturn
tIOReturn
;
...
@@ -213,14 +271,14 @@ static int find_osx_devices(void)
...
@@ -213,14 +271,14 @@ static int find_osx_devices(void)
&
kCFTypeArrayCallBacks
);
&
kCFTypeArrayCallBacks
);
/* build matching dictionary */
/* build matching dictionary */
result
=
creates_osx_device_match
(
kHID
Page_Sport
);
result
=
creates_osx_device_match
(
kHID
Usage_GD_Joystick
);
if
(
!
result
)
if
(
!
result
)
{
{
CFRelease
(
matching
);
CFRelease
(
matching
);
return
0
;
return
0
;
}
}
CFArrayAppendValue
(
(
CFMutableArrayRef
)
matching
,
result
);
CFArrayAppendValue
(
(
CFMutableArrayRef
)
matching
,
result
);
result
=
creates_osx_device_match
(
kHID
Page_Game
);
result
=
creates_osx_device_match
(
kHID
Usage_GD_GamePad
);
if
(
!
result
)
if
(
!
result
)
{
{
CFRelease
(
matching
);
CFRelease
(
matching
);
...
@@ -232,17 +290,31 @@ static int find_osx_devices(void)
...
@@ -232,17 +290,31 @@ static int find_osx_devices(void)
devset
=
IOHIDManagerCopyDevices
(
gIOHIDManagerRef
);
devset
=
IOHIDManagerCopyDevices
(
gIOHIDManagerRef
);
if
(
devset
)
if
(
devset
)
{
{
CFIndex
count
;
CFIndex
countDevices
,
countCollections
,
idx
;
gDevices
=
CFArrayCreateMutable
(
kCFAllocatorDefault
,
0
,
CFArrayRef
gDevices
=
CFArrayCreateMutable
(
kCFAllocatorDefault
,
0
,
&
kCFTypeArrayCallBacks
);
&
kCFTypeArrayCallBacks
);
CFSetApplyFunction
(
devset
,
CFSetApplierFunctionCopyToCFArray
,
(
void
*
)
gDevices
);
CFSetApplyFunction
(
devset
,
CFSetApplierFunctionCopyToCFArray
,
(
void
*
)
gDevices
);
count
=
CFArrayGetCount
(
gDevices
);
CFRelease
(
devset
);
CFRelease
(
devset
);
count
=
CFArrayGetCount
(
gDevices
);
count
Devices
=
CFArrayGetCount
(
gDevices
);
TRACE
(
"found %i device(s)
\n
"
,(
int
)
count
);
gCollections
=
CFArrayCreateMutable
(
kCFAllocatorDefault
,
0
,
&
kCFTypeArrayCallBacks
);
return
count
;
if
(
!
gCollections
)
return
0
;
countCollections
=
0
;
for
(
idx
=
0
;
idx
<
countDevices
;
idx
++
)
{
CFIndex
tTop
;
IOHIDDeviceRef
tDevice
;
tDevice
=
(
IOHIDDeviceRef
)
CFArrayGetValueAtIndex
(
gDevices
,
idx
);
tTop
=
find_top_level
(
tDevice
,
gCollections
);
countCollections
+=
tTop
;
}
CFRelease
(
gDevices
);
TRACE
(
"found %i device(s), %i collection(s)
\n
"
,(
int
)
countDevices
,(
int
)
countCollections
);
return
(
int
)
countCollections
;
}
}
return
0
;
return
0
;
}
}
...
@@ -250,12 +322,21 @@ static int find_osx_devices(void)
...
@@ -250,12 +322,21 @@ static int find_osx_devices(void)
static
int
get_osx_device_name
(
int
id
,
char
*
name
,
int
length
)
static
int
get_osx_device_name
(
int
id
,
char
*
name
,
int
length
)
{
{
CFStringRef
str
;
CFStringRef
str
;
IOHIDElementRef
tIOHIDElementRef
;
IOHIDDeviceRef
tIOHIDDeviceRef
;
IOHIDDeviceRef
tIOHIDDeviceRef
;
if
(
!
gDevices
)
if
(
!
gCollections
)
return
0
;
tIOHIDElementRef
=
(
IOHIDElementRef
)
CFArrayGetValueAtIndex
(
gCollections
,
id
);
if
(
!
tIOHIDElementRef
)
{
ERR
(
"Invalid Element requested %i
\n
"
,
id
);
return
0
;
return
0
;
}
tIOHIDDeviceRef
=
(
IOHIDDeviceRef
)
CFArrayGetValueAtIndex
(
gDevices
,
id
);
tIOHIDDeviceRef
=
IOHIDElementGetDevice
(
tIOHIDElementRef
);
if
(
name
)
if
(
name
)
name
[
0
]
=
0
;
name
[
0
]
=
0
;
...
@@ -304,7 +385,7 @@ static void insert_sort_button(int header, IOHIDElementRef tIOHIDElementRef,
...
@@ -304,7 +385,7 @@ static void insert_sort_button(int header, IOHIDElementRef tIOHIDElementRef,
static
void
get_osx_device_elements
(
JoystickImpl
*
device
,
int
axis_map
[
8
])
static
void
get_osx_device_elements
(
JoystickImpl
*
device
,
int
axis_map
[
8
])
{
{
IOHID
DeviceRef
tIOHIDDevice
Ref
;
IOHID
ElementRef
tIOHIDElement
Ref
;
CFArrayRef
gElementCFArrayRef
;
CFArrayRef
gElementCFArrayRef
;
DWORD
axes
=
0
;
DWORD
axes
=
0
;
DWORD
sliders
=
0
;
DWORD
sliders
=
0
;
...
@@ -313,16 +394,16 @@ static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
...
@@ -313,16 +394,16 @@ static void get_osx_device_elements(JoystickImpl *device, int axis_map[8])
device
->
elementCFArrayRef
=
NULL
;
device
->
elementCFArrayRef
=
NULL
;
if
(
!
g
Device
s
)
if
(
!
g
Collection
s
)
return
;
return
;
tIOHID
DeviceRef
=
(
IOHIDDeviceRef
)
CFArrayGetValueAtIndex
(
gDevices
,
device
->
id
);
tIOHID
ElementRef
=
(
IOHIDElementRef
)
CFArrayGetValueAtIndex
(
gCollections
,
device
->
id
);
if
(
!
tIOHID
Device
Ref
)
if
(
!
tIOHID
Element
Ref
)
return
;
return
;
gElementCFArrayRef
=
IOHIDDeviceCopyMatchingElements
(
tIOHIDDeviceRef
,
gElementCFArrayRef
=
CFArrayCreateMutable
(
kCFAllocatorDefault
,
0
,
&
kCFTypeArrayCallBacks
);
NULL
,
0
);
get_element_children
(
tIOHIDElementRef
,
gElementCFArrayRef
);
if
(
gElementCFArrayRef
)
if
(
gElementCFArrayRef
)
{
{
...
@@ -439,15 +520,17 @@ static void get_osx_device_elements_props(JoystickImpl *device)
...
@@ -439,15 +520,17 @@ static void get_osx_device_elements_props(JoystickImpl *device)
static
void
poll_osx_device_state
(
JoystickGenericImpl
*
device_in
)
static
void
poll_osx_device_state
(
JoystickGenericImpl
*
device_in
)
{
{
JoystickImpl
*
device
=
(
JoystickImpl
*
)
device_in
;
JoystickImpl
*
device
=
(
JoystickImpl
*
)
device_in
;
IOHIDElementRef
tIOHIDTopElementRef
;
IOHIDDeviceRef
tIOHIDDeviceRef
;
IOHIDDeviceRef
tIOHIDDeviceRef
;
CFArrayRef
gElementCFArrayRef
=
device
->
elementCFArrayRef
;
CFArrayRef
gElementCFArrayRef
=
device
->
elementCFArrayRef
;
TRACE
(
"polling device %i
\n
"
,
device
->
id
);
TRACE
(
"polling device %i
\n
"
,
device
->
id
);
if
(
!
g
Device
s
)
if
(
!
g
Collection
s
)
return
;
return
;
tIOHIDDeviceRef
=
(
IOHIDDeviceRef
)
CFArrayGetValueAtIndex
(
gDevices
,
device
->
id
);
tIOHIDTopElementRef
=
(
IOHIDElementRef
)
CFArrayGetValueAtIndex
(
gCollections
,
device
->
id
);
tIOHIDDeviceRef
=
IOHIDElementGetDevice
(
tIOHIDTopElementRef
);
if
(
!
tIOHIDDeviceRef
)
if
(
!
tIOHIDDeviceRef
)
return
;
return
;
...
...
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