(self, layout)
Creates a uinput device using the specified layout.
Creates a uinput device using the specified layout.
Creates a uinput device using the specified layout .
def create_device(self, layout):
        """Creates a uinput device using the specified layout."""
        events = {ecodes.EV_ABS: [], ecodes.EV_KEY: [],
                  ecodes.EV_REL: []}

        # Joystick device
        if layout.axes or layout.buttons or layout.hats:
            self.joystick_dev = next_joystick_device()

        for name in layout.axes:
            params = layout.axes_options.get(name, DEFAULT_AXIS_OPTIONS)
            if not absInfoUsesValue:
                params = params[1:]
            events[ecodes.EV_ABS].append((name, params))

        for name in layout.hats:
            params = (0, -1, 1, 0, 0)
            if not absInfoUsesValue:
                params = params[1:]
            events[ecodes.EV_ABS].append((name, params))

        for name in layout.buttons:
            events[ecodes.EV_KEY].append(name)

        if layout.mouse:
            self.mouse_pos = {}
            self.mouse_rel = {}
            self.mouse_analog_sensitivity = float(
                layout.mouse_options.get("MOUSE_SENSITIVITY",
                                         DEFAULT_MOUSE_SENSITIVTY)
            )
            self.mouse_analog_deadzone = int(
                layout.mouse_options.get("MOUSE_DEADZONE",
                                         DEFAULT_MOUSE_DEADZONE)
            )
            self.scroll_repeat_delay = float(
                layout.mouse_options.get("MOUSE_SCROLL_REPEAT_DELAY",
                                         DEFAULT_SCROLL_REPEAT_DELAY)
            )
            self.scroll_delay = float(
                layout.mouse_options.get("MOUSE_SCROLL_DELAY",
                                         DEFAULT_SCROLL_DELAY)
            )

            for name in layout.mouse:
                if name in (ecodes.REL_WHEELUP, ecodes.REL_WHEELDOWN):
                    if ecodes.REL_WHEEL not in events[ecodes.EV_REL]:
                        # This ensures that scroll wheel events can work
                        events[ecodes.EV_REL].append(ecodes.REL_WHEEL)
                else:
                    events[ecodes.EV_REL].append(name)
                self.mouse_rel[name] = 0.0

        self.device = UInput(name=layout.name, events=events,
                             bustype=layout.bustype, vendor=layout.vendor,
                             product=layout.product, version=layout.version)
        self.layout = layout
def create_device ( self , layout ) : events = { ecodes . EV_ABS : [ ] , ecodes . EV_KEY : [ ] , ecodes . EV_REL : [ ] } # Joystick device if layout . axes or layout . buttons or layout . hats : self . joystick_dev = next_joystick_device ( ) for name in layout . axes : params = layout . axes_options . get ( name , DEFAULT_AXIS_OPTIONS ) if not absInfoUsesValue : params = params [ 1 : ] events [ ecodes . EV_ABS ] . append ( ( name , params ) ) for name in layout . hats : params = ( 0 , - 1 , 1 , 0 , 0 ) if not absInfoUsesValue : params = params [ 1 : ] events [ ecodes . EV_ABS ] . append ( ( name , params ) ) for name in layout . buttons : events [ ecodes . EV_KEY ] . append ( name ) if layout . mouse : self . mouse_pos = { } self . mouse_rel = { } self . mouse_analog_sensitivity = float ( layout . mouse_options . get ( "MOUSE_SENSITIVITY" , DEFAULT_MOUSE_SENSITIVTY ) ) self . mouse_analog_deadzone = int ( layout . mouse_options . get ( "MOUSE_DEADZONE" , DEFAULT_MOUSE_DEADZONE ) ) self . scroll_repeat_delay = float ( layout . mouse_options . get ( "MOUSE_SCROLL_REPEAT_DELAY" , DEFAULT_SCROLL_REPEAT_DELAY ) ) self . scroll_delay = float ( layout . mouse_options . get ( "MOUSE_SCROLL_DELAY" , DEFAULT_SCROLL_DELAY ) ) for name in layout . mouse : if name in ( ecodes . REL_WHEELUP , ecodes . REL_WHEELDOWN ) : if ecodes . REL_WHEEL not in events [ ecodes . EV_REL ] : # This ensures that scroll wheel events can work events [ ecodes . EV_REL ] . append ( ecodes . REL_WHEEL ) else : events [ ecodes . EV_REL ] . append ( name ) self . mouse_rel [ name ] = 0.0 self . device = UInput ( name = layout . name , events = events , bustype = layout . bustype , vendor = layout . vendor , product = layout . product , version = layout . version ) self . layout = layout