home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / gnu / aplusplus-1.01-src.lha / src / amiga / aplusplus-1.01 / include / aplusplus / intuition / RawKeyDecoder.h < prev    next >
C/C++ Source or Header  |  1994-05-09  |  3KB  |  93 lines

  1. #ifndef APP_RawKeyDecoder_H
  2. #define APP_RawKeyDecoder_H
  3. /******************************************************************************
  4.  **
  5.  **    C++ Class Library for the Amiga© system software.
  6.  **
  7.  **    Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  8.  **    All Rights Reserved.
  9.  **
  10.  **    $VER: apphome:APlusPlus/intuition/RawKeyDecoder.h 1.04 (04.05.94) $
  11.  **    
  12.  ******************************************************************************/
  13.  
  14. extern "C" {
  15. #include <devices/inputevent.h>
  16. }
  17. #include <APlusPlus/intuition/IntuiMessageC.h>
  18.  
  19.  
  20. /******************************************************************************************
  21.       « RawKeyDecoder class »  
  22.         
  23.     A RawKeyDecoder object takes a single IntuiMessageC object of CLASS_RAWKEY and decodes
  24.     the rawkey codes within.
  25.     One object need to be created once to decode all incoming messages with the method
  26.     'decode(IntuiMessageC*)' which fills in the corresponding key code and qualifier.
  27.     These can be read with the methods 'qualifier()' and 'key()'. The return values are 
  28.     from the enumeration types listed below.
  29.     With Kickstart® 2.0 IDCMP_RAWKEY and IDCMP_VANILLAKEY can be specified both, which is
  30.     recommended to be done. Only the keystrokes that have no vanilla key need to be decoded
  31.     with a RawKeyDecoder.
  32.  
  33.  ******************************************************************************************/
  34.  
  35. // enumeration types for type safety reasons
  36. enum RKD_IEQualifier    // returned by ::qualifier()
  37. {
  38.     LEFTSHIFT = IEQUALIFIER_LSHIFT,
  39.     RIGHTSHIFT = IEQUALIFIER_RSHIFT,
  40.     CAPSLOCK = IEQUALIFIER_CAPSLOCK,
  41.     CONTROL = IEQUALIFIER_CONTROL,
  42.      LEFTALT = IEQUALIFIER_LALT,
  43.      RIGHTALT = IEQUALIFIER_RALT,
  44.      LEFTCOMMAND = IEQUALIFIER_LCOMMAND,
  45.      RIGHTCOMMAND = IEQUALIFIER_RCOMMAND,
  46.     NUMERICPAD = IEQUALIFIER_NUMERICPAD,
  47.      REPEAT = IEQUALIFIER_REPEAT,
  48.     RKDQ_EMPTY = 65535
  49. };
  50. enum RKD_KeyCode    // returned by ::key()
  51. {
  52.     CURSOR_UP  =     'A',
  53.    CURSOR_DOWN =    'B',
  54.     CURSOR_RIGHT =   'C',
  55.     CURSOR_LEFT =    'D',
  56.     KEY_F1 = 0,
  57.     KEY_F2,
  58.     KEY_F3,
  59.     KEY_F4,
  60.     KEY_F5,
  61.     KEY_F6,
  62.     KEY_F7,
  63.     KEY_F8,
  64.     KEY_F9,
  65.     KEY_F10,
  66.     HELP,
  67.     // add further codes here
  68.     RKDC_EMPTY = 65535
  69. };
  70.  
  71. class RawKeyDecoder
  72. {
  73.     private:
  74.         RKD_IEQualifier keyQualifier;
  75.         RKD_KeyCode keycode;        
  76.  
  77.     public:
  78.         RawKeyDecoder() { clear(); }
  79.         RawKeyDecoder(const IntuiMessageC *imsg);
  80.         
  81.         BOOL isEmpty() { return (keycode==RKDC_EMPTY); }
  82.         void clear() {    keyQualifier = RKDQ_EMPTY; keycode = RKDC_EMPTY; }
  83.         
  84.         void decode(const IntuiMessageC *imsg);
  85.         // have an incoming IntuiMessageC decoded
  86.         
  87.         RKD_IEQualifier qualifier() { return keyQualifier; }    
  88.         RKD_KeyCode key() { return keycode; }        
  89.         // after decoding read the result
  90. };
  91.  
  92.  
  93. #endif