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


Python uinput.Device方法代码示例

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


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

示例1: get_altgr_keys

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def get_altgr_keys():
    import sys
    import time
    time.sleep(5)
    device = uinput.Device(uinput_all_keys.uinput_all_keys)
    for i in range(48, 58):
        sys.stdout.write("'")
        sys.stdout.flush()

        for key in wrap_altgr(click(getattr(uinput, "KEY_" + chr(i)))):
            time.sleep(0.1)
            device.emit(*key)
        device.emit_click(uinput.KEY_SPACE)
        time.sleep(0.1)
        sys.stdout.write("': wrap_altgr(click(uinput.KEY_" + chr(i) + ")+click(uinput.KEY_SPACE)),\n")
        sys.stdout.flush() 
开发者ID:JSubelj,项目名称:g910-gkey-macro-support,代码行数:18,代码来源:layout_config_helpers.py

示例2: register_device

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def register_device(keylist):

    return uinput.Device(keylist) 
开发者ID:dillbyrne,项目名称:es-cec-input,代码行数:5,代码来源:es-cec-input.py

示例3: main

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def main():
  #Setup uinput
  events_dpad = (uinput.KEY_UP,uinput.KEY_DOWN,uinput.KEY_LEFT,
                 uinput.KEY_RIGHT,uinput.KEY_ENTER,uinput.KEY_ENTER)
  events_z80 = (uinput.KEY_Q,uinput.KEY_A,uinput.KEY_O,
                uinput.KEY_P,uinput.KEY_M,uinput.KEY_ENTER)
  events=events_z80

  device = uinput.Device(events)
  time.sleep(2) # seconds
  dpad_setup()
  print("DPad Ready!")

  btn_state=[False,False,False,False,False,False]
  key_state=[False,False,False,False,False,False]
  while True:
    #Catch all the buttons pressed before pressing the related keys
    for idx, val in enumerate(BTN):
      if GPIO.input(val) == False:
        btn_state[idx]=True
      else:
        btn_state[idx]=False

    #Perform the button presses/releases
    #(but only change state once)
    for idx, val in enumerate(btn_state):
      if val == True and key_state[idx] == False:
        if DEBUG:print (str(val) + ":" + MSG[idx])
        device.emit(events[idx], 1) # Press.
        key_state[idx]=True
      elif val == False and key_state[idx] == True:
        if DEBUG:print (str(val) + ":!" + MSG[idx])
        device.emit(events[idx], 0) # Release.
        key_state[idx]=False

    time.sleep(.1) 
开发者ID:PacktPublishing,项目名称:Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition,代码行数:38,代码来源:gpiokeys-events.py

示例4: main

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def main():
  #Setup uinput
  events = (uinput.KEY_UP,uinput.KEY_DOWN,uinput.KEY_LEFT,
            uinput.KEY_RIGHT,uinput.KEY_ENTER,uinput.KEY_ENTER)
  device = uinput.Device(events)
  time.sleep(2) # seconds
  dpad_setup()
  print("DPad Ready!")

  btn_state=[False,False,False,False,False,False]
  key_state=[False,False,False,False,False,False]
  while True:
    #Catch all the buttons pressed before pressing the related keys
    for idx, val in enumerate(BTN):
      if GPIO.input(val) == False:
        btn_state[idx]=True
      else:
        btn_state[idx]=False

    #Perform the button presses/releases
    #(but only change state once)
    for idx, val in enumerate(btn_state):
      if val == True and key_state[idx] == False:
        if DEBUG:print (str(val) + ":" + MSG[idx])
        device.emit(events[idx], 1) # Press.
        key_state[idx]=True
      elif val == False and key_state[idx] == True:
        if DEBUG:print (str(val) + ":!" + MSG[idx])
        device.emit(events[idx], 0) # Release.
        key_state[idx]=False

    time.sleep(.1) 
开发者ID:PacktPublishing,项目名称:Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition,代码行数:34,代码来源:gpiokeys.py

示例5: main

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def main():
  #Setup uinput
  events_mouse=(uinput.REL_Y,uinput.REL_Y, uinput.REL_X,
                uinput.REL_X,uinput.BTN_LEFT,uinput.BTN_RIGHT)
  events = events_mouse
  device = uinput.Device(events)
  time.sleep(2) # seconds
  dpad_setup()
  print("DPad Ready!")

  btn_state=[False,False,False,False,False,False]
  key_state=[False,False,False,False,False,False]
  while True:
    #Catch all the buttons pressed before pressing the related keys
    for idx, val in enumerate(BTN):
      if GPIO.input(val) == False:
        btn_state[idx]=True
      else:
        btn_state[idx]=False

    #Perform the button presses/releases
    #(but only change state once)
    for idx, val in enumerate(btn_state):
      if MSG[idx] == "M_UP" or MSG[idx] == "M_LEFT":
        state = -1
      else:
        state = 1
      if val == True:
        device.emit(events[idx], state) # Press.
      elif val == False:
        device.emit(events[idx], 0) # Release.

    time.sleep(0.01) 
开发者ID:PacktPublishing,项目名称:Raspberry-Pi-3-Cookbook-for-Python-Programmers-Third-Edition,代码行数:35,代码来源:gpiokeys-mouse.py

示例6: get_shift_keys

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def get_shift_keys():
    import sys
    import time
    time.sleep(5)
    device = uinput.Device(uinput_all_keys.uinput_all_keys)
    for i in range(48, 58):
        sys.stdout.write("'")
        sys.stdout.flush()

        for key in wrap_shift(click(getattr(uinput, "KEY_" + chr(i)))):
            time.sleep(0.1)
            device.emit(*key)
        sys.stdout.write("': wrap_shift(click(uinput.KEY_" + chr(i) + ")),\n")
        sys.stdout.flush() 
开发者ID:JSubelj,项目名称:g910-gkey-macro-support,代码行数:16,代码来源:layout_config_helpers.py

示例7: test

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def test():
    import sys
    import time

    device = uinput.Device(uinput_all_keys.uinput_all_keys)
    time.sleep(4)
    events = keys['en']
    for key, event in events.items():
        sys.stdout.write("'"+key+"'=='")
        sys.stdout.flush()
        time.sleep(0.1)
        execute_events(event,device)
        time.sleep(0.1)
        sys.stdout.write("'\n") 
开发者ID:JSubelj,项目名称:g910-gkey-macro-support,代码行数:16,代码来源:layout_config_helpers.py

示例8: init_uinput_device

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def init_uinput_device():
    device = uinput.Device(uinput_all_keys.uinput_all_keys)
    log.debug("got uinput device: " + str(device))
    return device 
开发者ID:JSubelj,项目名称:g910-gkey-macro-support,代码行数:6,代码来源:usb_and_keyboard_device_init.py

示例9: read_and_emulate_mouse

# 需要导入模块: import uinput [as 别名]
# 或者: from uinput import Device [as 别名]
def read_and_emulate_mouse(deviceFound):
    with open(deviceFound, 'rb') as f:
        print("Read buffer")

        device = uinput.Device([
            uinput.BTN_LEFT,
            uinput.BTN_RIGHT,
            uinput.ABS_X,
            uinput.ABS_Y,
        ])
        cal_data = read_pointercal_calib_file()
        
        clicked = False
        rightClicked = False
        (lastX, lastY) = (0, 0)
        startTime = time.time()

        while True:
            try:
                b = f.read(22)
                (tag, btnLeft, x, y) = struct.unpack_from('>c?HH', b)
                print(btnLeft, x, y)
            except:
                print('failed to read from deviceFound' + str(deviceFound))
                syslog.syslog(syslog.LOG_WARNING,'TouchDriver: Failed to read from {0}'.format(deviceFound))
                return
            
            time.sleep(0.01)

            if btnLeft:
                # calc real touch point
                dp = display_touch_point(cal_data, [x,y])
                # dp[0] - LCD X , dp[1] - LCD Y
                device.emit(uinput.ABS_X, dp[0], True)
                device.emit(uinput.ABS_Y, dp[1], True)

                if not clicked:
                    print("Left click")
                    device.emit(uinput.BTN_LEFT, 1)
                    clicked = True
                    startTime = time.time()
                    (lastX, lastY) = (x, y)

                duration = time.time() - startTime
                movement = math.sqrt(pow(x - lastX, 2) + pow(y - lastY, 2))

                if clicked and (not rightClicked) and (duration > 1) and (movement < 20):
                    print("Right click")
                    device.emit(uinput.BTN_RIGHT, 1)
                    device.emit(uinput.BTN_RIGHT, 0)
                    rightClicked = True
            else:
                print("Release")
                clicked = False
                rightClicked = False
                device.emit(uinput.BTN_LEFT, 0) 
开发者ID:saper-2,项目名称:rpi-5inch-hdmi-touchscreen-driver,代码行数:58,代码来源:touch.py


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