]> icculus.org git repositories - btb/d2x.git/blob - arch/include/joy.h
disable texture format verification for OS X - Textures work fine
[btb/d2x.git] / arch / include / joy.h
1 /* $ Id: $ */
2 /*
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
13 */
14
15 /*
16  *
17  * Header for joystick functions
18  *
19  *
20  */
21
22 #ifndef _JOY_H
23 #define _JOY_H
24
25 #include "pstypes.h"
26 #include "fix.h"
27
28 #define JOY_1_BUTTON_A  1
29 #define JOY_1_BUTTON_B  2
30 #define JOY_2_BUTTON_A  4
31 #define JOY_2_BUTTON_B  8
32 #define JOY_ALL_BUTTONS (1+2+4+8)
33
34 #define JOY_1_X_AXIS            1
35 #define JOY_1_Y_AXIS            2
36 #define JOY_1_Z_AXIS            4
37 #define JOY_1_R_AXIS            16
38 #define JOY_1_U_AXIS            32
39 #define JOY_1_V_AXIS            64
40
41 #if defined WINDOWS
42 #define JOY_NUM_AXES            7
43 #elif defined __unix__
44 #define JOY_NUM_AXES            5
45 #else
46 #define JOY_NUM_AXES            4
47 #endif
48
49 #if defined(_WIN32) && !defined(__MINGW32__)
50 #define JOY_1_POV                       8
51 #define JOY_ALL_AXIS            (1+2+4+8)
52 #define JOY_EXT_AXIS            (16+32+64)
53 #else
54 #define JOY_2_X_AXIS            4
55 #define JOY_2_Y_AXIS            8
56 #define JOY_ALL_AXIS            (1+2+4+8)
57 #endif
58
59 #define JOY_SLOW_READINGS       1
60 #define JOY_POLLED_READINGS     2
61 #define JOY_BIOS_READINGS       4
62 /* not present in d2src, maybe we don't really need it? */
63 #define JOY_FRIENDLY_READINGS   8
64
65 #ifdef __unix__
66 #define MAX_BUTTONS 64
67 #else
68 #define MAX_BUTTONS 20
69 #endif
70
71 //==========================================================================
72 // This initializes the joy and does a "quick" calibration which
73 // assumes the stick is centered and sets the minimum value to 0 and
74 // the maximum value to 2 times the centered reading. Returns 0 if no
75 // joystick was detected, 1 if everything is ok.
76 // joy_init() is called.
77
78 #if defined (__NT__)
79 extern int joy_init(int joy, int spjoy);
80 extern int joy95_init_stick(int joy, int spjoy);
81 #else
82 extern int joy_init();
83 #endif
84 extern void joy_close();
85
86 extern char joy_installed;
87 extern char joy_present;
88
89 //==========================================================================
90 // The following 3 routines can be used to zero in on better joy
91 // calibration factors. To use them, ask the user to hold the stick
92 // in either the upper left, lower right, or center and then have them
93 // press a key or button and then call the appropriate one of these
94 // routines, and it will read the stick and update the calibration factors.
95 // Usually, assuming that the stick was centered when joy_init was
96 // called, you really only need to call joy_set_lr, since the upper
97 // left position is usually always 0,0 on most joys.  But, the safest
98 // bet is to do all three, or let the user choose which ones to set.
99
100 extern void joy_set_ul();
101 extern void joy_set_lr();
102 extern void joy_set_cen();
103
104
105 //==========================================================================
106 // This reads the joystick. X and Y will be between -128 and 127.
107 // Takes about 1 millisecond in the worst case when the stick
108 // is in the lower right hand corner. Always returns 0,0 if no stick
109 // is present.
110
111 extern void joy_get_pos( int *x, int *y );
112
113 //==========================================================================
114 // This just reads the buttons and returns their status.  When bit 0
115 // is 1, button 1 is pressed, when bit 1 is 1, button 2 is pressed.
116 extern int joy_get_btns();
117
118 //==========================================================================
119 // This returns the number of times a button went either down or up since
120 // the last call to this function.
121 extern int joy_get_button_up_cnt( int btn );
122 extern int joy_get_button_down_cnt( int btn );
123
124 //==========================================================================
125 // This returns how long (in approximate milliseconds) that each of the
126 // buttons has been held down since the last call to this function.
127 // It is the total time... say you pressed it down for 3 ticks, released
128 // it, and held it down for 6 more ticks. The time returned would be 9.
129 extern fix joy_get_button_down_time( int btn );
130
131 extern ubyte joy_read_raw_buttons();
132 extern ubyte joystick_read_raw_axis( ubyte mask, int * axis );
133 extern void joy_flush();
134 extern ubyte joy_get_present_mask();
135 extern void joy_set_timer_rate(int max_value );
136 extern int joy_get_timer_rate();
137
138 extern int joy_get_button_state( int btn );
139 extern void joy_set_cen_fake(int channel);
140 extern ubyte joy_read_stick( ubyte masks, int *axis );
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 );
146
147 #if defined(_WIN32) && !defined(__MINGW32__)
148 extern int joy95_init_stick(int joy, int spjoy);
149 #endif
150
151
152 #endif