home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / RawKeyDecoder.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  2.0 KB  |  77 lines

  1. /******************************************************************************
  2.  **
  3.  **   C++ Class Library for the Amiga⌐ system software.
  4.  **
  5.  **   Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **   All Rights Reserved.
  7.  **
  8.  **   $Source: apphome:RCS/libsource/RawKeyDecoder.cxx,v $
  9.  **   $Revision: 1.7 $
  10.  **   $Date: 1994/07/31 13:31:33 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. extern "C" {
  17. #ifdef __GNUG__
  18. #include <inline/keymap.h>
  19. #endif
  20.  
  21. #ifdef __SASC
  22. #include <proto/keymap.h>
  23. #endif
  24.  
  25. #include <devices/inputevent.h>
  26. #include <devices/keymap.h>
  27. }
  28. #include <APlusPlus/intuition/RawKeyDecoder.h>
  29. #include <APlusPlus/intuition/IntuiMessageC.h>
  30.  
  31.  
  32. static const char rcs_id[] = "$Id: RawKeyDecoder.cxx,v 1.7 1994/07/31 13:31:33 Armin_Vogt Exp Armin_Vogt $";
  33.  
  34.  
  35. RawKeyDecoder::RawKeyDecoder()
  36. {
  37.    clear();
  38. }
  39.  
  40. RawKeyDecoder::RawKeyDecoder(const IntuiMessageC *imsg)
  41. {
  42.    decode(imsg);
  43. }
  44.  
  45. void RawKeyDecoder::decode(const IntuiMessageC *imsg)
  46. {
  47.    #define RKD_MAX_INPUT_LEN 10
  48.    UBYTE inputBuffer[RKD_MAX_INPUT_LEN+1];
  49.  
  50.    struct InputEvent inputEvent = { 0,IECLASS_RAWKEY,0,0,0 };
  51.    inputEvent.ie_Code      = imsg->Code;
  52.    inputEvent.ie_Qualifier = imsg->Qualifier;
  53.    inputEvent.ie_EventAddress = (APTR)((struct IntuiMessage*)imsg)->IAddress;
  54.  
  55.    (void) MapRawKey(&inputEvent,(char*)inputBuffer,RKD_MAX_INPUT_LEN,NULL);
  56.  
  57.    keyQualifier = (RKD_IEQualifier)imsg->Qualifier;
  58.  
  59.    UBYTE *bufferPtr = inputBuffer;
  60.    if (*bufferPtr==0x9b)
  61.    {
  62.       keycode = (RKD_KeyCode)*++bufferPtr;
  63.       if (keycode==' ')
  64.       {
  65.          switch (keycode = (RKD_KeyCode)*++bufferPtr)
  66.          {
  67.             // rewrite SHIFTED cursor keys to non-shifted with qualifier
  68.             case 'T' : keycode = CURSOR_UP; break;
  69.             case 'S' : keycode = CURSOR_DOWN; break;
  70.             case '@' : keycode = CURSOR_RIGHT; break;
  71.             case 'A' : keycode = CURSOR_LEFT; break;
  72.          }
  73.       }
  74.    }
  75.    else keycode = (RKD_KeyCode)*bufferPtr;
  76. }
  77.