class Gosu::Input
Manages initialization and shutdown of the input system. Only one Input
instance can exist per application.
Public Class Methods
# File lib/gosu_android/input/input.rb, line 40 def initialize(display, window) @display = display @window = window @touch_event_list = [] @key_event_list_up = [] @key_event_list_down = [] @id = 0 @ingnore_buttons = [JavaImports::KeyEvent::KEYCODE_VOLUME_DOWN, JavaImports::KeyEvent::KEYCODE_VOLUME_MUTE, JavaImports::KeyEvent::KEYCODE_VOLUME_UP, JavaImports::KeyEvent::KEYCODE_BACK, JavaImports::KeyEvent::KEYCODE_HOME, JavaImports::KeyEvent::KEYCODE_MENU, JavaImports::KeyEvent::KEYCODE_POWER, JavaImports::KeyEvent::KEYCODE_APP_SWITCH, JavaImports::KeyEvent::KEYCODE_UNKNOWN] end
Public Instance Methods
Accelerometer positions in all three dimensions (smoothened).
# File lib/gosu_android/input/input.rb, line 111 def accelerometerX; end
# File lib/gosu_android/input/input.rb, line 112 def accelerometerY; end
# File lib/gosu_android/input/input.rb, line 113 def accelerometerZ; end
Returns the button that has to be pressed to produce the given character, or noButton.
# File lib/gosu_android/input/input.rb, line 83 def char_to_id(ch); end
# File lib/gosu_android/input/input.rb, line 142 def clear @touch_event_list.clear @key_event_list_down.clear @key_event_list_up.clear end
Currently known touches.
# File lib/gosu_android/input/input.rb, line 108 def currentTouches; end
# File lib/gosu_android/input/input.rb, line 62 def feed_key_event_down(keyCode) if @ingnore_buttons.include? keyCode return false end @key_event_list_down.push keyCode return true end
# File lib/gosu_android/input/input.rb, line 70 def feed_key_event_up(keyCode) if @ingnore_buttons.include? keyCode return false end @key_event_list_up.push keyCode return true end
# File lib/gosu_android/input/input.rb, line 58 def feed_touch_event(event) @touch_event_list.push event end
Returns the character a button usually produces, or 0.
# File lib/gosu_android/input/input.rb, line 79 def id_to_char(btn); end
Returns the horizontal position of the mouse relative to the top left corner of the window given to Input’s constructor.
# File lib/gosu_android/input/input.rb, line 93 def mouseX; end
Returns true if a button is currently pressed. Updated every tick.
# File lib/gosu_android/input/input.rb, line 97 def mouseY; end
Undocumented for the moment. Also applies to currentTouches().
# File lib/gosu_android/input/input.rb, line 105 def set_mouse_factors(factorX, factorY); end
Immediately moves the mouse as far towards the desired position as possible. x and y are relative to the window just as in the mouse position accessors.
# File lib/gosu_android/input/input.rb, line 102 def set_mouse_position(x, y); end
Sets the currently active TextInput, or clears it (input = 0).
# File lib/gosu_android/input/input.rb, line 156 def set_text_input(input); end
Returns the currently active TextInput instance, or 0.
# File lib/gosu_android/input/input.rb, line 154 def text_input; end
Collects new information about which buttons are pressed, where the mouse is and calls onButtonUp/onButtonDown, if assigned.
# File lib/gosu_android/input/input.rb, line 117 def update @touch_event_list.each do |touch_event| touch_event.getPointerCount.times do |index| touch = Touch.new(touch_event. getPointerId(index), touch_event.getX(index), touch_event.getY(index)) case touch_event.getAction when JavaImports::MotionEvent::ACTION_DOWN @window.touch_began(touch) when JavaImports::MotionEvent::ACTION_MOVE @window.touch_moved(touch) when JavaImports::MotionEvent::ACTION_UP @window.touch_ended(touch) end end end @key_event_list_down.each do |key_event| @window.button_down key_event end @key_event_list_up.each do |key_event| @window.button_up key_event end end