Steve Kondik | 95027ea | 2017-06-14 17:22:58 -0700 | [diff] [blame] | 1 | // |
| 2 | // vncflinger - Copyright (C) 2017 Steve Kondik |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | // |
| 17 | |
Steve Kondik | 107d2e5 | 2017-06-13 17:34:56 -0700 | [diff] [blame] | 18 | #ifndef INPUT_DEVICE_H |
| 19 | #define INPUT_DEVICE_H |
| 20 | |
| 21 | #include <utils/Errors.h> |
| 22 | #include <utils/RefBase.h> |
| 23 | |
| 24 | #include <rfb/rfb.h> |
| 25 | |
| 26 | |
| 27 | #define UINPUT_DEVICE "/dev/uinput" |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | class InputDevice : public RefBase { |
| 32 | public: |
| 33 | static status_t start(uint32_t width, uint32_t height); |
| 34 | static status_t stop(); |
| 35 | |
| 36 | static void keyEvent(rfbBool down, rfbKeySym key, rfbClientPtr cl); |
| 37 | static void pointerEvent(int buttonMask, int x, int y, rfbClientPtr cl); |
| 38 | |
| 39 | private: |
| 40 | |
| 41 | static status_t inject(uint16_t type, uint16_t code, int32_t value); |
| 42 | static status_t injectSyn(uint16_t type, uint16_t code, int32_t value); |
| 43 | static status_t movePointer(int32_t x, int32_t y); |
| 44 | static status_t setPointer(int32_t x, int32_t y); |
| 45 | static status_t press(uint16_t code); |
| 46 | static status_t release(uint16_t code); |
| 47 | static status_t click(uint16_t code); |
| 48 | |
| 49 | static int keysym2scancode(rfbKeySym c, rfbClientPtr cl, int* sh, int* alt); |
| 50 | |
| 51 | static int sFD; |
| 52 | |
| 53 | }; |
| 54 | |
| 55 | }; |
| 56 | #endif |