IOHIDService.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. IOHIDService.h ... I/O Kit HID Service
  3. Copyright (c) 2009 KennyTM~ <kennytm@gmail.com>
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without modification,
  6. are permitted provided that the following conditions are met:
  7. * Redistributions of source code must retain the above copyright notice, this
  8. list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright notice,
  10. this list of conditions and the following disclaimer in the documentation
  11. and/or other materials provided with the distribution.
  12. * Neither the name of the KennyTM~ nor the names of its contributors may be
  13. used to endorse or promote products derived from this software without
  14. specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  19. ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  22. ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. // With reference to http://www.opensource.apple.com/source/IOHIDFamily/IOHIDFamily-258.1/IOHIDLib/IOHIDEventServiceClass.h
  27. #ifndef IOHID_SERVICE_H
  28. #define IOHID_SERVICE_H
  29. #include <CoreFoundation/CoreFoundation.h>
  30. #include <IOKit/IOKitLib.h>
  31. #include "IOHIDEvent.h"
  32. #include "IOHIDNotification.h"
  33. #if __cplusplus
  34. extern "C" {
  35. #endif
  36. typedef struct __IOHIDService
  37. #if 0
  38. {
  39. CFRuntimeBase _base; // 0, 4
  40. CFTypeRef client; // 8
  41. io_service_t service; // c
  42. void** pluginInterface1; // 10; GUID = D12C833F-B15B-11DA-902D-0014519758EF
  43. void** pluginInterface2; // 14;
  44. IOCFPlugInInterface** interface; // 18
  45. CFRunLoopRef runloop; // 1c
  46. CFStringRef mode; // 20
  47. IONotificationPortRef notify; // 24
  48. CFMutableSetRef removalNotifications; // 2c
  49. void* eventTarget; // 30
  50. void* eventRefcon; // 34
  51. IOHIDServiceEventCallback eventCallback; // 38
  52. uint32_t previousButtonMask; // 3c
  53. }
  54. #endif
  55. * IOHIDServiceRef;
  56. typedef void(*IOHIDServiceEventCallback)(void* target, void* refcon, IOHIDServiceRef service, IOHIDEventRef event);
  57. /*
  58. metaObject->
  59. [0] = NULL
  60. [4] = IOHIDIUnknown::genericQueryInterface(void*, CFUUIDBytes, void**)
  61. [8] = IOHIDIUnknown::genericAddRef(void*)
  62. [0x0c] = IOHIDIUnknown::genericRelease(void*)
  63. [0x10] = IOHIDEventServiceClass::_open(void*, unsigned long)
  64. [0x14] = IOHIDEventServiceClass::_close(void*, unsigned long)
  65. [0x18] = IOHIDEventServiceClass::_getProperty(void*, __CFString const*)
  66. [0x1c] = IOHIDEventServiceClass::_setProperty(void*, __CFString const*, void const*)
  67. [0x20] = IOHIDEventServiceClass::_setEventCallback(void*, void (*)(void*, void*, void*, __IOHIDEvent*, unsigned long), void*, void*)
  68. [0x24] = IOHIDEventServiceClass::_scheduleWithRunLoop(void*, __CFRunLoop*, __CFString const*)
  69. [0x28] = IOHIDEventServiceClass::_unscheduleFromRunLoop(void*, __CFRunLoop*, __CFString const*)
  70. [0x2c] = IOHIDEventServiceClass::_copyEvent(void*, unsigned int, __IOHIDEvent*, unsigned long)
  71. */
  72. #pragma mark -
  73. #pragma mark Creators
  74. CFTypeID IOHIDServiceGetTypeID(void);
  75. IOHIDServiceRef _IOHIDServiceCreate(CFAllocatorRef allocator, io_service_t service);
  76. #pragma mark -
  77. #pragma mark Accessors
  78. CFTypeRef IOHIDServiceGetProperty(IOHIDServiceRef service, CFStringRef property);
  79. Boolean IOHIDServiceSetProperty(IOHIDServiceRef service, CFStringRef property, CFTypeRef value);
  80. CFTypeRef _IOHIDServiceGetClient(IOHIDServiceRef service);
  81. Boolean _IOHIDServiceMatchPropertyTable(IOHIDServiceRef service, CFDictionaryRef propertyTable);
  82. IOHIDEventRef IOHIDServiceCopyEvent(IOHIDServiceRef service, IOHIDEventType type, IOHIDEventRef event, IOOptionBits options);
  83. void _IOHIDServiceSetEventCallback(IOHIDServiceRef service, IOHIDServiceEventCallback eventCallback, void* target, void* refcon);
  84. #pragma mark -
  85. #pragma mark Actions
  86. void _IOHIDServiceScheduleWithRunLoop(IOHIDServiceRef service, CFRunLoopRef runloop, CFStringRef mode);
  87. void _IOHIDServiceUnscheduleWithRunLoop(IOHIDServiceRef service);
  88. IOHIDNotificationRef IOHIDServiceCreateRemovalNotification(IOHIDServiceRef display, IOHIDNotificationCallback callback, void* target, void* refcon);
  89. Boolean _IOHIDServiceOpen(IOHIDServiceRef service, CFTypeRef client, IOOptionBits options);
  90. Boolean _IOHIDServiceClose(IOHIDServiceRef service, CFTypeRef client, IOOptionBits options);
  91. #if __cplusplus
  92. }
  93. #endif
  94. #endif