Ejemplo n.º 1
0
def _create_joystick(device):
    # Ignore desktop devices that are not joysticks, gamepads or m-a controllers
    if device.usage_page == kHIDPage_GenericDesktop and \
       device.usage not in (kHIDUsage_GD_Joystick,
                            kHIDUsage_GD_GamePad,
                            kHIDUsage_GD_MultiAxisController):
        return

    # Anything else is interesting enough to be a joystick?
    return Joystick(device)
Ejemplo n.º 2
0
def _create_joystick(device):
    # Look for something with an ABS X and ABS Y axis, and a joystick 0 button
    have_x = False
    have_y = False
    have_button = False
    for control in device.controls:
        if control._event_type == EV_ABS and control._event_code == ABS_X:
            have_x = True
        elif control._event_type == EV_ABS and control._event_code == ABS_Y:
            have_y = True
        elif control._event_type == EV_KEY and \
             control._event_code in (BTN_JOYSTICK, BTN_GAMEPAD):
            have_button = True
    if not (have_x and have_y and have_button):
        return

    return Joystick(device)
Ejemplo n.º 3
0
def get_joysticks(display=None):
    return [ Joystick(PygletDevice(display, device, _manager)) for device in _manager.devices
             if device.is_joystick() or device.is_gamepad() or device.is_multi_axis() ]