Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

563 lines
14 KiB

  1. /*
  2. File: Keyboards.h
  3. Contains: Keyboard API.
  4. Version: QuickTime 7.3
  5. Copyright: (c) 2007 (c) 1997-2001 by Apple Computer, Inc., all rights reserved
  6. Bugs?: For bug reports, consult the following page on
  7. the World Wide Web:
  8. http://developer.apple.com/bugreporter/
  9. */
  10. #ifndef __KEYBOARDS__
  11. #define __KEYBOARDS__
  12. #ifndef __MACTYPES__
  13. #include <MacTypes.h>
  14. #endif
  15. #ifndef __CFBASE__
  16. #include <CFBase.h>
  17. #endif
  18. #if PRAGMA_ONCE
  19. #pragma once
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #if PRAGMA_IMPORT
  25. #pragma import on
  26. #endif
  27. /*----------------------------------------------------------------------------------*/
  28. /* Keyboard API constants */
  29. /*----------------------------------------------------------------------------------*/
  30. /* Keyboard API Trap Number. Should be moved to Traps.i */
  31. enum {
  32. _KeyboardDispatch = 0xAA7A
  33. };
  34. /* Gestalt selector and values for the Keyboard API */
  35. enum {
  36. gestaltKeyboardsAttr = FOUR_CHAR_CODE('kbds'),
  37. gestaltKBPS2Keyboards = 1,
  38. gestaltKBPS2SetIDToAny = 2,
  39. gestaltKBPS2SetTranslationTable = 4
  40. };
  41. /* Keyboard API Error Codes */
  42. /*
  43. I stole the range blow from the empty space in the Allocation project but should
  44. be updated to the officially registered range.
  45. */
  46. enum {
  47. errKBPS2KeyboardNotAvailable = -30850,
  48. errKBIlligalParameters = -30851,
  49. errKBFailSettingID = -30852,
  50. errKBFailSettingTranslationTable = -30853,
  51. errKBFailWritePreference = -30854
  52. };
  53. /*
  54. * PhysicalKeyboardLayoutType
  55. *
  56. * Summary:
  57. * Physical keyboard layout types indicate the physical keyboard
  58. * layout. They are returned by the KBGetLayoutType API.
  59. */
  60. typedef UInt32 PhysicalKeyboardLayoutType;
  61. enum {
  62. /*
  63. * A JIS keyboard layout type.
  64. */
  65. kKeyboardJIS = FOUR_CHAR_CODE('JIS '),
  66. /*
  67. * An ANSI keyboard layout type.
  68. */
  69. kKeyboardANSI = FOUR_CHAR_CODE('ANSI'),
  70. /*
  71. * An ISO keyboard layout type.
  72. */
  73. kKeyboardISO = FOUR_CHAR_CODE('ISO '),
  74. /*
  75. * An unknown physical keyboard layout type.
  76. */
  77. kKeyboardUnknown = kUnknownType /* '????'*/
  78. };
  79. /*----------------------------------------------------------------------------------*/
  80. /* Keyboard API types */
  81. /*----------------------------------------------------------------------------------*/
  82. /*----------------------------------------------------------------------------------*/
  83. /* Keyboard API routines */
  84. /*----------------------------------------------------------------------------------*/
  85. #if CALL_NOT_IN_CARBON
  86. /*
  87. * KBInitialize()
  88. *
  89. * Availability:
  90. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  91. * CarbonLib: not available
  92. * Mac OS X: not available
  93. */
  94. EXTERN_API( OSErr )
  95. KBInitialize(void) THREEWORDINLINE(0x303C, 0x0000, 0xAA7A);
  96. /*
  97. * KBSetupPS2Keyboard()
  98. *
  99. * Availability:
  100. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  101. * CarbonLib: not available
  102. * Mac OS X: not available
  103. */
  104. EXTERN_API( OSErr )
  105. KBSetupPS2Keyboard(
  106. SInt16 keyboardType,
  107. SInt8 * alternativeTable) THREEWORDINLINE(0x303C, 0x0001, 0xAA7A);
  108. /*
  109. * KBGetPS2KeyboardID()
  110. *
  111. * Availability:
  112. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  113. * CarbonLib: not available
  114. * Mac OS X: not available
  115. */
  116. EXTERN_API( OSErr )
  117. KBGetPS2KeyboardID(SInt16 * keyboardType) THREEWORDINLINE(0x303C, 0x0002, 0xAA7A);
  118. /*
  119. * KBIsPS2KeyboardConnected()
  120. *
  121. * Availability:
  122. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  123. * CarbonLib: not available
  124. * Mac OS X: not available
  125. */
  126. EXTERN_API( Boolean )
  127. KBIsPS2KeyboardConnected(void) THREEWORDINLINE(0x303C, 0x0003, 0xAA7A);
  128. /*
  129. * KBIsPS2KeyboardEnabled()
  130. *
  131. * Availability:
  132. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  133. * CarbonLib: not available
  134. * Mac OS X: not available
  135. */
  136. EXTERN_API( Boolean )
  137. KBIsPS2KeyboardEnabled(void) THREEWORDINLINE(0x303C, 0x0004, 0xAA7A);
  138. /*
  139. * KBGetPS2KeyboardAttributes()
  140. *
  141. * Availability:
  142. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  143. * CarbonLib: not available
  144. * Mac OS X: not available
  145. */
  146. EXTERN_API( SInt32 )
  147. KBGetPS2KeyboardAttributes(void) THREEWORDINLINE(0x303C, 0x0005, 0xAA7A);
  148. /*
  149. * KBSetKCAPForPS2Keyboard()
  150. *
  151. * Availability:
  152. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  153. * CarbonLib: not available
  154. * Mac OS X: not available
  155. */
  156. EXTERN_API( OSErr )
  157. KBSetKCAPForPS2Keyboard(Handle kcapHandle) THREEWORDINLINE(0x303C, 0x0006, 0xAA7A);
  158. /*
  159. * KBSetupPS2KeyboardFromLayoutType()
  160. *
  161. * Availability:
  162. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  163. * CarbonLib: not available
  164. * Mac OS X: not available
  165. */
  166. EXTERN_API( OSErr )
  167. KBSetupPS2KeyboardFromLayoutType(OSType layoutType) THREEWORDINLINE(0x303C, 0x0008, 0xAA7A);
  168. /*
  169. * KBGetPS2KeyboardLayoutType()
  170. *
  171. * Availability:
  172. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  173. * CarbonLib: not available
  174. * Mac OS X: not available
  175. */
  176. EXTERN_API( OSErr )
  177. KBGetPS2KeyboardLayoutType(OSType * layoutType) THREEWORDINLINE(0x303C, 0x0009, 0xAA7A);
  178. #endif /* CALL_NOT_IN_CARBON */
  179. /*
  180. * KBGetLayoutType()
  181. *
  182. * Summary:
  183. * Returns the physical keyboard layout type.
  184. *
  185. * Parameters:
  186. *
  187. * iKeyboardType:
  188. * The keyboard type ID. LMGetKbdType().
  189. *
  190. * Availability:
  191. * Non-Carbon CFM: in KeyboardsLib 1.0 and later
  192. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.0 and later
  193. * Mac OS X: in version 10.0 and later
  194. */
  195. EXTERN_API( OSType )
  196. KBGetLayoutType(SInt16 iKeyboardType) THREEWORDINLINE(0x303C, 0x0007, 0xAA7A);
  197. /*
  198. * KeyboardLayoutRef
  199. *
  200. * Summary:
  201. * The opaque keyboard layout contains information about a keyboard
  202. * layout. It is used with the keyboard layout APIs.
  203. *
  204. * Discussion:
  205. * KeyboardLayoutRef APIs follow CoreFoundation function naming
  206. * convention. You mustn't release any references you get from APIs
  207. * named "Get."
  208. */
  209. typedef struct OpaqueKeyboardLayoutRef* KeyboardLayoutRef;
  210. /*
  211. * KeyboardLayoutPropertyTag
  212. *
  213. * Summary:
  214. * Keyboard layout property tags specify the value you want to
  215. * retrieve. They are used with the KLGetKeyboardLayoutProperty API.
  216. */
  217. typedef UInt32 KeyboardLayoutPropertyTag;
  218. enum {
  219. /*
  220. * The keyboard layout data (const void *). It is used with the
  221. * KeyTranslate API.
  222. */
  223. kKLKCHRData = 0,
  224. /*
  225. * The keyboard layout data (const void *). It is used with the
  226. * UCKeyTranslate API.
  227. */
  228. kKLuchrData = 1,
  229. /*
  230. * The keyboard layout identifier (SInt32).
  231. */
  232. kKLIdentifier = 2,
  233. /*
  234. * The keyboard layout icon (IconRef).
  235. */
  236. kKLIcon = 3,
  237. /*
  238. * The localized keyboard layout name (CFStringRef).
  239. */
  240. kKLLocalizedName = 4,
  241. /*
  242. * The keyboard layout name (CFStringRef).
  243. */
  244. kKLName = 5,
  245. /*
  246. * The keyboard layout group identifier (SInt32).
  247. */
  248. kKLGroupIdentifier = 6,
  249. /*
  250. * The keyboard layout kind (SInt32).
  251. */
  252. kKLKind = 7
  253. };
  254. /*
  255. * KeyboardLayoutKind
  256. *
  257. * Summary:
  258. * Keyboard layout kinds indicate available keyboard layout formats.
  259. */
  260. typedef SInt32 KeyboardLayoutKind;
  261. enum {
  262. /*
  263. * Both KCHR and uchr formats are available.
  264. */
  265. kKLKCHRuchrKind = 0,
  266. /*
  267. * Only KCHR format is avaiable.
  268. */
  269. kKLKCHRKind = 1,
  270. /*
  271. * Only uchr format is available.
  272. */
  273. kKLuchrKind = 2
  274. };
  275. /*
  276. * KeyboardLayoutIdentifier
  277. *
  278. * Summary:
  279. * Keyboard layout identifiers specify particular keyboard layouts.
  280. */
  281. typedef SInt32 KeyboardLayoutIdentifier;
  282. enum {
  283. kKLUSKeyboard = 0
  284. };
  285. /* iterate keyboard layouts*/
  286. /*
  287. * KLGetKeyboardLayoutCount()
  288. *
  289. * Summary:
  290. * Returns the number of keyboard layouts.
  291. *
  292. * Parameters:
  293. *
  294. * oCount:
  295. * On exit, the number of keyboard layouts
  296. *
  297. * Availability:
  298. * Non-Carbon CFM: not available
  299. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  300. * Mac OS X: in version 10.2 and later
  301. */
  302. EXTERN_API_C( OSStatus )
  303. KLGetKeyboardLayoutCount(CFIndex * oCount);
  304. /*
  305. * KLGetKeyboardLayoutAtIndex()
  306. *
  307. * Summary:
  308. * Retrieves the keyboard layout at the given index.
  309. *
  310. * Parameters:
  311. *
  312. * iIndex:
  313. * The index of the keyboard layout to retrieve. If the index is
  314. * outside the index space of the keyboard layouts (0 to N-1
  315. * inclusive, where N is the count of the keyboard layouts), the
  316. * behavior is undefined.
  317. *
  318. * oKeyboardLayout:
  319. * On exit, the keyboard layout with the given index.
  320. *
  321. * Availability:
  322. * Non-Carbon CFM: not available
  323. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  324. * Mac OS X: in version 10.2 and later
  325. */
  326. EXTERN_API_C( OSStatus )
  327. KLGetKeyboardLayoutAtIndex(
  328. CFIndex iIndex,
  329. KeyboardLayoutRef * oKeyboardLayout);
  330. /* NOTE: "Indexed" is a wrong name, please use "AtIndex"...*/
  331. /*
  332. * KLGetIndexedKeyboardLayout()
  333. *
  334. * Availability:
  335. * Non-Carbon CFM: not available
  336. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  337. * Mac OS X: in version 10.2 and later
  338. */
  339. EXTERN_API_C( OSStatus )
  340. KLGetIndexedKeyboardLayout(
  341. CFIndex iIndex,
  342. KeyboardLayoutRef * oKeyboardLayout);
  343. /* get keyboard layout info*/
  344. /*
  345. * KLGetKeyboardLayoutProperty()
  346. *
  347. * Summary:
  348. * Retrives property value for the given keyboard layout and tag.
  349. *
  350. * Parameters:
  351. *
  352. * iKeyboardLayout:
  353. * The keyboard layout to be queried. If this parameter is not a
  354. * valid KeyboardLayoutRef, the behavior is undefined.
  355. *
  356. * iPropertyTag:
  357. * The property tag.
  358. *
  359. * oValue:
  360. * On exit, the property value for the given keyboard layout and
  361. * tag.
  362. *
  363. * Availability:
  364. * Non-Carbon CFM: not available
  365. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  366. * Mac OS X: in version 10.2 and later
  367. */
  368. EXTERN_API_C( OSStatus )
  369. KLGetKeyboardLayoutProperty(
  370. KeyboardLayoutRef iKeyboardLayout,
  371. KeyboardLayoutPropertyTag iPropertyTag,
  372. const void ** oValue);
  373. /* get keyboard layout with identifier or name*/
  374. /*
  375. * KLGetKeyboardLayoutWithIdentifier()
  376. *
  377. * Summary:
  378. * Retrieves the keyboard layout with the given identifier.
  379. *
  380. * Discussion:
  381. * For now, the identifier is in the range of SInt16 which is
  382. * compatible with the Resource Manager resource ID. However, it
  383. * will become an arbitrary SInt32 value at some point, so do not
  384. * assume it is in SInt16 range or falls into the "script range" of
  385. * the resource IDs.
  386. *
  387. * Parameters:
  388. *
  389. * iIdentifier:
  390. * The keyboard layout identifier.
  391. *
  392. * oKeyboardLayout:
  393. * On exit, the keyboard layout with the given identifier.
  394. *
  395. * Availability:
  396. * Non-Carbon CFM: not available
  397. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  398. * Mac OS X: in version 10.2 and later
  399. */
  400. EXTERN_API_C( OSStatus )
  401. KLGetKeyboardLayoutWithIdentifier(
  402. SInt32 iIdentifier,
  403. KeyboardLayoutRef * oKeyboardLayout);
  404. /*
  405. * KLGetKeyboardLayoutWithName()
  406. *
  407. * Summary:
  408. * Retrieves the keyboard layout with the given name.
  409. *
  410. * Parameters:
  411. *
  412. * iName:
  413. * The keyboard layout name.
  414. *
  415. * oKeyboardLayout:
  416. * On exit, the keyboard layout with the given name.
  417. *
  418. * Availability:
  419. * Non-Carbon CFM: not available
  420. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  421. * Mac OS X: in version 10.2 and later
  422. */
  423. EXTERN_API_C( OSStatus )
  424. KLGetKeyboardLayoutWithName(
  425. CFStringRef iName,
  426. KeyboardLayoutRef * oKeyboardLayout);
  427. /* get/set current keyboard layout of the current group identifier*/
  428. /*
  429. * KLGetCurrentKeyboardLayout()
  430. *
  431. * Summary:
  432. * Retrieves the current keyboard layout.
  433. *
  434. * Parameters:
  435. *
  436. * oKeyboardLayout:
  437. * On exit, the current keyboard layout.
  438. *
  439. * Availability:
  440. * Non-Carbon CFM: not available
  441. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  442. * Mac OS X: in version 10.2 and later
  443. */
  444. EXTERN_API_C( OSStatus )
  445. KLGetCurrentKeyboardLayout(KeyboardLayoutRef * oKeyboardLayout);
  446. /*
  447. * KLSetCurrentKeyboardLayout()
  448. *
  449. * Summary:
  450. * Sets the current keyboard layout.
  451. *
  452. * Parameters:
  453. *
  454. * iKeyboardLayout:
  455. * The keyboard layout.
  456. *
  457. * Availability:
  458. * Non-Carbon CFM: not available
  459. * CarbonLib: not available in CarbonLib 1.x, is available on Mac OS X version 10.2 and later
  460. * Mac OS X: in version 10.2 and later
  461. */
  462. EXTERN_API_C( OSStatus )
  463. KLSetCurrentKeyboardLayout(KeyboardLayoutRef iKeyboardLayout);
  464. #ifdef PRAGMA_IMPORT_OFF
  465. #pragma import off
  466. #elif PRAGMA_IMPORT
  467. #pragma import reset
  468. #endif
  469. #ifdef __cplusplus
  470. }
  471. #endif
  472. #endif /* __KEYBOARDS__ */