home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1990 / USERJL90.MSA / LISTINGS.ARC / INSERT.C < prev    next >
C/C++ Source or Header  |  1990-05-16  |  1KB  |  47 lines

  1. /* Insert keypresses by Lloyd Patton */
  2.  
  3. #include <local.h>
  4. #include <osbind.h>
  5.  
  6. main()
  7.   {
  8.  
  9.   long UpperA = 0x001e0041; /* 'A' */
  10.   long Number0 = 0x000b0030; /* '0' */
  11.   long ch;
  12.  
  13.   appl_init();
  14.   insert_char(UpperA);
  15.   ch = evnt_keybd();  /* test GEM call */
  16.   printf("\nkeystroke should be 0x1e41 and is 0x%lx\n",
  17. ch);
  18.   insert_char(Number0);
  19.   ch = Bconin(2);   /* test BIOS call */
  20.   printf("\nkeystroke should be 0x000b0030 and is
  21. 0x%08lx\n", ch);
  22.   evnt_keybd();
  23.   appl_exit();
  24.   }
  25.  
  26. insert_char(keycode)
  27.   long keycode;
  28.   {
  29.  
  30.   iorec *keybuf;
  31.   long stack;
  32.  
  33.   keybuf = Iorec(1);  /* get Iorec address */
  34.   stack = Super(0L);  /* supervisor mode to access Iorec
  35.  */
  36.  
  37.     /* loop around buffer */
  38.   if ((keybuf->ibuftl += 4) >= keybuf->ibufsiz)
  39.     keybuf->ibuftl = 0;
  40.  
  41.     /* if room in buffer store keystroke */
  42.   if (keybuf->ibuftl != keybuf->ibufhd)
  43.     *(long *)&keybuf->ibuf[keybuf->ibuftl] = keycode;
  44.  
  45.   Super(stack);   /* back to user mode */
  46.   }
  47.