Class Rubygame::Joystick
In: lib/rubygame/joystick.rb
lib/rubygame/joystick.rb
Parent: Object

The Joystick class interfaces with joysticks, gamepads, and other similar hardware devices used to play games. Each joystick may have zero or more axes, balls, hats, and/or buttons.

After a Joystick object is successfully created, events for that Joystick will begin appearing on the EventQueue when a button is pressed or released, a control stick is moved, etc.

You can use Joystick.activate_all to start receiving events for all joysticks (equivalent to creating them all individually with Joystick.new). You can use Joystick.deactivate_all to stop receiving events for all joysticks.

As of Rubygame 2.4, these are the current, "new-style" Joystick event classes:

These old Joystick-related events are deprecated and will be removed in Rubygame 3.0:

For more information about "new-style" events, see EventQueue.enable_new_style_events.

Methods

activate_all   activate_all   axes   axes   balls   balls   buttons   buttons   deactivate_all   deactivate_all   get_name   get_name   hats   hats   index   index   name   name   new   new   num_joysticks   num_joysticks  

Public Class methods

Activate all joysticks on the system, equivalent to calling Joystick.new for every joystick available. This will allow joystick-related events to be sent to the EventQueue for all joysticks.

Returns:Array of zero or more Joysticks.
May raise:SDLError, if the joystick system could not be initialized.

Activate all joysticks on the system, equivalent to calling Joystick.new for every joystick available. This will allow joystick-related events to be sent to the EventQueue for all joysticks.

Returns:Array of zero or more Joysticks.
May raise:SDLError, if the joystick system could not be initialized.

Deactivate all joysticks on the system. This will stop all joystick-related events from being sent to the EventQueue.

Deactivate all joysticks on the system. This will stop all joystick-related events from being sent to the EventQueue.

Returns the name of Nth joystick on the system. The name is implementation-dependent. See also name.

Returns the name of Nth joystick on the system. The name is implementation-dependent. See also name.

Create and initialize an interface to the Nth joystick on the system. Raises SDLError if the joystick could not be opened.

Create and initialize an interface to the Nth joystick on the system. Raises SDLError if the joystick could not be opened.

Returns the total number of joysticks detected on the system.

Returns the total number of joysticks detected on the system.

Public Instance methods

Returns the number of axes (singular: axis) featured on the Joystick. Each control stick generally has two axes (X and Y), although there are other types of controls which are represented as one or more axes.

Returns the number of axes (singular: axis) featured on the Joystick. Each control stick generally has two axes (X and Y), although there are other types of controls which are represented as one or more axes.

Returns the number of trackballs featured on the Joystick. A trackball is usually a small sphere which can be rotated in-place in any direction, registering relative movement along two axes.

Returns the number of trackballs featured on the Joystick. A trackball is usually a small sphere which can be rotated in-place in any direction, registering relative movement along two axes.

Returns the number of buttons featured on the Joystick. A button can be in one of two states: neutral, or pushed.

Returns the number of buttons featured on the Joystick. A button can be in one of two states: neutral, or pushed.

Returns the number of hats featured on the Joystick. A hat is a switch which can be pushed in one of several directions, or centered.

Returns the number of hats featured on the Joystick. A hat is a switch which can be pushed in one of several directions, or centered.

Returns the index number of the Joystick, i.e. the identifier number of the joystick that this interface controls. This is the same number that was given to Joystick.new.

Returns the index number of the Joystick, i.e. the identifier number of the joystick that this interface controls. This is the same number that was given to Joystick.new.

Returns a String containing the name of the Joystick. The name is implementation-dependent. See also Joystick.get_name.

Returns a String containing the name of the Joystick. The name is implementation-dependent. See also Joystick.get_name.

[Validate]