Class: GLFW::GamepadState

Inherits:
Object
  • Object
show all
Defined in:
lib/glfw/stubs/gamepad_state.rb,
lib/glfw/constants.rb

Overview

Describes the captured state of a gamepad.

Gamepad Axes collapse

AXIS_LEFT_X =
0
AXIS_LEFT_Y =
1
AXIS_RIGHT_X =
2
AXIS_RIGHT_Y =
3
AXIS_LEFT_TRIGGER =
4
AXIS_RIGHT_TRIGGER =
5

Gamepad Buttons collapse

BUTTON_A =
0
BUTTON_B =
1
BUTTON_X =
2
BUTTON_Y =
3
BUTTON_LEFT_BUMPER =
4
BUTTON_RIGHT_BUMPER =
5
BUTTON_BACK =
6
BUTTON_START =
7
BUTTON_GUIDE =
8
BUTTON_LEFT_THUMB =
9
BUTTON_RIGHT_THUMB =
10
BUTTON_DPAD_UP =
11
BUTTON_DPAD_RIGHT =
12
BUTTON_DPAD_DOWN =
13
BUTTON_DPAD_LEFT =
14
BUTTON_CROSS =
BUTTON_A
BUTTON_CIRCLE =
BUTTON_B
BUTTON_SQUARE =
BUTTON_X
BUTTON_TRIANGLE =
BUTTON_Y

Instance Method Summary collapse

Instance Method Details

#axis(index) ⇒ Float

Note:

It is recommended to use the return value rounded to a specific precision, or "dead zone", as many devices will report miniscule values even when stationary.

Note:

Use the class constants prefixed with AXIS for strongly typed index values if desired.

Queries the value of the axis at the specified index.

Parameters:

  • index (Integer)

    The desired index of the axis to query.

Returns:

  • (Float)

    The current axis value, or 0.0 if out of range.



17
18
# File 'lib/glfw/stubs/gamepad_state.rb', line 17

def axis(index)
end

#button(index) ⇒ Float

Note:

Use the class constants prefixed with BUTTON for strongly typed index values if desired.

Queries the button state at the specified index.

Parameters:

  • index (Integer)

    The desired index of the button to query.

Returns:

  • (Float)

    true if button is depressed, otherwise false if no input is detected or if index is out of range.



27
28
# File 'lib/glfw/stubs/gamepad_state.rb', line 27

def button(index)
end