-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
31 lines (26 loc) · 831 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <string>
void sendKeys(std::string combo){
std::string cmd = "xdotool keydown " + combo + " keyup " + combo;
system(cmd.c_str());
}
int main(int argc, char** argv){
int threshold = 300;
int delay = 100;
sf::Vector2i initPos = sf::Mouse::getPosition();
sf::sleep(sf::milliseconds(delay));
sf::Vector2i displacement = sf::Mouse::getPosition() - initPos ;
if(displacement.x > threshold){ //RIGHT
sendKeys("ctrl alt Right");
}else if(displacement.x < -threshold){ //LEFT
sendKeys("ctrl alt Left");
}else if(displacement.y < -threshold){ //UP
sendKeys("ctrl alt Down");
}else if(displacement.y > threshold){ //DOWN
sendKeys("ctrl alt Up");
}else if(displacement == sf::Vector2i(0,0)){ //NONE
sendKeys("ctrl alt d");
}
return 0;
}