Issues.00115 - lordmundi/wikidoctest GitHub Wiki
Summary: generic joystick support
Created: 2008–10–22 15:49
Status: Released
Category: Request
From: frankie
Version: 2.0
Released_In: 2.1
Description:
it would be nice to have a plugin that provides generic support for joysticks that are recognized by the OS.
Actions for joystick inputs could be customized by the user. Then, building hardware interfaces to the graphics (such as camera panels, or general controls), would require some simple electronics that emulates a standard joystick.
frankie October 22, 2008, at 03:53 PM: Implemented this in the joystick2 plugin. A tcl script can register with the plugin what function to call when there is a joystick event. Then, the user's tcl code can be written to do almost anything. Examples are in the joystick2_demo.tcl script. Works great for USB joysticks or anything that shows up in linux as a joystick device.
frankie January 08, 2013, at 04:23 PM: Just realizing the tcl file is good for documenting the tcl calls, but the command line options to the plugin are left out. Here they are:
dsp_joystick2 command line options:
-device_path <path> # A path to the joystick device. Defaults to "/dev/input/js0"
-verbose # Turn on debug printouts
And for completeness, here are the tcl commands that are available (which are also demonstrated in "gui/joystick2_demo.tcl"):
dsp_joystick2.event_handler <tcl_proc> : Assign a callback to handle events that occur on the joystick. Arguments passed to the tcl_proc callback are type, time, number, value. "type" is "1" for a button event and "2" for an axis event (129 and 130 are also passed on initial values). "time" is just the event time. "number" represents wither the button number or the axis number for the event. "value" is "0" for a button release and "1" for a button press. For axis events, "value" represents the actual axis value.
dsp_joystick2.connect_handler <tcl_proc> : Assign a callback to handle joystick connection and disconnection events. A single argument "connected" is passed to the tcl_proc callback which is non-zero if the joystick is connected, and zero if the joystick is disconnected.
dsp_joystick2.status -num_buttons : Returns the number of buttons on the joystick
dsp_joystick2.status -num_axes : Returns the number of axes on the joystick
dsp_joystick2.status -name : Returns the name of the joystick
dsp_joystick2.status -driver_version : Returns the driver version of the joystick
dsp_joystick2.status -device_path : Returns the device path being used
dsp_joystick2.status -connection_status : Returns the current connection status of the joystick