def _create_control(fileno, event_type, event_code):
    if event_type == EV_ABS:
        raw_name = _abs_raw_names.get(event_code, 'EV_ABS(%x)' % event_code)
        name = _abs_names.get(event_code)
        absinfo = EVIOCGABS(fileno, event_code)
        value = absinfo.value
        min = absinfo.minimum
        max = absinfo.maximum
        control = AbsoluteAxis(name, min, max, raw_name)
        control._set_value(value)

        if name == 'hat_y':
            control.inverted = True
    elif event_type == EV_REL:
        raw_name = _rel_raw_names.get(event_code, 'EV_REL(%x)' % event_code)
        name = _rel_names.get(event_code)
        # TODO min/max?
        control = RelativeAxis(name, raw_name)
    elif event_type == EV_KEY:
        raw_name = _key_raw_names.get(event_code, 'EV_KEY(%x)' % event_code)
        name = None
        control = Button(name, raw_name)
    else:
        value = min = max = 0 # TODO
        return None
    control._event_type = event_type
    control._event_code = event_code
    return control
dataset/ETHPy150Open ardekantur/pyglet/pyglet/input/evdev.py/_create_control/original