37
37
38
38
#define VALVE_USB_VID 0x28DE
39
39
40
- /* As defined in AppKit.h, but we don't need the entire AppKit for a single constant. */
41
- extern const double NSAppKitVersionNumber ;
42
-
43
40
/* Barrier implementation because Mac OSX doesn't have pthread_barrier.
44
41
It also doesn't have clock_gettime(). So much for POSIX and SUSv2.
45
42
This implementation came from Brent Priddy and was posted on
@@ -134,7 +131,6 @@ struct hid_device_list_node
134
131
};
135
132
136
133
static IOHIDManagerRef hid_mgr = 0x0 ;
137
- static int is_macos_10_10_or_greater = 0 ;
138
134
static struct hid_device_list_node * device_list = 0x0 ;
139
135
140
136
static hid_device * new_hid_device (void )
@@ -489,7 +485,6 @@ static int init_hid_manager(void)
489
485
int HID_API_EXPORT hid_init (void )
490
486
{
491
487
if (!hid_mgr ) {
492
- is_macos_10_10_or_greater = (NSAppKitVersionNumber >= 1343 ); /* NSAppKitVersionNumber10_10 */
493
488
return init_hid_manager ();
494
489
}
495
490
@@ -1143,10 +1138,8 @@ void HID_API_EXPORT hid_close(hid_device *dev)
1143
1138
if (!dev )
1144
1139
return ;
1145
1140
1146
- /* Disconnect the report callback before close.
1147
- See comment below.
1148
- */
1149
- if (is_macos_10_10_or_greater || !dev -> disconnected ) {
1141
+ /* Disconnect the report callback before close. */
1142
+ if (!dev -> disconnected ) {
1150
1143
IOHIDDeviceRegisterInputReportCallback (
1151
1144
dev -> device_handle , dev -> input_report_buf , dev -> max_input_report_len ,
1152
1145
NULL , dev );
@@ -1169,14 +1162,8 @@ void HID_API_EXPORT hid_close(hid_device *dev)
1169
1162
1170
1163
/* Close the OS handle to the device, but only if it's not
1171
1164
been unplugged. If it's been unplugged, then calling
1172
- IOHIDDeviceClose() will crash.
1173
-
1174
- UPD: The crash part was true in/until some version of macOS.
1175
- Starting with macOS 10.15, there is an opposite effect in some environments:
1176
- crash happenes if IOHIDDeviceClose() is not called.
1177
- Not leaking a resource in all tested environments.
1178
- */
1179
- if (is_macos_10_10_or_greater || !dev -> disconnected ) {
1165
+ IOHIDDeviceClose() will crash. */
1166
+ if (!dev -> disconnected ) {
1180
1167
IOHIDDeviceClose (dev -> device_handle , kIOHIDOptionsTypeNone );
1181
1168
}
1182
1169
0 commit comments