diff --git a/.gitignore b/.gitignore index 5367fb6..70a8594 100644 --- a/.gitignore +++ b/.gitignore @@ -16,5 +16,5 @@ #*.pro *.user *.directory -build-* -*build-* \ No newline at end of file +build* +*build* diff --git a/XInputSimulator/CMakeLists.txt b/XInputSimulator/CMakeLists.txt index 8e2b620..01f76e8 100644 --- a/XInputSimulator/CMakeLists.txt +++ b/XInputSimulator/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 2.8.4) project(XInputSimulator) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - set(SOURCE_FILES main.cpp notimplementedexception.cpp @@ -23,15 +21,23 @@ set(SOURCE_FILES find_library(X_11 X11) find_library(X_TST Xtst) set(EXTRA_LIBS ${X_11} ${X_TST}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif(UNIX AND NOT APPLE) # Apple if(APPLE) find_library(APP_SERVICES ApplicationServices) find_library(CARBON Carbon) - find_library(CORE_FOUNDATION CoreFoundation ) + find_library(CORE_FOUNDATION CoreFoundation) set(EXTRA_LIBS ${APP_SERVICES_LIBRARY} ${CARBON} ${CORE_FOUNDATION}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") endif(APPLE) + + # Windows + if(WIN32) + #find_library(USER_32 User32.Lib) + #set(EXTRA_LIBS ${USER_32}) + endif(WIN32) add_executable(XInputSimulator ${SOURCE_FILES}) target_link_libraries(XInputSimulator ${EXTRA_LIBS} ) \ No newline at end of file diff --git a/XInputSimulator/main.cpp b/XInputSimulator/main.cpp index 1d16f6b..ea6e94e 100644 --- a/XInputSimulator/main.cpp +++ b/XInputSimulator/main.cpp @@ -18,7 +18,16 @@ #include #include "xinputsimulator.h" +#ifdef __linux__ +//sleep #include +#elif __APPLE__ +//sleep +#include +#elif _WIN32 +//sleep +#include +#endif using namespace std; @@ -51,7 +60,8 @@ int main() waitABit(); sim.mouseScrollX(-10); - char anA = 'a'; +#ifdef __linux__ || __APPLE__ + char anA = 'a'; cout << "a: " << (int)anA << " " << sim.charToKeyCode(anA) << endl; std::cout << std::endl; waitABit(); @@ -59,15 +69,24 @@ int main() std::cout << std::endl; waitABit(); sim.keySequence(" Simple sentence Here 123 "); +#elif _WIN32 + //not implemented +#endif - - //waitABit(); + waitABit(); return 0; } void waitABit() { //std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - sleep(1); +#ifdef __linux__ + sleep(1); +#elif __APPLE__ + sleep(1); +#elif _WIN32 + Sleep(1000); +#endif + }