
Sounds nice - I am looking forward to that.ShiftPlusOne wrote:There's this:
https://python-evdev.readthedocs.org/en/latest/
Also, works is being done on the python-sense-hat library to make using the joystick easier.

Code: Select all
from sense_hat import SenseHat
import time
import random
from stick import SenseStick
sense = SenseHat()
sense.set_rotation(270)
KEY_UP = 103
KEY_LEFT = 105
KEY_RIGHT = 106
KEY_DOWN = 108
KEY_ENTER = 28
stick = SenseStick()
try:
while True:
red = random.randint(0, 255)
green = random.randint(0, 255)
blue = random.randint(0, 255)
x = random.randint(0, 7)
y = random.randint(0, 7)
sense.set_pixel(x, y, [red, green, blue])
x = random.randint(0, 7)
y = random.randint(0, 7)
sense.set_pixel(x, y, [0, 0, 0])
x = random.randint(0, 7)
y = random.randint(0, 7)
sense.set_pixel(x, y, [0, 0, 0])
time.sleep(0.02)
if stick.wait(timeout=0.01)==True:
user_input = stick.read()[1]
if user_input==KEY_LEFT:
print "Left"
elif user_input==KEY_RIGHT:
print "Right"
elif user_input==KEY_UP:
print "Up"
elif user_input==KEY_DOWN:
print "Down"
elif user_input==KEY_ENTER:
print "exiting"
sense.clear()
break
except KeyboardInterrupt:
sense.clear()
print
print ("program stopped")