blob: d194f2020b37e731a7ee25eda7c2d8f19ef70744 (
plain)
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
|
package input
import (
"fmt"
"io"
)
const (
InputType_debug int = 0
InputType_uinput int = 1
)
type Keyboard interface {
KeyDown(key int) error
KeyUp(key int) error
io.Closer
}
type Mouse interface {
Move(x, y int32) error
LeftPress() error
LeftRelease() error
Wheel(horizontal bool, delta int32) error
io.Closer
}
func CreateKeyboard(inputType int) (Keyboard, error) {
switch inputType {
case InputType_debug:
return KeyboardEmptyWrapper{}, nil
case InputType_uinput:
uinputKeyboard := new(KeyboardUinputWrapper)
uinputKeyboard.Init()
return uinputKeyboard, nil
}
return nil, fmt.Errorf("Unknown inputType: %d", inputType)
}
func CreateMouse(inputType int) (Mouse, error) {
switch inputType {
case InputType_debug:
return MouseEmptyWrapper{}, nil
case InputType_uinput:
uinputMouse := new(MouseUinputWrapper)
uinputMouse.Init()
return uinputMouse, nil
}
return nil, fmt.Errorf("Unknown inputType: %d", inputType)
}
|