Module: Input

Included in:
GamePlay::Base
Defined in:
docs/0_Dependencies.rb

Overview

The virtual keys of the Input module are : :A, :B, :X, :Y, :L, :R, :L2, :R2, :L3, :R3, :START, :SELECT, :HOME, :UP, :DOWN, :LEFT, :RIGHT

Constant Summary collapse

Keyboard =

Alias for the Keyboard module

Sf::Keyboard
DEAD_ZONE =

Range giving dead zone of axis

-20..20
NON_TRIGGER_ZONE =

Range outside of which a trigger is considered on an exis

-50..50
AXIS_SENSITIVITY =

Sensitivity in order to take a trigger in account on joystick movement

10
REPEAT_COOLDOWN =

Cooldown delta of Input.repeat?

0.25
REPEAT_SPACE =

Time between each signals of Input.repeat? after cooldown

0.08
Keys =

List of keys the input knows

{A: [s::C, s::Space, s::Enter, s::NumpadEnter, -1], B: [s::X, s::Backspace, s::Escape, s::LShift, -2], X: [s::V, s::Menu, s::Numpad3, s::V, -3], Y: [s::B, s::Numpad1, s::RShift, s::B, -4], L: [s::F, s::Num1, s::Numpad7, s::F, -5], R: [s::G, s::Num3, s::Numpad9, s::G, -6], L2: [s::R, s::R, s::R, s::R, -7], R2: [s::T, s::T, s::T, s::T, -8], L3: [s::Num4, s::Num4, s::Y, s::F2, -9], R3: [s::Num5, s::Num5, s::U, s::F3, -10], START: [s::J, s::J, s::Insert, s::Insert, -8], SELECT: [s::H, s::H, s::Pause, s::Pause, -7], HOME: [s::Semicolon, s::Semicolon, s::Home, s::Home, 255], UP: [s::Up, s::W, s::Numpad8, s::Up, -13], DOWN: [s::Down, s::S, s::Numpad2, s::Down, -14], LEFT: [s::Left, s::A, s::Numpad4, s::Left, -15], RIGHT: [s::Right, s::D, s::Numpad6, s::Right, -16]}
ALIAS_KEYS =

List of key ALIAS

{up: :UP, down: :DOWN, left: :LEFT, right: :RIGHT, a: :A, b: :B, x: :X, y: :Y, start: :START, select: :SELECT}
AXIS_MAPPING =

List of Axis mapping (axis => key_neg, key_pos)

{Sf::Joystick::Z => %i[R2 L2]}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.main_joyInteger

Get the main joystick

Returns:

  • (Integer)


933
934
935
# File 'docs/0_Dependencies.rb', line 933

def main_joy
  @main_joy
end

.x_axis

Get the X axis



935
936
937
# File 'docs/0_Dependencies.rb', line 935

def x_axis
  @x_axis
end

.x_joy_axis

Get the Joystick X axis



939
940
941
# File 'docs/0_Dependencies.rb', line 939

def x_joy_axis
  @x_joy_axis
end

.y_axis

Get the Y axis



937
938
939
# File 'docs/0_Dependencies.rb', line 937

def y_axis
  @y_axis
end

.y_joy_axis

Get the Joystick Y axis



941
942
943
# File 'docs/0_Dependencies.rb', line 941

def y_joy_axis
  @y_joy_axis
end

Class Method Details

.dir4Integer

Get the 4 direction status

Returns:

  • (Integer)

    2 = down, 4 = left, 6 = right, 8 = up, 0 = none



944
945
# File 'docs/0_Dependencies.rb', line 944

def dir4
end

.dir8Integer

Get the 8 direction status

Returns:

  • (Integer)

    see NumPad to know direction



948
949
# File 'docs/0_Dependencies.rb', line 948

def dir8
end

.get_textString?

Get the last entered text

Returns:



952
953
# File 'docs/0_Dependencies.rb', line 952

def get_text
end

.joy_axis_position(id, axis) ⇒ Integer

Get the axis position of a joystick

Parameters:

  • id (Integer)

    ID of the joystick

  • axis (Integer)

    axis

Returns:

  • (Integer)


958
959
# File 'docs/0_Dependencies.rb', line 958

def joy_axis_position(id, axis)
end

.press?(key) ⇒ Boolean

Tell if a key is pressed

Parameters:

  • key (Symbol)

    name of the key

Returns:

  • (Boolean)


963
964
# File 'docs/0_Dependencies.rb', line 963

def press?(key)
end

.register_events(window)

Register all events in the window

Parameters:



985
986
# File 'docs/0_Dependencies.rb', line 985

def register_events(window)
end

.released?(key) ⇒ Boolean

Tell if a key was released

Parameters:

  • key (Symbol)

    name of the key

Returns:

  • (Boolean)


973
974
# File 'docs/0_Dependencies.rb', line 973

def released?(key)
end

.repeat?(key) ⇒ Boolean

Tell if a key is repeated (0.25s then each 0.08s)

Parameters:

  • key (Symbol)

    name of the key

Returns:

  • (Boolean)


978
979
# File 'docs/0_Dependencies.rb', line 978

def repeat?(key)
end

.swap_states

Swap the states (each time input gets updated)



981
982
# File 'docs/0_Dependencies.rb', line 981

def swap_states
end

.trigger?(key) ⇒ Boolean

Tell if a key was triggered

Parameters:

  • key (Symbol)

    name of the key

Returns:

  • (Boolean)


968
969
# File 'docs/0_Dependencies.rb', line 968

def trigger?(key)
end