Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- from __future__ import print_function
- import threading
- import time
- import socket
- import queue
- import pygame
- #from pygame import joystick, event
- j = pygame.joystick.Joystick(0)
- UDP_IP = "127.0.0.1"
- UDP_PORT = 5005
- KEEPAMSG = "Otherdata 12"
- XNAME = "xpos"
- YNAME = "ypos"
- STICKX
- STICK
- pygame.init()
- # joystick.init()
- q = queue.Queue()
- sock = socket.socket(socket.AF_INET, # Internet
- socket.SOCK_DGRAM) # UDP
- j = pygame.joystick.Joystick(0)
- j.init()
- print("Initialized Joystick :" + j.get_name())
- class Keepalive(threading.Thread):
- def run(self):
- if q.Empty():
- q.put(KEEPAMSG)
- time.sleep(1)
- class JoystickPoll(threading.Thread):
- def run(self):
- # TBD
- class UDPsend(threading.Thread):
- def run(self):
- sock.sendto(q.get(True), (UDP_IP, UDP_PORT))
- UDPsend.start()
- JoystickPoll.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement