Skip to content

Commit

Permalink
inputs:
Browse files Browse the repository at this point in the history
- on_key_pressed lua function
- let_game_input_go_through_gui_layer option
- enable_vanilla_debug_keybinds option
  • Loading branch information
xiaoxiao921 committed May 28, 2024
1 parent 93dcbab commit d520b34
Show file tree
Hide file tree
Showing 8 changed files with 547 additions and 15 deletions.
40 changes: 40 additions & 0 deletions docs/lua/tables/rom.inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Table: rom.inputs

## Functions (3)

### `on_key_pressed(keybind, callback)`

- **Parameters:**
- `keybind` (string): The key binding string representing the key that, when pressed, will trigger the callback function. The format used is the one used by the vanilla game, please check the vanilla scripts using "OnKeyPressed".
- `callback` (function): The function to be called when the specified keybind is pressed.

**Example Usage:**
```lua
rom.inputs.on_key_pressed(keybind, callback)
```

### `let_game_input_go_through_gui_layer(new_value)`

Allows game input to be processed even when the GUI layer is active. This is useful for scenarios where you need the game to remain responsive to player actions or on key presses callbacks despite overlay interfaces.

- **Parameters:**
- `new_value` (bool): Optional. Set the backing field to the passed new value.

**Example Usage:**
```lua
rom.inputs.let_game_input_go_through_gui_layer(new_value)
```

### `enable_vanilla_debug_keybinds(new_value)`

Enables the default debug key bindings used in the vanilla game.

- **Parameters:**
- `new_value` (bool): Optional. Set the backing field to the passed new value.

**Example Usage:**
```lua
rom.inputs.enable_vanilla_debug_keybinds(new_value)
```


10 changes: 10 additions & 0 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <input/is_key_pressed.hpp>
#include <lua/lua_manager.hpp>
#include <lua_extensions/bindings/hades/hades_ida.hpp>
#include <lua_extensions/bindings/hades/inputs.hpp>
#include <memory/gm_address.hpp>
#include <pointers.hpp>

Expand Down Expand Up @@ -202,6 +203,8 @@ namespace big
editing_gui_keybind = true;
}

ImGui::Checkbox("Let Game Input Go Through Gui Layer", &lua::hades::inputs::let_game_input_go_through_gui_layer);

ImGui::EndMenu();
}

Expand Down Expand Up @@ -256,6 +259,13 @@ namespace big
ImGui::EndMenu();
}

if (ImGui::BeginMenu("Debug"))
{
ImGui::Checkbox("Enable Vanilla Debug Keybinds", &lua::hades::inputs::enable_vanilla_debug_keybinds);

ImGui::EndMenu();
}

ImGui::EndMainMenuBar();
}

Expand Down
Loading

0 comments on commit d520b34

Please sign in to comment.