basic joystick support
This commit is contained in:
parent
553fa56442
commit
7c43155a90
3 changed files with 100 additions and 24 deletions
|
@ -856,6 +856,7 @@ void ReadPlayerGameInput(STRATEGYBLOCK* sbPtr)
|
||||||
|
|
||||||
switch (AvP.PlayerType)
|
switch (AvP.PlayerType)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case I_Marine:
|
case I_Marine:
|
||||||
{
|
{
|
||||||
primaryInput = &MarineInputPrimaryConfig;
|
primaryInput = &MarineInputPrimaryConfig;
|
||||||
|
@ -1351,10 +1352,7 @@ void ReadPlayerGameInput(STRATEGYBLOCK* sbPtr)
|
||||||
/* KJL 18:27:34 04/29/97 - joystick control */
|
/* KJL 18:27:34 04/29/97 - joystick control */
|
||||||
if (GotJoystick)
|
if (GotJoystick)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ReadPlayerGameInput: GotJoystick\n");
|
|
||||||
#if 0
|
|
||||||
#define JOYSTICK_DEAD_ZONE 12000
|
#define JOYSTICK_DEAD_ZONE 12000
|
||||||
extern int GotJoystick;
|
|
||||||
extern JOYINFOEX JoystickData;
|
extern JOYINFOEX JoystickData;
|
||||||
extern JOYCAPS JoystickCaps;
|
extern JOYCAPS JoystickCaps;
|
||||||
|
|
||||||
|
@ -1580,7 +1578,7 @@ void ReadPlayerGameInput(STRATEGYBLOCK* sbPtr)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 1
|
#if 0
|
||||||
textprint("%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",
|
textprint("%d\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n",
|
||||||
JoystickData.dwXpos,
|
JoystickData.dwXpos,
|
||||||
JoystickData.dwYpos,
|
JoystickData.dwYpos,
|
||||||
|
@ -1591,7 +1589,6 @@ void ReadPlayerGameInput(STRATEGYBLOCK* sbPtr)
|
||||||
JoystickData.dwButtons,
|
JoystickData.dwButtons,
|
||||||
JoystickData.dwPOV);
|
JoystickData.dwPOV);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* KJL 16:03:06 05/11/97 - Handle map options */
|
/* KJL 16:03:06 05/11/97 - Handle map options */
|
||||||
|
|
17
src/fixer.h
17
src/fixer.h
|
@ -205,6 +205,23 @@ typedef struct DPMSG_DESTROYPLAYERORGROUP
|
||||||
} DPMSG_DESTROYPLAYERORGROUP;
|
} DPMSG_DESTROYPLAYERORGROUP;
|
||||||
typedef DPMSG_DESTROYPLAYERORGROUP * LPDPMSG_DESTROYPLAYERORGROUP;
|
typedef DPMSG_DESTROYPLAYERORGROUP * LPDPMSG_DESTROYPLAYERORGROUP;
|
||||||
|
|
||||||
|
#define JOYCAPS_HASR 1
|
||||||
|
|
||||||
|
typedef struct JOYINFOEX
|
||||||
|
{
|
||||||
|
int dwXpos;
|
||||||
|
int dwYpos;
|
||||||
|
int dwRpos;
|
||||||
|
int dwUpos;
|
||||||
|
int dwVpos;
|
||||||
|
int dwPOV;
|
||||||
|
} JOYINFOEX;
|
||||||
|
|
||||||
|
typedef struct JOYCAPS
|
||||||
|
{
|
||||||
|
int wCaps;
|
||||||
|
} JOYCAPS;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
98
src/main.c
98
src/main.c
|
@ -58,15 +58,16 @@ extern unsigned char GotAnyKey;
|
||||||
extern int NormalFrameTime;
|
extern int NormalFrameTime;
|
||||||
|
|
||||||
SDL_Surface *surface;
|
SDL_Surface *surface;
|
||||||
/* SDL_Joystick *joy; */
|
|
||||||
|
SDL_Joystick *joy;
|
||||||
|
JOYINFOEX JoystickData;
|
||||||
|
JOYCAPS JoystickCaps;
|
||||||
|
|
||||||
/* defaults */
|
/* defaults */
|
||||||
static int WantFullscreen = 1;
|
static int WantFullscreen = 1;
|
||||||
int WantSound = 1;
|
int WantSound = 1;
|
||||||
static int WantCDRom = 1;
|
static int WantCDRom = 1;
|
||||||
#if 0
|
|
||||||
static int WantJoystick = 1;
|
static int WantJoystick = 1;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0 /* NVIDIA gl.h breaks this */
|
#if 0 /* NVIDIA gl.h breaks this */
|
||||||
#if GL_EXT_secondary_color
|
#if GL_EXT_secondary_color
|
||||||
|
@ -104,6 +105,67 @@ void DirectReadMouse()
|
||||||
|
|
||||||
void ReadJoysticks()
|
void ReadJoysticks()
|
||||||
{
|
{
|
||||||
|
int axes, balls, hats;
|
||||||
|
Uint8 hat;
|
||||||
|
|
||||||
|
JoystickData.dwXpos = 0;
|
||||||
|
JoystickData.dwYpos = 0;
|
||||||
|
JoystickData.dwRpos = 0;
|
||||||
|
JoystickData.dwUpos = 0;
|
||||||
|
JoystickData.dwVpos = 0;
|
||||||
|
JoystickData.dwPOV = -1;
|
||||||
|
|
||||||
|
if (joy == NULL || !GotJoystick) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_JoystickUpdate();
|
||||||
|
|
||||||
|
axes = SDL_JoystickNumAxes(joy);
|
||||||
|
balls = SDL_JoystickNumBalls(joy);
|
||||||
|
hats = SDL_JoystickNumHats(joy);
|
||||||
|
|
||||||
|
if (axes > 0) {
|
||||||
|
JoystickData.dwXpos = SDL_JoystickGetAxis(joy, 0) + 32768;
|
||||||
|
}
|
||||||
|
if (axes > 1) {
|
||||||
|
JoystickData.dwYpos = SDL_JoystickGetAxis(joy, 1) + 32768;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hats > 0) {
|
||||||
|
hat = SDL_JoystickGetHat(joy, 0);
|
||||||
|
|
||||||
|
switch (hat) {
|
||||||
|
default:
|
||||||
|
case SDL_HAT_CENTERED:
|
||||||
|
JoystickData.dwPOV = -1;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_UP:
|
||||||
|
JoystickData.dwPOV = 0;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_RIGHT:
|
||||||
|
JoystickData.dwPOV = 9000;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_DOWN:
|
||||||
|
JoystickData.dwPOV = 18000;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_LEFT:
|
||||||
|
JoystickData.dwPOV = 27000;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_RIGHTUP:
|
||||||
|
JoystickData.dwPOV = 4500;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_RIGHTDOWN:
|
||||||
|
JoystickData.dwPOV = 13500;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_LEFTUP:
|
||||||
|
JoystickData.dwPOV = 31500;
|
||||||
|
break;
|
||||||
|
case SDL_HAT_LEFTDOWN:
|
||||||
|
JoystickData.dwPOV = 22500;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ** */
|
/* ** */
|
||||||
|
@ -352,18 +414,27 @@ int InitSDL()
|
||||||
|
|
||||||
LoadDeviceAndVideoModePreferences();
|
LoadDeviceAndVideoModePreferences();
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (WantJoystick) {
|
if (WantJoystick) {
|
||||||
SDL_Init(SDL_INIT_JOYSTICK);
|
SDL_Init(SDL_INIT_JOYSTICK);
|
||||||
|
|
||||||
if (SDL_NumJoysticks() > 0) {
|
if (SDL_NumJoysticks() > 0) {
|
||||||
|
/* TODO: make joystick number a configuration parameter */
|
||||||
|
|
||||||
joy = SDL_JoystickOpen(0);
|
joy = SDL_JoystickOpen(0);
|
||||||
if (joy) {
|
if (joy) {
|
||||||
GotJoystick = 1;
|
GotJoystick = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JoystickCaps.wCaps = 0; /* no rudder... ? */
|
||||||
|
|
||||||
|
JoystickData.dwXpos = 0;
|
||||||
|
JoystickData.dwYpos = 0;
|
||||||
|
JoystickData.dwRpos = 0;
|
||||||
|
JoystickData.dwUpos = 0;
|
||||||
|
JoystickData.dwVpos = 0;
|
||||||
|
JoystickData.dwPOV = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
surface = NULL;
|
surface = NULL;
|
||||||
|
|
||||||
|
@ -544,11 +615,10 @@ int InitialiseWindowsSystem(HANDLE hInstance, int nCmdShow, int WinInitMode)
|
||||||
|
|
||||||
int ExitWindowsSystem()
|
int ExitWindowsSystem()
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
if (joy) {
|
if (joy) {
|
||||||
SDL_JoystickClose(joy);
|
SDL_JoystickClose(joy);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
/* SDL_Quit(); */
|
/* SDL_Quit(); */
|
||||||
if (surface)
|
if (surface)
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
|
@ -944,12 +1014,6 @@ void CheckForWindowsMessages()
|
||||||
MouseVelY = 0;
|
MouseVelY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
This is half of the necessary joystick code, the rest of the changes
|
|
||||||
involve avp/win95/usr_io.c. I don't own a joystick so I have no idea
|
|
||||||
how things should be implemented.
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
if (GotJoystick) {
|
if (GotJoystick) {
|
||||||
int numbuttons;
|
int numbuttons;
|
||||||
|
|
||||||
|
@ -970,7 +1034,7 @@ how things should be implemented.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if ((KeyboardInput[KEY_LEFTALT]||KeyboardInput[KEY_RIGHTALT]) && DebouncedKeyboardInput[KEY_CR]) {
|
if ((KeyboardInput[KEY_LEFTALT]||KeyboardInput[KEY_RIGHTALT]) && DebouncedKeyboardInput[KEY_CR]) {
|
||||||
SDL_GrabMode gm;
|
SDL_GrabMode gm;
|
||||||
|
|
||||||
|
@ -1069,7 +1133,7 @@ static struct option getopt_long_options[] = {
|
||||||
{ "windowed", 0, NULL, 'w' },
|
{ "windowed", 0, NULL, 'w' },
|
||||||
{ "nosound", 0, NULL, 's' },
|
{ "nosound", 0, NULL, 's' },
|
||||||
{ "nocdrom", 0, NULL, 'c' },
|
{ "nocdrom", 0, NULL, 'c' },
|
||||||
/* { "nojoy", 0, NULL, 'j' }, */
|
{ "nojoy", 0, NULL, 'j' },
|
||||||
{ "debug", 0, NULL, 'd' },
|
{ "debug", 0, NULL, 'd' },
|
||||||
/*
|
/*
|
||||||
{ "loadrifs", 1, NULL, 'l' },
|
{ "loadrifs", 1, NULL, 'l' },
|
||||||
|
@ -1088,7 +1152,7 @@ static const char *usage_string =
|
||||||
" [-w | --windowed] Run the game in a window\n"
|
" [-w | --windowed] Run the game in a window\n"
|
||||||
" [-s | --nosound] Do not access the soundcard\n"
|
" [-s | --nosound] Do not access the soundcard\n"
|
||||||
" [-c | --nocdrom] Do not access the CD-ROM\n"
|
" [-c | --nocdrom] Do not access the CD-ROM\n"
|
||||||
/* " [-j | --nojoy] Do not access the joystick\n" */
|
" [-j | --nojoy] Do not access the joystick\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
@ -1116,11 +1180,9 @@ int main(int argc, char *argv[])
|
||||||
case 'c':
|
case 'c':
|
||||||
WantCDRom = 0;
|
WantCDRom = 0;
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case 'j':
|
case 'j':
|
||||||
WantJoystick = 0;
|
WantJoystick = 0;
|
||||||
break;
|
break;
|
||||||
*/
|
|
||||||
case 'd': {
|
case 'd': {
|
||||||
extern int DebuggingCommandsActive;
|
extern int DebuggingCommandsActive;
|
||||||
DebuggingCommandsActive = 1;
|
DebuggingCommandsActive = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue