Module: Input

Included in:
GamePlay::Base
Defined in:
docs/00000_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)


359
360
361
# File 'docs/00000_Dependencies.rb', line 359

def main_joy
  @main_joy
end

.x_axis

Get the X axis



361
362
363
# File 'docs/00000_Dependencies.rb', line 361

def x_axis
  @x_axis
end

.x_joy_axis

Get the Joystick X axis



365
366
367
# File 'docs/00000_Dependencies.rb', line 365

def x_joy_axis
  @x_joy_axis
end

.y_axis

Get the Y axis



363
364
365
# File 'docs/00000_Dependencies.rb', line 363

def y_axis
  @y_axis
end

.y_joy_axis

Get the Joystick Y axis



367
368
369
# File 'docs/00000_Dependencies.rb', line 367

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



370
371
# File 'docs/00000_Dependencies.rb', line 370

def dir4
end

.dir8Integer

Get the 8 direction status

Returns:

  • (Integer)

    see NumPad to know direction



374
375
# File 'docs/00000_Dependencies.rb', line 374

def dir8
end

.get_textString?

Get the last entered text

Returns:



378
379
# File 'docs/00000_Dependencies.rb', line 378

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)


384
385
# File 'docs/00000_Dependencies.rb', line 384

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)


389
390
# File 'docs/00000_Dependencies.rb', line 389

def press?(key)
end

.register_events(window)

Register all events in the window

Parameters:



411
412
# File 'docs/00000_Dependencies.rb', line 411

def register_events(window)
end

.released?(key) ⇒ Boolean

Tell if a key was released

Parameters:

  • key (Symbol)

    name of the key

Returns:

  • (Boolean)


399
400
# File 'docs/00000_Dependencies.rb', line 399

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)


404
405
# File 'docs/00000_Dependencies.rb', line 404

def repeat?(key)
end

.swap_states

Swap the states (each time input gets updated)



407
408
# File 'docs/00000_Dependencies.rb', line 407

def swap_states
end

.trigger?(key) ⇒ Boolean

Tell if a key was triggered

Parameters:

  • key (Symbol)

    name of the key

Returns:

  • (Boolean)


394
395
# File 'docs/00000_Dependencies.rb', line 394

def trigger?(key)
end