JOY.H 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/bios/rcs/joy.h $
  15. * $Revision: 1.17 $
  16. * $Author: john $
  17. * $Date: 1995/10/07 13:22:30 $
  18. *
  19. * Headers for joystick functions
  20. *
  21. * $Log: joy.h $
  22. * Revision 1.17 1995/10/07 13:22:30 john
  23. * Added new method of reading joystick that allows higher-priority
  24. * interrupts to go off.
  25. *
  26. * Revision 1.16 1995/02/14 11:17:13 john
  27. * Added BIOS readings for stick.
  28. *
  29. * Revision 1.15 1995/02/14 10:09:58 john
  30. * Added OS2 switch.
  31. *
  32. * Revision 1.14 1994/12/28 13:49:20 john
  33. * Added function to set joystick for slow reading
  34. *
  35. * Revision 1.13 1994/10/13 11:36:06 john
  36. * Made joy_down_time be kept track of in fixed seconds,
  37. * not ticks.
  38. *
  39. * Revision 1.12 1994/10/12 17:03:16 john
  40. * Added prototype for joy_get_scaled_reading.
  41. *
  42. * Revision 1.11 1994/10/12 16:57:55 john
  43. * Added function to set a joystick button's state.
  44. *
  45. * Revision 1.10 1994/09/22 16:09:00 john
  46. * Fixed some virtual memory lockdown problems with timer and
  47. * joystick.
  48. *
  49. * Revision 1.9 1994/08/31 09:54:57 john
  50. * *** empty log message ***
  51. *
  52. * Revision 1.8 1994/08/29 21:02:24 john
  53. * Added joy_set_cal_values...
  54. *
  55. * Revision 1.7 1994/08/29 20:51:52 john
  56. * Added better cyberman support; also, joystick calibration
  57. * value return funcctiionn,
  58. *
  59. * Revision 1.6 1994/07/01 10:55:44 john
  60. * Fixed some bugs... added support for 4 axis.
  61. *
  62. * Revision 1.5 1994/06/30 20:36:51 john
  63. * Revamped joystick code.
  64. *
  65. * Revision 1.4 1994/04/22 12:52:10 john
  66. * *** empty log message ***
  67. *
  68. * Revision 1.3 1994/01/18 13:53:39 john
  69. * Made all joystick functions return int's instead of
  70. * shorts. Also made the stick reading be CPU speed
  71. * independant by using the timer_get_Stamp_64
  72. * function.
  73. *
  74. * Revision 1.2 1994/01/18 10:58:42 john
  75. * *** empty log message ***
  76. *
  77. * Revision 1.1 1993/07/10 13:10:39 matt
  78. * Initial revision
  79. *
  80. *
  81. */
  82. #ifndef _JOY_H
  83. #define _JOY_H
  84. #include "types.h"
  85. #include "fix.h"
  86. #define JOY_1_BUTTON_A 1
  87. #define JOY_1_BUTTON_B 2
  88. #define JOY_2_BUTTON_A 4
  89. #define JOY_2_BUTTON_B 8
  90. #define JOY_ALL_BUTTONS (1+2+4+8)
  91. #define JOY_1_X_AXIS 1
  92. #define JOY_1_Y_AXIS 2
  93. #define JOY_2_X_AXIS 4
  94. #define JOY_2_Y_AXIS 8
  95. #define JOY_ALL_AXIS (1+2+4+8)
  96. #define JOY_SLOW_READINGS 1
  97. #define JOY_POLLED_READINGS 2
  98. #define JOY_BIOS_READINGS 4
  99. #define JOY_FRIENDLY_READINGS 8
  100. //==========================================================================
  101. // This initializes the joy and does a "quick" calibration which
  102. // assumes the stick is centered and sets the minimum value to 0 and
  103. // the maximum value to 2 times the centered reading. Returns 0 if no
  104. // joystick was detected, 1 if everything is ok.
  105. // joy_init() is called.
  106. extern int joy_init();
  107. extern void joy_close();
  108. extern char joy_installed;
  109. extern char joy_present;
  110. //==========================================================================
  111. // The following 3 routines can be used to zero in on better joy
  112. // calibration factors. To use them, ask the user to hold the stick
  113. // in either the upper left, lower right, or center and then have them
  114. // press a key or button and then call the appropriate one of these
  115. // routines, and it will read the stick and update the calibration factors.
  116. // Usually, assuming that the stick was centered when joy_init was
  117. // called, you really only need to call joy_set_lr, since the upper
  118. // left position is usually always 0,0 on most joys. But, the safest
  119. // bet is to do all three, or let the user choose which ones to set.
  120. extern void joy_set_ul();
  121. extern void joy_set_lr();
  122. extern void joy_set_cen();
  123. //==========================================================================
  124. // This reads the joystick. X and Y will be between -128 and 127.
  125. // Takes about 1 millisecond in the worst case when the stick
  126. // is in the lower right hand corner. Always returns 0,0 if no stick
  127. // is present.
  128. extern void joy_get_pos( int *x, int *y );
  129. //==========================================================================
  130. // This just reads the buttons and returns their status. When bit 0
  131. // is 1, button 1 is pressed, when bit 1 is 1, button 2 is pressed.
  132. extern int joy_get_btns();
  133. //==========================================================================
  134. // This returns the number of times a button went either down or up since
  135. // the last call to this function.
  136. extern int joy_get_button_up_cnt( int btn );
  137. extern int joy_get_button_down_cnt( int btn );
  138. //==========================================================================
  139. // This returns how long (in approximate milliseconds) that each of the
  140. // buttons has been held down since the last call to this function.
  141. // It is the total time... say you pressed it down for 3 ticks, released
  142. // it, and held it down for 6 more ticks. The time returned would be 9.
  143. extern fix joy_get_button_down_time( int btn );
  144. extern ubyte joy_read_raw_buttons();
  145. extern ubyte joystick_read_raw_axis( ubyte mask, int * axis );
  146. extern void joy_flush();
  147. extern ubyte joy_get_present_mask();
  148. extern void joy_set_timer_rate(int max_value );
  149. extern int joy_get_timer_rate();
  150. extern int joy_get_button_state( int btn );
  151. extern void joy_set_cen_fake(int channel);
  152. extern ubyte joy_read_stick( ubyte masks, int *axis );
  153. extern void joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max);
  154. extern void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max);
  155. extern void joy_set_btn_values( int btn, int state, fix timedown, int downcount, int upcount );
  156. extern int joy_get_scaled_reading( int raw, int axn );
  157. extern void joy_set_slow_reading( int flag );
  158. #endif
  159.