Tizen 2.1 base
[platform/upstream/libbullet.git] / Extras / AllBulletDemosOSX / src / toolkit / BTGLUTKeyAdapter.m
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose, 
8 including commercial applications, and to alter it and redistribute it freely, 
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #import "BTGLUTKeyAdapter.h"
17 #import <Cocoa/Cocoa.h>
18
19 BOOL BTKeyIsAlpha( int key )
20 {
21         return !BTKeyIsSpecial( key );
22 }
23
24 BOOL BTKeyIsSpecial( int keycode )
25 {
26         BOOL ret = NO;
27         switch( keycode )
28         {
29                 case NSUpArrowFunctionKey:
30                 case NSDownArrowFunctionKey:
31                 case NSLeftArrowFunctionKey:
32                 case NSRightArrowFunctionKey:
33                 case NSF1FunctionKey:
34                 case NSF2FunctionKey:
35                 case NSF3FunctionKey:
36                 case NSF4FunctionKey:
37                 case NSF5FunctionKey:
38                 case NSF6FunctionKey:
39                 case NSF7FunctionKey:
40                 case NSF8FunctionKey:
41                 case NSF9FunctionKey:
42                 case NSF10FunctionKey:
43                 case NSF11FunctionKey:
44                 case NSF12FunctionKey:
45                         ret = YES;
46                         break;
47                                                 
48                 default: break; 
49         }
50         
51         return ret;
52 }
53
54
55 int BTKeyTranslateKeyCodeToSpecial( int kc )
56 {
57         int ret = kc;
58         switch( kc )
59         {
60                 case NSUpArrowFunctionKey:
61                         ret = GLUT_KEY_UP;
62                         break;
63         
64                 case NSDownArrowFunctionKey:
65                         ret = GLUT_KEY_DOWN;
66                         break;
67         
68                 case NSLeftArrowFunctionKey:
69                         ret = GLUT_KEY_LEFT;
70                         break;
71         
72                 case NSRightArrowFunctionKey:
73                         ret = GLUT_KEY_RIGHT;
74                         break;
75
76                 case NSF1FunctionKey:
77                         ret = GLUT_KEY_F1;
78                         break;
79
80                 case NSF2FunctionKey:
81                         ret = GLUT_KEY_F2;
82                         break;
83
84                 case NSF3FunctionKey:
85                         ret = GLUT_KEY_F3;
86                         break;
87
88                 case NSF4FunctionKey:
89                         ret = GLUT_KEY_F4;
90                         break;
91
92                 case NSF5FunctionKey:
93                         ret = GLUT_KEY_F5;
94                         break;
95
96                 case NSF6FunctionKey:
97                         ret = GLUT_KEY_F6;
98                         break;
99
100                 case NSF7FunctionKey:
101                         ret = GLUT_KEY_F7;
102                         break;
103
104                 case NSF8FunctionKey:
105                         ret = GLUT_KEY_F8;
106                         break;
107
108                 case NSF9FunctionKey:
109                         ret = GLUT_KEY_F9;
110                         break;
111
112                 case NSF10FunctionKey:
113                         ret = GLUT_KEY_F10;
114                         break;
115
116                 case NSF11FunctionKey:
117                         ret = GLUT_KEY_F11;
118                         break;
119
120                 case NSF12FunctionKey:
121                         ret = GLUT_KEY_F12;
122                         break;
123                                                 
124                 default: break; 
125         }
126         
127         return ret;
128 }