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

SCA_IInputDevice.h

Go to the documentation of this file.
00001 
00007 
00008 #ifndef KX_INPUTDEVICE_H
00009 #define KX_INPUTDEVICE_H
00010 
00011 /*bool KX_Win32System::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)

00012 {

00013         return m_keystatus[inputcode]!=0;

00014 }

00015 
00016 unsigned short KX_Win32System::KeyValue(SCA_IInputDevice::KX_EnumInputs inputcode)

00017 {

00018         return m_keystatus[inputcode];

00019 }

00020 */
00021 
00022 class SCA_InputEvent
00023 {
00024         
00025 public:
00026         enum SCA_EnumInputs {
00027         
00028                 KX_NO_INPUTSTATUS = 0,
00029                 KX_JUSTACTIVATED,
00030                 KX_ACTIVE,
00031                 KX_JUSTRELEASED,
00032                 KX_MAX_INPUTSTATUS
00033         };
00034 
00035         SCA_InputEvent(SCA_EnumInputs status=KX_NO_INPUTSTATUS,int eventval=0)
00036                 :       m_status(status),
00037                 m_eventval(eventval)

00038         {
00039 
00040         }
00041 
00042         SCA_EnumInputs m_status;
00043         int             m_eventval;
00044 };
00045 
00046 class SCA_IInputDevice
00047 {
00048 
00049         
00050 public:
00051 
00052         SCA_IInputDevice() : m_currentTable(0)
00053         {
00054                 ClearStatusTable(0);
00055                 ClearStatusTable(1);
00056         };
00057         virtual ~SCA_IInputDevice() {}; 
00058 
00059 
00060 
00061         enum KX_EnumInputs {
00062         
00063                 KX_NOKEY = 0,
00064         
00065                 // TIMERS 
00066         
00067                 KX_TIMER0,
00068                 KX_TIMER1,
00069                 KX_TIMER2,
00070                 KX_TIMER3,
00071         
00072                 // SYSTEM
00073         
00074                 KX_KEYBD,
00075                 KX_RAWKEYBD,
00076                 KX_REDRAW,
00077                 KX_INPUTCHANGE,
00078                 KX_QFULL,
00079                 KX_WINFREEZE,
00080                 KX_WINTHAW,
00081                 KX_WINCLOSE,
00082                 KX_WINQUIT,
00083                 KX_Q_FIRSTTIME,
00084         
00085                 // standard keyboard 
00086                 
00087                 KX_BEGINKEY,
00088 
00089                 KX_RETKEY = 13,
00090                 KX_SPACEKEY = 32,
00091                 KX_PADASTERKEY = 42,
00092                 KX_COMMAKEY = 44,               
00093                 KX_MINUSKEY = 45,               
00094                 KX_PERIODKEY = 46,
00095                 KX_ZEROKEY = 48,
00096                 
00097                 KX_ONEKEY,              
00098                 KX_TWOKEY,              
00099                 KX_THREEKEY,
00100                 KX_FOURKEY,             
00101                 KX_FIVEKEY,             
00102                 KX_SIXKEY,              
00103                 KX_SEVENKEY,
00104                 KX_EIGHTKEY,
00105                 KX_NINEKEY,             
00106 
00107                 KX_AKEY = 97,
00108                 KX_BKEY,
00109                 KX_CKEY,
00110                 KX_DKEY,
00111                 KX_EKEY,
00112                 KX_FKEY,
00113                 KX_GKEY,
00114                 KX_HKEY,
00115                 KX_IKEY,
00116                 KX_JKEY,
00117                 KX_KKEY,
00118                 KX_LKEY,
00119                 KX_MKEY,
00120                 KX_NKEY,
00121                 KX_OKEY,
00122                 KX_PKEY,
00123                 KX_QKEY,
00124                 KX_RKEY,
00125                 KX_SKEY,
00126                 KX_TKEY,
00127                 KX_UKEY,
00128                 KX_VKEY,
00129                 KX_WKEY,
00130                 KX_XKEY,
00131                 KX_YKEY,
00132                 KX_ZKEY,
00133         
00134                 
00135                 
00136                 KX_CAPSLOCKKEY,
00137                 
00138                 KX_LEFTCTRLKEY, 
00139                 KX_LEFTALTKEY,          
00140                 KX_RIGHTALTKEY,         
00141                 KX_RIGHTCTRLKEY,        
00142                 KX_RIGHTSHIFTKEY,       
00143                 KX_LEFTSHIFTKEY,
00144                 
00145                 KX_ESCKEY,
00146                 KX_TABKEY,
00147                 
00148                 
00149                 KX_LINEFEEDKEY,         
00150                 KX_BACKSPACEKEY,
00151                 KX_DELKEY,
00152                 KX_SEMICOLONKEY,
00153                 
00154                 
00155                 KX_QUOTEKEY,            
00156                 KX_ACCENTGRAVEKEY,      
00157                 
00158                 KX_VIRGULEKEY,          
00159                 KX_SLASHKEY,            
00160                 KX_BACKSLASHKEY,
00161                 KX_EQUALKEY,            
00162                 KX_LEFTBRACKETKEY,      
00163                 KX_RIGHTBRACKETKEY,     
00164                 
00165                 KX_LEFTARROWKEY,
00166                 KX_DOWNARROWKEY,
00167                 KX_RIGHTARROWKEY,       
00168                 KX_UPARROWKEY,          
00169         
00170                 KX_PAD2 ,
00171                 KX_PAD4 ,
00172                 KX_PAD6 ,
00173                 KX_PAD8 ,
00174                 
00175                 KX_PAD1 ,
00176                 KX_PAD3 ,
00177                 KX_PAD5 ,
00178                 KX_PAD7 ,
00179                 KX_PAD9 ,
00180                 
00181                 KX_PADPERIOD,
00182                 KX_PADVIRGULEKEY,
00183                 
00184                 
00185                 
00186                 KX_PAD0 ,
00187                 KX_PADMINUS,
00188                 KX_PADENTER,
00189                 KX_PADPLUSKEY,
00190                 
00191                 
00192                 KX_F1KEY ,
00193                 KX_F2KEY ,
00194                 KX_F3KEY ,
00195                 KX_F4KEY ,
00196                 KX_F5KEY ,
00197                 KX_F6KEY ,
00198                 KX_F7KEY ,
00199                 KX_F8KEY ,
00200                 KX_F9KEY ,
00201                 KX_F10KEY,
00202                 KX_F11KEY,
00203                 KX_F12KEY,
00204                 
00205                 KX_PAUSEKEY,
00206                 KX_INSERTKEY,
00207                 KX_HOMEKEY ,
00208                 KX_PAGEUPKEY,
00209                 KX_PAGEDOWNKEY,
00210                 KX_ENDKEY,
00211 
00212                 // MOUSE
00213                 KX_BEGINMOUSE,
00214                 
00215                 KX_BEGINMOUSEBUTTONS,
00216 
00217                 KX_LEFTMOUSE,
00218                 KX_MIDDLEMOUSE,
00219                 KX_RIGHTMOUSE,
00220                 
00221                 KX_ENDMOUSEBUTTONS,
00222 
00223                 KX_MOUSEX,
00224                 KX_MOUSEY,
00225         
00226                 KX_ENDMOUSE,
00227 
00228 
00229 
00230                 KX_MAX_KEYS
00231                 
00232         } ; // enum  
00233 
00234 
00235 protected:
00240 
00241         SCA_InputEvent          m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS];
00245         int                             m_currentTable; 
00246 
00247         void    ClearStatusTable(int tableid) {
00248                 for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++)
00249                         m_eventStatusTables[tableid][i]=SCA_InputEvent(SCA_InputEvent::KX_NO_INPUTSTATUS,0);
00250         }
00251 
00252 public:
00253         virtual bool    IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
00254 
00255         virtual const SCA_InputEvent&   GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)

00256         {
00257                 return m_eventStatusTables[m_currentTable][inputcode];
00258         }
00259 
00260         virtual int             GetNumActiveEvents()

00261         {
00262                 int num = 0;
00263                 for (int i=0;i<SCA_IInputDevice::KX_MAX_KEYS;i++)
00264                 {
00265                         const SCA_InputEvent& event = m_eventStatusTables[m_currentTable][i];
00266                         if (event.m_status == SCA_InputEvent::KX_JUSTACTIVATED) //KX_NO_INPUTSTATUS)
00267                                 num++;
00268                 }
00269                 return num;
00270         }
00271         virtual void    NextFrame()

00272         {
00273                 m_currentTable = 1 - m_currentTable;
00274                 ClearStatusTable(m_currentTable);
00275         }
00276 
00277 };
00278 
00279 #endif  //KX_INPUTDEVICE_H

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