FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
KeyCodesCarbon.cpp
1 /**********************************************************\
2  Original Author: Anson Mackeracher
3 
4 Created: Jul 12, 2010
5 License: Dual license model; choose one of two:
6 New BSD License
7 http://www.opensource.org/licenses/bsd-license.php
8 - or -
9 GNU Lesser General Public License, version 2.1
10 http://www.gnu.org/licenses/lgpl-2.1.html
11 
12 Copyright 2010 Anson MacKeracher and the Firebreath development team
13 \**********************************************************/
14 
15 #include "KeyCodesCarbon.h"
16 #include <Carbon/Carbon.h>
17 
18 namespace CarbonConst {
19  enum {
20  kVK_Return = 0x24,
21  kVK_Tab = 0x30,
22  kVK_Space = 0x31,
23  kVK_Delete = 0x33,
24  kVK_Escape = 0x35,
25  kVK_Command = 0x37,
26  kVK_Shift = 0x38,
27  kVK_CapsLock = 0x39,
28  kVK_Option = 0x3A,
29  kVK_Control = 0x3B,
30  kVK_RightShift = 0x3C,
31  kVK_RightOption = 0x3D,
32  kVK_RightControl = 0x3E,
33  kVK_Function = 0x3F,
34  kVK_F17 = 0x40,
35  kVK_VolumeUp = 0x48,
36  kVK_VolumeDown = 0x49,
37  kVK_Mute = 0x4A,
38  kVK_F18 = 0x4F,
39  kVK_F19 = 0x50,
40  kVK_F20 = 0x5A,
41  kVK_F5 = 0x60,
42  kVK_F6 = 0x61,
43  kVK_F7 = 0x62,
44  kVK_F3 = 0x63,
45  kVK_F8 = 0x64,
46  kVK_F9 = 0x65,
47  kVK_F11 = 0x67,
48  kVK_F13 = 0x69,
49  kVK_F16 = 0x6A,
50  kVK_F14 = 0x6B,
51  kVK_F10 = 0x6D,
52  kVK_F12 = 0x6F,
53  kVK_F15 = 0x71,
54  kVK_Help = 0x72,
55  kVK_Home = 0x73,
56  kVK_PageUp = 0x74,
57  kVK_ForwardDelete = 0x75,
58  kVK_F4 = 0x76,
59  kVK_End = 0x77,
60  kVK_F2 = 0x78,
61  kVK_PageDown = 0x79,
62  kVK_F1 = 0x7A,
63  kVK_LeftArrow = 0x7B,
64  kVK_RightArrow = 0x7C,
65  kVK_DownArrow = 0x7D,
66  kVK_UpArrow = 0x7E
67  };
68 }
69 
70 namespace FB {
71  FBKeyCode CarbonKeyCodeToFBKeyCode(unsigned long carbonKey) {
72  FBKeyCode retVal = FBKEY_UNKNOWN;
73 
74  switch(carbonKey) {
75  case CarbonConst::kVK_Return : retVal = FBKEY_RETURN; break;
76  case CarbonConst::kVK_Tab : retVal = FBKEY_TAB; break;
77  case CarbonConst::kVK_Space : retVal = FBKEY_SPACE; break;
78  case CarbonConst::kVK_CapsLock : retVal = FBKEY_CAPSLOCK; break;
79  case CarbonConst::kVK_Control : retVal = FBKEY_CONTROL; break;
80  case CarbonConst::kVK_Delete : retVal = FBKEY_DELETE; break;
81  case CarbonConst::kVK_Escape : retVal = FBKEY_ESCAPE; break;
82  case CarbonConst::kVK_Command : retVal = FBKEY_COMMAND; break;
83  case CarbonConst::kVK_Shift : retVal = FBKEY_SHIFT; break;
84  case CarbonConst::kVK_Option : retVal = FBKEY_OPTION; break;
85  case CarbonConst::kVK_RightShift : retVal = FBKEY_RSHIFT; break;
86  case CarbonConst::kVK_RightOption : retVal = FBKEY_ROPTION; break;
87  case CarbonConst::kVK_RightControl : retVal = FBKEY_RCONTROL; break;
88  case CarbonConst::kVK_Function : retVal = FBKEY_FUNCTION; break;
89  case CarbonConst::kVK_F1 : retVal = FBKEY_F1; break;
90  case CarbonConst::kVK_F2 : retVal = FBKEY_F2; break;
91  case CarbonConst::kVK_F3 : retVal = FBKEY_F3; break;
92  case CarbonConst::kVK_F4 : retVal = FBKEY_F4; break;
93  case CarbonConst::kVK_F5 : retVal = FBKEY_F5; break;
94  case CarbonConst::kVK_F6 : retVal = FBKEY_F6; break;
95  case CarbonConst::kVK_F7 : retVal = FBKEY_F7; break;
96  case CarbonConst::kVK_F8 : retVal = FBKEY_F8; break;
97  case CarbonConst::kVK_F9 : retVal = FBKEY_F9; break;
98  case CarbonConst::kVK_F10 : retVal = FBKEY_F10; break;
99  case CarbonConst::kVK_F11 : retVal = FBKEY_F11; break;
100  case CarbonConst::kVK_F12 : retVal = FBKEY_F12; break;
101  case CarbonConst::kVK_F13 : retVal = FBKEY_F13; break;
102  case CarbonConst::kVK_F14 : retVal = FBKEY_F14; break;
103  case CarbonConst::kVK_F15 : retVal = FBKEY_F15; break;
104  case CarbonConst::kVK_Help : retVal = FBKEY_HELP; break;
105  case CarbonConst::kVK_Home : retVal = FBKEY_HOME; break;
106  case CarbonConst::kVK_PageUp : retVal = FBKEY_PAGEUP; break;
107  case CarbonConst::kVK_ForwardDelete : retVal = FBKEY_FORWARDDELETE; break;
108  case CarbonConst::kVK_End : retVal = FBKEY_END; break;
109  case CarbonConst::kVK_PageDown : retVal = FBKEY_PAGEDOWN; break;
110  case CarbonConst::kVK_LeftArrow : retVal = FBKEY_LEFTARROW; break;
111  case CarbonConst::kVK_RightArrow : retVal = FBKEY_RIGHTARROW; break;
112  case CarbonConst::kVK_DownArrow : retVal = FBKEY_DOWNARROW; break;
113  case CarbonConst::kVK_UpArrow : retVal = FBKEY_UPARROW; break;
114  }
115  return retVal;
116  }
117 }
118 
FBKeyCode
Values that represent different keys in a platform agnostic way.
Definition: KeyCodes.h:26