home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / CBGRX102 / EVTEST.C < prev    next >
Text File  |  1992-08-12  |  3KB  |  118 lines

  1. /** 
  2.  ** EVTEST.C 
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24. #include "eventque.h"
  25.  
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include <ctype.h>
  29. #include <dos.h>
  30.  
  31. EventQueue *q;
  32.  
  33. #define ATTR 0x70;
  34.  
  35. void printloc(void)
  36. {
  37. #ifdef __TURBOC__
  38.     char far *p = MK_FP(0xb800,0);
  39. #endif
  40. #ifdef __GNUC__
  41.     char *p = (char *)(0xe00b8000L);
  42. #endif
  43.     static char hexdigit[] = { "0123456789abcdef" };
  44.     int x = q->evq_xpos;
  45.     int y = q->evq_ypos;
  46.     int i,j;
  47.  
  48.     for(i = 0; i < 2; i++) {
  49.         *p++ = i ? 'Y' : 'X';
  50.         *p++ = ATTR;
  51.         *p++ = '=';
  52.         *p++ = ATTR;
  53.         *p++ = '0';
  54.         *p++ = ATTR;
  55.         *p++ = 'x';
  56.         *p++ = ATTR;
  57.         for(j = 0; j < 4; j++) {
  58.         *p++ = hexdigit[(x >> 12) & 0x0f];
  59.         *p++ = ATTR;
  60.         x <<= 4;
  61.         }
  62.         for(j = 0; j < 4; j++) {
  63.         *p++ = ' ';
  64.         *p++ = ATTR;
  65.         }
  66.         x = y;
  67.     }
  68. }
  69.  
  70. void main(void)
  71. {
  72.     EventRecord e;
  73.     long ii;
  74.  
  75.     q = EventQueueInit(100,320,printloc);
  76.     if(q == NULL) {
  77.         printf("could not init queues\n");
  78.         exit(1);
  79.     }
  80.     q->evq_drawmouse = 1;
  81.     for( ; ; ) {
  82.         if(!EventQueueNextEvent(q,&e)) {
  83.         for(ii = 0L; ii < 1000000L; ii++);
  84.         continue;
  85.         }
  86.         if(e.evt_type == EVENT_MOUSE) {
  87.         printf("MOUSE event: mask 0x%02x, btn 0x%02x, "
  88.                "kbstat 0x%02x xpos %3d, ypos %3d, time %5ld\n",
  89.             e.evt_mask,
  90.             e.evt_button,
  91.             e.evt_kbstat,
  92.             e.evt_xpos,
  93.             e.evt_ypos,
  94.             e.evt_time
  95.         );
  96.         continue;
  97.         }
  98.         if(e.evt_keycode == 0x1b)
  99.         break;
  100.         if(isprint(e.evt_keycode)) {
  101.         printf("KEYBD event: key '%c', kbstat 0x%02x, time %5ld\n",
  102.             e.evt_keycode,
  103.             e.evt_kbstat,
  104.             e.evt_time
  105.         );
  106.         continue;
  107.         }
  108.         printf("KEYBD event: key 0x%03x, kbstat 0x%02x, time %5ld\n",
  109.         e.evt_keycode,
  110.         e.evt_kbstat,
  111.         e.evt_time
  112.         );
  113.     }
  114.     EventQueueDeInit();
  115.     exit(0);
  116. }
  117.  
  118.