home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / 3dstudio / ipas / mouser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-11  |  2.4 KB  |  141 lines

  1.  
  2. /* IPAS 3 Mouse usage demo by Tom Hudson 5/11/94 */
  3.  
  4. /* Displays mouse coordinates and button status until ALT key is pressed */
  5.  
  6. #include <stdio.h>
  7. #include <math.h>
  8. #include <stdlib.h>
  9. #include "pxp.h"
  10.  
  11. /* Variable definitions */
  12.  
  13. /************************/
  14.  
  15. /* Dialog description */
  16.  
  17. DlgEntry cdialog[]={
  18.     0,NULL
  19.     };
  20.  
  21. /* Version test value */
  22.  
  23. #define VERSION 0x0000
  24.     
  25. typedef struct {
  26.     ulong version;
  27.     } State;
  28.  
  29. /* the "state" struct MUST start with a "ulong" which is the version#,
  30.     to prevent using data from old versions of this program.
  31.     This verification is performed automatically. */
  32.  
  33. static State init_state = { VERSION };
  34. static State state = { VERSION };
  35.  
  36. /*----------------------------------------------------------------*/
  37.  
  38. int ClientUsesInitDialog(void) {
  39.     return(0);
  40.     }
  41.  
  42. void ClientSetStateVar(int id, void *ptr) {
  43.     OVL o;
  44.     ulong *ul;
  45.     char *s;
  46.  
  47.     ul=(ulong *)ptr;
  48.     s=(char *)ptr;
  49.     o.ul = *ul;
  50.     switch(id) {
  51.         }
  52.     }
  53.  
  54. ulong ClientGetStateVar(int id) {
  55.     OVL o;
  56.     switch(id) {
  57.         }
  58.     return(o.ul);
  59.     }
  60.  
  61. int ClientVarSize(int id)
  62.     {
  63.     switch(id)
  64.         {
  65.         default:
  66.             return(1);
  67.         }
  68.     }
  69.  
  70. char  *ClientGetState(int *size) {
  71.     *size = sizeof(State);
  72.     return((char *)&state);
  73.     }
  74.  
  75. void ClientResetState() {    
  76.     state = init_state;    
  77.     }
  78.  
  79. void ClientStartup(EXPbuf *buf) {
  80.     do_mouse_test();
  81.     buf->opcode=buf->usercode=EXP_TERMINATE;
  82.     }
  83.  
  84. /* User routines -- use user codes to process your data */
  85.  
  86. void ClientUserCode(EXPbuf *buf)
  87.     {
  88.     switch(buf->usercode)
  89.         {
  90.         default:
  91.             terminate:
  92.             buf->opcode=buf->usercode=EXP_TERMINATE;
  93.             buf->status=0;
  94.             break;
  95.         }
  96.     }
  97.  
  98. void ClientTerminate(void) { 
  99.     /* free any data structures, etc. */
  100.     }
  101.  
  102. DlgEntry *ClientDialog(int n) {    
  103.     return(&cdialog[n]); 
  104.     }
  105.  
  106. /* Format your floating-point strings */
  107.  
  108. void
  109. ClientFormatString(int id,float value,char *string)
  110. {
  111. switch(id)
  112.  {
  113.  }
  114. }
  115.  
  116. /* This function should return 1 if the PXP can function in any module,    */
  117. /* otherwise, it should return 0.                                        */
  118.  
  119. int
  120. ClientIsUniversal(void)
  121. {
  122. return(1);
  123. }
  124.  
  125. do_mouse_test()
  126. {
  127. while(1)
  128.     {
  129.     int state;
  130.     gfx_wait_input();
  131.     sprintf(gp_buffer,"[%04d %04d %c %c] Press ALT to exit",
  132.         GC->mouse_x,GC->mouse_y,
  133.         (GC->mouse_button & 1)?'L':' ',(GC->mouse_button & 2)?'R':' ');
  134.     gfx_2text(gp_buffer,0,0,WHITE,BLACK);
  135.     gfx_kstate(state);
  136.     if(state & 8)
  137.         break;
  138.     }
  139. gfx_redraw();
  140. }
  141.