]> icculus.org git repositories - taylor/freespace2.git/blob - include/joy.h
Initial revision
[taylor/freespace2.git] / include / joy.h
1 /*
2  * $Logfile: /Freespace2/code/Io/Joy.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Include file for joystick stuff
8  *
9  * $Log$
10  * Revision 1.1  2002/05/03 03:28:12  root
11  * Initial revision
12  *
13  * 
14  * 2     10/07/98 10:53a Dave
15  * Initial checkin.
16  * 
17  * 1     10/07/98 10:49a Dave
18  * 
19  * 20    5/13/98 1:17a Hoffoss
20  * Added joystick axes configurability.
21  * 
22  * 19    5/05/98 8:38p Hoffoss
23  * Added sensitivity adjustment to options menu and made it save to pilot
24  * file.
25  * 
26  * 18    5/04/98 11:08p Hoffoss
27  * Expanded on Force Feedback code, and moved it all into Joy_ff.cpp.
28  * Updated references everywhere to it.
29  * 
30  * 17    4/29/98 12:13a Lawrance
31  * Add function for reading down count without resetting internal count.
32  * Add hook to reset demo trailer timer.
33  * 
34  * 16    3/21/98 11:29a John
35  * Made joy_flush work when a button is held down
36  * 
37  * 15    3/06/98 10:02a Hoffoss
38  * Made dead zone adjustable, and defaulted it to 10% instead of 5%.
39  * 
40  * 14    1/29/98 11:04a Sandeep
41  * 
42  * 13    1/27/98 8:40p Sandeep
43  * 
44  * 12    1/08/98 6:35p Hoffoss
45  * Fixed joystick undefined detection.
46  * 
47  * 11    9/15/97 11:42p Lawrance
48  * change button_info to joy_button_info to avoid name conflict
49  * 
50  * 10    8/07/97 11:26p Lawrance
51  * add support for 4th axis (rudder)
52  * 
53  * 9     7/29/97 5:30p Lawrance
54  * move gettime() from keyboard module to timer module
55  * 
56  * 8     7/10/97 12:29a Lawrance
57  * fix problem with NT not recognizing an axis that was set under 95
58  * 
59  * 7     7/09/97 11:41p Lawrance
60  * added throttle and hat support
61  * 
62  * 6     2/17/97 5:18p John
63  * Added a bunch of RCS headers to a bunch of old files that don't have
64  * them.
65  *
66  * $NoKeywords: $
67  */
68
69 #ifndef __JOY_H__
70 #define __JOY_H__
71
72 #define JOY_NUM_BUTTONS         32
73 #define JOY_NUM_HAT_POS         4
74 #define JOY_TOTAL_BUTTONS       (JOY_NUM_BUTTONS + JOY_NUM_HAT_POS)
75 #define JOY_NUM_AXES                    6
76
77 #define JOY_HATBACK                     (JOY_NUM_BUTTONS)
78 #define JOY_HATFORWARD          (JOY_NUM_BUTTONS+1)
79 #define JOY_HATLEFT                     (JOY_NUM_BUTTONS+2)
80 #define JOY_HATRIGHT                    (JOY_NUM_BUTTONS+3)
81
82 #define JOY_AXIS_UNDEFINED              -10000
83
84 typedef struct Joy_info {
85         int     axis_valid[JOY_NUM_AXES];
86         int     axis_min[JOY_NUM_AXES];
87         int     axis_center[JOY_NUM_AXES];
88         int     axis_max[JOY_NUM_AXES];
89 } Joy_info;
90
91 extern int Joy_sensitivity;
92 extern int Dead_zone_size;  // percentage of range that is dead zone
93
94 int     joy_init();
95 void    joy_flush();
96 int     joy_get_pos(int * x, int * y, int *z, int *r);
97 int     joy_down_count(int btn, int reset_count = 1);
98 int     joy_down(int btn);
99 int     joy_up_count(int btn);
100 float   joy_down_time(int btn);
101 void    joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max);
102 void    joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max);
103 void    joy_set_ul();
104 void    joy_set_lr();
105 void    joy_set_cen(); 
106 void    joy_cheap_cal();
107 int     joystick_read_raw_axis( int num_axes, int * axis );
108 void joy_get_delta(int *dx, int *dy);
109 int joy_get_scaled_reading(int raw, int axn);
110 int joy_get_unscaled_reading(int raw, int axn);
111
112 #endif  /* __JOY_H__ */
113