File: input.py

package info (click to toggle)
python-pure-python-adb 0.3.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,500 kB
  • sloc: python: 2,597; makefile: 8; sh: 1
file content (43 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download
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
from ppadb.plugins import Plugin


class Source:
    KEYBOARD = 'keyboard'
    MOUSE = 'mouse'
    JOYSTICK = 'joystick'
    TOUCHNAVIGATION = 'touchnavigation'
    TOUCHPAD = 'touchpad'
    TRACKBALL = 'trackball'
    DPAD = 'dpad'
    STYLUS = 'stylus'
    GAMEPAD = 'gamepad'
    touchscreen = 'touchscreen'


class Input(Plugin):
    def input_text(self, string):
        return self.shell('input text "{}"'.format(string))

    def input_keyevent(self, keycode, longpress=False):
        cmd = 'input keyevent {}'.format(keycode)
        if longpress:
            cmd += " --longpress"
        return self.shell(cmd)

    def input_tap(self, x, y):
        return self.shell("input tap {} {}".format(x, y))

    def input_swipe(self, start_x, start_y, end_x, end_y, duration):
        return self.shell("input swipe {} {} {} {} {}".format(
            start_x,
            start_y,
            end_x,
            end_y,
            duration
        ))

    def input_press(self):
        return self.shell("input press")

    def input_roll(self, dx, dy):
        return self.roll("roll {} {}".format(dx, dy))