Use CMake to set a preprocessor marco, rearrage CMakeLists.txt
Review Changes 6 Review Changes 7
This commit is contained in:
parent
f87056289a
commit
9ae6bf08a4
5 changed files with 11 additions and 10 deletions
|
@ -1,10 +1,11 @@
|
||||||
set(SRCS input_common.cpp)
|
|
||||||
|
|
||||||
if(SDL2_FOUND)
|
if(SDL2_FOUND)
|
||||||
set(SDL_SRCS sdl_input/sdl_input.cpp)
|
set(SDL_SRCS sdl_input/sdl_input.cpp)
|
||||||
|
add_definitions(-DHAS_SDL)
|
||||||
endif()
|
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)
|
if(SDL2_FOUND)
|
||||||
target_link_libraries(input_common ${SDL2_LIBRARY})
|
target_link_libraries(input_common ${SDL2_LIBRARY})
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#include "input_common/input_common.h"
|
#include "input_common/input_common.h"
|
||||||
|
|
||||||
#ifdef _SDL_H
|
#ifdef HAS_SDL
|
||||||
#include "input_common/sdl_input/sdl_input.h"
|
#include "input_common/sdl_input/sdl_input.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ static void InputCallback(u64 userdata, int cycles_late) {
|
||||||
g_user_input->Poll();
|
g_user_input->Poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reschedule recurrent event
|
//Reschedule recurrent event
|
||||||
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event);
|
CoreTiming::ScheduleEvent(frame_ticks - cycles_late, input_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ std::string ControllerBase::GetDeviceName() const {
|
||||||
return device_name;
|
return device_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Service::HID::PadState ControllerBase::GetPadState() const {
|
Service::HID::PadState ControllerBase::GetPadState() const {
|
||||||
return controller.pad_state;
|
return controller.pad_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(ControllerBackends backend) {
|
void Init(ControllerBackends backend) {
|
||||||
switch (backend) {
|
switch (backend) {
|
||||||
#ifdef _SDL_H
|
#ifdef HAS_SDL
|
||||||
//SDL2 backend selected
|
//SDL2 backend selected
|
||||||
case SDL2_JOY:
|
case SDL2_JOY:
|
||||||
g_user_input = new SDLController();
|
g_user_input = new SDLController();
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
std::string GetDeviceName() const;
|
std::string GetDeviceName() const;
|
||||||
|
|
||||||
/// Returns internal pad state
|
/// Returns internal pad state
|
||||||
const Service::HID::PadState GetPadState() const;
|
Service::HID::PadState GetPadState() const;
|
||||||
|
|
||||||
bool activated;
|
bool activated;
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ void SDLController::SetDeadZone(int range) {
|
||||||
dead_zone = range;
|
dead_zone = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDLController::CheckDeadZone(int range) {
|
bool SDLController::CheckDeadZone(int range) const {
|
||||||
if ((range < -dead_zone) || (range > dead_zone)) {
|
if ((range < -dead_zone) || (range > dead_zone)) {
|
||||||
return true;
|
return true;
|
||||||
} else if ((range > -dead_zone) && (range < dead_zone)) {
|
} else if ((range > -dead_zone) && (range < dead_zone)) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
void SetDeadZone(int range);
|
void SetDeadZone(int range);
|
||||||
|
|
||||||
/// Checks if analog input is within the dead zone
|
/// Checks if analog input is within the dead zone
|
||||||
bool CheckDeadZone(int range);
|
bool CheckDeadZone(int range) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SDL_Joystick* jpad;
|
SDL_Joystick* jpad;
|
||||||
|
|
Loading…
Reference in a new issue