Skip to content

OldTechDreamer/Joystick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Joystick

Python/Linux Joystick / Game controller reader

Requirements

  • Linux
  • Python 3 (or python 2 (not tested))

Example

from Joystick import Joystick

def OnEvent(time, value, type, number):
	# Handel joystick event with:
	# time = Event timestamp in milliseconds
	# value = Value of joystick (+ and -)
	# type = Type of Joystick (1 = button, 2 = stick, 3 = initial state)
	# number = Axis (0 = X1, 1 = Y1, 2 = X2, 3 = Y2, etc...)

joystick = Joystick("/dev/input/js0")	# Create the instance (path to linux joystick device js0, js1, js2, etc...)
joystick.Open()			# Open it
joystick.AddListener(OnEvent)	# Listen for events

#### Rest of your program here ####

joystick.Close()		# Close it

About

Python/Linux Joystick / Game controller reader

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages