Use CMake to set a preprocessor marco, rearrage CMakeLists.txt

Review Changes 6

Review Changes 7
This commit is contained in:
Daniel Stuart Baxter 2015-05-30 19:22:51 -05:00
parent f87056289a
commit 9ae6bf08a4
5 changed files with 11 additions and 10 deletions

View file

@ -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})

View file

@ -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();

View file

@ -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;

View file

@ -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)) {

View file

@ -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;