Esempio n. 1
0
    def __init__(self,
                 profile,
                 keyboard=b"SCController Keyboard",
                 mouse=b"SCController Mouse",
                 gamepad=b"Microsoft X-Box 360 pad"):
        """
		If any of keyboard, mouse or gamepad is set to None, that device
		will not be emulated.
		"""
        self.profile = profile
        self.controller = None
        self.xdisplay = None

        # Create virtual devices
        log.debug("Creating virtual devices")
        self.keyboard = Keyboard(name=keyboard) if keyboard else Dummy()
        log.debug("Keyboard: %s" % (self.keyboard, ))
        self.mouse = Mouse(name=mouse) if mouse else Dummy()
        log.debug("Mouse:    %s" % (self.mouse, ))
        self.gamepad = Gamepad(name=gamepad) if gamepad else Dummy()
        log.debug("Gamepad:  %s" % (self.gamepad, ))

        self.mouse.updateParams(friction=Mouse.DEFAULT_FRICTION,
                                xscale=Mouse.DEFAULT_XSCALE,
                                yscale=Mouse.DEFAULT_YSCALE)
        self.mouse.updateScrollParams(
            friction=0.1,  # Mouse.DEFAULT_SCR_FRICTION
            xscale=Mouse.DEFAULT_SCR_XSCALE,
            yscale=Mouse.DEFAULT_SCR_XSCALE)

        # Set by SCCDaemon instance; Used to handle actions
        # from scc.special_actions
        self._sa_handler = None

        # Setup emulation
        self.keypress_list = []
        self.keyrelease_list = []
        self.mouse_dq = [
            deque(maxlen=8),
            deque(maxlen=8),
            deque(maxlen=8),
            deque(maxlen=8)
        ]  # x, y, wheel, hwheel
        self.mouse_tb = [False, False]  # trackball mode for mouse / wheel
        self.mouse_feedback = [None, None]  # for mouse / wheel
        self.travelled = [
            0, 0
        ]  # for mouse / wheel, used when generating "rolling ball" feedback
        self.syn_list = set()
        self.scheduled_tasks = []
        self.buttons, self.old_buttons = 0, 0
        self.state, self.old_state = SCI_NULL, SCI_NULL
        self.mouse_movements = [None, None, None, None]
        self.force_event = set()
Esempio n. 2
0
    def __init__(self,
                 profile,
                 keyboard=b"SCController Keyboard",
                 mouse=b"SCController Mouse",
                 gamepad=True,
                 poller=None):
        """
		If any of keyboard, mouse or gamepad is set to None, that device
		will not be emulated.
		Emulated gamepad will have rumble enabled only if poller is set to
		instance and configuration allows it.
		"""
        self.profile = profile
        self.controller = None
        self.xdisplay = None

        # Create virtual devices
        log.debug("Creating virtual devices")
        self.keyboard = Keyboard(name=keyboard) if keyboard else Dummy()
        log.debug("Keyboard: %s" % (self.keyboard, ))
        self.mouse = Mouse(name=mouse) if mouse else Dummy()
        log.debug("Mouse:    %s" % (self.mouse, ))
        self.gamepad = self._create_gamepad(gamepad,
                                            poller) if gamepad else Dummy()
        log.debug("Gamepad:  %s" % (self.gamepad, ))

        # Set by SCCDaemon instance; Used to handle actions
        # from scc.special_actions
        self._sa_handler = None

        # Setup emulation
        self.keypress_list = []
        self.keyrelease_list = []
        self.mouse_movements = [0, 0, 0,
                                0]  # mouse x, y, wheel vertical, horisontal
        self.feedbacks = [None, None]  # left, right
        self.pressed = {
        }  # for ButtonAction, holds number of times virtual button was pressed without releasing it first
        self.syn_list = set()
        self.scheduled_tasks = []
        self.buttons, self.old_buttons = 0, 0
        self.lpad_touched = False
        self.state, self.old_state = None, None
        self.force_event = set()
Esempio n. 3
0
 def create_keyboard(self, name):
     return Keyboard(name=name)