-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHIDSystem.m
29 lines (26 loc) · 841 Bytes
/
HIDSystem.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* HIDSystem.m
* Mouse Acceleration
*
* Created by Peter Hosey on 2010-02-28.
* Copyright 2010 Peter Hosey. All rights reserved.
*
*/
#include "HIDSystem.h"
#import <IOKit/hid/IOHIDKeys.h>
#import <IOKit/hidsystem/IOHIDShared.h>
kern_return_t openConnectionToHIDSystem(io_connect_t *HIDSystem_p) {
kern_return_t err;
mach_port_t masterPort = MACH_PORT_NULL;
err = IOMasterPort(/*bootstrapPort*/ MACH_PORT_NULL, &masterPort);
if (err == kIOReturnSuccess) {
CFDictionaryRef classDescription = IOServiceMatching("IOHIDSystem");
if (classDescription) {
io_service_t HIDSystemService = IOServiceGetMatchingService(masterPort, classDescription);
if (HIDSystemService != MACH_PORT_NULL) {
err = IOServiceOpen(HIDSystemService, mach_task_self(), kIOHIDParamConnectType, &(*HIDSystem_p));
}
}
}
return err;
}