fixed spacing in the headers to get rid of some warnings and some other
[blender.git] / source / gameengine / BlenderRoutines / KX_BlenderInputDevice.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32 #ifndef __KX_BLENDERINPUTDEVICE
33 #define __KX_BLENDERINPUTDEVICE
34
35 #ifdef WIN32
36 #pragma warning(disable : 4786)  // shut off 255 char limit debug template warning
37 #endif
38
39 /* need to be here for conversion purposes */
40 #include "mydevice.h"
41 #include "SCA_IInputDevice.h"
42
43 #include <map>
44 /**
45  Base Class for Blender specific inputdevices. Blender specific inputdevices are used when the gameengine is running in embedded mode instead of standalone mode.
46 */
47 class BL_BlenderInputDevice : public SCA_IInputDevice                                                               
48 {
49         // this map is Blender specific: a conversion between blender and ketsji enums
50         std::map<int,KX_EnumInputs> m_reverseKeyTranslateTable;
51 public:
52         BL_BlenderInputDevice()                                                                                    
53                 {                                                                                                          
54                         
55                         /* The reverse table. In order to not confuse ourselves, we      */
56                         /* immediately convert all events that come in to KX codes.      */
57                         m_reverseKeyTranslateTable[LEFTMOUSE                    ] =     KX_LEFTMOUSE            ;                       
58                         m_reverseKeyTranslateTable[MIDDLEMOUSE                  ] =     KX_MIDDLEMOUSE          ;                       
59                         m_reverseKeyTranslateTable[RIGHTMOUSE                   ] =     KX_RIGHTMOUSE           ;                       
60                         m_reverseKeyTranslateTable[MOUSEX                               ] = KX_MOUSEX                   ;                       
61                         m_reverseKeyTranslateTable[MOUSEY                               ] =     KX_MOUSEY                       ;                       
62                                                                                                                    
63                         // TIMERS                                                                                                  
64
65                         m_reverseKeyTranslateTable[TIMER0                           ] = KX_TIMER0                  ;                  
66                         m_reverseKeyTranslateTable[TIMER1                           ] = KX_TIMER1                  ;                  
67                         m_reverseKeyTranslateTable[TIMER2                           ] = KX_TIMER2                  ;                  
68                         m_reverseKeyTranslateTable[TIMER3                           ] = KX_TIMER3                  ;                  
69                                                                                                                    
70                         // SYSTEM                                                                                                  
71                                                                                                                    
72                         m_reverseKeyTranslateTable[KEYBD                            ] = KX_KEYBD                   ;                  
73                         m_reverseKeyTranslateTable[RAWKEYBD                         ] = KX_RAWKEYBD                ;                  
74                         m_reverseKeyTranslateTable[REDRAW                           ] = KX_REDRAW                  ;                  
75                         m_reverseKeyTranslateTable[INPUTCHANGE                      ] = KX_INPUTCHANGE             ;                  
76                         m_reverseKeyTranslateTable[QFULL                            ] = KX_QFULL                   ;                  
77                         m_reverseKeyTranslateTable[WINFREEZE                        ] = KX_WINFREEZE               ;                  
78                         m_reverseKeyTranslateTable[WINTHAW                          ] = KX_WINTHAW                 ;                  
79                         m_reverseKeyTranslateTable[WINCLOSE                         ] = KX_WINCLOSE                ;                  
80                         m_reverseKeyTranslateTable[WINQUIT                          ] = KX_WINQUIT                 ;                  
81                         m_reverseKeyTranslateTable[Q_FIRSTTIME                      ] = KX_Q_FIRSTTIME             ;                  
82                                                                                                                    
83                         // standard keyboard                                                                                       
84                                                                                                                    
85                         m_reverseKeyTranslateTable[AKEY                             ] = KX_AKEY                    ;                  
86                         m_reverseKeyTranslateTable[BKEY                             ] = KX_BKEY                    ;                  
87                         m_reverseKeyTranslateTable[CKEY                             ] = KX_CKEY                    ;                  
88                         m_reverseKeyTranslateTable[DKEY                             ] = KX_DKEY                    ;                  
89                         m_reverseKeyTranslateTable[EKEY                             ] = KX_EKEY                    ;                  
90                         m_reverseKeyTranslateTable[FKEY                             ] = KX_FKEY                    ;                  
91                         m_reverseKeyTranslateTable[GKEY                             ] = KX_GKEY                    ;                  
92                         m_reverseKeyTranslateTable[HKEY                             ] = KX_HKEY                    ;                  
93                         m_reverseKeyTranslateTable[IKEY                             ] = KX_IKEY                    ;                  
94                         m_reverseKeyTranslateTable[JKEY                             ] = KX_JKEY                    ;                  
95                         m_reverseKeyTranslateTable[KKEY                             ] = KX_KKEY                    ;                  
96                         m_reverseKeyTranslateTable[LKEY                             ] = KX_LKEY                    ;                  
97                         m_reverseKeyTranslateTable[MKEY                             ] = KX_MKEY                    ;                  
98                         m_reverseKeyTranslateTable[NKEY                             ] = KX_NKEY                    ;                  
99                         m_reverseKeyTranslateTable[OKEY                             ] = KX_OKEY                    ;                  
100                         m_reverseKeyTranslateTable[PKEY                             ] = KX_PKEY                    ;                  
101                         m_reverseKeyTranslateTable[QKEY                             ] = KX_QKEY                    ;                  
102                         m_reverseKeyTranslateTable[RKEY                             ] = KX_RKEY                    ;                  
103                         m_reverseKeyTranslateTable[SKEY                             ] = KX_SKEY                    ;                  
104                         m_reverseKeyTranslateTable[TKEY                             ] = KX_TKEY                    ;                  
105                         m_reverseKeyTranslateTable[UKEY                             ] = KX_UKEY                    ;                  
106                         m_reverseKeyTranslateTable[VKEY                             ] = KX_VKEY                    ;                  
107                         m_reverseKeyTranslateTable[WKEY                             ] = KX_WKEY                    ;                  
108                         m_reverseKeyTranslateTable[XKEY                             ] = KX_XKEY                    ;                  
109                         m_reverseKeyTranslateTable[YKEY                             ] = KX_YKEY                    ;                  
110                         m_reverseKeyTranslateTable[ZKEY                             ] = KX_ZKEY                    ;                  
111                                                                                                                    
112                         m_reverseKeyTranslateTable[ZEROKEY                              ] = KX_ZEROKEY                  ;                  
113                         m_reverseKeyTranslateTable[ONEKEY                               ] = KX_ONEKEY                   ;                  
114                         m_reverseKeyTranslateTable[TWOKEY                               ] = KX_TWOKEY                   ;                  
115                         m_reverseKeyTranslateTable[THREEKEY                     ] = KX_THREEKEY                ;                  
116                         m_reverseKeyTranslateTable[FOURKEY                              ] = KX_FOURKEY                  ;                  
117                         m_reverseKeyTranslateTable[FIVEKEY                              ] = KX_FIVEKEY                  ;                  
118                         m_reverseKeyTranslateTable[SIXKEY                               ] = KX_SIXKEY                   ;                  
119                         m_reverseKeyTranslateTable[SEVENKEY                         ] = KX_SEVENKEY                ;                  
120                         m_reverseKeyTranslateTable[EIGHTKEY                         ] = KX_EIGHTKEY                ;                  
121                         m_reverseKeyTranslateTable[NINEKEY                              ] = KX_NINEKEY                  ;                  
122                                                                                                                    
123                         m_reverseKeyTranslateTable[CAPSLOCKKEY                      ] = KX_CAPSLOCKKEY             ;                  
124                                                                 
125                         m_reverseKeyTranslateTable[LEFTCTRLKEY                  ] = KX_LEFTCTRLKEY              ;                  
126                         m_reverseKeyTranslateTable[LEFTALTKEY                   ] = KX_LEFTALTKEY               ;                  
127                         m_reverseKeyTranslateTable[RIGHTALTKEY                  ] = KX_RIGHTALTKEY              ;                  
128                         m_reverseKeyTranslateTable[RIGHTCTRLKEY                         ] = KX_RIGHTCTRLKEY             ;                  
129                         m_reverseKeyTranslateTable[RIGHTSHIFTKEY                        ] = KX_RIGHTSHIFTKEY            ;                  
130                         m_reverseKeyTranslateTable[LEFTSHIFTKEY                     ] = KX_LEFTSHIFTKEY            ;                  
131                                                                                                                    
132                         m_reverseKeyTranslateTable[ESCKEY                           ] = KX_ESCKEY                  ;                  
133                         m_reverseKeyTranslateTable[TABKEY                           ] = KX_TABKEY                  ;                  
134                         m_reverseKeyTranslateTable[RETKEY                           ] = KX_RETKEY                  ;                  
135                         m_reverseKeyTranslateTable[SPACEKEY                         ] = KX_SPACEKEY                ;                  
136                         m_reverseKeyTranslateTable[LINEFEEDKEY                  ] = KX_LINEFEEDKEY              ;                  
137                         m_reverseKeyTranslateTable[BACKSPACEKEY                     ] = KX_BACKSPACEKEY            ;                  
138                         m_reverseKeyTranslateTable[DELKEY                           ] = KX_DELKEY                  ;                  
139                         m_reverseKeyTranslateTable[SEMICOLONKEY                     ] = KX_SEMICOLONKEY            ;                  
140                         m_reverseKeyTranslateTable[PERIODKEY                    ] = KX_PERIODKEY                ;                  
141                         m_reverseKeyTranslateTable[COMMAKEY                             ] = KX_COMMAKEY         ;                  
142                         m_reverseKeyTranslateTable[QUOTEKEY                             ] = KX_QUOTEKEY         ;                  
143                         m_reverseKeyTranslateTable[ACCENTGRAVEKEY                       ] = KX_ACCENTGRAVEKEY           ;                  
144                         m_reverseKeyTranslateTable[MINUSKEY                             ] = KX_MINUSKEY         ;                  
145                         m_reverseKeyTranslateTable[SLASHKEY                             ] = KX_SLASHKEY         ;                  
146                         m_reverseKeyTranslateTable[BACKSLASHKEY                     ] = KX_BACKSLASHKEY            ;                  
147                         m_reverseKeyTranslateTable[EQUALKEY                             ] = KX_EQUALKEY         ;                  
148                         m_reverseKeyTranslateTable[LEFTBRACKETKEY                       ] = KX_LEFTBRACKETKEY           ;                  
149                         m_reverseKeyTranslateTable[RIGHTBRACKETKEY                      ] = KX_RIGHTBRACKETKEY          ;                  
150                                                                                                                    
151                         m_reverseKeyTranslateTable[LEFTARROWKEY                     ] = KX_LEFTARROWKEY            ;                  
152                         m_reverseKeyTranslateTable[DOWNARROWKEY                     ] = KX_DOWNARROWKEY            ;                  
153                         m_reverseKeyTranslateTable[RIGHTARROWKEY                        ] = KX_RIGHTARROWKEY            ;                  
154                         m_reverseKeyTranslateTable[UPARROWKEY                   ] = KX_UPARROWKEY               ;                  
155                                                                                                                    
156                         m_reverseKeyTranslateTable[PAD2                         ] = KX_PAD2                     ;                  
157                         m_reverseKeyTranslateTable[PAD4                         ] = KX_PAD4                     ;                  
158                         m_reverseKeyTranslateTable[PAD6                         ] = KX_PAD6                     ;                  
159                         m_reverseKeyTranslateTable[PAD8                         ] = KX_PAD8                     ;                  
160                                                                                                                    
161                         m_reverseKeyTranslateTable[PAD1                         ] = KX_PAD1                     ;                  
162                         m_reverseKeyTranslateTable[PAD3                         ] = KX_PAD3                     ;                  
163                         m_reverseKeyTranslateTable[PAD5                         ] = KX_PAD5                     ;                  
164                         m_reverseKeyTranslateTable[PAD7                         ] = KX_PAD7                     ;                  
165                         m_reverseKeyTranslateTable[PAD9                         ] = KX_PAD9                     ;                  
166
167                         m_reverseKeyTranslateTable[PADPERIOD                        ] = KX_PADPERIOD               ;                  
168                         m_reverseKeyTranslateTable[PADSLASHKEY                    ] = KX_PADSLASHKEY           ;                  
169                         m_reverseKeyTranslateTable[PADASTERKEY                      ] = KX_PADASTERKEY             ;                  
170                                                                                                                    
171                                                                                                                    
172                         m_reverseKeyTranslateTable[PAD0                         ] = KX_PAD0                     ;                  
173                         m_reverseKeyTranslateTable[PADMINUS                         ] = KX_PADMINUS                ;                  
174                         m_reverseKeyTranslateTable[PADENTER                         ] = KX_PADENTER                ;                  
175                         m_reverseKeyTranslateTable[PADPLUSKEY                       ] = KX_PADPLUSKEY              ;                  
176                                                                                                                    
177                                                                                                                    
178                         m_reverseKeyTranslateTable[F1KEY                            ] = KX_F1KEY                   ;                  
179                         m_reverseKeyTranslateTable[F2KEY                            ] = KX_F2KEY                   ;                  
180                         m_reverseKeyTranslateTable[F3KEY                            ] = KX_F3KEY                   ;                  
181                         m_reverseKeyTranslateTable[F4KEY                            ] = KX_F4KEY                   ;                  
182                         m_reverseKeyTranslateTable[F5KEY                            ] = KX_F5KEY                   ;                  
183                         m_reverseKeyTranslateTable[F6KEY                            ] = KX_F6KEY                   ;                  
184                         m_reverseKeyTranslateTable[F7KEY                            ] = KX_F7KEY                   ;                  
185                         m_reverseKeyTranslateTable[F8KEY                            ] = KX_F8KEY                   ;                  
186                         m_reverseKeyTranslateTable[F9KEY                            ] = KX_F9KEY                   ;                  
187                         m_reverseKeyTranslateTable[F10KEY                           ] = KX_F10KEY                  ;                  
188                         m_reverseKeyTranslateTable[F11KEY      ] = KX_F11KEY                  ;                  
189                         m_reverseKeyTranslateTable[F12KEY      ] = KX_F12KEY                  ;                  
190                                                                                                                    
191                         m_reverseKeyTranslateTable[PAUSEKEY    ] = KX_PAUSEKEY                ;                  
192                         m_reverseKeyTranslateTable[INSERTKEY   ] = KX_INSERTKEY               ;                  
193                         m_reverseKeyTranslateTable[HOMEKEY     ] = KX_HOMEKEY                 ;                  
194                         m_reverseKeyTranslateTable[PAGEUPKEY   ] = KX_PAGEUPKEY               ;                  
195                         m_reverseKeyTranslateTable[PAGEDOWNKEY ] = KX_PAGEDOWNKEY             ;                  
196                         m_reverseKeyTranslateTable[ENDKEY      ] = KX_ENDKEY                  ;                  
197
198                                                                                                                    
199                 }                                                                                                          
200
201         virtual ~BL_BlenderInputDevice()
202                 {
203
204                 }
205                                                                                                                    
206          KX_EnumInputs ToNative(unsigned short incode) {
207                 return m_reverseKeyTranslateTable[incode];
208         }
209
210         virtual bool    IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
211 //      virtual const SCA_InputEvent&   GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
212         virtual bool    ConvertBlenderEvent(unsigned short incode,short val)=0;
213
214 };                                                                                                                 
215 #endif //__KX_BLENDERINPUTDEVICE
216