GSKeyboard.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. GSKeyboard.h ... Hardware keyboard.
  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 GSKEYBOARD_H
  27. #define GSKEYBOARD_H
  28. #include <Availability2.h>
  29. #if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_3_2
  30. #if __cplusplus
  31. extern "C" {
  32. #endif
  33. #include <CoreFoundation/CoreFoundation.h>
  34. #include "GSEvent.h"
  35. enum {
  36. kUCKeyActionDown = 0,
  37. kUCKeyActionUp = 1,
  38. kUCKeyActionAutoKey = 2,
  39. kUCKeyActionDisplay = 3
  40. };
  41. typedef struct __GSKeyboard
  42. #if 0
  43. {
  44. CFRuntimeBase base; // 0, 4
  45. int fildes;
  46. void* ptr;
  47. size_t length;
  48. struct uchrKeyboardLayout* keyLayoutPtr;
  49. UInt32 keyboardType;
  50. UInt32 deadKeyState;
  51. int modifierState; // 2 = shift, 4 = ctrl, 8 = alt, 16 = cmd
  52. CFStringRef layoutName;
  53. pthread_mutex_t mutex;
  54. }
  55. #endif
  56. * GSKeyboardRef;
  57. // The keyboard layout list is stored in /System/Library/KeyboardLayouts/USBKeyboardLayouts.bundle/USBKeyboardLayouts.plist
  58. CFDictionaryRef GSKeyboardHWKeyboardLayoutsPlist(void);
  59. CFTypeID GSKeyboardGetTypeID(void);
  60. GSKeyboardRef GSKeyboardCreate(CFStringRef layoutName, UInt32 keyboardType);
  61. void GSKeyboardRelease(GSKeyboardRef keyboard);
  62. void GSKeyboardReset(GSKeyboardRef keyboard);
  63. CFStringRef GSKeyboardGetLayout(GSKeyboardRef keyboard);
  64. void GSKeyboardSetLayout(GSKeyboardRef keyboard, CFStringRef layoutName);
  65. GSEventFlags GSKeyboardGetModifierState(GSKeyboardRef keyboard);
  66. // ref: http://developer.apple.com/mac/library/documentation/Carbon/Reference/Unicode_Utilities_Ref/Reference/reference.html#//apple_ref/doc/uid/TP30000122-CH1g-F10792
  67. OSStatus GSKeyTranslate(GSKeyboardRef keyboard,
  68. UInt16 virtualKeyCode,
  69. UInt16 keyAction,
  70. UInt32 modifierKeyState,
  71. UInt32 keyboardType,
  72. OptionBits keyTranslateOptions,
  73. UInt32 *deadKeyState,
  74. UniCharCount maxStringLength,
  75. UniCharCount *actualStringLength,
  76. UniChar unicodeString[]);
  77. OSStatus GSKeyboardTranslateKey(GSKeyboardRef keyboard,
  78. UInt16 virtualKeyCode,
  79. UInt16 unknown,
  80. OptionBits keyTranslateOptions,
  81. UniCharCount maxStringLength,
  82. UniCharCount *actualStringLength,
  83. UniChar unicodeString[],
  84. UniCharCount *actualStringLength2,
  85. UniChar unicodeString2[]);
  86. #if __cplusplus
  87. }
  88. #endif
  89. #endif
  90. #endif