示例#1
0
文件: output.py 项目: j-szulc/hdlib
 def __init__(self):
     try:
         self.uinput = UInput()
     except UInputError:
         print("Error when opening /dev/uinput")
         print("Ensure you have write permissions")
         exit(1)
示例#2
0
class EvdevBase(object):

    _uinput_dev = UInput(events={
        ecodes.EV_KEY: ecodes.keys.keys(),
        ecodes.EV_REL: [ecodes.REL_WHEEL]
    },
                         name='pikuli-evdev-uinput')
示例#3
0
    def start(self):
        if self._running:
            return

        self._uinput = UInput.from_device(driver.input_manager.input_devices[0], \
            name='UChroma Virtual Macro Device %d' % driver.device_index)
        self._queue = InputQueue(driver)

        self._queue.attach()
        self._driver.input_manager.grab(True)

        self._task = ensure_future(self._listen())
        self._running = True
示例#4
0
文件: output.py 项目: j-szulc/hdlib
class Output:
    def __init__(self):
        try:
            self.uinput = UInput()
        except UInputError:
            print("Error when opening /dev/uinput")
            print("Ensure you have write permissions")
            exit(1)

    def sync(self):
        self.uinput.syn()

    def send(self, key, action):
        # IMPORTANT - choose Right Alt over Left Alt
        self.uinput.write(ecodes.EV_KEY, key.codes[-1], int(action))
        self.sync()

    def __del__(self):
        try:
            self.uinput.close()
        except ImportError:
            pass
示例#5
0
                      fuzz=0,
                      flat=0,
                      resolution=5074)),
             (WACOM_EVCODE_XPOS,
              AbsInfo(value=11344,
                      min=0,
                      max=WACOM_HEIGHT,
                      fuzz=0,
                      flat=0,
                      resolution=100)),
             (WACOM_EVCODE_YPOS,
              AbsInfo(value=10471,
                      min=0,
                      max=WACOM_WIDTH,
                      fuzz=0,
                      flat=0,
                      resolution=100))]
}

# Prod and Vend Ids are random as well as phys !
with UInput(events=capabilities,
            name='reMarkableTablet-FakePen',
            vendor=0x0002,
            product=0x02FE,
            phys='fake-tablet-input') as inputDevice:
    print('Running...')

    while True:
        evDevType, evDevCode, evDevValue = struct.unpack('HHi', client.recv(8))
        inputDevice.write(evDevType, evDevCode, evDevValue)
示例#6
0
    258: 'BTN_2',
    259: 'BTN_3',
    260: 'BTN_4',
    261: 'BTN_5',
    262: 'BTN_6',
    263: 'BTN_7',
    264: 'BTN_8',
    265: 'BTN_9',
    272: ['BTN_LEFT', 'BTN_MOUSE'],
    274: 'BTN_MIDDLE',
    273: 'BTN_RIGHT'
}
_keyboard_codes.update(mouse_btns)

_uinput = UInput(events={
    ecodes.EV_KEY: _keyboard_codes,
    ecodes.EV_REL: set([0, 1, 6, 8, 9]),
})

_pressed_modifier_keys = set()
_pressed_keys = set()


def update_modifier_key_pressed(key, action):
    if key in Modifier.get_all_keys():
        if action.is_pressed():
            _pressed_modifier_keys.add(key)
        else:
            _pressed_modifier_keys.discard(key)


def update_pressed_keys(key, action):
示例#7
0
def check_uinput():
    from evdev.uinput import UInput
    UInput()  # this will raise an error if /dev/uinput is not writable
示例#8
0
文件: output.py 项目: zenny/xkeysnail
# -*- coding: utf-8 -*-

from evdev import ecodes
from evdev.uinput import UInput
from .key import Action, Combo, Modifier

__author__ = 'zh'

_uinput = UInput()

_pressed_modifier_keys = set()
_pressed_keys = set()


def output_modifier_key():
    return _pressed_modifier_keys


def update_modifier_key_pressed(key, action):
    if key in Modifier.get_all_keys():
        if action.is_pressed():
            _pressed_modifier_keys.add(key)
        else:
            _pressed_modifier_keys.discard(key)


def update_pressed_keys(key, action):
    if action.is_pressed():
        _pressed_keys.add(key)
    else:
        _pressed_keys.discard(key)
示例#9
0
# -*- coding: utf-8 -*-

from evdev import ecodes
from evdev.uinput import UInput
from .key import Action, Combo, Modifier

__author__ = 'zh'

_uinput = UInput(
    events={
        ecodes.EV_KEY: ecodes.keys.keys(),
        ecodes.EV_REL: [k for k in ecodes.REL.keys() if k != 16]
    })

_pressed_modifier_keys = set()


def update_modifier_key_pressed(key, action):
    if key in Modifier.get_all_keys():
        if action.is_pressed():
            _pressed_modifier_keys.add(key)
        else:
            _pressed_modifier_keys.discard(key)


def send_sync():
    _uinput.syn()


def send_event(event):
    _uinput.write_event(event)
示例#10
0
def create_ui(on_write):
    ui = UInput()
    ui.write = Mock(side_effect=on_write)
    return ui
示例#11
0
              257: 'BTN_1',
              258: 'BTN_2',
              259: 'BTN_3',
              260: 'BTN_4',
              261: 'BTN_5',
              262: 'BTN_6',
              263: 'BTN_7',
              264: 'BTN_8',
              265: 'BTN_9',
              272: ['BTN_LEFT', 'BTN_MOUSE'],
              274: 'BTN_MIDDLE',
              273: 'BTN_RIGHT'}
_keyboard_codes.update(mouse_btns)

_uinput = UInput(events={ecodes.EV_KEY: _keyboard_codes,
                         ecodes.EV_REL: set([0,1,6,8,9]),
                         })

_pressed_modifier_keys = set()
_pressed_keys = set()

def update_modifier_key_pressed(key, action):
    if key in Modifier.get_all_keys():
        if action.is_pressed():
            _pressed_modifier_keys.add(key)
        else:
            _pressed_modifier_keys.discard(key)

def update_pressed_keys(key, action):
    if action.is_pressed():
        _pressed_keys.add(key)