| 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_Hcxx . . $ `lib/joystick.h:66:9`! |
| 67 | |
| 68 | #include <cstdint> |
| 69 | |
| 70 | // joystick ids. used to initialize a stick and get its position |
| 71 | #define MAX_JOYSTICKScxx . . $ `lib/joystick.h:71:9`! 8 |
| 72 | #define JOYPOV_NUMcxx . . $ `lib/joystick.h:72:9`! 4 |
| 73 | |
| 74 | // these flags tell what axes these controllers control. |
| 75 | #define JOYFLAG_XVALIDcxx . . $ `lib/joystick.h:75:9`! 1 |
| 76 | #define JOYFLAG_YVALIDcxx . . $ `lib/joystick.h:76:9`! 2 |
| 77 | #define JOYFLAG_ZVALIDcxx . . $ `lib/joystick.h:77:9`! 4 |
| 78 | #define JOYFLAG_RVALIDcxx . . $ `lib/joystick.h:78:9`! 8 |
| 79 | #define JOYFLAG_UVALIDcxx . . $ `lib/joystick.h:79:9`! 16 |
| 80 | #define JOYFLAG_VVALIDcxx . . $ `lib/joystick.h:80:9`! 32 |
| 81 | #define JOYFLAG_POVVALIDcxx . . $ `lib/joystick.h:81:9`! 64 |
| 82 | #define JOYFLAG_POV2VALIDcxx . . $ `lib/joystick.h:82:9`! 128 |
| 83 | #define JOYFLAG_POV3VALIDcxx . . $ `lib/joystick.h:83:9`! 256 |
| 84 | #define JOYFLAG_POV4VALIDcxx . . $ `lib/joystick.h:84:9`! 512 |
| 85 | |
| 86 | // set in joystate.pov |
| 87 | #define JOYPOV_DIRcxx . . $ `lib/joystick.h:87:9`! 8 |
| 88 | #define JOYPOV_MAXVALcxx . . $ `lib/joystick.h:88:9`! 0x100 |
| 89 | #define JOYPOV_UPcxx . . $ `lib/joystick.h:89:9`! 0 |
| 90 | #define JOYPOV_RIGHTcxx . . $ `lib/joystick.h:90:9`! 0x40 |
| 91 | #define JOYPOV_DOWNcxx . . $ `lib/joystick.h:91:9`! 0x80 |
| 92 | #define JOYPOV_LEFTcxx . . $ `lib/joystick.h:92:9`! 0xc0 |
| 93 | #define JOYPOV_CENTERcxx . . $ `lib/joystick.h:93:9`! 0xff |
| 94 | |
| 95 | #define JOYAXIS_RANGEcxx . . $ `lib/joystick.h:95:9`! 256 |
| 96 | |
| 97 | typedef int tJoystickcxx . . $ tJoystick#; |
| 98 | |
| 99 | #define JOYSTICK_1cxx . . $ `lib/joystick.h:99:9`! 0 |
| 100 | #define JOYSTICK_2cxx . . $ `lib/joystick.h:100:9`! 1 |
| 101 | #define JOYSTICK_3cxx . . $ `lib/joystick.h:101:9`! 2 |
| 102 | #define JOYSTICK_4cxx . . $ `lib/joystick.h:102:9`! 3 |
| 103 | #define JOYSTICK_5cxx . . $ `lib/joystick.h:103:9`! 4 |
| 104 | #define JOYSTICK_6cxx . . $ `lib/joystick.h:104:9`! 5 |
| 105 | #define JOYSTICK_7cxx . . $ `lib/joystick.h:105:9`! 6 |
| 106 | #define JOYSTICK_8cxx . . $ `lib/joystick.h:106:9`! 7 |
| 107 | |
| 108 | struct tJoyInfocxx . . $ tJoyInfo# { |
| 109 | char namecxx . . $ tJoyInfo#name.[128]; |
| 110 | unsigned axes_maskcxx . . $ tJoyInfo#axes_mask.; |
| 111 | unsigned num_btnscxx . . $ tJoyInfo#num_btns.; |
| 112 | int minxcxx . . $ tJoyInfo#minx., maxxcxx . . $ tJoyInfo#maxx.; |
| 113 | int minycxx . . $ tJoyInfo#miny., maxycxx . . $ tJoyInfo#maxy.; |
| 114 | int minzcxx . . $ tJoyInfo#minz., maxzcxx . . $ tJoyInfo#maxz.; |
| 115 | int minrcxx . . $ tJoyInfo#minr., maxrcxx . . $ tJoyInfo#maxr.; |
| 116 | int minucxx . . $ tJoyInfo#minu., maxucxx . . $ tJoyInfo#maxu.; |
| 117 | int minvcxx . . $ tJoyInfo#minv., maxvcxx . . $ tJoyInfo#maxv.; |
| 118 | }; |
| 119 | |
| 120 | // shared between joystick remote server and local client. |
| 121 | #define JOY_PORTcxx . . $ `lib/joystick.h:121:9`! 3192 |
| 122 | #define JOY_REQTERMcxx . . $ `lib/joystick.h:122:9`! "RTRM" |
| 123 | #define JOY_TERMcxx . . $ `lib/joystick.h:123:9`! "TERM" |
| 124 | #define JOY_POScxx . . $ `lib/joystick.h:124:9`! "POSI" |
| 125 | #define JOY_INFOcxx . . $ `lib/joystick.h:125:9`! "INFO" |
| 126 | #define JOY_POLLcxx . . $ `lib/joystick.h:126:9`! "POLL" |
| 127 | |
| 128 | struct tJoyPacketcxx . . $ tJoyPacket# { |
| 129 | char codacxx . . $ tJoyPacket#coda.[4]; // used to identify packet |
| 130 | char bufcxx . . $ tJoyPacket#buf.[128]; |
| 131 | }; |
| 132 | |
| 133 | struct tJoyPoscxx . . $ tJoyPos# { |
| 134 | int xcxx . . $ tJoyPos#x.; |
| 135 | int ycxx . . $ tJoyPos#y.; |
| 136 | int zcxx . . $ tJoyPos#z.; |
| 137 | int rcxx . . $ tJoyPos#r.; |
| 138 | int ucxx . . $ tJoyPos#u.; |
| 139 | int vcxx . . $ tJoyPos#v.; |
| 140 | unsigned buttonscxx . . $ tJoyPos#buttons.; |
| 141 | unsigned btncxx . . $ tJoyPos#btn.; |
| 142 | unsigned povcxx . . $ tJoyPos#pov.[JOYPOV_NUMcxx . . $ `lib/joystick.h:72:9`!]; |
| 143 | }; |
| 144 | |
| 145 | // joystick system initialization |
| 146 | bool joy_Initcxx . . $ joy_Init(efaadfb7dc14930a).(bool emulation); |
| 147 | void joy_Closecxx . . $ joy_Close(49f6e7a06ebc5aa8).(); |
| 148 | |
| 149 | // retreive information about joystick. |
| 150 | void joy_GetJoyInfocxx . . $ joy_GetJoyInfo(6d54e3a34f20aef).(tJoystickcxx . . $ tJoystick# joy, tJoyInfocxx . . $ tJoyInfo# *info); |
| 151 | |
| 152 | // retreive position of joystick |
| 153 | void joy_GetPoscxx . . $ joy_GetPos(47f0a1b684eacd68).(tJoystickcxx . . $ tJoystick# joy, tJoyPoscxx . . $ tJoyPos# *pos); |
| 154 | |
| 155 | // retreive uncalibrated position of joystick |
| 156 | void joy_GetRawPoscxx . . $ joy_GetRawPos(47f0a1b684eacd68).(tJoystickcxx . . $ tJoystick# joy, tJoyPoscxx . . $ tJoyPos# *pos); |
| 157 | |
| 158 | // returns true if joystick valid |
| 159 | bool joy_IsValidcxx . . $ joy_IsValid(83c267b20bac841a).(tJoystickcxx . . $ tJoystick# joy); |
| 160 | |
| 161 | // run by ddio_Frame |
| 162 | void ddio_InternalJoyFramecxx . . $ ddio_InternalJoyFrame(49f6e7a06ebc5aa8).(); |
| 163 | |
| 164 | // DAJ Added to support InSprocket |
| 165 | #endif |