FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
KeyCodesCocoa.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 "KeyCodesCocoa.h"
16 
17 namespace CocoaConst {
18  enum {
19  kVK_Return = 0x24,
20  kVK_Tab = 0x30,
21  kVK_Space = 0x31,
22  kVK_Delete = 0x33,
23  kVK_Escape = 0x35,
24  kVK_Command = 0x37,
25  kVK_Shift = 0x38,
26  kVK_CapsLock = 0x39,
27  kVK_Option = 0x3A,
28  kVK_Control = 0x3B,
29  kVK_RightShift = 0x3C,
30  kVK_RightOption = 0x3D,
31  kVK_RightControl = 0x3E,
32  kVK_Function = 0x3F,
33  kVK_F17 = 0x40,
34  kVK_VolumeUp = 0x48,
35  kVK_VolumeDown = 0x49,
36  kVK_Mute = 0x4A,
37  kVK_F18 = 0x4F,
38  kVK_F19 = 0x50,
39  kVK_F20 = 0x5A,
40  kVK_F5 = 0x60,
41  kVK_F6 = 0x61,
42  kVK_F7 = 0x62,
43  kVK_F3 = 0x63,
44  kVK_F8 = 0x64,
45  kVK_F9 = 0x65,
46  kVK_F11 = 0x67,
47  kVK_F13 = 0x69,
48  kVK_F16 = 0x6A,
49  kVK_F14 = 0x6B,
50  kVK_F10 = 0x6D,
51  kVK_F12 = 0x6F,
52  kVK_F15 = 0x71,
53  kVK_Help = 0x72,
54  kVK_Home = 0x73,
55  kVK_PageUp = 0x74,
56  kVK_ForwardDelete = 0x75,
57  kVK_F4 = 0x76,
58  kVK_End = 0x77,
59  kVK_F2 = 0x78,
60  kVK_PageDown = 0x79,
61  kVK_F1 = 0x7A,
62  kVK_LeftArrow = 0x7B,
63  kVK_RightArrow = 0x7C,
64  kVK_DownArrow = 0x7D,
65  kVK_UpArrow = 0x7E
66  };
67 }
68 namespace FB {
69  FBKeyCode CocoaKeyCodeToFBKeyCode(unsigned long cocoaKey) {
70  FBKeyCode retVal = FBKEY_UNKNOWN;
71 
72  switch(cocoaKey) {
73  case CocoaConst::kVK_Return : retVal = FBKEY_RETURN; break;
74  case CocoaConst::kVK_Tab : retVal = FBKEY_TAB; break;
75  case CocoaConst::kVK_Space : retVal = FBKEY_SPACE; break;
76  case CocoaConst::kVK_CapsLock : retVal = FBKEY_CAPSLOCK; break;
77  case CocoaConst::kVK_Control : retVal = FBKEY_CONTROL; break;
78  case CocoaConst::kVK_Delete : retVal = FBKEY_DELETE; break;
79  case CocoaConst::kVK_Escape : retVal = FBKEY_ESCAPE; break;
80  case CocoaConst::kVK_Command : retVal = FBKEY_COMMAND; break;
81  case CocoaConst::kVK_Shift : retVal = FBKEY_SHIFT; break;
82  case CocoaConst::kVK_Option : retVal = FBKEY_OPTION; break;
83  case CocoaConst::kVK_RightShift : retVal = FBKEY_RSHIFT; break;
84  case CocoaConst::kVK_RightOption : retVal = FBKEY_ROPTION; break;
85  case CocoaConst::kVK_RightControl : retVal = FBKEY_RCONTROL; break;
86  case CocoaConst::kVK_Function : retVal = FBKEY_FUNCTION; break;
87  case CocoaConst::kVK_F1 : retVal = FBKEY_F1; break;
88  case CocoaConst::kVK_F2 : retVal = FBKEY_F2; break;
89  case CocoaConst::kVK_F3 : retVal = FBKEY_F3; break;
90  case CocoaConst::kVK_F4 : retVal = FBKEY_F4; break;
91  case CocoaConst::kVK_F5 : retVal = FBKEY_F5; break;
92  case CocoaConst::kVK_F6 : retVal = FBKEY_F6; break;
93  case CocoaConst::kVK_F7 : retVal = FBKEY_F7; break;
94  case CocoaConst::kVK_F8 : retVal = FBKEY_F8; break;
95  case CocoaConst::kVK_F9 : retVal = FBKEY_F9; break;
96  case CocoaConst::kVK_F10 : retVal = FBKEY_F10; break;
97  case CocoaConst::kVK_F11 : retVal = FBKEY_F11; break;
98  case CocoaConst::kVK_F12 : retVal = FBKEY_F12; break;
99  case CocoaConst::kVK_F13 : retVal = FBKEY_F13; break;
100  case CocoaConst::kVK_F14 : retVal = FBKEY_F14; break;
101  case CocoaConst::kVK_F15 : retVal = FBKEY_F15; break;
102  case CocoaConst::kVK_Help : retVal = FBKEY_HELP; break;
103  case CocoaConst::kVK_Home : retVal = FBKEY_HOME; break;
104  case CocoaConst::kVK_PageUp : retVal = FBKEY_PAGEUP; break;
105  case CocoaConst::kVK_ForwardDelete : retVal = FBKEY_FORWARDDELETE; break;
106  case CocoaConst::kVK_End : retVal = FBKEY_END; break;
107  case CocoaConst::kVK_PageDown : retVal = FBKEY_PAGEDOWN; break;
108  case CocoaConst::kVK_LeftArrow : retVal = FBKEY_LEFTARROW; break;
109  case CocoaConst::kVK_RightArrow : retVal = FBKEY_RIGHTARROW; break;
110  case CocoaConst::kVK_DownArrow : retVal = FBKEY_DOWNARROW; break;
111  case CocoaConst::kVK_UpArrow : retVal = FBKEY_UPARROW; break;
112  }
113 
114  return retVal;
115  }
116 }
117 
FBKeyCode
Values that represent different keys in a platform agnostic way.
Definition: KeyCodes.h:26