home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 266.lha / SetKey_v2.0 / src / showkey.c < prev    next >
C/C++ Source or Header  |  1989-07-10  |  4KB  |  141 lines

  1. #include <stdio.h>
  2. #include <exec/types.h>
  3. #include <exec/io.h>
  4. #include <exec/memory.h>
  5.  
  6. #include <graphics/gfxbase.h>
  7. #include <graphics/text.h>
  8. #include <intuition/intuition.h>
  9. #include <devices/console.h>
  10. #include <devices/keymap.h>
  11. #include <libraries/dos.h>
  12. #include <functions.h>
  13.  
  14. SHORT key_to_g[] = 
  15.    {
  16.       12,13,14,15,16,17,18,19,20,21,22,23,24,25,99,79,31,32,
  17.       33,34,35,36,37,38,39,40,41,42,99,62,63,64,49,50,51,52,
  18.       53,54,55,56,57,58,59,99,99,44,45,46,99,66,67,68,69,70,
  19.       71,72,73,74,75,99,80,27,28,29,83,26,30,88,60,0,11,99,99,99,87,
  20.       99,61,86,78,77,1,2,3,4,5,6,7,8,9,10,99,99,99,99,99,43,
  21.       65,76,48,47,81,85,82,84
  22.    };
  23.  
  24. extern UBYTE name[90][11];
  25. extern UBYTE qual_name[8][18];
  26.  
  27. struct GfxBase *GfxBase;
  28. struct IntuitionBase *IntuitionBase;
  29. struct NewWindow nw = 
  30.    {
  31.    500,0,1,1, /* position */
  32.    -1,-1,       /* pens     */
  33.    NULL,
  34.    SMART_REFRESH,
  35.    0,           /* gadet pointer */
  36.    NULL,        /* user check    */
  37.    (unsigned char *)" Console Test Program ",
  38.    NULL,   /* screen */
  39.    NULL,   /* superbitmap */
  40.    1,1,640,200, /* minmax size */
  41.    WBENCHSCREEN
  42.    };
  43.  
  44. struct Window *w;
  45.  
  46. #include "showsubs.c"
  47.  
  48. main(argc,argv)
  49. int argc;
  50. char *argv[];
  51. {
  52.    USHORT which,key,qual,totlen;
  53.    int i,j,k,l;
  54.    int line=0;
  55.    char string[180];
  56.  
  57.    if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0L))) exit(100);
  58.    if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",0L)))  exit(101);
  59.    if(!(w=OpenWindow(&nw))) exit(102);
  60.    if (OpenConsole(w)!=NULL)     exit(103);
  61.  
  62.    AllocKeyMap();
  63.    
  64.    DefaultKeyMap();
  65.  
  66.    printf("/********** Current Key Assignments **********/\n");
  67.    printf("/Key       : Qualifier         :  String      /\n");
  68.    printf("-----------------------------------------------\n");
  69.    for(i=0;i<0x60;i++)
  70.    {
  71.      which = key_to_g[i];
  72.      if(which != 99)
  73.      {
  74.         if(LoTypes[i] & 0x40) 
  75.         {
  76.            totlen=0;
  77.            String(i);
  78.            for (qual=0;qual<8;qual++) 
  79.            {
  80.               if((DStr[qual].length) && (DStr[qual].string[0] != 0x9B))
  81.               {
  82.                   printf("%s : ",name[which]);
  83.                   for(l=k=0;DStr[qual].string[k] != '\0';k++)
  84.                   {
  85.                      switch(DStr[qual].string[k]) 
  86.                      {
  87.                         case 0x0D:
  88.                            string[l++] = '<';
  89.                            string[l++] = 'C';
  90.                            string[l++] = 'R';
  91.                            string[l++] = '>';
  92.                            break;
  93.                         case 0x1F: case 0x1E: case 0x1D:
  94.                         case 0x1C: case 0x1B: case 0x1A: case 0x19:
  95.                         case 0x18: case 0x17: case 0x16: case 0x15:
  96.                         case 0x14: case 0x13: case 0x12: case 0x11:
  97.                         case 0x10: case 0x0F: case 0x0E:
  98.                         case 0x0C: case 0x0B: case 0x0A: case 0x09:
  99.                         case 0x08: case 0x07: case 0x06: case 0x05:
  100.                         case 0x04: case 0x03: case 0x02: case 0x01:
  101.                            string[l++] = 0xDB;
  102.                            break;
  103.                         default:
  104.                            string[l++] = DStr[qual].string[k];
  105.                            break;
  106.                      }
  107.                   }
  108.                   string[l] = '\0';
  109.                   printf("%s : %s\n",qual_name[qual],string);
  110.                   if(totlen>127)
  111.                   {
  112.                      line++;
  113.                      printf(".^. The above key is TOO LONG; Please make shorter! .^.\n");
  114.                   }
  115.                   totlen+=DStr[qual].length;
  116.                   line++;
  117.                   if(DStr[qual].length>44)line++;/* wrap around */
  118.                   if(line>18)
  119.                   {
  120.                      line=0;
  121.                      printf("Press Return to Continue");
  122.                      fflush(stdout);
  123.                      getchar();
  124.    printf("/********** Current Key Assignments **********/\n");
  125.    printf("/Key       : Qualifier         :  String      /\n");
  126.    printf("-----------------------------------------------\n");
  127.                   }
  128.                }
  129.             }
  130.          }
  131.       }
  132.    }
  133.    ClearStr(120);
  134.    FreeKeyMap(4);
  135.  
  136.    ConsoleCleanup();
  137.    CloseWindow(w);
  138.    CloseLibrary(GfxBase);
  139.    CloseLibrary(IntuitionBase);
  140. }
  141.