Skip to content

Input Management

In 3D games, your player controller usually requires the mouse to be captured (MOUSE_MODE_CAPTURED) to look around. However, when an inventory is open, the mouse must be visible (MOUSE_MODE_VISIBLE) to click on slots.

InputMode Autoload prevents the mouse controls from interfering with each other.

Properties

  • startup_mode (bool): Whether the game starts in Game Mode (captured) or UI Mode (visible).
  • prevent_game_input_in_ui (bool): Flag for your player controller to check.

Methods

InputMode.ui()     # Switch to UI mode (Shows cursor, allows clicking)
InputMode.game()   # Switch to Game mode (Hides cursor, captures for camera)
InputMode.toggle() # Toggle between the two

# Returns true if the game is in captured mode.
InputMode.is_game_mode() -> bool

# Returns true ONLY if in game mode AND not currently dragging an item.
# Use this in your player controller to block movement while dragging!
InputMode.allow_game_input() -> bool 
  • Window Focus: It listens to NOTIFICATION_WM_MOUSE_EXIT to automatically release the mouse if the user alt-tabs out of the game, preventing the cursor from being permanently locked.