diff --git a/XInputSimulator/xinputsimularotimplwin.cpp b/XInputSimulator/xinputsimularotimplwin.cpp deleted file mode 100644 index bd0cd14..0000000 --- a/XInputSimulator/xinputsimularotimplwin.cpp +++ /dev/null @@ -1,148 +0,0 @@ - -// Copyright 2013 Dustin Bensing - -// This file is part of XInputSimulator. - -// XInputSimulator is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// any later version. - -// XInputSimulator is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser Public License for more details. - -// You should have received a copy of the GNU Lesser Public License -// along with XInputSimulator. If not, see . - -#ifdef _WIN32 - -#include "xinputsimularotimplwin.h" -#include "notimplementedexception.h" -#include - -#include - -#define MOUSEEVENTF_HWHEEL 0x01000 - -XInputSimularotImplWin::XInputSimularotImplWin() -{ - this->initCurrentMousePosition(); -} - -void XInputSimularotImplWin::initCurrentMousePosition() -{ - POINT p; - if (GetCursorPos(&p)) - { - this->currentX = p.x; - this->currentY = p.y; - } -} - - -void XInputSimularotImplWin::mouseMoveTo(int x, int y) -{ - SetCursorPos(x, y); - - this->currentX = x; - this->currentY = y; -} - -void XInputSimularotImplWin::mouseMoveRelative(int x, int y) -{ - int newX = this->currentX + x; - int newY = this->currentY + y; - - SetCursorPos(newX, newY); - - this->currentX = newX; - this->currentY = newY; -} - -//TODO use the button from parameter list -void XInputSimularotImplWin::mouseDown(int button) -{ - INPUT in={0}; - in.type = INPUT_MOUSE; - in.mi.dwFlags = MOUSEEVENTF_LEFTDOWN; - SendInput(1,&in,sizeof(INPUT)); - ZeroMemory(&in,sizeof(INPUT)); -} - -//TODO use the button from parameter list -void XInputSimularotImplWin::mouseUp(int button) -{ - INPUT in={0}; - in.type = INPUT_MOUSE; - in.mi.dwFlags = MOUSEEVENTF_LEFTUP; - SendInput(1,&in,sizeof(INPUT)); - ZeroMemory(&in,sizeof(INPUT)); -} - -//TODO use the button from parameter list -void XInputSimularotImplWin::mouseClick(int button) -{ - 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 XInputSimularotImplWin::mouseScrollX(int length) -{ - int scrollDirection = 1 * 50; // 1 left -1 right - - if(length < 0){ - length *= -1; - scrollDirection *= -1; - } - - for(int cnt = 0; cnt < length; cnt++) - { - INPUT in; - in.type = INPUT_MOUSE; - in.mi.dx = 0; - in.mi.dy = 0; - in.mi.dwFlags = MOUSEEVENTF_HWHEEL; - in.mi.time = 0; - in.mi.dwExtraInfo = 0; - in.mi.mouseData = scrollDirection;// WHEEL_DELTA; - SendInput(1,&in,sizeof(in)); - } -} - -void XInputSimularotImplWin::mouseScrollY(int length) -{ - int scrollDirection = -1 * 50; // 1 up -1 down - - if(length < 0){ - length *= -1; - scrollDirection *= -1; - } - - for(int cnt = 0; cnt < length; cnt++) - { - INPUT in; - in.type = INPUT_MOUSE; - in.mi.dx = 0; - in.mi.dy = 0; - in.mi.dwFlags = MOUSEEVENTF_WHEEL; - in.mi.time = 0; - in.mi.dwExtraInfo = 0; - in.mi.mouseData = scrollDirection;// WHEEL_DELTA; - SendInput(1,&in,sizeof(in)); - } -} - -void XInputSimularotImplWin::keyDown(int key) -{ - throw NotImplementedException(); -} - -void XInputSimularotImplWin::keyUp(int key) -{ - throw NotImplementedException(); -} - -#endif //win diff --git a/XInputSimulator/xinputsimularotimplwin.h b/XInputSimulator/xinputsimularotimplwin.h deleted file mode 100644 index 6c710e3..0000000 --- a/XInputSimulator/xinputsimularotimplwin.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2013 Dustin Bensing - -// This file is part of XInputSimulator. - -// XInputSimulator is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// any later version. - -// XInputSimulator is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser Public License for more details. - -// You should have received a copy of the GNU Lesser Public License -// along with XInputSimulator. If not, see . - -#ifdef _WIN32 - -#ifndef XINPUTSIMULAROTIMPLWIN_H -#define XINPUTSIMULAROTIMPLWIN_H - -#include "xinputsimulatorimpl.h" - -class XInputSimularotImplWin: public XInputSimulatorImpl -{ -private: - int currentX; - int currentY; - - void initCurrentMousePosition(); - -public: - XInputSimularotImplWin(); - ~XInputSimularotImplWin(){} - - virtual void mouseMoveTo(int x, int y) override; - virtual void mouseMoveRelative(int x, int y) override; - virtual void mouseDown(int button) override; - virtual void mouseUp(int button) override; - virtual void mouseClick(int button) override; - virtual void mouseScrollX(int length) override; - virtual void mouseScrollY(int length) override; - - virtual void keyDown(int key) override; - virtual void keyUp(int key) override; -}; - -#endif // XINPUTSIMULAROTIMPLWIN_H - -#endif //win