diff options
Diffstat (limited to 'input/wrapper.go')
-rw-r--r-- | input/wrapper.go | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/input/wrapper.go b/input/wrapper.go new file mode 100644 index 0000000..d194f20 --- /dev/null +++ b/input/wrapper.go @@ -0,0 +1,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) +} |