Skip to content

Commit 7d3feb7

Browse files
committed
added windows cmake building
1 parent 384ad88 commit 7d3feb7

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616
#*.pro
1717
*.user
1818
*.directory
19-
build-*
20-
*build-*
19+
build*
20+
*build*

XInputSimulator/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
cmake_minimum_required(VERSION 2.8.4)
22
project(XInputSimulator)
33

4-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
5-
64
set(SOURCE_FILES
75
main.cpp
86
notimplementedexception.cpp
@@ -23,15 +21,23 @@ set(SOURCE_FILES
2321
find_library(X_11 X11)
2422
find_library(X_TST Xtst)
2523
set(EXTRA_LIBS ${X_11} ${X_TST})
24+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2625
endif(UNIX AND NOT APPLE)
2726

2827
# Apple
2928
if(APPLE)
3029
find_library(APP_SERVICES ApplicationServices)
3130
find_library(CARBON Carbon)
32-
find_library(CORE_FOUNDATION CoreFoundation )
31+
find_library(CORE_FOUNDATION CoreFoundation)
3332
set(EXTRA_LIBS ${APP_SERVICES_LIBRARY} ${CARBON} ${CORE_FOUNDATION})
33+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
3434
endif(APPLE)
35+
36+
# Windows
37+
if(WIN32)
38+
#find_library(USER_32 User32.Lib)
39+
#set(EXTRA_LIBS ${USER_32})
40+
endif(WIN32)
3541

3642
add_executable(XInputSimulator ${SOURCE_FILES})
3743
target_link_libraries(XInputSimulator ${EXTRA_LIBS} )

XInputSimulator/main.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,16 @@
1818
#include <iostream>
1919
#include "xinputsimulator.h"
2020

21+
#ifdef __linux__
22+
//sleep
2123
#include <unistd.h>
24+
#elif __APPLE__
25+
//sleep
26+
#include <unistd.h>
27+
#elif _WIN32
28+
//sleep
29+
#include <windows.h>
30+
#endif
2231

2332
using namespace std;
2433

@@ -51,23 +60,33 @@ int main()
5160
waitABit();
5261
sim.mouseScrollX(-10);
5362

54-
char anA = 'a';
63+
#ifdef __linux__ || __APPLE__
64+
char anA = 'a';
5565
cout << "a: " << (int)anA << " " << sim.charToKeyCode(anA) << endl;
5666
std::cout << std::endl;
5767
waitABit();
5868
sim.keyClick(sim.charToKeyCode(anA));
5969
std::cout << std::endl;
6070
waitABit();
6171
sim.keySequence(" Simple sentence Here 123 ");
72+
#elif _WIN32
73+
//not implemented
74+
#endif
6275

6376

64-
65-
//waitABit();
77+
waitABit();
6678
return 0;
6779
}
6880

6981
void waitABit()
7082
{
7183
//std::this_thread::sleep_for(std::chrono::milliseconds(1000));
72-
sleep(1);
84+
#ifdef __linux__
85+
sleep(1);
86+
#elif __APPLE__
87+
sleep(1);
88+
#elif _WIN32
89+
Sleep(1000);
90+
#endif
91+
7392
}

0 commit comments

Comments
 (0)