Debian Codegraph @

lib/joystick.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/Lib/joystick.h $
21 * $Revision: 11 $
22 * $Date: 10/21/99 9:27p $
23 * $Author: Jeff $
24 *
25 * Joystick interface.
26 *
27 * $Log: /DescentIII/Main/Lib/joystick.h $
28 *
29 * 11 10/21/99 9:27p Jeff
30 * B.A. Macintosh code merge
31 *
32 * 10 7/28/99 3:19p Kevin
33 * Mac Stuff
34 *
35 * 9 7/26/99 11:59a Samir
36 * add code to get name of joystick
37 *
38 * 8 7/16/99 11:14a Samir
39 * multiple hat support and improved direct input support.
40 *
41 * 7 4/09/99 12:02p Samir
42 * joystick changes (Win32 DirectInput support)
43 *
44 * 6 6/18/98 4:49p Samir
45 * modified for better mouse support?
46 *
47 * 5 6/02/98 4:37p Samir
48 * multiple joysticks supported.
49 *
50 * 4 6/01/98 4:27p Samir
51 * pov may return multiple positions.
52 *
53 * 3 12/05/97 12:49p Samir
54 * New POV constants.
55 *
56 * 2 12/03/97 7:33p Samir
57 * Newer joystick library.
58 *
59 * 1 11/24/97 3:27p Samir
60 * Initial revision
61 *
62 * $NoKeywords: $
63 */
64
65 #ifndef JOYSTICK_H
66 #define JOYSTICK_H
67
68 #include <cstdint>
69
70 // joystick ids. used to initialize a stick and get its position
71 #define MAX_JOYSTICKS 8
72 #define JOYPOV_NUM 4
73
74 // these flags tell what axes these controllers control.
75 #define JOYFLAG_XVALID 1
76 #define JOYFLAG_YVALID 2
77 #define JOYFLAG_ZVALID 4
78 #define JOYFLAG_RVALID 8
79 #define JOYFLAG_UVALID 16
80 #define JOYFLAG_VVALID 32
81 #define JOYFLAG_POVVALID 64
82 #define JOYFLAG_POV2VALID 128
83 #define JOYFLAG_POV3VALID 256
84 #define JOYFLAG_POV4VALID 512
85
86 // set in joystate.pov
87 #define JOYPOV_DIR 8
88 #define JOYPOV_MAXVAL 0x100
89 #define JOYPOV_UP 0
90 #define JOYPOV_RIGHT 0x40
91 #define JOYPOV_DOWN 0x80
92 #define JOYPOV_LEFT 0xc0
93 #define JOYPOV_CENTER 0xff
94
95 #define JOYAXIS_RANGE 256
96
97 typedef int tJoystick;
98
99 #define JOYSTICK_1 0
100 #define JOYSTICK_2 1
101 #define JOYSTICK_3 2
102 #define JOYSTICK_4 3
103 #define JOYSTICK_5 4
104 #define JOYSTICK_6 5
105 #define JOYSTICK_7 6
106 #define JOYSTICK_8 7
107
108 struct tJoyInfo {
109 char name[128];
110 unsigned axes_mask;
111 unsigned num_btns;
112 int minx, maxx;
113 int miny, maxy;
114 int minz, maxz;
115 int minr, maxr;
116 int minu, maxu;
117 int minv, maxv;
118 };
119
120 // shared between joystick remote server and local client.
121 #define JOY_PORT 3192
122 #define JOY_REQTERM "RTRM"
123 #define JOY_TERM "TERM"
124 #define JOY_POS "POSI"
125 #define JOY_INFO "INFO"
126 #define JOY_POLL "POLL"
127
128 struct tJoyPacket {
129 char coda[4]; // used to identify packet
130 char buf[128];
131 };
132
133 struct tJoyPos {
134 int x;
135 int y;
136 int z;
137 int r;
138 int u;
139 int v;
140 unsigned buttons;
141 unsigned btn;
142 unsigned pov[JOYPOV_NUM];
143 };
144
145 // joystick system initialization
146 bool joy_Init(bool emulation);
147 void joy_Close();
148
149 // retreive information about joystick.
150 void joy_GetJoyInfo(tJoystick joy, tJoyInfo *info);
151
152 // retreive position of joystick
153 void joy_GetPos(tJoystick joy, tJoyPos *pos);
154
155 // retreive uncalibrated position of joystick
156 void joy_GetRawPos(tJoystick joy, tJoyPos *pos);
157
158 // returns true if joystick valid
159 bool joy_IsValid(tJoystick joy);
160
161 // run by ddio_Frame
162 void ddio_InternalJoyFrame();
163
164 // DAJ Added to support InSprocket
165 #endif