pyglet.input
¶Joystick, tablet and USB HID device support.
This module provides a unified interface to almost any input device, besides the regular mouse and keyboard support provided by Window. At the lowest level, get_devices can be used to retrieve a list of all supported devices, including joysticks, tablets, space controllers, wheels, pedals, remote controls, keyboards and mice. The set of returned devices varies greatly depending on the operating system (and, of course, what’s plugged in).
At this level pyglet does not try to interpret what a particular device is,
merely what controls it provides. A Control can be either a button, whose
value is either True
or False
, or a relative or absolute-valued axis,
whose value is a float. Sometimes the name of a control can be provided (for
example, x
, representing the horizontal axis of a joystick), but often
not. In these cases the device API may still be useful – the user will have
to be asked to press each button in turn or move each axis separately to
identify them.
Higher-level interfaces are provided for joysticks, tablets and the Apple remote control. These devices can usually be identified by pyglet positively, and a base level of functionality for each one provided through a common interface.
To use an input device:
To use a tablet, follow the procedure above using get_tablets, but note that no control list is available; instead, calling Tablet.open returns a TabletCanvas onto which you should set your event handlers.
Note
Since pyglet 1.2
evdev_constants |
Event constants from /usr/include/linux/input.h |
get_apple_remote ([display]) |
Get the Apple remote control device. |
get_devices ([display]) |
Get a list of all attached input devices. |
get_joysticks ([display]) |
Get a list of attached joysticks. |
get_tablets ([display]) |
Get a list of tablets. |
Defined
base
sys