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


Python InputDevice.active_keys方法代码示例

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


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

示例1: key_input_test

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
def key_input_test():

  dev = InputDevice('/dev/input/event0')

  sr.sendbit(0)
  foundkeys = 0 
  for i in range(len(KEYPRESSES)):
    if (dev.active_keys() ==  KEYPRESSES[i]):
      print('Found Key' , KEYPRESSES[i])
      foundkeys += 1 
    else:
      print('Fail!!',dev.active_keys() ,'Expected ', KEYPRESSES[i])
    sleep(0.1)
    sr.sendbit(1)
  if( foundkeys == 16 ):
    print( 'Test Passed')
    dev.close()
    return True 
  else:
    print( 'Test FAIL!!!!!!!!!!!')
    dev.close()
    return False
开发者ID:rabid-inventor,项目名称:PicadeTestKit,代码行数:24,代码来源:picadetest.py

示例2: ShortcutsTab

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
class ShortcutsTab(QWidget):

    def __init__(self):
        self.dev = InputDevice("/dev/input/event6")
        super(ShortcutsTab, self).__init__()
        grid_main = QGridLayout()

        form_left = QFormLayout()
        form_right = QFormLayout()

        self.add_image(form_left)
        self.add_image(form_right)
        self.add_image(form_left)
        self.add_image(form_right)

        grid_main.addLayout(form_left, 0, 0)
        grid_main.addLayout(form_right, 0, 1)
        self.setLayout(grid_main)

    def add_image(self, v_box):
        image = QPixmap(Images.rotate.value)
        image = image.scaled(32, 32, Qt.KeepAspectRatio, Qt.SmoothTransformation)
        imageLabel = QLabel()
        imageLabel.setPixmap(image)

        button_shortcuts = QPushButton("teste")
        button_shortcuts.clicked.connect(self.change_button_name)

        v_box.addRow(imageLabel, button_shortcuts)

    def change_button_name(self):
        button = self.sender()

        array = list()
        while (True):
            array = self.dev.active_keys()
            if 30 in array:
                break

        button.setText(str(array))
开发者ID:ivopanjos,项目名称:TouchpadPro-Python,代码行数:42,代码来源:ShortcutsTab.py

示例3: print

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
  e.KEY_9: e.KEY_F9,
  e.KEY_0: e.KEY_F10,
  e.KEY_MINUS: e.KEY_F11,
  e.KEY_EQUAL: e.KEY_F12,
  e.KEY_BACKSPACE: e.KEY_DELETE,
}
# The names can be found with evtest or in evdev docs.

esc = False
intercepted = False
# Create a new keyboard mimicking the original one.
with UInput.from_device(kbd, name='kbdremap') as ui:
  for ev in kbd.read_loop():  # Read events from original keyboard.
    if ev.type == e.EV_KEY:  # Process key events.
      # ke = evdev.categorize(ev)
      act = kbd.active_keys()
      # print(act)
      # print(ev.value)
      if e.KEY_ESC in act:
        esc = True
        for k, v in REMAP_TABLE.items():
          if k in act:
            intercepted = True
            ui.write(e.EV_KEY, v, 1)
            ui.write(e.EV_KEY, v, 0)
            ui.syn()
      elif esc and not intercepted:
        ui.write(e.EV_KEY, e.KEY_ESC, 1)
        ui.write(e.EV_KEY, e.KEY_ESC, 0)
        ui.syn()
        intercepted = False
开发者ID:joetoth,项目名称:dotfiles,代码行数:33,代码来源:keyboard.py

示例4: InputDevice

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
import mpd
import socket
import alsaaudio
import time
client = mpd.MPDClient(use_unicode=True)
dev = InputDevice('/dev/input/event2')
drop_lb_event = False
drop_rb_event = False

while True:
        r,w,x = select([dev], [], [])
        try:
                for event in dev.read():
                        client.connect("192.168.0.2", 6600)
                        if event.code == 8:
                                if 272 in dev.active_keys():
                                        drop_lb_event = True
                                        if (event.value > 0):
                                                client.seekcur("+5")
                                        else:
                                                client.seekcur("-5")
                                elif 273 in dev.active_keys():
                                        drop_rb_event = True
                                        if (event.value > 0):
                                                client.seekcur("+30")
                                        else:
                                                client.seekcur("-30")
                                else:
                                        mixer = alsaaudio.Mixer("PCM", **{"cardindex": 1})
                                        if (event.value > 0):
                                                mixer.setvolume(int(mixer.getvolume()[0])+2, -1)
开发者ID:degifted,项目名称:mpd_mouse_control,代码行数:33,代码来源:mpd_mouse_control.py

示例5: main

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
def main():
    """Checks PS3 inputs and sends them via UDP"""
    dev = InputDevice('/dev/input/by-id/usb-Sony_PLAYSTATION_R_3_Controller-event-joystick')
    ser = serial.Serial('/dev/ttyACM3', 19200)

    servo1 = 90
    servo2 = 90
    servo3 = 90
    servo4 = 90
    servo5 = 90

    send = True

    print(dev)
    print(dev.capabilities(verbose=True, absinfo=False))

    UDP_IP = "192.168.0.249"
    UDP_PORT = 5000

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    while True:
        event = dev.active_keys()
        print(dev.active_keys())
        print(servo1)
        print(servo2)
        print(servo3)
        print(servo4)
        print(servo5)
        try:
            for evn in event:
                # 299 & 298
                if evn == 299:
                    send = True
                    if servo1 >= 180:
                        servo1 = 180
                        servo2 = 0
                    else:
                        servo1 += 0.5
                        servo2 -= 0.5
                elif evn == 298:
                    send = True
                    if servo1 <= 0:
                        servo1 = 0
                        servo2 = 180
                    else:
                        servo1 -= 0.5
                        servo2 += 0.5

                # 296 & 297
                if evn == 296:
                    send = True
                    if servo3 >= 180:
                        servo3 = 180
                    else:
                        servo3 += 0.5
                elif evn== 297:
                    send = True
                    if servo3 <= 0:
                        servo3 = 0
                    else:
                        servo3 -= 0.5

                # 295 & 293 - dcha izq
                if evn== 295: # dcha
                    send = True
                    if servo4 >= 180:
                        servo4 = 180
                    else:
                        servo4 += 0.5
                elif evn== 293: # izq
                    send = True
                    if servo4 <= 0:
                        servo4 = 0
                    else:
                        servo4 -= 0.5

                # 292 & 294 - arriba abajo
                if evn== 292: # arriba
                    send = True
                    if servo5 >= 180:
                        servo5 = 180
                    else:
                        servo5 += 0.5
                elif evn== 294: # abajo
                    send = True
                    if servo5 <= 0:
                        servo5 = 0
                    else:
                        servo5 -= 0.5

            if(send):
                ser.write(str(int(servo1)).zfill(3).encode() +
                        str(int(servo2)).zfill(3).encode() +
                        str(int(servo3)).zfill(3).encode() +
                        str(int(servo4)).zfill(3).encode() +
                        str(int(servo5)).zfill(3).encode() +
                        "\n".encode())
                send= False
            gc.collect()
#.........这里部分代码省略.........
开发者ID:bluetronics-India,项目名称:robot,代码行数:103,代码来源:armClient.py

示例6: print

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
    query_value = argv[3]
else:
    print(usage)
    exit(1)

capabs = device.capabilities(verbose=True)

print('Device name: {.name}'.format(device))
print('Device info: {.info}'.format(device))
print('Repeat settings: {}\n'.format(device.repeat))

if ('EV_LED', ecodes.EV_LED) in capabs:
    leds = ','.join(i[0] for i in device.leds(True))
    print('Active LEDs: %s' % leds)

active_keys = ','.join(k[0] for k in device.active_keys(True))
print('Active keys: %s\n' % active_keys)

print('Device capabilities:')
for type, codes in capabs.items():
    print('  Type {} {}:'.format(*type))
    for i in codes:
        # i <- ('BTN_RIGHT', 273) or (['BTN_LEFT', 'BTN_MOUSE'], 272)
        if isinstance(i[1], AbsInfo):
            print('    Code {:<4} {}:'.format(*i[0]))
            print('      {}'.format(i[1]))
        else:
            # multiple names may resolve to one value
            s = ', '.join(i[0]) if isinstance(i[0], list) else i[0]
            print('    Code {:<4} {}'.format(s, i[1]))
    print('')
开发者ID:forsenonlhaimaisentito,项目名称:python-evdev,代码行数:33,代码来源:evtest.py

示例7: InputDevice

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
# Returns 0 or 1 to shell, depending on touch screen is pressed
import sys
from evdev import InputDevice
dev = InputDevice('/dev/input/event0')
keys=dev.active_keys()
if keys:
        if keys[0] == 330:
                sys.exit(0)
else:
        sys.exit(1)

开发者ID:chr1573r,项目名称:consolex,代码行数:12,代码来源:readTouch.py

示例8: main

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
def main():
    """Checks PS3 inputs and sends them via UDP"""
    dev = InputDevice('/dev/input/by-id/usb-Sony_PLAYSTATION_R_3_Controller-event-joystick')
    speed1 = 0
    speed2 = 0
    speed3 = 0
    dir1 = 'F'
    dir2 = 'F'
    dir3 = 'F'
    arm_pos = 0

    print(dev)
    print(dev.capabilities(verbose=True, absinfo=False))

    UDP_IP = "192.168.43.2"
    UDP_PORT = 5000

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    while True:
        event = dev.read()
        keys = dev.active_keys()
        print(keys)
        try:
            for key in keys:
                if key == 295:
                    arm_pos = 0
                    print("295")
                if key == 292:
                    arm_pos = 1
                    print("292")
                if key == 293:
                    arm_pos = 2
                    print("293")
                if key == 294:
                    arm_pos = 3
                    print("294")
            for evn in event:
                if evn.code == 1:  # right x
                    # print(ev)
                    speed1 = evn.value - 128
                    if speed1 < 0:
                        dir1 = 'F'
                        if speed1 == -128:
                            speed1 = -127
                        # ser.write('AF'.encode() + str(abs(dir * 2)).encode())
                        print("Motor A - Forward - " + str(abs(speed1 * 2)))
                    else:
                        dir1 = 'B'
                        # ser.write('AB'.encode() + str(dir).encode())
                        print("Motor A - Backward - " + str(abs(speed1 * 2)))
                    # ser.write('A'.encode() + str(evn.value - 128).encode())
                elif evn.code == 5:  # left x
                    speed2 = evn.value - 128
                    # print(ev)
                    if speed2 < 0:
                        dir2 = 'F'
                        if speed2 == -128:
                            speed2 = -127
                        # ser.write('BF'.encode() + str(abs(dir * 2)).encode())
                        print("Motor B - Forward - " + str(abs(speed2 * 2)))
                    else:
                        dir2 = 'B'
                        # ser.write('BB'.encode() + str(dir * 2).encode())
                        print("Motor B - Backward - " + str(abs(speed2 * 2)))
                elif evn.code == 300:  # left x
                    print("motor 3 F")
                    speed3 = 127
                    dir3 = 'F'
                elif evn.code == 302:
                    print("motor 3 B")
                    speed3 = 127
                    dir3 = 'B'
                elif evn.code == 301:
                    speed3 = 0
            sock.sendto(dir1.encode() +
                        str(abs(speed1 * 2)).zfill(3).encode() +
                        dir2.encode() +
                        str(abs(speed2 * 2)).zfill(3).encode() +
                        dir3.encode() +
                        str(abs(speed3 * 2)).zfill(3).encode() +
                        # str(arm_pos).encode() +
                        "\n".encode(), (UDP_IP, UDP_PORT))
            gc.collect()
        except IOError:
            pass
开发者ID:hugo19941994,项目名称:robot,代码行数:88,代码来源:control.py

示例9: InputDevice

# 需要导入模块: from evdev import InputDevice [as 别名]
# 或者: from evdev.InputDevice import active_keys [as 别名]
from evdev import InputDevice, categorize, ecodes

key_map = {
    115: "FRWD",
    114: "BKWD",
    165: "LEFT",
    163: "RIGHT",
    164: "BTN_A",
    304: "SUPER_UP",
    305: "SUPER_DOWN",
}

remote = InputDevice("/dev/input/event2")
print("Device : {}".format(remote))

for event in remote.read_loop():
    c_event = categorize(event)
    # print("categorized event : {}".format())
    if event.type == ecodes.EV_KEY:
        print("key: {}".format(remote.active_keys(verbose=False)))
开发者ID:daiemna,项目名称:robocup_home_working,代码行数:22,代码来源:bluetooth_test.py


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