Module: KeyboardButtons

Included in:
FullKeyboard
Defined in:
tomes/conjurations/keyboard/keyboard_buttons.rb

Overview

A method for handling controller-style inputs on the Keyboard.

Instance Method Summary collapse

Instance Method Details

#buttonArray

Gives current controller-style-button presses as a list.

Returns:

  • (Array)
[View source]

7
8
9
10
11
# File 'tomes/conjurations/keyboard/keyboard_buttons.rb', line 7

def button
  button_inputs.map do |key, value|
    key unless (value.intersection down_inputs).empty?
  end.compact
end

#button?Boolean

Checks if a controller-style-button is currently pressed or held (down).

Returns:

  • (Boolean)
[View source]

33
34
35
# File 'tomes/conjurations/keyboard/keyboard_buttons.rb', line 33

def button?
  !button_held.empty?
end

#button_heldArray Also known as: button_hold

Gives current controller-style-button holds as a list.

Returns:

  • (Array)
[View source]

15
16
17
18
19
20
# File 'tomes/conjurations/keyboard/keyboard_buttons.rb', line 15

def button_held
  button_inputs.map do |key, value|
    value = [value] unless value.is_a? Array
    key unless (value.intersection held_inputs).empty?
  end.compact
end

#button_upArray

Gives current controller-style-button releases as a list.

Returns:

  • (Array)
[View source]

25
26
27
28
29
# File 'tomes/conjurations/keyboard/keyboard_buttons.rb', line 25

def button_up
  button_inputs.map do |key, value|
    key unless (value.intersection up_inputs).empty?
  end.compact
end