2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Io/Joy.h $
15 * Include file for joystick stuff
18 * Revision 1.2 2002/06/09 04:41:13 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 2 10/07/98 10:53a Dave
28 * 1 10/07/98 10:49a Dave
30 * 20 5/13/98 1:17a Hoffoss
31 * Added joystick axes configurability.
33 * 19 5/05/98 8:38p Hoffoss
34 * Added sensitivity adjustment to options menu and made it save to pilot
37 * 18 5/04/98 11:08p Hoffoss
38 * Expanded on Force Feedback code, and moved it all into Joy_ff.cpp.
39 * Updated references everywhere to it.
41 * 17 4/29/98 12:13a Lawrance
42 * Add function for reading down count without resetting internal count.
43 * Add hook to reset demo trailer timer.
45 * 16 3/21/98 11:29a John
46 * Made joy_flush work when a button is held down
48 * 15 3/06/98 10:02a Hoffoss
49 * Made dead zone adjustable, and defaulted it to 10% instead of 5%.
51 * 14 1/29/98 11:04a Sandeep
53 * 13 1/27/98 8:40p Sandeep
55 * 12 1/08/98 6:35p Hoffoss
56 * Fixed joystick undefined detection.
58 * 11 9/15/97 11:42p Lawrance
59 * change button_info to joy_button_info to avoid name conflict
61 * 10 8/07/97 11:26p Lawrance
62 * add support for 4th axis (rudder)
64 * 9 7/29/97 5:30p Lawrance
65 * move gettime() from keyboard module to timer module
67 * 8 7/10/97 12:29a Lawrance
68 * fix problem with NT not recognizing an axis that was set under 95
70 * 7 7/09/97 11:41p Lawrance
71 * added throttle and hat support
73 * 6 2/17/97 5:18p John
74 * Added a bunch of RCS headers to a bunch of old files that don't have
83 #define JOY_NUM_BUTTONS 32
84 #define JOY_NUM_HAT_POS 4
85 #define JOY_TOTAL_BUTTONS (JOY_NUM_BUTTONS + JOY_NUM_HAT_POS)
86 #define JOY_NUM_AXES 6
88 #define JOY_HATBACK (JOY_NUM_BUTTONS)
89 #define JOY_HATFORWARD (JOY_NUM_BUTTONS+1)
90 #define JOY_HATLEFT (JOY_NUM_BUTTONS+2)
91 #define JOY_HATRIGHT (JOY_NUM_BUTTONS+3)
93 #define JOY_AXIS_UNDEFINED -10000
95 typedef struct Joy_info {
97 int axis_min[JOY_NUM_AXES];
98 int axis_center[JOY_NUM_AXES];
99 int axis_max[JOY_NUM_AXES];
100 int axis_current[JOY_NUM_AXES];
103 extern int Joy_sensitivity;
104 extern int Dead_zone_size; // percentage of range that is dead zone
109 int joy_get_pos(int * x, int * y, int *z, int *r);
110 int joy_down_count(int btn, int reset_count = 1);
111 int joy_down(int btn);
112 int joy_up_count(int btn);
113 float joy_down_time(int btn);
114 void joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max);
115 void joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max);
119 void joy_cheap_cal();
120 int joystick_read_raw_axis( int num_axes, int * axis );
121 void joy_get_delta(int *dx, int *dy);
122 int joy_get_scaled_reading(int axn);
123 int joy_get_unscaled_reading(int axn);
124 bool joy_axis_valid(int axis);
125 void joy_mark_button(int btn, int state);
126 int joystick_get_id();
127 void joystick_update_axis(int axis, int value);
129 #endif /* __JOY_H__ */