button consts
This commit is contained in:
parent
f355a18442
commit
322439692e
|
@ -18,9 +18,6 @@
|
|||
#include <iostream>
|
||||
#include "xinputsimulator.h"
|
||||
|
||||
//#include <chrono>
|
||||
//#include <thread>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
using namespace std;
|
||||
|
@ -37,11 +34,11 @@ int main()
|
|||
waitABit();
|
||||
sim.mouseMoveRelative(400, -100);
|
||||
waitABit();
|
||||
sim.mouseDown(1);
|
||||
sim.mouseDown(XInputSimulator::LEFT_MOUSE_BUTTON);
|
||||
waitABit();
|
||||
sim.mouseMoveRelative(0, 300);
|
||||
waitABit();
|
||||
sim.mouseUp(1);
|
||||
sim.mouseUp(XInputSimulator::LEFT_MOUSE_BUTTON);
|
||||
waitABit();
|
||||
//scroll down and up
|
||||
sim.mouseScrollY(10);
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#define XINPUTSIMULATOR_H
|
||||
|
||||
#include <memory>
|
||||
//#include <mutex>
|
||||
#include <iostream>
|
||||
#include "xinputsimulatorimpl.h"
|
||||
#include "notimplementedexception.h"
|
||||
|
@ -35,8 +34,6 @@
|
|||
class XInputSimulator
|
||||
{
|
||||
private:
|
||||
//XInputSimulator XInputSimulator instance;
|
||||
//std::unique_ptr<XInputSimulatorImpl> implementation;
|
||||
XInputSimulatorImpl *implementation;
|
||||
|
||||
XInputSimulator(){}
|
||||
|
@ -46,19 +43,14 @@ public:
|
|||
void operator=(XInputSimulator&) = delete;
|
||||
|
||||
~XInputSimulator() {
|
||||
std::cout << "Singleton::~Singleton" << std::endl;
|
||||
delete implementation;
|
||||
}
|
||||
//TODO add impl choose
|
||||
|
||||
static XInputSimulator & getInstance()
|
||||
{
|
||||
static XInputSimulator instance;
|
||||
|
||||
std::cout << "ThreadSafeSingleton::create_singleton_() "<< std::endl;
|
||||
|
||||
#ifdef __linux__
|
||||
// get linux impl
|
||||
//instance.implementation = std::move(std::unique_ptr<XInputSimulatorImpl>(new XInputSimulatorImplLinux));
|
||||
instance.implementation = new XInputSimulatorImplLinux;
|
||||
#elif __APPLE__
|
||||
instance.implementation = new XInputSimulatorImplMacOs;
|
||||
|
@ -68,7 +60,11 @@ public:
|
|||
return instance;
|
||||
}
|
||||
|
||||
void mouseMoveTo(int x, int y);//{ implementation->mouseMoveTo(x, y); }
|
||||
static const int LEFT_MOUSE_BUTTON = 1;
|
||||
static const int RIGHT_MOUSE_BUTTON = 2;
|
||||
static const int MIDDLE_MOUSE_BUTTON = 3;
|
||||
|
||||
void mouseMoveTo(int x, int y);
|
||||
void mouseMoveRelative(int x, int y);
|
||||
void mouseDown(int button);
|
||||
void mouseUp(int button);
|
||||
|
|
|
@ -25,10 +25,6 @@
|
|||
#include <stdio.h>
|
||||
#include <cstring>
|
||||
|
||||
//sleep
|
||||
//#include <chrono>
|
||||
//#include <thread>
|
||||
|
||||
XInputSimulatorImplLinux::XInputSimulatorImplLinux()
|
||||
{
|
||||
if((display = XOpenDisplay(NULL)) == NULL) {
|
||||
|
@ -57,8 +53,6 @@ void XInputSimulatorImplLinux::initMouseEvent(int button)
|
|||
|
||||
void XInputSimulatorImplLinux::mouseMoveTo(int x, int y)
|
||||
{
|
||||
std::cout << "move the mouse!\n";
|
||||
|
||||
if(!display){
|
||||
return;
|
||||
}
|
||||
|
@ -73,8 +67,6 @@ void XInputSimulatorImplLinux::mouseMoveTo(int x, int y)
|
|||
|
||||
void XInputSimulatorImplLinux::mouseMoveRelative(int x, int y)
|
||||
{
|
||||
//throw NotImplementedException();
|
||||
|
||||
if(!display){
|
||||
return;
|
||||
}
|
||||
|
@ -85,8 +77,6 @@ void XInputSimulatorImplLinux::mouseMoveRelative(int x, int y)
|
|||
|
||||
void XInputSimulatorImplLinux::mouseDown(int button)
|
||||
{
|
||||
//throw NotImplementedException();
|
||||
|
||||
this->initMouseEvent(button);
|
||||
|
||||
event.type = ButtonPress;
|
||||
|
@ -97,8 +87,6 @@ void XInputSimulatorImplLinux::mouseDown(int button)
|
|||
|
||||
void XInputSimulatorImplLinux::mouseUp(int button)
|
||||
{
|
||||
//throw NotImplementedException();
|
||||
|
||||
this->initMouseEvent(button);
|
||||
|
||||
event.type = ButtonRelease;
|
||||
|
@ -109,21 +97,17 @@ void XInputSimulatorImplLinux::mouseUp(int button)
|
|||
|
||||
void XInputSimulatorImplLinux::mouseClick(int button)
|
||||
{
|
||||
//throw NotImplementedException();
|
||||
this->mouseDown(button);
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
||||
this->mouseUp(button);
|
||||
}
|
||||
//kajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjfkajsdölfkjasdölfkjasldökfjaölsdkjfalsdkjfalskdjfaldskjf
|
||||
void XInputSimulatorImplLinux::mouseScrollX(int length)
|
||||
{
|
||||
//throw NotImplementedException();
|
||||
|
||||
int button;
|
||||
if(length < 0){
|
||||
button = 6;
|
||||
button = 6; //scroll left button
|
||||
}else{
|
||||
button = 7;
|
||||
button = 7; //scroll right button
|
||||
}
|
||||
|
||||
if(length < 0){
|
||||
|
@ -132,20 +116,17 @@ void XInputSimulatorImplLinux::mouseScrollX(int length)
|
|||
|
||||
for(int cnt = 0; cnt < length; cnt++){
|
||||
this->mouseDown(button);
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
this->mouseUp(button);
|
||||
}
|
||||
}
|
||||
|
||||
void XInputSimulatorImplLinux::mouseScrollY(int length)
|
||||
{
|
||||
//throw NotImplementedException();
|
||||
|
||||
int button;
|
||||
if(length < 0){
|
||||
button = 4;
|
||||
button = 4; //scroll up button
|
||||
}else{
|
||||
button = 5;
|
||||
button = 5; //scroll down button
|
||||
}
|
||||
|
||||
if(length < 0){
|
||||
|
@ -154,7 +135,6 @@ void XInputSimulatorImplLinux::mouseScrollY(int length)
|
|||
|
||||
for(int cnt = 0; cnt < length; cnt++){
|
||||
this->mouseDown(button);
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
this->mouseUp(button);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue