-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathVirtualInput.h
More file actions
61 lines (45 loc) · 1.11 KB
/
VirtualInput.h
File metadata and controls
61 lines (45 loc) · 1.11 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: VirtualInput.h
* Author: kubatek94
*
* Created on 17 March 2016, 13:29
*/
#ifndef VIRTUALINPUT_H
#define VIRTUALINPUT_H
#include <stdexcept>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/input.h>
#include <linux/uinput.h>
#include <iostream>
typedef signed char jbyte;
class VirtualInput {
public:
enum class Button { LEFT, RIGHT };
VirtualInput();
virtual ~VirtualInput();
bool openDevice();
void closeDevice();
bool isOpen();
void move(int dy, int dx);
void scroll(int val);
void click(Button button);
void onKeyDown(jbyte key);
void onKeyUp(jbyte key);
static jbyte javaKeyToInputKey(jbyte key);
private:
bool _isOpen = false;
int fd;
struct uinput_user_dev uidev;
struct input_event ev[3];
static jbyte keyMap[117];
};
#endif /* VIRTUALINPUT_H */