home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / gamesystem / includes / gs_keyboard.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-07-19  |  1.7 KB  |  75 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    gsCKeyboard
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    12/03/00
  8. //
  9. // Base:    gsCInput
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #ifndef _INCLUDE_GS_KEYBOARD_H
  16. #define _INCLUDE_GS_KEYBOARD_H
  17.  
  18. #include "gs_types.h"
  19. #include "gs_input.h"
  20. #include "gs_keycodes.h"
  21.  
  22. //-------------------------------------------------------------
  23.  
  24. const int gsKEYBOARD_KEYCODES = 256;
  25. const int gsKEYBOARD_BUFFER_SIZE = 16;
  26.  
  27. //-------------------------------------------------------------
  28.  
  29. typedef enum {
  30.     gsKEY_STATE = 1,
  31.     gsKEY_PRESSED = 2,
  32.     gsKEY_RELEASED = 4,
  33. } gsKeyState;
  34.  
  35. //-------------------------------------------------------------
  36.  
  37. class gsCKeyboard : public gsCInput
  38. {
  39.     private:
  40.         static gsLPDIRECTINPUTDEVICE m_keyboard_device;
  41.  
  42.         gsUBYTE m_previous_key_states[gsKEYBOARD_KEYCODES];
  43.         gsUBYTE m_new_key_states[gsKEYBOARD_KEYCODES];
  44.         gsUBYTE m_key_states[gsKEYBOARD_KEYCODES];
  45.         gsCList<gsKeyCode> m_key_buffer;
  46.         
  47.         static char keycode_to_lower[gsKEYBOARD_KEYCODES];
  48.         static char keycode_to_upper[gsKEYBOARD_KEYCODES];
  49.  
  50.         static const char *keycode_description[gsKEYBOARD_KEYCODES];
  51.  
  52.     public:
  53.         gsCKeyboard();
  54.         virtual ~gsCKeyboard();
  55.  
  56.         bool create();
  57.         bool destroy();
  58.  
  59.         bool acquire();
  60.         bool update();
  61.         bool isActive();
  62.  
  63.         bool testKey(gsKeyCode keycode,gsKeyState state = gsKEY_STATE);
  64.         gsKeyCode getKey();
  65.         void flush();
  66.  
  67.         char keyCodeToAscii(gsKeyCode code);
  68.  
  69.         const char *keyCodeToDescription(gsKeyCode code);
  70. };
  71.  
  72. //-------------------------------------------------------------
  73.  
  74. #endif
  75.