class

PointClickEngine::Core::InputManager

Inherits PointClickEngine::Core::IInputManager < PointClickEngine::Core::GameConstants < PointClickEngine::Core::ErrorHelpers < Reference < Object

Manages all input-related operations including event processing, input state, and coordination

The InputManager centralizes input handling logic that was previously scattered throughout the Engine class. It provides priority-based input processing, input blocking for UI elements, and coordinated event handling.

Features

  • Priority-based input processing
  • Input blocking for dialogs and UI
  • Event coordination between systems
  • Input state tracking and validation
  • Keyboard and mouse event handling
  • Customizable input mappings

Usage

manager = InputManager.new
manager.add_input_handler(ui_handler, priority: 10)
manager.add_input_handler(game_handler, priority: 5)
manager.process_input(dt)

Constructors

Instance methods

add_input_handler(handler : Proc(Float32, Bool), priority : Int32, enabled : Bool = true)

Add an input handler with priority

Higher priority handlers are processed first. UI handlers should typically have higher priority than game handlers.

  • handler : The input processing function
  • priority : Processing priority (higher = first)
  • enabled : Whether the handler is initially enabled
Source
any_key_pressed?
Source
any_mouse_button_pressed?
Source
block_input(frames : Int32, source : String = "unknown")

Block all input for a specified number of frames

Useful for preventing input during scene transitions or scripted sequences.

  • frames : Number of frames to block input
  • source : Description of what is blocking input
Source
click_count
Source
consume_input(input_type : String, handler_name : String)

Mark an input as consumed

  • input_type : Type of input to mark as consumed
  • handler_name : Name of the handler consuming the input
Source
consume_keyboard_input
Source
consume_mouse_input
Source
double_click_detected?
Source
get_action_for_key(key : Raylib::KeyboardKey) : String | Nil
Source
input_block_source

Get the source of input blocking

Source
input_blocked?

Check if input is currently blocked

Source
is_consumed(input_type : String) : Bool

Check if a specific input has been consumed

  • input_type : Type of input to check (e.g., "mouse_click", "key_space")

Returns true if the input has been consumed this frame

Source
key_held?(key : Raylib::KeyboardKey) : Bool
Source
key_pressed?(key : Raylib::KeyboardKey) : Bool
Source
key_released?(key : Raylib::KeyboardKey) : Bool
Source
keyboard_consumed?
Source
last_click_position
Source
map_key_to_action(key : Raylib::KeyboardKey, action : String)
Source
mouse_button_held?(button : Raylib::MouseButton) : Bool
Source
mouse_button_pressed?(button : Raylib::MouseButton) : Bool
Source
mouse_button_released?(button : Raylib::MouseButton) : Bool
Source
mouse_consumed?
Source
mouse_delta
Source
mouse_in_bounds?(bounds : Raylib::Rectangle) : Bool
Source
mouse_moved?
Source
mouse_position
Source
process_input(dt : Float32)

Main input processing method

Processes all input events and distributes them to registered handlers based on priority. Updates input state and handles frame-based cleanup.

  • dt : Delta time since last frame
Source
register_handler(name : String, priority : Int32, enabled : Bool = true, &handler : Float32 -> Bool)

Register a named input handler with a block

Named handlers are easier to manage and remove later. The handler should return true if it consumed the input.

  • name : Unique name for the handler
  • priority : Processing priority (higher = first)
  • enabled : Whether the handler is initially enabled
Source
register_handler(name : String, priority : Int32, enabled : Bool = true)

Register a named input handler (non-block version)

For simpler cases where you just need a placeholder handler. Creates a no-op handler that doesn't consume input.

  • name : Unique name for the handler
  • priority : Processing priority (higher = first)
  • enabled : Whether the handler is initially enabled
Source
remove_input_handler(handler : Proc(Float32, Bool)) : Bool

Remove an input handler

Source
set_handler_enabled(handler : Proc(Float32, Bool), enabled : Bool)

Enable or disable an input handler

Source
unblock_input

Unblock input immediately

Source
unregister_handler(name : String) : Bool

Unregister a named input handler

  • name : Name of the handler to remove

Returns true if the handler was found and removed

Source
update(dt : Float32)

Update the input manager state

This is an alias for process_input for API compatibility.

  • dt : Delta time since last frame
Source