]> icculus.org git repositories - btb/d2x.git/blob - arch/include/joy.h
Removed duplicate files
[btb/d2x.git] / arch / include / joy.h
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-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 /*
15  * $Source: /cvs/cvsroot/d2x/arch/include/joy.h,v $
16  * $Revision: 1.2 $
17  * $Author: bradleyb $
18  * $Date: 2001-01-29 13:36:14 $
19  *
20  * Header for joystick functions
21  *
22  * $Log: not supported by cvs2svn $
23  * Revision 1.1  2001/01/28 16:10:57  bradleyb
24  * unified input headers.
25  *
26  */
27
28 #ifndef _JOY_H
29 #define _JOY_H
30
31 #include "pstypes.h"
32 #include "fix.h"
33
34 #define JOY_1_BUTTON_A  1
35 #define JOY_1_BUTTON_B  2
36 #define JOY_2_BUTTON_A  4
37 #define JOY_2_BUTTON_B  8
38 #define JOY_ALL_BUTTONS (1+2+4+8)
39
40 #define JOY_1_X_AXIS            1
41 #define JOY_1_Y_AXIS            2
42 #define JOY_1_Z_AXIS            4
43 #define JOY_1_R_AXIS            16
44 #define JOY_1_U_AXIS            32
45 #define JOY_1_V_AXIS            64
46
47 #if defined WINDOWS
48 #define JOY_NUM_AXES            7
49 #elif defined __ENV_LINUX__
50 #define JOY_NUM_AXES            5
51 #else
52 #define JOY_NUM_AXES            4
53 #endif
54
55 #ifdef  _WIN32
56 #define JOY_1_POV                       8
57 #define JOY_ALL_AXIS            (1+2+4+8)
58 #define JOY_EXT_AXIS            (16+32+64)
59 #else
60 #define JOY_2_X_AXIS            4
61 #define JOY_2_Y_AXIS            8
62 #define JOY_ALL_AXIS            (1+2+4+8)
63 #endif
64
65 #define JOY_SLOW_READINGS       1
66 #define JOY_POLLED_READINGS     2
67 #define JOY_BIOS_READINGS       4
68 /* not present in d2src, maybe we don't really need it? */
69 #define JOY_FRIENDLY_READINGS   8
70
71 #ifdef __ENV_LINUX__
72 #define MAX_BUTTONS 64
73 #else
74 #define MAX_BUTTONS 20
75 #endif
76
77 //==========================================================================
78 // This initializes the joy and does a "quick" calibration which
79 // assumes the stick is centered and sets the minimum value to 0 and
80 // the maximum value to 2 times the centered reading. Returns 0 if no
81 // joystick was detected, 1 if everything is ok.
82 // joy_init() is called.
83
84 #if defined (__NT__)
85 extern int joy_init(int joy, int spjoy);
86 extern int joy95_init_stick(int joy, int spjoy);
87 #else
88 extern int joy_init();
89 #endif
90 extern void joy_close();
91
92 extern char joy_installed;
93 extern char joy_present;
94
95 //==========================================================================
96 // The following 3 routines can be used to zero in on better joy
97 // calibration factors. To use them, ask the user to hold the stick
98 // in either the upper left, lower right, or center and then have them
99 // press a key or button and then call the appropriate one of these
100 // routines, and it will read the stick and update the calibration factors.
101 // Usually, assuming that the stick was centered when joy_init was
102 // called, you really only need to call joy_set_lr, since the upper
103 // left position is usually always 0,0 on most joys.  But, the safest
104 // bet is to do all three, or let the user choose which ones to set.
105
106 extern void joy_set_ul();
107 extern void joy_set_lr();
108 extern void joy_set_cen();
109
110
111 //==========================================================================
112 // This reads the joystick. X and Y will be between -128 and 127.
113 // Takes about 1 millisecond in the worst case when the stick
114 // is in the lower right hand corner. Always returns 0,0 if no stick
115 // is present.
116
117 extern void joy_get_pos( int *x, int *y );
118
119 //==========================================================================
120 // This just reads the buttons and returns their status.  When bit 0
121 // is 1, button 1 is pressed, when bit 1 is 1, button 2 is pressed.
122 extern int joy_get_btns();
123
124 //==========================================================================
125 // This returns the number of times a button went either down or up since
126 // the last call to this function.
127 extern int joy_get_button_up_cnt( int btn );
128 extern int joy_get_button_down_cnt( int btn );
129
130 //==========================================================================
131 // This returns how long (in approximate milliseconds) that each of the
132 // buttons has been held down since the last call to this function.
133 // It is the total time... say you pressed it down for 3 ticks, released
134 // it, and held it down for 6 more ticks. The time returned would be 9.
135 extern fix joy_get_button_down_time( int btn );
136
137 extern ubyte joy_read_raw_buttons();
138 extern ubyte joystick_read_raw_axis( ubyte mask, int * axis );
139 extern void joy_flush();
140 extern ubyte joy_get_present_mask();
141 extern void joy_set_timer_rate(int max_value );
142 extern int joy_get_timer_rate();
143
144 extern int joy_get_button_state( int btn );
145 extern void joy_set_cen_fake(int channel);
146 extern ubyte joy_read_stick( ubyte masks, int *axis );
147 extern void joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max);
148 extern void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max);
149 extern void joy_set_btn_values( int btn, int state, fix timedown, int downcount, int upcount );
150 extern int joy_get_scaled_reading( int raw, int axn );
151 extern void joy_set_slow_reading( int flag );
152
153 #ifdef _WIN32
154 extern int joy95_init_stick(int joy, int spjoy);
155 #endif
156
157
158 #endif