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.
20 #define JOY_1_BUTTON_A 1
21 #define JOY_1_BUTTON_B 2
22 #define JOY_2_BUTTON_A 4
23 #define JOY_2_BUTTON_B 8
24 #define JOY_ALL_BUTTONS (1+2+4+8)
26 #define JOY_1_X_AXIS 1
27 #define JOY_1_Y_AXIS 2
28 #define JOY_2_X_AXIS 4
29 #define JOY_2_Y_AXIS 8
30 #define JOY_ALL_AXIS (1+2+4+8)
32 #define JOY_SLOW_READINGS 1
33 #define JOY_POLLED_READINGS 2
34 #define JOY_BIOS_READINGS 4
35 #define JOY_FRIENDLY_READINGS 8
38 #define MAX_BUTTONS 64
40 #define JOY_NUM_AXES 5
42 typedef struct joystick_device {
50 typedef struct joystick_axis {
58 typedef struct joystick_button {
61 //changed 6/24/1999 to finally squish the timedown bug - Owen Evans
69 //==========================================================================
70 // This initializes the joy and does a "quick" calibration which
71 // assumes the stick is centered and sets the minimum value to 0 and
72 // the maximum value to 2 times the centered reading. Returns 0 if no
73 // joystick was detected, 1 if everything is ok.
74 // joy_init() is called.
76 extern int joy_init();
77 extern void joy_close();
79 extern char joy_installed;
80 extern char joy_present;
82 extern int j_num_axes;
83 extern int j_num_buttons;
85 extern int joy_deadzone;
87 extern joystick_device j_joystick[4];
88 extern joystick_axis j_axis[MAX_AXES];
89 extern joystick_button j_button[MAX_BUTTONS];
91 //==========================================================================
92 // The following 3 routines can be used to zero in on better joy
93 // calibration factors. To use them, ask the user to hold the stick
94 // in either the upper left, lower right, or center and then have them
95 // press a key or button and then call the appropriate one of these
96 // routines, and it will read the stick and update the calibration factors.
97 // Usually, assuming that the stick was centered when joy_init was
98 // called, you really only need to call joy_set_lr, since the upper
99 // left position is usually always 0,0 on most joys. But, the safest
100 // bet is to do all three, or let the user choose which ones to set.
102 extern void joy_set_cen();
104 //==========================================================================
105 // This reads the joystick. X and Y will be between -128 and 127.
106 // Takes about 1 millisecond in the worst case when the stick
107 // is in the lower right hand corner. Always returns 0,0 if no stick
110 extern void joy_get_pos( int *x, int *y );
112 //==========================================================================
113 // This just reads the buttons and returns their status. When bit 0
114 // is 1, button 1 is pressed, when bit 1 is 1, button 2 is pressed.
115 extern int joy_get_btns();
117 //==========================================================================
118 // This returns the number of times a button went either down or up since
119 // the last call to this function.
120 extern int joy_get_button_up_cnt( int btn );
121 extern int joy_get_button_down_cnt( int btn );
123 //==========================================================================
124 // This returns how long (in approximate milliseconds) that each of the
125 // buttons has been held down since the last call to this function.
126 // It is the total time... say you pressed it down for 3 ticks, released
127 // it, and held it down for 6 more ticks. The time returned would be 9.
128 extern fix joy_get_button_down_time( int btn );
130 extern int j_Update_state ();
131 extern int j_Get_joydev_axis_number (int all_axis_number);
132 extern int j_Get_joydev_button_number (int all_button_number);
134 extern ubyte joystick_read_raw_axis( ubyte mask, int * axis );
135 extern void joy_flush();
136 extern ubyte joy_get_present_mask();
137 extern void joy_set_timer_rate(int max_value );
138 extern int joy_get_timer_rate();
140 extern int joy_get_button_state( int btn );
141 extern void joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max);
142 extern void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max);
143 extern void joy_set_btn_values( int btn, int state, fix timedown, int downcount, int upcount );
144 extern int joy_get_scaled_reading( int raw, int axn );
145 extern void joy_set_slow_reading( int flag );
147 extern void joy_set_min (int axis_number, int value);
148 extern void joy_set_center (int axis_number, int value);
149 extern void joy_set_max (int axis_number, int value);