home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / e / amigae / src / tools / cookrawkey / cookrawkey.e < prev    next >
Text File  |  1994-10-04  |  2KB  |  70 lines

  1. /*---------------------------------------------------------------------------*
  2.   cookRawkey.e - Use console.device to convert rawkeys to asciikeys.
  3.  
  4.   Modifications:
  5.     Rev 1, 4 Oct 94, Barry Wills
  6.       cookRawkey() modified to correctly process deadkeys;
  7.       1) changed parameter 'iAddress' to 'iAddress:PTR TO LONG';
  8.       2) changed statement 'PutLong(ie+10, iAddress)' to
  9.          'PutLong(ie+10, iAddress[])'
  10.  *---------------------------------------------------------------------------*/
  11. OPT MODULE
  12.  
  13. MODULE 'console',
  14.        'devices/console',
  15.        'devices/conunit',
  16.        'devices/inputevent',
  17.        'devices/keymap',
  18.        'exec/io',
  19.        'exec/ports'
  20.  
  21. EXPORT CONST ER_NONE        = 0,
  22.              ER_CREATEPORT  = "PORT",
  23.              ER_CREATEIO    = "IO",
  24.              ER_OPENDEVICE  = "DEV",
  25.              ER_ASKKEYMAP   = "KMAP"
  26.  
  27. DEF consoleMessagePort:PTR TO mp,
  28.     consoleIO:PTR TO iostd
  29.  
  30. EXPORT PROC warmupRawkeyCooker()
  31.   IF (consoleMessagePort:=CreateMsgPort())=NIL THEN RETURN ER_CREATEPORT
  32.   IF (consoleIO:=CreateIORequest(consoleMessagePort, SIZEOF iostd))=
  33.        NIL THEN RETURN ER_CREATEIO
  34.   IF OpenDevice('console.device', CONU_LIBRARY,
  35.                 consoleIO, CONFLAG_DEFAULT) THEN RETURN ER_OPENDEVICE
  36.   consoleIO.command:=CD_ASKKEYMAP
  37.   consoleIO.length:=SIZEOF keymap
  38.   consoleIO.data:=NewR(SIZEOF keymap)
  39.   IF DoIO(consoleIO) THEN RETURN ER_ASKKEYMAP
  40.   IF (consoleIO.flags AND IOF_QUICK)=0 THEN WaitIO(consoleIO)
  41.   consoledevice:=consoleIO.device
  42. ENDPROC  ER_NONE
  43.   /* warmupRawkeyCooker */
  44.  
  45. EXPORT PROC shutdownRawkeyCooker()
  46.   IF consoleIO
  47.     IF consoleIO.data THEN Dispose(consoleIO.data)
  48.     IF consoleIO.device
  49.       AbortIO(consoleIO)
  50.       CloseDevice(consoleIO)
  51.     ENDIF
  52.     DeleteIORequest(consoleIO)
  53.   ENDIF
  54.   IF consoleMessagePort THEN DeleteMsgPort(consoleMessagePort)
  55. ENDPROC
  56.   /* shutdownRawkeyCooker */
  57.  
  58. EXPORT PROC cookRawkey(idcmpCode, idcmpQualifier, iAddress:PTR TO LONG)
  59.   DEF asciiChar=0, ie:inputevent, buffer[1]:STRING, actual
  60.   ie.nextevent:=NIL
  61.   ie.class:=IECLASS_RAWKEY
  62.   ie.subclass:=0
  63.   ie.code:=idcmpCode
  64.   ie.qualifier:=idcmpQualifier
  65.   PutLong(ie+10, iAddress[])
  66.   actual:=RawKeyConvert(ie, buffer, 1, consoleIO.data)
  67.   IF actual=1 THEN asciiChar:=buffer[0]
  68. ENDPROC  asciiChar
  69.   /* cookRawkey */
  70.