home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 545a.lha / PowerVisor_v1.0 / Source.LZH / Source / GetCode.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-31  |  1.3 KB  |  84 lines

  1. #include <exec/types.h>
  2. #include <pragmas/exec.h>
  3. #include <pragmas/keymap.h>
  4. #include <string.h>
  5.  
  6. struct myCode
  7.     {
  8.         char *str;
  9.         UWORD code;
  10.     };
  11.  
  12. struct myCode Codes[] =
  13.     {
  14.         "f1",            0x50,
  15.         "f2",            0x51,
  16.         "f3",            0x52,
  17.         "f4",            0x53,
  18.         "f5",            0x54,
  19.         "f6",            0x55,
  20.         "f7",            0x56,
  21.         "f8",            0x57,
  22.         "f9",            0x58,
  23.         "f10",        0x59,
  24.         "esc",        0x45,
  25.         "enter",    0x43,
  26.         "ret",        0x44,
  27.         "up",            0x4c,
  28.         "down",        0x4d,
  29.         "right",    0x4e,
  30.         "left",        0x4f,
  31.         "del",        0x46,
  32.         "help",        0x5f,
  33.         "tab",        0x42,
  34.         "numl",        0x5a,
  35.         "scrl",        0x5b,
  36.         "prtsc",    0x5d,
  37.         "home",        0x3d,
  38.         "end",        0x1d,
  39.         "nup",        0x3e,
  40.         "nleft",    0x2d,
  41.         "nright",    0x2f,
  42.         "ndown",    0x1e,
  43.         "pgup",        0x3f,
  44.         "pgdn",        0x1f,
  45.         "ins",        0x0f,
  46.         "ndel",        0x3c,
  47.         NULL,            0
  48.     };
  49.  
  50.  
  51. int __saveds __asm Code (register __a0 char *cmdline, register __a2 APTR table[])
  52. {
  53.     struct Library *KeymapBase;
  54.     char codequal[3],*p;
  55.     int code;
  56.     struct myCode *mc;
  57.     char __regargs * (*GetString)(char *);
  58.  
  59.     GetString = table[9];
  60.     p = GetString (cmdline);
  61.  
  62.     code = -1;
  63.     mc = Codes;
  64.     while (mc->str)
  65.         {
  66.             if (!strcmp (mc->str,p))
  67.                 {
  68.                     code = (int)(mc->code);
  69.                     break;
  70.                 }
  71.             mc++;
  72.         }
  73.  
  74.     if (code == -1)
  75.         {
  76.             KeymapBase = (struct Library *)OpenLibrary ("keymap.library",0);
  77.             MapANSI (p,1,codequal,1,NULL);
  78.             CloseLibrary (KeymapBase);
  79.             code = (int)codequal[0];
  80.         }
  81.  
  82.     return (code);
  83. }
  84.