diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index d0965892b..348f9e159 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -1,10 +1,11 @@ -set(SRCS input_common.cpp) - if(SDL2_FOUND) set(SDL_SRCS sdl_input/sdl_input.cpp) + add_definitions(-DHAS_SDL) endif() -add_library(input_common STATIC ${SRCS} ${SDL_SRCS}) +set(SRCS input_common.cpp) + +add_library(input_common STATIC ${SDL_SRCS} ${SRCS} ) if(SDL2_FOUND) target_link_libraries(input_common ${SDL2_LIBRARY}) diff --git a/src/input_common/input_common.cpp b/src/input_common/input_common.cpp index afd4291e1..ac0b51c5b 100644 --- a/src/input_common/input_common.cpp +++ b/src/input_common/input_common.cpp @@ -4,7 +4,7 @@ #include "input_common/input_common.h" -#ifdef _SDL_H +#ifdef HAS_SDL #include "input_common/sdl_input/sdl_input.h" #endif @@ -30,7 +30,7 @@ static void InputCallback(u64 userdata, int cycles_late) { g_user_input->Poll(); } - // Reschedule recurrent event + //Reschedule recurrent event CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event); } @@ -38,13 +38,13 @@ std::string ControllerBase::GetDeviceName() const { return device_name; } -const Service::HID::PadState ControllerBase::GetPadState() const { +Service::HID::PadState ControllerBase::GetPadState() const { return controller.pad_state; } void Init(ControllerBackends backend) { switch (backend) { - #ifdef _SDL_H + #ifdef HAS_SDL //SDL2 backend selected case SDL2_JOY: g_user_input = new SDLController(); diff --git a/src/input_common/input_common.h b/src/input_common/input_common.h index 05f5d9617..15e9b99e6 100644 --- a/src/input_common/input_common.h +++ b/src/input_common/input_common.h @@ -36,7 +36,7 @@ public: std::string GetDeviceName() const; /// Returns internal pad state - const Service::HID::PadState GetPadState() const; + Service::HID::PadState GetPadState() const; bool activated; diff --git a/src/input_common/sdl_input/sdl_input.cpp b/src/input_common/sdl_input/sdl_input.cpp index a837bca1d..3668f06cc 100644 --- a/src/input_common/sdl_input/sdl_input.cpp +++ b/src/input_common/sdl_input/sdl_input.cpp @@ -227,7 +227,7 @@ void SDLController::SetDeadZone(int range) { dead_zone = range; } -bool SDLController::CheckDeadZone(int range) { +bool SDLController::CheckDeadZone(int range) const { if ((range < -dead_zone) || (range > dead_zone)) { return true; } else if ((range > -dead_zone) && (range < dead_zone)) { diff --git a/src/input_common/sdl_input/sdl_input.h b/src/input_common/sdl_input/sdl_input.h index 32db3aaa3..3ef8bae43 100644 --- a/src/input_common/sdl_input/sdl_input.h +++ b/src/input_common/sdl_input/sdl_input.h @@ -37,7 +37,7 @@ public: void SetDeadZone(int range); /// Checks if analog input is within the dead zone - bool CheckDeadZone(int range); + bool CheckDeadZone(int range) const; private: SDL_Joystick* jpad;