IOHIDSession.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. IOHIDSession.h ... I/O Kit HID Session
  3. Copyright (c) 2010 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. #ifndef IOHID_NOTIFICATION_H
  27. #define IOHID_NOTIFICATION_H
  28. #include <CoreFoundation/CoreFoundation.h>
  29. #include "IOHIDDisplay.h"
  30. #include "IOHIDService.h"
  31. #include "IOHIDEvent.h"
  32. #if __cplusplus
  33. extern "C" {
  34. #endif
  35. typedef struct IOHIDSessionWorkSpace {
  36. uint64_t value;
  37. } IOHIDSessionWorkSpace;
  38. typedef struct __IOHIDSession
  39. #if 0
  40. {
  41. CFRuntimeBase _base; // 0, 4
  42. int isOpen; // 8
  43. CFTypeRef client; // c
  44. IOHIDSessionCallback callback; // 10
  45. void* refcon; // 14
  46. IOHIDSessionWorkSpace workSpace; // 18, 1c
  47. CFRunLoopRef runloop; // 20
  48. pthread_mutex_t lock; // 24
  49. pthread_cond_t cond; // 50
  50. pthread_mutexattr_t attr; // 6c
  51. CFMutableSetRef services; // 78
  52. CFMutableSetRef displays; // 7c
  53. CFMutableSetRef ALSStates; // 80
  54. CFMutableDictionaryRef properties; // 84
  55. Boolean displayStatus; // 88, initially = true
  56. float factor; // brightnessFactor. 8c, initially = 1
  57. float deviceAmbient; // 94, initially = 0.5
  58. float interval; // displayInternval. 98, initially = 0.402
  59. float ALSIntPeriod; // 9c, initially = 5.5
  60. float xa4; // a4, initially = 0
  61. float xa8; // a8, initially = 5.5
  62. float xac; // ac, initially = -1
  63. float xb0; // b0, initially = 1
  64. float backlight; // b4, initially = 1
  65. CFTypeRef xe0; // e0
  66. int displayOrientation; // e8, initially = 1
  67. Boolean orientationEnabled; // ec, initially = false
  68. Boolean ALSIntPeriodOrientationEnabled; // ed, initially = false
  69. float ALSIntPeriodOrientationPortrait; // f0, initially = 5.5
  70. float ALSIntPeriodOrientationPortraitInv; // f4, initially = 0
  71. float ALSIntPeriodOrientationLandscape; // f8, initially = 0
  72. int lockStateToken; // fc. (for the "com.apple.springboard.lockstate" Darwin notification)
  73. uint64_t lockState; // 100, 104
  74. mach_port_t lockStateNotifyPort; // 108 (leads to __IOHIDSessionLockCallback)
  75. int bootedCleanlyToken; // 10c (for the "com.apple.springboard.bootedcleanly" Darwin notification)
  76. mach_port_t bootedCleanlyNotifyPort; // 118 (leads to __IOHIDSessionBootCallback)
  77. int displayStatusToken; // 11c (for the "com.apple.iokit.hid.displayStatus" Darwin notification)
  78. int substantialTransitionToken; // 12c (for the "com.apple.mobile.SubstantialTransition" Darwin notification)
  79. mach_port_t substantialTransitionNotifyPort; // 130 (leads to __IOHIDSessionTransitionCallback)
  80. int thermalNotificationToken; // 134 (for the kOSThermalNotificationName Darwin notification)
  81. mach_port_t thermalNotificationNotifyPort; // 138 (leads to __IOHIDSessionThermalCallback)
  82. int thermalLevel; // 13c, initially = OSThermalNotificationCurrentLevel()
  83. int logLevel; // 144, initially = 6
  84. }
  85. #endif
  86. * IOHIDSessionRef;
  87. typedef void(*IOHIDSessionCallback)(CFTypeRef client, void* refcon, IOHIDServiceRef service, IOHIDEventRef event);
  88. #pragma mark -
  89. #pragma mark Creators
  90. CFTypeID IOHIDSessionGetTypeID(void);
  91. IOHIDSessionRef IOHIDSessionCreate(CFAllocatorRef allocator);
  92. #pragma mark -
  93. #pragma mark Accessors
  94. CFTypeRef IOHIDSessionGetProperty(IOHIDSessionRef session, CFStringRef key);
  95. Boolean IOHIDSessionSetProperty(IOHIDSessionRef session, CFStringRef key, CFTypeRef value);
  96. IOHIDSessionWorkSpace IOHIDSessionGetWorkSpace(IOHIDSessionRef session);
  97. void IOHIDSessionSetWorkSpace(IOHIDSessionRef session, IOHIDSessionWorkSpace workSpace);
  98. Boolean IOHIDSessionGetLockState(IOHIDSessionRef session);
  99. void IOHIDSessionSetLockState(IOHIDSessionRef session, Boolean lockState);
  100. #pragma mark -
  101. #pragma mark Actions
  102. Boolean IOHIDSessionOpen(IOHIDSessionRef session, CFTypeRef client, IOHIDSessionCallback callback, void* refcon)
  103. void IOHIDSessionClose(IOHIDSessionRef session, CFTypeRef client);
  104. void IOHIDSessionAddService(IOHIDSessionRef, IOHIDServiceRef service);
  105. void IOHIDSessionRemoveService(IOHIDSessionRef, IOHIDServiceRef service);
  106. void IOHIDSessionAddDisplay(IOHIDSessionRef, IOHIDDisplayRef display);
  107. void IOHIDSessionRemoveDisplay(IOHIDSessionRef session, IOHIDDisplayRef display);
  108. IOHIDEventRef IOHIDSessionCopyEvent(IOHIDSessionRef session, IOHIDEventType type, IOHIDEventRef event, IOOptionBits options);
  109. #pragma mark -
  110. #pragma mark Constants
  111. static const CFStringRef kIOHIDSessionPropertyDisplayOrientation = CFSTR("DisplayOrientation");
  112. static const CFStringRef kIOHIDSessionPropertyDisplayBrightnessFactor = CFSTR("DisplayBrightnessFactor");
  113. static const CFStringRef kIOHIDSessionPropertyDisplayBrightnessFactorWithFade = CFSTR("DisplayBrightnessFactorWithFade");
  114. static const CFStringRef kIOHIDSessionPropertyDisplayBrightnessFactorPending = CFSTR("DisplayBrightnessFactorPending");
  115. static const CFStringRef kIOHIDSessionPropertyLogLevel = CFSTR("LogLevel");
  116. static const CFStringRef kIOHIDSessionPropertyALSIntPeriodOrientationEnabled = CFSTR("ALSIntPeriodOrientationEnabled");
  117. static const CFStringRef kIOHIDSessionPropertyALSIntPeriod = CFSTR("ALSIntPeriod");
  118. static const CFStringRef kIOHIDSessionPropertyALSIntPeriodOrientationPortrait = CFSTR("ALSIntPeriodOrientationPortrait");
  119. static const CFStringRef kIOHIDSessionPropertyALSIntPeriodOrientationPortraitInv = CFSTR("ALSIntPeriodOrientationPortraitInv");
  120. static const CFStringRef kIOHIDSessionPropertyALSIntPeriodOrientationLandscape = CFSTR("ALSIntPeriodOrientationLandscape");
  121. #if __cplusplus
  122. }
  123. #endif
  124. #endif