Example #1
0
 def run(self):
     evm = evminit()
     sc = SteamController(callback=evm.process)
     sc.run()
     del sc
     del evm
     gc.collect()
Example #2
0
def _main():

    try:
        sc = SteamController(callback=dump)
        sc.handleEvents()
        sc._sendControl(struct.pack('>' + 'I' * 1, 0x81000000))
        sc._sendControl(struct.pack('>' + 'I' * 6, 0x87153284, 0x03180000, 0x31020008, 0x07000707, 0x00301400, 0x2f010000))

        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xad020000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xad020000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xad020000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0x8e000000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0x85000000))

        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xb4000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x9610730b, 0xc7191248, 0x074eff14, 0x464e82d6, 0xaa960000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x9610e0b5, 0xda3a1e90, 0x5b325088, 0x0a6224d2, 0x67690000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x96107ef6, 0x0e193e8c, 0xe61d2eda, 0xb80906eb, 0x9fe90000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x96106e4a, 0xa4753ef0, 0x017ab50a, 0x24390f1f, 0x71fa0000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0x83000000))

       #sc._sendControl(struct.pack('>' + 'I' * 6, 0xae150100, 0x00000001, 0x02110000, 0x02030000, 0x000a6d92, 0xd2550400))
        sc.run()

    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write(str(e) + '\n')

    print("Bye")
Example #3
0
    def _main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument('command',
                            type=str,
                            choices=['start', 'stop', 'restart', 'debug'])
        parser.add_argument('-i',
                            '--index',
                            type=int,
                            choices=[0, 1, 2, 3],
                            default=None)
        args = parser.parse_args()
        if args.index != None:
            daemon = SCDaemon('/tmp/steamcontroller{:d}.pid'.format(
                args.index))
        else:
            daemon = SCDaemon('/tmp/steamcontroller.pid')

        if 'start' == args.command:
            daemon.start()
        elif 'stop' == args.command:
            daemon.stop()
        elif 'restart' == args.command:
            daemon.restart()
        elif 'debug' == args.command:
            try:
                evm = evminit()
                sc = SteamController(callback=evm.process)
                sc.run()

            except KeyboardInterrupt:
                pass
Example #4
0
 def run(self):
     evm = evminit()
     sc = SteamController(callback=evm.process)
     sc.run()
     del sc
     del evm
     gc.collect()
Example #5
0
File: sc.py Project: rorik/UBUBOT
 def run(self):
     if self.lock is not None:
         self.lock.start()
     dm_evm = evminit()
     dm_sc = SteamController(callback=dm_evm.process)
     dm_sc.run()
     del dm_sc
     del dm_evm
     gc.collect()
Example #6
0
 def run(self):
     while True:
         try:
             xb = steamcontroller.uinput.Xbox360()
             sc = SteamController(callback=scInput2Uinput, callback_args=[xb, ])
             sc.run()
         except KeyboardInterrupt:
             return
         except:
             pass
Example #7
0
def _main():

    try:
        sc = SteamController(callback=dump)
        sc.run()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write(str(e) + '\n')

    print("Bye")
Example #8
0
def _main():

    try:
        sc = SteamController(callback=dump)
        sc.run()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write(str(e) + '\n')

    print("Bye")
Example #9
0
def _main():

    try:
        sc = SteamController(callback=dump)
        for line in sys.stdin:
            sc.handleEvents()
            words = [int('0x' + x, 16) for x in  line.split()]
            sc._sendControl(struct.pack('>' + 'I' * len(words), *words))
        sc.run()

    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write(str(e) + '\n')

    print("Bye")
Example #10
0
    def _main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument('command', type=str, choices=['start', 'stop', 'restart', 'debug'])
        args = parser.parse_args()
        daemon = SCDaemon('/tmp/steamcontroller.pid')

        if 'start' == args.command:
            daemon.start()
        elif 'stop' == args.command:
            daemon.stop()
        elif 'restart' == args.command:
            daemon.restart()
        elif 'debug' == args.command:
            xb = steamcontroller.uinput.Xbox360()
            sc = SteamController(callback=scInput2Uinput, callback_args=[xb, ])
            sc.run()
Example #11
0
def _main():

    try:
        sc = SteamController(callback=dump)
        for line in sys.stdin:
            sc.handleEvents()
            words = [int('0x' + x, 16) for x in line.split()]
            sc._sendControl(struct.pack('>' + 'I' * len(words), *words))
        sc.run()

    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write(str(e) + '\n')

    print("Bye")
Example #12
0
    def _main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument('command', type=str, choices=['start', 'stop', 'restart', 'debug'])
        args = parser.parse_args()
        daemon = SCDaemon('/tmp/steamcontroller.pid')

        if 'start' == args.command:
            daemon.start()
        elif 'stop' == args.command:
            daemon.stop()
        elif 'restart' == args.command:
            daemon.restart()
        elif 'debug' == args.command:
            try:
                evm = evminit()
                sc = SteamController(callback=evm.process)
                sc.run()
            except KeyboardInterrupt:
                return
Example #13
0
    def _main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument("command", type=str, choices=["start", "stop", "restart", "debug"])
        args = parser.parse_args()
        daemon = SCDaemon("/tmp/steamcontroller.pid")

        if "start" == args.command:
            daemon.start()
        elif "stop" == args.command:
            daemon.stop()
        elif "restart" == args.command:
            daemon.restart()
        elif "debug" == args.command:
            try:
                evm = evminit()
                sc = SteamController(callback=evm.process)
                sc.run()
            except KeyboardInterrupt:
                return
Example #14
0
    def _main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument('command',
                            type=str,
                            choices=['start', 'stop', 'restart', 'debug'])
        args = parser.parse_args()
        daemon = SCDaemon('/tmp/steamcontroller.pid')

        if 'start' == args.command:
            daemon.start()
        elif 'stop' == args.command:
            daemon.stop()
        elif 'restart' == args.command:
            daemon.restart()
        elif 'debug' == args.command:
            try:
                evm = evminit()
                sc = SteamController(callback=evm.process)
                sc.run()
            except KeyboardInterrupt:
                return
Example #15
0
    def _main():
        parser = argparse.ArgumentParser(description=__doc__)
        parser.add_argument('command', type=str, choices=['start', 'stop', 'restart', 'debug'])
        parser.add_argument('-i', '--index', type=int, choices=[0,1,2,3], default=None)
        args = parser.parse_args()
        if args.index != None:
            daemon = SCDaemon('/tmp/steamcontroller{:d}.pid'.format(args.index))
        else:
            daemon = SCDaemon('/tmp/steamcontroller.pid')

        if 'start' == args.command:
            daemon.start()
        elif 'stop' == args.command:
            daemon.stop()
        elif 'restart' == args.command:
            daemon.restart()
        elif 'debug' == args.command:
            try:
                evm = evminit()
                sc = SteamController(callback=evm.process)
                sc.run()
            except KeyboardInterrupt:
                return
Example #16
0
def _main():

    try:
        sc = SteamController(callback=dump)
        sc.handleEvents()
        sc._sendControl(struct.pack('>' + 'I' * 1, 0x81000000))
        sc._sendControl(
            struct.pack('>' + 'I' * 6, 0x87153284, 0x03180000, 0x31020008,
                        0x07000707, 0x00301400, 0x2f010000))

        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xad020000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xad020000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xad020000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0x8e000000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0x85000000))

        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xb4000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x9610730b, 0xc7191248, 0x074eff14, 0x464e82d6, 0xaa960000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x9610e0b5, 0xda3a1e90, 0x5b325088, 0x0a6224d2, 0x67690000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x96107ef6, 0x0e193e8c, 0xe61d2eda, 0xb80906eb, 0x9fe90000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0xa1000000))
        #sc._sendControl(struct.pack('>' + 'I' * 5, 0x96106e4a, 0xa4753ef0, 0x017ab50a, 0x24390f1f, 0x71fa0000))
        #sc._sendControl(struct.pack('>' + 'I' * 1, 0x83000000))

        #sc._sendControl(struct.pack('>' + 'I' * 6, 0xae150100, 0x00000001, 0x02110000, 0x02030000, 0x000a6d92, 0xd2550400))
        sc.run()

    except KeyboardInterrupt:
        pass
    except Exception as e:
        sys.stderr.write(str(e) + '\n')

    print("Bye")
Example #17
0
 def run(self):
     evm = evminit()
     sc = SteamController(callback=evm.process)
     sc.run()
Example #18
0

def evminit():
    evm = EventMapper()
    evm.setButtonCallback(SCButtons.STEAM, steam_pressed)
    evm.setButtonCallback(SCButtons.A, a_pressed)
    evm.setButtonCallback(SCButtons.B, b_pressed)
    evm.setButtonCallback(SCButtons.X, x_pressed)
    evm.setButtonCallback(SCButtons.Y, y_pressed)
    evm.setButtonCallback(SCButtons.LB, bumper_pressed)
    evm.setButtonCallback(SCButtons.RB, bumper_pressed)
    evm.setButtonCallback(SCButtons.LGRIP, grip_pressed)
    evm.setButtonCallback(SCButtons.RGRIP, grip_pressed)
    evm.setButtonCallback(SCButtons.START, start_pressed)
    evm.setButtonCallback(SCButtons.BACK, back_pressed)
    evm.setPadButtonCallback(Pos.LEFT, pad_axes)
    evm.setPadButtonCallback(Pos.RIGHT, pad_axes)
    evm.setPadButtonCallback(Pos.LEFT, pad_pressed, clicked=True)
    evm.setPadButtonCallback(Pos.RIGHT, pad_pressed, clicked=True)
    evm.setStickAxesCallback(stick_axes)
    evm.setStickPressedCallback(stick_pressed)
    evm.setTrigAxesCallback(Pos.RIGHT, trig_axes)
    evm.setTrigAxesCallback(Pos.LEFT, trig_axes)
    return evm


if __name__ == '__main__':
    evm = evminit()
    sc = SteamController(callback=evm.process)
    sc.run()
Example #19
0
 def run(self):
     evm = evminit()
     sc = SteamController(callback=evm.process)
     sc.run()
Example #20
0
def joythread():
    sc = SteamController(callback=joyParse)
    sc.run()
Example #21
0
class SCThread(QtCore.QThread):
    def __init__(self, buttons=None, stick_deadzone=0.1):
        super(SCThread, self).__init__()

        self.stick_deadzone = stick_deadzone
        self._stick_lock = False

        evm = EventMapper()
        evm.setPadButtonCallback(Pos.LEFT, self.padtouch)
        evm.setPadButtonCallback(Pos.RIGHT, self.padtouch)
        evm.setStickAxesCallback(self.stick_axes)

        evm.setFirstPadTouchCallback(Pos.LEFT, self.first_padtouch)
        evm.setFirstPadTouchCallback(Pos.RIGHT, self.first_padtouch)

        evm.setGyroCallback(self.gyro)

        if buttons is None:
            buttons = (
                SCButtons.STEAM,
                SCButtons.A,
                SCButtons.B,
                SCButtons.X,
                SCButtons.Y,
                SCButtons.LT,
                SCButtons.RT,
                SCButtons.LB,
                SCButtons.RB,
                SCButtons.LGRIP,
                SCButtons.RGRIP,
                SCButtons.START,
                SCButtons.BACK
            )

        for btn in buttons:
            evm.setButtonCallback(btn, self.button_press)

        self.sc = SteamController(callback=evm.process)
        self.sc.handleEvents()
        self.sc._sendControl(struct.pack('>' + 'I' * 6,
                                    0x87153284,
                                    0x03180000,
                                    0x31020008,
                                    0x07000707,
                                    0x00301400,
                                    0x2f010000))

    def gyro(self, pitch, yaw, roll):
        self.emit(GYRO, pitch, yaw, roll)

    def stick_axes(self, evm, x, y):
        if (x**2 + y**2) < 2**30 * self.stick_deadzone:
            self._stick_lock = False
            return

        if self._stick_lock:
            return

        rads = math.atan2(x, y)
        degrees = (rads if rads > 0 else rads + 2 * math.pi) * 360 / (2 * math.pi)

        btn = _degrees_to_btn(degrees)
        if btn is None:
            return

        self.emit(BUTTON, btn, True)
        self._stick_lock = True

    def button_press(self, evm, btn, pressed):
        self.emit(BUTTON, btn, pressed)

    def padtouch(self, evm, pad, x, y):
        signal = PAD_TOUCH_LEFT if pad == Pos.LEFT else PAD_TOUCH_RIGHT
        self.emit(signal, x, y)

    def first_padtouch(self, pad, x, y):
        signal = FIRST_PAD_TOUCH_LEFT if pad == Pos.LEFT else FIRST_PAD_TOUCH_RIGHT
        self.emit(signal, x, y)

    def run(self):
        self.sc.run()

    def haptic_feedback_pad(self, pos, amplitude, **kwargs):
        self.sc.addFeedback(pos, amplitude=amplitude, **kwargs)
Example #22
0
def evminit():
    evm = EventMapper()
    evm.setButtonCallback(SCButtons.STEAM, button_pressed_callback)
    evm.setButtonCallback(SCButtons.A, button_pressed_callback)
    evm.setButtonCallback(SCButtons.B, button_pressed_callback)
    evm.setButtonCallback(SCButtons.X, button_pressed_callback)
    evm.setButtonCallback(SCButtons.Y, button_pressed_callback)
    evm.setButtonCallback(SCButtons.LB, button_pressed_callback)
    evm.setButtonCallback(SCButtons.RB, button_pressed_callback)
    evm.setButtonCallback(SCButtons.LT, button_pressed_callback)
    evm.setButtonCallback(SCButtons.RT, button_pressed_callback)
    evm.setButtonCallback(SCButtons.LGRIP, button_pressed_callback)
    evm.setButtonCallback(SCButtons.RGRIP, button_pressed_callback)
    evm.setButtonCallback(SCButtons.START, button_pressed_callback)
    evm.setButtonCallback(SCButtons.BACK, button_pressed_callback)
    evm.setPadButtonCallback(Pos.LEFT, touchpad_touch_callback)
    evm.setPadButtonCallback(Pos.RIGHT, touchpad_click_callback, clicked=True)
    evm.setStickAxesCallback(stick_axes_callback)
    evm.setStickPressedCallback(stick_pressed_callback)
    evm.setTrigAxesCallback(Pos.RIGHT, tigger_axes_callback)
    evm.setTrigAxesCallback(Pos.LEFT, tigger_axes_callback)
    return evm


if __name__ == '__main__':
    evm = evminit()
    sc = SteamController(callback=evm.process)
    sc.run()