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)
|
||||
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})
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue