joysticks working

stable
Penguin 2 years ago
parent 3cb525ca25
commit be14498e11

@ -2,25 +2,45 @@ import time
import zmq
from pyPS4Controller.controller import Controller
ctx = zmq.Context()
socket = ctx.socket(zmq.PUB)
ctrl_x = 1
ctrl_y = 1
class ps4if(Controller):
def __init__(self, **kwargs):
Controller.__init__(self, **kwargs)
def on_x_press(self):
socket.send_string("Hit x")
def on_R3_right(self, value):
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():
# do stuff
print("Hello world")
socket.bind("ipc:///penguinator/pubsub");
controller = ps4if(interface="/dev/input/js0",
connecting_using_ds4drv=False)
controller.debug = False
controller.listen()
while(True):
time.sleep(1)

Loading…
Cancel
Save