home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0636.ZIP / CCE_0636 / GEMLIB / GMLIBS30.ZOO / aesevnt.c < prev    next >
C/C++ Source or Header  |  1993-07-13  |  6KB  |  254 lines

  1. /*
  2.  *    Aes event library interface
  3.  *
  4.  *        evnt_keybd    Wait for a keyboard event
  5.  *        evnt_button    Wait for a mouse button
  6.  *        evnt_mouse    Wait for a mouse to enter/leave a rectangle
  7.  *        evnt_mesag    Wait for a message from another application
  8.  *        evnt_timer    Wait for a specified amount of time
  9.  *        evnt_multi    Wait for one of many possible events
  10.  *        evnt_dclick    Set or get the present double click speed
  11.  *        
  12.  *        ++jrb    bammi@cadence.com
  13.  *        modified: mj -- ntomczak@vm.ucs.ualberta.ca
  14.  */
  15. #include "common.h"
  16.  
  17. #ifdef __DEF_ALL__
  18.  
  19. #define L_evnt_key
  20. #define L_evnt_but
  21. #define L_evnt_mou
  22. #define L_evnt_mes
  23. #define L_evnt_tim
  24. #define L_evnt_mul
  25. #define L_evnt_dcl
  26.  
  27. #endif /* __DEF_ALL__ */
  28.  
  29.  
  30. #ifdef L_evnt_key
  31.  
  32. /* Wait for a keyboard event
  33.  *    returns    kdb code of the key hit
  34.  */
  35. int evnt_keybd(void)
  36. {
  37.     return __aes__(AES_CONTROL_ENCODE(20, 0, 1, 0));
  38. }
  39. #endif /* L_evnt_key */
  40.  
  41.  
  42. #ifdef L_evnt_but
  43.  
  44. /* wait for a mouse button state
  45.  *    Clicks        The number of times to wait for a button to enter state
  46.  *    WhichButton    Which of the mouse buttonss (1 for left 2 for right)
  47.  *    WhichState    Which state are we waiting for (0 = down  1 = up)
  48.  *    Mx, My        X,Y coordinate of mouse when event occured
  49.  *    ButtonState    The button state when event occured
  50.  *    KeyState    State of Shift, Ctrl and Alt keys when event occured
  51.  *
  52.  *    returns        The number of times the button actually entered
  53.  *            the desired state.
  54.  */
  55. int evnt_button(int Clicks, 
  56.         int WhichButton,
  57.         int WhichState,
  58.         int *Mx, int *My,
  59.         int *ButtonState, int *KeyState)
  60. {
  61.     int retval;
  62.     
  63.     _int_in[0] = Clicks;
  64.     _int_in[1] = WhichButton;
  65.     _int_in[2] = WhichState;
  66.     
  67.     retval = __aes__(AES_CONTROL_ENCODE(21, 3, 5, 0));
  68.     *Mx = _int_out[1];
  69.     *My = _int_out[2];
  70.     *ButtonState = _int_out[3];
  71.     *KeyState    = _int_out[4];
  72.     return retval;
  73. }
  74. #endif /* L_evnt_but */
  75.  
  76.  
  77. #ifdef L_evnt_mou
  78.  
  79. /* wait for mouse event
  80.  *    EnterExit    =0 return on entry    =1 return on exit
  81.  *    InX,InY,InW,InH The rectangle to monitor entry/exit out of
  82.  *    OutX,OutY     X,Y coordinate of mouse when event occured
  83.  *    ButtonState   State of mouse buttons when event occured (1=l  2=r but)
  84.  *    KeyState      State of Shift, Ctrl and Alt keys when event occured
  85.  *
  86.  *    always returns a reserved val.
  87.  */
  88. int evnt_mouse(int EnterExit, int InX, int InY, int InW, int InH,
  89.            int *OutX, int *OutY, 
  90.            int *ButtonState, 
  91.            int *KeyState)
  92. {
  93.     int retval;
  94.     
  95.     _int_in[0] = EnterExit;
  96.     _int_in[1] = InX;
  97.     _int_in[2] = InY;
  98.     _int_in[3] = InW;
  99.     _int_in[4] = InH;
  100.     retval = __aes__(AES_CONTROL_ENCODE(22, 5, 5, 0));
  101.     *OutX = _int_out[1];
  102.     *OutY = _int_out[2];
  103.     *ButtonState = _int_out[3];
  104.     *KeyState    = _int_out[4];
  105.     return retval;
  106. }
  107. #endif /* L_evnt_mou */
  108.  
  109.  
  110. #ifdef L_evnt_mes
  111.  
  112. /* Wait for a 16 byte message from pipe
  113.  *    returns a reserved value
  114.  */
  115. int evnt_mesag(int MesagBuf[])
  116. {
  117. #ifndef __MSHORT__
  118. #ifdef __GNUC__
  119.     volatile
  120. #endif
  121.     short dummy[8];
  122.     register int i;
  123.     register int   retval;
  124.  
  125.     _addrin[0] = (void *)&dummy[0];    /* Address of 16 byte message buffer */
  126.     retval = __aes__(AES_CONTROL_ENCODE(23, 0, 1, 1));
  127.     if(MesagBuf != (int *)0)
  128.     for(i = 0; i < 8; i++)
  129.         MesagBuf[i] = dummy[i];
  130.     return retval;
  131. #else
  132.     _addrin[0] = MesagBuf;    /* Address of 16 byte message buffer */
  133.     return __aes__(AES_CONTROL_ENCODE(23, 0, 1, 1));
  134. #endif    
  135. }
  136. #endif /* L_evnt_mes */
  137.  
  138.  
  139. #ifdef L_evnt_tim
  140.  
  141. /* sleep for Interval
  142.  *    returns a reserved value
  143.  */
  144. int evnt_timer(unsigned long Interval)
  145. {
  146.     unsigned short *i = (unsigned short *)&Interval;
  147.     
  148.     _int_in[0] = i[1];
  149.     _int_in[1] = i[0];
  150.     return __aes__(AES_CONTROL_ENCODE(24, 2, 1, 0));
  151. }
  152. #endif /* L_evnt_tim */
  153.  
  154. #ifdef L_evnt_mul
  155.  
  156. #ifdef __GNUC__
  157. asm(".stabs \"___evnt_multi\",5,0,0,_evnt_multi"); /* dept of clean tricks */
  158. #else
  159.     /* foo */
  160. #endif
  161.  
  162. /* wait for one of many events
  163.  *    Type    The types of Events to wait for
  164.  *        rest of the parameters analogus to ones defined above.
  165.  *
  166.  *    returns    The event that ended the wait
  167.  *
  168.  */
  169. int evnt_multi(int Type,
  170.            int Clicks,        /* Inputs */
  171.            int WhichButton,
  172.            int WhichState,
  173.            int EnterExit1, int In1X, int In1Y, int In1W, int In1H,
  174.            int EnterExit2, int In2X, int In2Y, int In2W, int In2H,
  175.            int MesagBuf[],
  176.            unsigned long Interval,
  177.            int *OutX, int *OutY,     /* Outputs */
  178.            int *ButtonState,
  179.            int *KeyState,
  180.            int *Key, 
  181.            int *ReturnCount)
  182. {
  183.     unsigned short *i = (unsigned short *)&Interval;
  184.     int retval;
  185. #ifndef __MSHORT__
  186.     register int j;
  187. #ifdef __GNUC__
  188.     volatile
  189. #endif
  190.     short dummy[8];
  191. #endif    
  192.     
  193.     _int_in[0] = Type;
  194.     _int_in[1] = Clicks;
  195.     _int_in[2] = WhichButton;
  196.     _int_in[3] = WhichState;
  197.     
  198.     _int_in[4] = EnterExit1;
  199.     _int_in[5] = In1X;
  200.     _int_in[6] = In1Y;
  201.     _int_in[7] = In1W;
  202.     _int_in[8] = In1H;
  203.     
  204.     _int_in[9] = EnterExit2;
  205.     _int_in[10] = In2X;
  206.     _int_in[11] = In2Y;
  207.     _int_in[12] = In2W;
  208.     _int_in[13] = In2H;
  209.     
  210.     _int_in[14] = i[1];
  211.     _int_in[15] = i[0];
  212.     
  213. #ifdef __MSHORT__
  214.     _addrin[0] = MesagBuf;
  215. #else
  216.     _addrin[0] = (void *)&dummy[0];
  217. #endif
  218.  
  219.     retval = __aes__(AES_CONTROL_ENCODE(25, 16, 7, 1));
  220.     
  221.     *OutX = _int_out[1];
  222.     *OutY = _int_out[2];
  223.     *ButtonState = _int_out[3];
  224.     *KeyState    = _int_out[4];
  225.     *Key     = _int_out[5];
  226.     *ReturnCount = _int_out[6];
  227.  
  228. #ifndef __MSHORT__
  229.     if(MesagBuf != (int *)0)
  230.         for(j = 0; j < 8; j++)
  231.         MesagBuf[j] = dummy[j];
  232. #endif
  233.  
  234.     return retval;
  235. }
  236. #endif /* L_evnt_mul */
  237.  
  238. #ifdef L_evnt_dcl
  239.  
  240. /*  Set/get double click speed
  241.  *    returns current setting
  242.  */
  243. int evnt_dclick(int ToSet,    /*  Speed to set at [0,4] */
  244.         int SetGet)    /*  1= set  0=get         */
  245. {
  246.     _int_in[0] = ToSet;
  247.     _int_in[1] = SetGet;
  248.     return __aes__(AES_CONTROL_ENCODE(26, 2, 1, 0));
  249. }
  250. #endif /* L_evnt_dcl */
  251.  
  252.  
  253. /* - eof - */    
  254.