diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85f04333a..f9291a5af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/sdl/i_input.cpp b/src/sdl/i_input.cpp index 0fe02cfd2..6e862e0a3 100644 --- a/src/sdl/i_input.cpp +++ b/src/sdl/i_input.cpp @@ -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 &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; -} diff --git a/src/sdl/i_main.cpp b/src/sdl/i_main.cpp index 4305a07ca..dc1dbfa05 100644 --- a/src/sdl/i_main.cpp +++ b/src/sdl/i_main.cpp @@ -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); diff --git a/src/sdl/st_start.cpp b/src/sdl/st_start.cpp index 81e50d23e..33a5abe0b 100644 --- a/src/sdl/st_start.cpp +++ b/src/sdl/st_start.cpp @@ -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); }