]> icculus.org git repositories - taylor/freespace2.git/blob - include/joy.h
fix issue with looping audio streams
[taylor/freespace2.git] / include / joy.h
1 /*
2  * Copyright (C) Volition, Inc. 1999.  All rights reserved.
3  *
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
6  * the source.
7  */
8
9 /*
10  * $Logfile: /Freespace2/code/Io/Joy.h $
11  * $Revision$
12  * $Date$
13  * $Author$
14  *
15  * Include file for joystick stuff
16  *
17  * $Log$
18  * Revision 1.2  2002/06/09 04:41:13  relnev
19  * added copyright header
20  *
21  * Revision 1.1.1.1  2002/05/03 03:28:12  root
22  * Initial import.
23  *
24  * 
25  * 2     10/07/98 10:53a Dave
26  * Initial checkin.
27  * 
28  * 1     10/07/98 10:49a Dave
29  * 
30  * 20    5/13/98 1:17a Hoffoss
31  * Added joystick axes configurability.
32  * 
33  * 19    5/05/98 8:38p Hoffoss
34  * Added sensitivity adjustment to options menu and made it save to pilot
35  * file.
36  * 
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.
40  * 
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.
44  * 
45  * 16    3/21/98 11:29a John
46  * Made joy_flush work when a button is held down
47  * 
48  * 15    3/06/98 10:02a Hoffoss
49  * Made dead zone adjustable, and defaulted it to 10% instead of 5%.
50  * 
51  * 14    1/29/98 11:04a Sandeep
52  * 
53  * 13    1/27/98 8:40p Sandeep
54  * 
55  * 12    1/08/98 6:35p Hoffoss
56  * Fixed joystick undefined detection.
57  * 
58  * 11    9/15/97 11:42p Lawrance
59  * change button_info to joy_button_info to avoid name conflict
60  * 
61  * 10    8/07/97 11:26p Lawrance
62  * add support for 4th axis (rudder)
63  * 
64  * 9     7/29/97 5:30p Lawrance
65  * move gettime() from keyboard module to timer module
66  * 
67  * 8     7/10/97 12:29a Lawrance
68  * fix problem with NT not recognizing an axis that was set under 95
69  * 
70  * 7     7/09/97 11:41p Lawrance
71  * added throttle and hat support
72  * 
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
75  * them.
76  *
77  * $NoKeywords: $
78  */
79
80 #ifndef __JOY_H__
81 #define __JOY_H__
82
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
87
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)
92
93 #define JOY_AXIS_UNDEFINED              -10000
94
95 typedef struct Joy_info {
96         int num_axes;
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];
101 } Joy_info;
102
103 extern int Joy_sensitivity;
104 extern int Dead_zone_size;  // percentage of range that is dead zone
105
106 int     joy_init();
107 void joy_close();
108 void joy_reinit(int with_index = -1);
109 void    joy_flush();
110 int     joy_get_pos(int * x, int * y, int *z, int *r);
111 int     joy_down_count(int btn, int reset_count = 1);
112 int     joy_down(int btn);
113 int     joy_up_count(int btn);
114 float   joy_down_time(int btn);
115 void    joy_get_cal_vals(int *axis_min, int *axis_center, int *axis_max);
116 void    joy_set_cal_vals(int *axis_min, int *axis_center, int *axis_max);
117 void    joy_set_ul();
118 void    joy_set_lr();
119 void    joy_set_cen(); 
120 void    joy_cheap_cal();
121 int     joystick_read_raw_axis( int num_axes, int * axis );
122 void joy_get_delta(int *dx, int *dy);
123 int joy_get_scaled_reading(int axn);
124 int joy_get_unscaled_reading(int axn);
125 bool joy_axis_valid(int axis);
126 void joy_mark_button(int btn, int state);
127 int joystick_get_id();
128 void joystick_update_axis(int axis, int value);
129
130 #endif  /* __JOY_H__ */
131