- Added SDL joystick support.

SVN r2939 (trunk)
This commit is contained in:
Braden Obrzut 2010-10-13 16:29:37 +00:00
parent 55585a36eb
commit 0d10718e67
4 changed files with 22 additions and 20 deletions

View file

@ -538,6 +538,7 @@ else( WIN32 )
sdl/hardware.cpp
sdl/i_cd.cpp
sdl/i_input.cpp
sdl/i_joystick.cpp
sdl/i_main.cpp
sdl/i_movie.cpp
sdl/i_system.cpp

View file

@ -17,7 +17,6 @@
#include "dikeys.h"
#include "templates.h"
#include "s_sound.h"
#include "m_joy.h"
static void I_CheckGUICapture ();
static void I_CheckNativeMouse ();
@ -437,6 +436,18 @@ void MessagePump (const SDL_Event &sev)
D_PostEvent (&event);
}
}
break;
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
if (!GUICapture)
{
event.type = sev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp;
event.data1 = KEY_FIRSTJOYBUTTON + sev.jbutton.button;
if(event.data1 != 0)
D_PostEvent(&event);
}
break;
}
}
@ -468,21 +479,3 @@ void I_StartFrame ()
InitKeySymMap ();
}
}
void I_GetJoysticks(TArray<IJoystickConfig *> &sticks)
{
sticks.Clear();
}
void I_GetAxes(float axes[NUM_JOYAXIS])
{
for (int i = 0; i < NUM_JOYAXIS; ++i)
{
axes[i] = 0;
}
}
IJoystickConfig *I_UpdateDeviceList()
{
return NULL;
}

View file

@ -245,6 +245,9 @@ static void unprotect_rtext()
}
#endif
void I_StartupJoysticks();
void I_ShutdownJoysticks();
int main (int argc, char **argv)
{
printf(GAMENAME" v%s - SVN revision %s - SDL version\nCompiled on %s\n\n",
@ -268,7 +271,7 @@ int main (int argc, char **argv)
setlocale (LC_ALL, "C");
if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE) == -1)
if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1)
{
fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError());
return -1;
@ -316,11 +319,13 @@ int main (int argc, char **argv)
progdir = "./";
}
I_StartupJoysticks();
C_InitConsole (80*8, 25*8, false);
D_DoomMain ();
}
catch (class CDoomError &error)
{
I_ShutdownJoysticks();
if (error.GetMessage ())
fprintf (stderr, "%s\n", error.GetMessage ());
exit (-1);

View file

@ -71,6 +71,8 @@ class FTTYStartupScreen : public FStartupScreen
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
void I_ShutdownJoysticks();
// PRIVATE FUNCTION PROTOTYPES ---------------------------------------------
static void DeleteStartupScreen();
@ -347,5 +349,6 @@ bool FTTYStartupScreen::NetLoop(bool (*timer_callback)(void *), void *userdata)
void ST_Endoom()
{
I_ShutdownJoysticks();
exit(0);
}