Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

SDLInputDevice.h

Go to the documentation of this file.
00001 
00006 
00007 #ifndef __SDLINPUTDEVICE_H
00008 #define __SDLINPUTDEVICE_H
00009 
00010 
00011 #include <map>
00012 
00013 #include <SDL/SDL.h>
00014 
00015 #include "SCA_IInputDevice.h"
00016 
00017 
00018 class SDLInputDevice : public SCA_IInputDevice
00019 {
00020                 // this map is Glut specific: a conversion between Glut and ketsji enums
00021                 std::map<int,KX_EnumInputs> m_reverseKeyTranslateTable;
00022 
00023         public:
00024                 SDLInputDevice()

00025                 {
00026                         /* The reverse table. In order to not confuse ourselves, we      */
00027                         /* immediately convert all events that come in to KX codes.      */
00028 //                      m_reverseKeyTranslateTable[GLUT_LEFT_BUTTON                     ] =     KX_LEFTMOUSE            ;
00029 //                      m_reverseKeyTranslateTable[GLUT_MIDDLE_BUTTON   ] =     KX_MIDDLEMOUSE          ;
00030 //                      m_reverseKeyTranslateTable[GLUT_RIGHT_BUTTON] = KX_RIGHTMOUSE           ;
00031                         //m_reverseKeyTranslateTable[MOUSEX                             ] = KX_MOUSEX                   ;
00032                         //m_reverseKeyTranslateTable[MOUSEY                             ] =     KX_MOUSEY                       ;
00033 
00034                         // TIMERS
00035                         //m_reverseKeyTranslateTable[TIMER0                           ] =       KX_TIMER0                  ;
00036                         //m_reverseKeyTranslateTable[TIMER1                           ] =       KX_TIMER1                  ;
00037                         //m_reverseKeyTranslateTable[TIMER2                           ] = KX_TIMER2                  ;
00038                         //m_reverseKeyTranslateTable[TIMER3                           ] = KX_TIMER3                  ;
00039 
00040                         // SYSTEM
00041                         //m_reverseKeyTranslateTable[KEYBD                            ] = KX_KEYBD                   ;
00042                         //m_reverseKeyTranslateTable[RAWKEYBD                         ] = KX_RAWKEYBD                ;
00043                         //m_reverseKeyTranslateTable[REDRAW                           ] = KX_REDRAW                  ;
00044                         //m_reverseKeyTranslateTable[INPUTCHANGE                      ] = KX_INPUTCHANGE             ;
00045                         //m_reverseKeyTranslateTable[QFULL                            ] = KX_QFULL                   ;
00046                         //m_reverseKeyTranslateTable[WINFREEZE                        ] = KX_WINFREEZE               ;
00047                         //m_reverseKeyTranslateTable[WINTHAW                          ] = KX_WINTHAW                 ;
00048                         //m_reverseKeyTranslateTable[WINCLOSE                         ] = KX_WINCLOSE                ;
00049                         //m_reverseKeyTranslateTable[WINQUIT                          ] = KX_WINQUIT                 ;
00050                         //m_reverseKeyTranslateTable[Q_FIRSTTIME                      ] = KX_Q_FIRSTTIME             ;
00051 
00052                         // standard keyboard
00053                         m_reverseKeyTranslateTable[SDLK_a                             ] = KX_AKEY                    ;
00054                         m_reverseKeyTranslateTable[SDLK_b                             ] = KX_BKEY                    ;
00055                         m_reverseKeyTranslateTable[SDLK_c                             ] = KX_CKEY                    ;
00056                         m_reverseKeyTranslateTable[SDLK_d                             ] = KX_DKEY                    ;
00057                         m_reverseKeyTranslateTable[SDLK_e                             ] = KX_EKEY                    ;
00058                         m_reverseKeyTranslateTable[SDLK_f                             ] = KX_FKEY                    ;
00059                         m_reverseKeyTranslateTable[SDLK_g                             ] = KX_GKEY                    ;
00060                         m_reverseKeyTranslateTable[SDLK_h                             ] = KX_HKEY                    ;
00061                         m_reverseKeyTranslateTable[SDLK_i                             ] = KX_IKEY                    ;
00062                         m_reverseKeyTranslateTable[SDLK_j                             ] = KX_JKEY                    ;
00063                         m_reverseKeyTranslateTable[SDLK_k                             ] = KX_KKEY                    ;
00064                         m_reverseKeyTranslateTable[SDLK_l                             ] = KX_LKEY                    ;
00065                         m_reverseKeyTranslateTable[SDLK_m                             ] = KX_MKEY                    ;
00066                         m_reverseKeyTranslateTable[SDLK_n                             ] = KX_NKEY                    ;
00067                         m_reverseKeyTranslateTable[SDLK_o                             ] = KX_OKEY                    ;
00068                         m_reverseKeyTranslateTable[SDLK_p                             ] = KX_PKEY                    ;
00069                         m_reverseKeyTranslateTable[SDLK_q                             ] = KX_QKEY                    ;
00070                         m_reverseKeyTranslateTable[SDLK_r                             ] = KX_RKEY                    ;
00071                         m_reverseKeyTranslateTable[SDLK_s                             ] = KX_SKEY                    ;
00072                         m_reverseKeyTranslateTable[SDLK_t                             ] = KX_TKEY                    ;
00073                         m_reverseKeyTranslateTable[SDLK_u                             ] = KX_UKEY                    ;
00074                         m_reverseKeyTranslateTable[SDLK_v                             ] = KX_VKEY                    ;
00075                         m_reverseKeyTranslateTable[SDLK_w                             ] = KX_WKEY                    ;
00076                         m_reverseKeyTranslateTable[SDLK_x                             ] = KX_XKEY                    ;
00077                         m_reverseKeyTranslateTable[SDLK_y                             ] = KX_YKEY                    ;
00078                         m_reverseKeyTranslateTable[SDLK_z                             ] = KX_ZKEY                    ;
00079                         m_reverseKeyTranslateTable[SDLK_ESCAPE                                            ] = KX_ESCKEY                  ;
00080                         
00081                 };
00082                 virtual ~SDLInputDevice () {};
00083         
00084                 virtual unsigned short Translate(KX_EnumInputs incode) {
00085                         return 0;
00086                 };
00087 
00088                 virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)

00089                 {
00090                         return false;  // for now
00091                 }
00092 
00093                 /*virtual const SCA_InputEvent& GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)

00094                 {

00095                         return 

00096                 }

00097                 */
00098                 KX_EnumInputs ToNative(SDLKey incode)

00099                 {
00100                         return m_reverseKeyTranslateTable[incode];
00101                 }
00102 
00103                 virtual bool ConvertSDLEvent(SDLKey incode, int val) = 0;
00104 };
00105 
00106 #endif //__SDLINPUTDEVICE_H

Generated at Thu Feb 1 13:03:11 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000