当前位置: 首页>>代码示例>>Python>>正文


Python ecodes.EV_KEY属性代码示例

本文整理汇总了Python中evdev.ecodes.EV_KEY属性的典型用法代码示例。如果您正苦于以下问题:Python ecodes.EV_KEY属性的具体用法?Python ecodes.EV_KEY怎么用?Python ecodes.EV_KEY使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在evdev.ecodes的用法示例。


在下文中一共展示了ecodes.EV_KEY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def __init__(self, can_id):
        self.can_id = can_id
        axis_cap = AbsInfo(-32700,32700,0,0,0,0)
        self._ev = UInput(name='vjoy',
            events={
                 ecodes.EV_ABS: [
                     (ecodes.ABS_X, axis_cap),
                     (ecodes.ABS_Y, axis_cap),
                     (ecodes.ABS_Z, axis_cap)
                 ],
                 ecodes.EV_KEY: [
                     ecodes.BTN_TRIGGER, 
                     ecodes.BTN_TOP, 
                     ecodes.BTN_TOP2
                 ]
            }
        ) 
开发者ID:fishpepper,项目名称:pyUSBtin,代码行数:19,代码来源:elobau_j6_joystick.py

示例2: read_events

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def read_events(req_device):
    for device in list_devices():
        # Look in all 3 identifiers + event number
        if req_device in device or \
           req_device == device[0].replace("/dev/input/event", ""):
            found = evdev.InputDevice(device[0])

    if 'found' not in locals():
        print("Device not found. \n"
              "Please use --list-devices to view a list of available devices.")
        return

    print(found)
    print("To stop, press Ctrl-C")

    for event in found.read_loop():
        try:
            if event.type == evdev.ecodes.EV_KEY:
                categorized = evdev.categorize(event)
                if categorized.keystate == 1:
                    keycode = categorized.keycode if type(categorized.keycode) is str \
                        else " | ".join(categorized.keycode)
                    print("Key pressed: %s (%s)" % (keycode, categorized.scancode))
        except KeyError:
            if event.value:
                print("Unknown key (%s) has been pressed." % event.code)
            else:
                print("Unknown key (%s) has been released." % event.code) 
开发者ID:philipl,项目名称:evdevremapkeys,代码行数:30,代码来源:evdevremapkeys.py

示例3: change_state

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def change_state(self, event):
        if event.type == ecodes.EV_SYN:
            current = time.monotonic()
            diff = 20/1000
            if current - self.last < diff and not self.change:
                return
            self.last = current
            speed = 1
            self.state[3] = min(127, max(-127, int(self.x * speed))) & 255
            self.state[4] = min(127, max(-127, int(self.y * speed))) & 255
            self.state[5] = min(127, max(-127, self.z)) & 255
            self.x = 0
            self.y = 0
            self.z = 0
            self.change = False
            BluetoothDevice.send_current(self.state)
        if event.type == ecodes.EV_KEY:
            debug("Key event %s %d", ecodes.BTN[event.code], event.value)
            self.change = True
            if event.code >= 272 and event.code <= 276 and event.value < 2:
                button_no = event.code - 272
                if event.value == 1:
                    self.state[2] |= 1 << button_no
                else:
                    self.state[2] &= ~(1 << button_no)
        if event.type == ecodes.EV_REL:
            if event.code == 0:
                self.x += event.value
            if event.code == 1:
                self.y += event.value
            if event.code == 8:
                self.z += event.value 
开发者ID:quangthanh010290,项目名称:keyboard_mouse_emulate_on_raspberry,代码行数:34,代码来源:mouse_client.py

示例4: _handle_event

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def _handle_event(self, flags):
    logging.debug("Key_pin_listener handler start")
    if flags != select.POLLIN:
      logging.error("Key_pin_listener read failure: %s", str(flags))
      try:
        events = self.dev.read()
        logging.error("Key_pin_listener still got events: %s ?!?", str(events))
      except IOError as e:
        logging.error("Key_pin_listener read failed: %s", str(e))
      logging.error("Key_pin_listener removing key pin FD")
      self.iomanager.remove_file(self.dev)
    else:
      try:
        for event in self.dev.read():
          logging.debug("key pin event: %s", event)
          if event.type == ecodes.EV_KEY:
            code = int(event.code)
            val = int(event.value)
            if code in self.keys:
              key = self.keys[code]
              if (key.edge == 0xff or val == key.edge) and key.callback:
                logging.debug("sending key pin event to handler %s", str(key))
                key.callback(key, event)
                logging.debug("key pin event handler done")
      except IOError as e:
        logging.error("Key_pin_listener read failed in read event: %s", str(e))
        self.iomanager.remove_file(self.dev)
    logging.debug("Key_pin_listener handler end") 
开发者ID:intelligent-agent,项目名称:redeem,代码行数:30,代码来源:Key_pin.py

示例5: signal

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def signal(self, x, y, z, b0, b1, b2):
       self._ev.write(ecodes.EV_ABS, ecodes.ABS_X, x)
       self._ev.write(ecodes.EV_ABS, ecodes.ABS_Y, y)
       self._ev.write(ecodes.EV_ABS, ecodes.ABS_Z, z)
       self._ev.write(ecodes.EV_KEY, ecodes.BTN_TRIGGER, b0)
       self._ev.write(ecodes.EV_KEY, ecodes.BTN_TOP,     b1)
       self._ev.write(ecodes.EV_KEY, ecodes.BTN_TOP2,    b2)
       self._ev.syn() 
开发者ID:fishpepper,项目名称:pyUSBtin,代码行数:10,代码来源:elobau_j6_joystick.py

示例6: listen_for_events

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def listen_for_events(dev):
    for event in dev.read_loop():
        if event.type == ecodes.EV_KEY:
            print dev.name+":  "+str(categorize(event)) 
开发者ID:CRImier,项目名称:pyLCI,代码行数:6,代码来源:debug_listener.py

示例7: runner

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def runner(self):
        """Blocking event loop which just calls supplied callbacks in the keymap."""
        try:
            while not self.stop_flag:
                event = self.device.read_one()
                if event is not None and event.type == ecodes.EV_KEY:
                    key = ecodes.keys[event.code]
                    value = event.value
                    if value == 0 and self.enabled:
                        self.send_key(key)
                sleep(0.01)
        except IOError as e: 
            if e.errno == 11:
                #raise #Uncomment only if you have nothing better to do - error seems to appear at random
                pass 
开发者ID:CRImier,项目名称:pyLCI,代码行数:17,代码来源:hid.py

示例8: event_loop

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def event_loop(self):
        for event in self.dev.read_loop():
            if event.type == ecodes.EV_KEY and event.value < 2:
                self.change_state_button(event)
            elif event.type == ecodes.EV_REL:
                self.change_state_movement(event)
            try:
                self.send_input()
            except:
                print("Couldn't send mouse input")
                break

    # forward mouse events to the dbus service 
开发者ID:AnesBenmerzoug,项目名称:Bluetooth_HID,代码行数:15,代码来源:mouse_client.py

示例9: event_loop

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def event_loop(self):
        for event in self.dev.read_loop():
            # only bother if we hit a key and its an up or down event
            if event.type == ecodes.EV_KEY and event.value < 2:
                self.change_state(event)
                try:
                    self.send_input()
                except:
                    print("Couldn't send keyboard input")
                    break

    # forward keyboard events to the dbus service 
开发者ID:AnesBenmerzoug,项目名称:Bluetooth_HID,代码行数:14,代码来源:keyboard_client.py

示例10: combined_event_loop

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def combined_event_loop(self):
        print("Starting combined event loop")
        devices = {dev.fd: dev for dev in [self.keyboard, self.mouse] if dev is not None}
        while True:
            r, w, e = select(devices, [], [])
            for fd in r:
                if devices[fd] == self.keyboard:
                    for event in self.keyboard.read():
                        # only bother if we hit a key and its an up or down event
                        if event.type == ecodes.EV_KEY and event.value < 2:
                            self.change_keyboard_state(event)
                            try:
                                self.send_keyboard_input()
                            except:
                                break

                else:
                    for event in self.mouse.read():
                        if event.type == ecodes.EV_KEY and event.value < 2:
                            self.change_state_button(event)
                        elif event.type == ecodes.EV_REL:
                            self.change_state_movement(event)
                        try:
                            self.send_mouse_input()
                        except :
                            break

######################################################################################################################## 
开发者ID:AnesBenmerzoug,项目名称:Bluetooth_HID,代码行数:30,代码来源:devices_client.py

示例11: ButtonEvent

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def ButtonEvent(channel):                                                 
    if GPIO.input(JUMP_PIN) == 1:
        ui.write(e.EV_KEY, e.KEY_LEFTALT, 0)  
        ui.syn()
    if GPIO.input(JUMP_PIN) == 0:
        ui.write(e.EV_KEY, e.KEY_LEFTALT, 1) 
        ui.syn()
    if GPIO.input(FIRE_PIN) == 1:
        ui.write(e.EV_KEY, e.KEY_LEFTCTRL, 0)  
        ui.syn()
    if GPIO.input(FIRE_PIN) == 0:
        ui.write(e.EV_KEY, e.KEY_LEFTCTRL, 1) 
        ui.syn() 
开发者ID:raspberrypi-tw,项目名称:gpio-game-console,代码行数:15,代码来源:gaming_console.py

示例12: button_p_handler

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def button_p_handler(button, pressed):
    keycode = KEYCODES[button]
    print("Press: {}".format(keycode))
    ui.write(e.EV_KEY, keycode, 1)
    ui.syn() 
开发者ID:pimoroni,项目名称:button-shim,代码行数:7,代码来源:keyboard.py

示例13: button_r_handler

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def button_r_handler(button, pressed):
    keycode = KEYCODES[button]
    print("Release: {}".format(keycode))
    ui.write(e.EV_KEY, keycode, 0)
    ui.syn() 
开发者ID:pimoroni,项目名称:button-shim,代码行数:7,代码来源:keyboard.py

示例14: press

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def press( self ):
		self.isPressed = time.time()
		self.injector.write(e.EV_KEY, self.command, 1)
		self.injector.syn()
		self.waitForRelease() 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:7,代码来源:device.py

示例15: release

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_KEY [as 别名]
def release( self ):
		if self.isPressed:
			self.isPressed = 0
			self.injector.write(e.EV_KEY, self.command, 0)
			self.injector.syn() 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:7,代码来源:device.py


注:本文中的evdev.ecodes.EV_KEY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。