1 /*****************************************************************************/ 2 /* */ 3 /* COPYRIGHT Copyright (C) 1995 IBM Corporation */ 4 /* */ 5 /* The following IBM OS/2 source code is provided to you solely for */ 6 /* the purpose of assisting you in your development of OS/2 device */ 7 /* drivers. You may use this code in accordance with the IBM License */ 8 /* Agreement provided in the IBM Device Driver Source Kit for OS/2. This */ 9 /* Copyright statement may not be removed. */ 10 /* */ 11 /*****************************************************************************/ 12 #ifndef JOYOS2_H 13 #define JOYOS2_H 14 15 /****** GAMEPORT.SYS joystick definitions, start *****************************/ 16 #define GAME_VERSION 0x20 /* 2.0 First IBM version */ 17 #define GAMEPDDNAME "GAME$ " 18 #define IOCTL_CAT_USER 0x80 19 #define GAME_PORT_GET 0x20 /* read GAMEPORT.SYS values */ 20 #define GAME_PORT_RESET 0x60 /* reset joystick mask with given value */ 21 22 #pragma pack(1) /* pack structure size is 1 byte */ 23 typedef struct { /* GAMEPORT.SYS structure */ 24 USHORT usJs_AxCnt; /* Joystick_A X position */ 25 USHORT usJs_AyCnt; /* Joystick_A Y position */ 26 USHORT usJs_BxCnt; /* Joystick_B X position */ 27 USHORT usJs_ByCnt; /* Joystick_B Y position */ 28 USHORT usJs_ButtonA1Cnt; /* button A1 press count */ 29 USHORT usJs_ButtonA2Cnt; /* button A2 press count */ 30 USHORT usJs_ButtonB1Cnt; /* button B1 press count */ 31 USHORT usJs_ButtonB2Cnt; /* button B2 press count */ 32 UCHAR ucJs_JoyStickMask; /* mask of connected joystick pots */ 33 UCHAR ucJs_ButtonStatus; /* bits of switches down */ 34 ULONG ulJs_Ticks; /* joystick clock ticks */ 35 } GAME_PORT_STRUCT; 36 #pragma pack() /*reset to normal pack size */ 37 /****** GAMEPORT.SYS joystick definitions, end *******************************/ 38 39 40 /****************************************************************************/ 41 #define GAME_GET_VERSION 0x01 42 #define GAME_GET_PARMS 0x02 43 #define GAME_SET_PARMS 0x03 44 #define GAME_GET_CALIB 0x04 45 #define GAME_SET_CALIB 0x05 46 #define GAME_GET_DIGSET 0x06 47 #define GAME_SET_DIGSET 0x07 48 #define GAME_GET_STATUS 0x10 49 #define GAME_GET_STATUS_BUTWAIT 0x11 50 #define GAME_GET_STATUS_SAMPWAIT 0x12 51 /****************************************************************************/ 52 53 /****************************************************************************/ 54 // bit masks for each axis 55 #define JOY_AX_BIT 0x01 56 #define JOY_AY_BIT 0x02 57 #define JOY_A_BITS (JOY_AX_BIT|JOY_AY_BIT) 58 #define JOY_BX_BIT 0x04 59 #define JOY_BY_BIT 0x08 60 #define JOY_B_BITS (JOY_BX_BIT|JOY_BY_BIT) 61 #define JOY_ALLPOS_BITS (JOY_A_BITS|JOY_B_BITS) 62 63 // bit masks for each button 64 #define JOY_BUT1_BIT 0x10 65 #define JOY_BUT2_BIT 0x20 66 #define JOY_BUT3_BIT 0x40 67 #define JOY_BUT4_BIT 0x80 68 #define JOY_ALL_BUTS (JOY_BUT1_BIT|JOY_BUT2_BIT|JOY_BUT3_BIT|JOY_BUT4_BIT) 69 /****************************************************************************/ 70 71 /****************************************************************************/ 72 // 1-D position struct used for each axis 73 typedef SHORT GAME_POS; /* some data formats require signed values */ 74 75 // simple 2-D position for each joystick 76 typedef struct 77 { 78 GAME_POS x; 79 GAME_POS y; 80 } 81 GAME_2DPOS_STRUCT; 82 83 // struct defining the instantaneous state of both sticks and all buttons 84 typedef struct 85 { 86 GAME_2DPOS_STRUCT A; 87 GAME_2DPOS_STRUCT B; 88 USHORT butMask; 89 } 90 GAME_DATA_STRUCT; 91 92 // struct to be used for calibration and digital response on each axis 93 typedef struct 94 { 95 GAME_POS lower; 96 GAME_POS centre; 97 GAME_POS upper; 98 } 99 GAME_3POS_STRUCT; 100 /****************************************************************************/ 101 102 /****************************************************************************/ 103 // status struct returned to OS/2 applications: 104 // current data for all sticks as well as button counts since last read 105 typedef struct 106 { 107 GAME_DATA_STRUCT curdata; 108 USHORT b1cnt; 109 USHORT b2cnt; 110 USHORT b3cnt; 111 USHORT b4cnt; 112 } 113 GAME_STATUS_STRUCT; 114 /****************************************************************************/ 115 116 /****************************************************************************/ 117 /* in use bitmasks originating in 0.2b */ 118 #define GAME_USE_BOTH_OLDMASK 0x01 /* for backward compat with bool */ 119 #define GAME_USE_X_NEWMASK 0x02 120 #define GAME_USE_Y_NEWMASK 0x04 121 #define GAME_USE_X_EITHERMASK (GAME_USE_X_NEWMASK|GAME_USE_BOTH_OLDMASK) 122 #define GAME_USE_Y_EITHERMASK (GAME_USE_Y_NEWMASK|GAME_USE_BOTH_OLDMASK) 123 #define GAME_USE_BOTH_NEWMASK (GAME_USE_X_NEWMASK|GAME_USE_Y_NEWMASK) 124 125 /* only timed sampling implemented in version 1.0 */ 126 #define GAME_MODE_TIMED 1 /* timed sampling */ 127 #define GAME_MODE_REQUEST 2 /* request driven sampling */ 128 129 /* only raw implemented in version 1.0 */ 130 #define GAME_DATA_FORMAT_RAW 1 /* [l,c,r] */ 131 #define GAME_DATA_FORMAT_SIGNED 2 /* [-l,0,+r] */ 132 #define GAME_DATA_FORMAT_BINARY 3 /* {-1,0,+1} */ 133 #define GAME_DATA_FORMAT_SCALED 4 /* [-10,+10] */ 134 135 // parameters defining the operation of the driver 136 typedef struct 137 { 138 USHORT useA; /* new bitmasks: see above */ 139 USHORT useB; 140 USHORT mode; /* see consts above */ 141 USHORT format; /* see consts above */ 142 USHORT sampDiv; /* samp freq = 32 / n */ 143 USHORT scale; /* scaling factor */ 144 USHORT res1; /* must be 0 */ 145 USHORT res2; /* must be 0 */ 146 } 147 GAME_PARM_STRUCT; 148 /****************************************************************************/ 149 150 /****************************************************************************/ 151 // calibration values for each axis: 152 // - upper limit on value to be considered in lower range 153 // - centre value 154 // - lower limit on value to be considered in upper range 155 typedef struct 156 { 157 GAME_3POS_STRUCT Ax; 158 GAME_3POS_STRUCT Ay; 159 GAME_3POS_STRUCT Bx; 160 GAME_3POS_STRUCT By; 161 } 162 GAME_CALIB_STRUCT; 163 /****************************************************************************/ 164 165 /****************************************************************************/ 166 // struct defining the digital response values for all axes 167 typedef struct 168 { 169 GAME_3POS_STRUCT Ax; 170 GAME_3POS_STRUCT Ay; 171 GAME_3POS_STRUCT Bx; 172 GAME_3POS_STRUCT By; 173 } 174 GAME_DIGSET_STRUCT; 175 /****************************************************************************/ 176 177 #endif 178