#include <exec/types.h>
#include <exec/memory.h>
#include <intuition/intuition.h>
#include <libraries/dos.h>
#include <clib/exec_protos.h>

struct ConsoleDevice *ConsoleDevice=NULL;
struct IOStdReq ioreq;

long DeadKeyConvert(struct
    IntuiMessage *msg,
    UBYTE *buffer,long size,
    struct KeyMap *map ) {
static struct InputEvent
ievent={NULL,IECLASS_RAWKEY,0,0,0};

if( msg->Class!=RAWKEY )
  return( -2 );
ievent.ie_Code=msg->Code;
ievent.ie_Qualifier=msg->Qualifier;
ievent.ie_position.ie_addr=
          *((APTR *)msg->IAddress);
return( (LONG)RawKeyConvert(
 &ievent,(char *)buffer,size,map));
}

int GetKey(struct IntuiMessage
     *message, UBYTE *ibuf ) {
  LONG  numchars;
  UBYTE buffer[15];
  strcpy( buffer,"           " );
  if( message->Code>=0x00 &&
          message->Code<=0x40 ) {
    // ASCII-Code
    numchars=DeadKeyConvert(
         message, buffer,15,0L );
    if( numchars>0 ) {
      *ibuf=*buffer;
      return ASCII;
    }
  }
  /* hier steht der tastencode */
  switch( message->Code ) {
    case 0x41:
         return BACKSPACE;
    case 0x42:
         return TAB;
    case 0x43:
    case 0x44:
         return ENTER;
    ...
  }
}

main() {
  char buf;
  struct IntuiMessage *imessage;
  OpenDevice("console.device",-1L,
    (struct IORequest *)&ioreq,0L);
  ConsoleDevice=ioreq.io_Device;
  /*
   * Hier erfolgt eine Schleife
   * und übergeben die Intuition-
   * Message
   */
  GetKey( intuimessage,&ibuf );
  /*
   * In buf steht nun der ASCII-Code
   */

  /* Und wieder schließen */
  CloseDevice( ioreq );
}
