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


Python ecodes.EV_ABS属性代码示例

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


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

示例1: __init__

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_ABS [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: defineAxis

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_ABS [as 别名]
def defineAxis( self, direction, dpad, deviceName, offset = 0 ):
		cmdName = '{0} {1}'.format( direction, dpad + 1 )
		colorDirection = pcolor( 'cyan', direction )
		colorDpad = pcolor( 'fuschia', dpad + 1 )
		print( 'Hold {0} on Dpad/Joystick {1}'.format( colorDirection, colorDpad), end = ' ')
		sys.stdout.flush()
		pressed =  self.wait_for_pin()
		pressed = ', '.join( map(str, pressed) )
		print( '- Pin(s):', pressed )
		self.waitForButtonRelease()
		if direction in ["DOWN", "RIGHT"]:
			value = JOYSTICK_AXIS.max
		else:
			value = JOYSTICK_AXIS.min
		command = '(e.EV_ABS, {0}, {1})'.format( dpad * 2 + offset, value )
		return deviceName, cmdName, 'AXIS', command, pressed 
开发者ID:mholgatem,项目名称:GPIOnext,代码行数:18,代码来源:config_manager.py

示例3: signal

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_ABS [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

示例4: read_events

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_ABS [as 别名]
def read_events(self, device):
        for event in device.read():
            if event.type == ecodes.EV_ABS:
                if event.code == ecodes.ABS_X:
                    if self.emulation_mode != 'G29':
                        value = event.value * 4
                    else:
                        value = event.value
                    self.ui.set_steering_input(value)
                elif event.code == ecodes.ABS_Y:
                    if self.emulation_mode == 'DFGT' or self.emulation_mode == 'DFP':
                        self.ui.set_accelerator_input(event.value)
                    else:
                        self.ui.set_clutch_input(event.value)
                elif event.code == ecodes.ABS_Z:
                    if self.emulation_mode == 'DFGT' or self.emulation_mode == 'DFP':
                        self.ui.set_brakes_input(event.value)
                    else:
                        self.ui.set_accelerator_input(event.value)
                elif event.code == ecodes.ABS_RZ:
                    self.ui.set_brakes_input(event.value)
                elif event.code == ecodes.ABS_HAT0X:
                    self.ui.set_hatx_input(event.value)
                    if event.value == -1:
                        self.on_button_press(100, 1)
                    elif event.value == 1:
                        self.on_button_press(101, 1)
                elif event.code == ecodes.ABS_HAT0Y:
                    self.ui.set_haty_input(event.value)
                    if event.value == -1:
                        self.on_button_press(102, 1)
                    elif event.value == 1:
                        self.on_button_press(103, 1)
            if event.type == ecodes.EV_KEY:
                if event.value:
                    delay = 0
                else:
                    delay = 100
                if event.code >= 288 and event.code <= 303:
                    button = event.code - 288
                if event.code >= 704 and event.code <= 712:
                    button = event.code - 688
                self.ui.set_btn_input(button, event.value, delay)
                self.on_button_press(button, event.value) 
开发者ID:berarma,项目名称:oversteer,代码行数:46,代码来源:gui.py

示例5: handle_event

# 需要导入模块: from evdev import ecodes [as 别名]
# 或者: from evdev.ecodes import EV_ABS [as 别名]
def handle_event(device, myMQTTClient):
    async for event in device.async_read_loop():
        for num, joystick in enumerate(joysticks):
            if joystick['device']==device:
                jsindex = num
        categorized = categorize(event)
        if event.type == ecodes.EV_KEY:
            logging.debug(f'button push {joysticks[jsindex]["color"]} {joysticks[jsindex]["path"]}: {categorized.keycode}, {categorized.keystate}')
            logging.info(f'move {joysticks[jsindex]["move"]} locked {joysticks[jsindex]["movelocked"]}')
            if (categorized.keycode[0] == KEY_JOYSTICK or categorized.keycode[0]
                == KEY_BTNA) and categorized.keystate == 1 and not (
                joysticks[jsindex]['move'] == '') and not (
                joysticks[jsindex]['movelocked'] == True):
                #submit move if there is one
                logging.debug(f'move submitted for {joysticks[jsindex]["color"]}, {joysticks[jsindex]["device"]}:{joysticks[jsindex]["move"]}')
                joysticks[jsindex]['movelocked']=True
                message = {}
                message['joystick']=joysticks[jsindex]['color']
                message['move']=joysticks[jsindex]['move']
                jsonmsg = json.dumps(message)
                topic = joysticks[jsindex]['movetopic']
                myMQTTClient.publish(topic, jsonmsg, 0)
                logging.info(f'posted move {jsonmsg}')
                await setLightStatus(jsindex, MOVE_LOCKED)
            elif (categorized.keycode==KEY_THUMB or categorized.keycode==KEY_TL2
                ) and categorized.keystate==1:
                #for debugging, clear move
                joysticks[jsindex]['move'] = ''
                joysticks[jsindex]['movelocked']=False
                await setLightStatus(jsindex, READY_FOR_MOVES)
                logging.info(f'{joysticks[jsindex]["color"]} {joysticks[jsindex]["path"]} unlocked')
                logging.info(f'{joysticks}')
        elif event.type == ecodes.EV_ABS and joysticks[jsindex]['movelocked']==False and (
            event.value == ABS_LEFT or event.value==ABS_RIGHT):
            logging.debug(f'joystick move {joysticks[jsindex]["move"]} {joysticks[jsindex]["path"]} value: {event.value} {event}')
            if event.code == ABS_X:
                if event.value == ABS_RIGHT:
                    joysticks[jsindex]['move'] = MOVE_RIGHT
                    logging.info(f'{joysticks[jsindex]["color"]} {joysticks[jsindex]["path"]} right')
                elif event.value == ABS_LEFT:
                    joysticks[jsindex]['move'] = MOVE_LEFT
                    logging.info(f'{joysticks[jsindex]["color"]} {joysticks[jsindex]["path"]} left')
            elif event.code == ABS_Y:
                if event.value == ABS_UP:
                    joysticks[jsindex]['move'] = MOVE_FORWARD
                    logging.info(f'{joysticks[jsindex]["color"]} {joysticks[jsindex]["path"]} forward') 
开发者ID:aws-samples,项目名称:aws-builders-fair-projects,代码行数:48,代码来源:joy.py


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