forked from r0ket/r0ket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add comment expaining what it does. Convert to unix lineends
- Loading branch information
Showing
1 changed file
with
34 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,50 @@ | ||
import r0ketrem0te.game | ||
# | ||
# allows you to control the roketlauncher via the rem0te l0dable | ||
# documented this in the wiki: | ||
# - http://r0ket.badge.events.ccc.de/r0ketlauncher#launch0r | ||
# | ||
import r0ketrem0te.game | ||
import time | ||
import hid | ||
|
||
class Launch0r: | ||
def __init__(self): | ||
self.rem0te = r0ketrem0te.game.Game('/dev/cu.usbmodem411', "Launch0r", 83, 87, [ord(x) for x in 'REM0T'], 1, False) | ||
import hid | ||
|
||
class Launch0r: | ||
def __init__(self): | ||
self.rem0te = r0ketrem0te.game.Game('/dev/cu.usbmodem411', "Launch0r", 83, 87, [ord(x) for x in 'REM0T'], 1, False) | ||
self.rem0te.registerPlayerCallback(self.playercallback) | ||
self.player = Rem0tePlayer(self.rem0te) | ||
|
||
self.player = Rem0tePlayer(self.rem0te) | ||
|
||
def playercallback(self, action, player): | ||
if action == 'added': | ||
if self.player == None: | ||
self.player.player = player | ||
elif action == 'removed': | ||
if action == 'added': | ||
if self.player == None: | ||
self.player.player = player | ||
elif action == 'removed': | ||
self.player = None | ||
|
||
def run(self): | ||
|
||
def run(self): | ||
self.player.launcher = hid.device(0x0a81, 0x0701) | ||
self.player.launcher.set_nonblocking(1) | ||
self.player.launcher.set_nonblocking(1) | ||
|
||
class Rem0tePlayer(object): | ||
def __init__(self, rem0te): | ||
self.rem0te = rem0te | ||
self.rem0te.bridge.registerCallback(self.receivedPacket) | ||
class Rem0tePlayer(object): | ||
def __init__(self, rem0te): | ||
self.rem0te = rem0te | ||
self.rem0te.bridge.registerCallback(self.receivedPacket) | ||
self.player = None | ||
self.launcher = None | ||
|
||
self.launcher = None | ||
|
||
def receivedPacket(self, packet): | ||
if packet.button == 0:#off | ||
self.launcher.write([0x20, 0, 0]) | ||
if packet.button == 4:#left | ||
self.launcher.write([0x04, 0, 0]) | ||
if packet.button == 8:#right | ||
if packet.button == 8:#right | ||
self.launcher.write([0x08, 0, 0]) | ||
if packet.button == 1:#up | ||
if packet.button == 1:#up | ||
self.launcher.write([0x02, 0, 0]) | ||
if packet.button == 2:#down | ||
if packet.button == 2:#down | ||
self.launcher.write([0x01, 0, 0]) | ||
if packet.button == 16:#fire | ||
if packet.button == 16:#fire | ||
self.launcher.write([0x10, 0, 0]) | ||
|
||
if __name__ == '__main__': | ||
launch0r = Launch0r() | ||
launch0r.run() | ||
|
||
if __name__ == '__main__': | ||
launch0r = Launch0r() | ||
launch0r.run() |