|
|
@ -2,25 +2,45 @@ import time
|
|
|
|
import zmq
|
|
|
|
import zmq
|
|
|
|
from pyPS4Controller.controller import Controller
|
|
|
|
from pyPS4Controller.controller import Controller
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ctx = zmq.Context()
|
|
|
|
ctx = zmq.Context()
|
|
|
|
socket = ctx.socket(zmq.PUB)
|
|
|
|
socket = ctx.socket(zmq.PUB)
|
|
|
|
|
|
|
|
ctrl_x = 1
|
|
|
|
|
|
|
|
ctrl_y = 1
|
|
|
|
class ps4if(Controller):
|
|
|
|
class ps4if(Controller):
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
Controller.__init__(self, **kwargs)
|
|
|
|
Controller.__init__(self, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def on_x_press(self):
|
|
|
|
def on_R3_right(self, value):
|
|
|
|
socket.send_string("Hit x")
|
|
|
|
global ctrl_x
|
|
|
|
|
|
|
|
ctrl_x = value
|
|
|
|
|
|
|
|
socket.send_string(("X:%d Y:%d" % (ctrl_x, ctrl_y)))
|
|
|
|
|
|
|
|
def on_R3_left(self, value):
|
|
|
|
|
|
|
|
global ctrl_x
|
|
|
|
|
|
|
|
ctrl_x = value
|
|
|
|
|
|
|
|
socket.send_string(("X:%d Y:%d" % (ctrl_x, ctrl_y)))
|
|
|
|
|
|
|
|
def on_R3_up(self, value):
|
|
|
|
|
|
|
|
global ctrl_y
|
|
|
|
|
|
|
|
ctrl_y = value
|
|
|
|
|
|
|
|
socket.send_string(("X:%d Y:%d" % (ctrl_x, ctrl_y)))
|
|
|
|
|
|
|
|
def on_R3_down(self, value):
|
|
|
|
|
|
|
|
global ctrl_y
|
|
|
|
|
|
|
|
ctrl_y = value
|
|
|
|
|
|
|
|
socket.send_string(("X:%d Y:%d" % (ctrl_x, ctrl_y)))
|
|
|
|
|
|
|
|
def on_R3_x_at_rest(self):
|
|
|
|
|
|
|
|
global ctrl_x
|
|
|
|
|
|
|
|
ctrl_x = 0
|
|
|
|
|
|
|
|
socket.send_string(("X:%d Y:%d" % (ctrl_x, ctrl_y)))
|
|
|
|
|
|
|
|
def on_R3_y_at_rest(self):
|
|
|
|
|
|
|
|
global ctrl_y
|
|
|
|
|
|
|
|
ctrl_y = 0
|
|
|
|
|
|
|
|
socket.send_string(("X:%d Y:%d" % (ctrl_x, ctrl_y)))
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|
# do stuff
|
|
|
|
|
|
|
|
print("Hello world")
|
|
|
|
|
|
|
|
socket.bind("ipc:///penguinator/pubsub");
|
|
|
|
socket.bind("ipc:///penguinator/pubsub");
|
|
|
|
|
|
|
|
|
|
|
|
controller = ps4if(interface="/dev/input/js0",
|
|
|
|
controller = ps4if(interface="/dev/input/js0",
|
|
|
|
connecting_using_ds4drv=False)
|
|
|
|
connecting_using_ds4drv=False)
|
|
|
|
|
|
|
|
controller.debug = False
|
|
|
|
controller.listen()
|
|
|
|
controller.listen()
|
|
|
|
while(True):
|
|
|
|
while(True):
|
|
|
|
time.sleep(1)
|
|
|
|
time.sleep(1)
|
|
|
|