Skip to content

Commit

Permalink
fix input things
Browse files Browse the repository at this point in the history
  • Loading branch information
Dregu committed Nov 5, 2023
1 parent 812c92b commit f5561d5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 25 deletions.
23 changes: 9 additions & 14 deletions src/game_api/game_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,37 +98,32 @@ struct RawInput
std::array<ControllerInput, 12> controller;
};

struct SomeInput
struct InputDevice
{
bool disabled;
bool enabled;
uint8_t padding1[3];
bool menu_input;
bool connected;
int8_t input_index;
uint8_t padding2[3];
uint32_t buttons;
};

struct GameProps
{
/// Might be used for some menu inputs not found in buttons_menu
uint32_t buttons;
uint32_t unknown1;
uint32_t unknown2;
uint32_t unknown3;
/// Might be used for some menu inputs not found in buttons_menu
uint32_t buttons_extra;
uint32_t unknown4;
uint32_t unknown5;
uint32_t unknown6;
/// Might be used for some menu inputs not found in buttons_menu. You can probably capture and edit this in ON.PRE_UPDATE or ON.POST_PROCESS_INPUT.
std::array<uint32_t, MAX_PLAYERS> buttons;
std::array<uint32_t, MAX_PLAYERS> buttons_previous;
/// Previous state of buttons_menu
MENU_INPUT buttons_menu_previous;
/// Inputs used to control all the menus, separate from player inputs. You can probably capture and edit this in ON.PRE_UPDATE.
/// Inputs used to control all the menus, separate from player inputs. You can probably capture and edit this in ON.PRE_UPDATE or ON.POST_PROCESS_INPUT.
MENU_INPUT buttons_menu;
int8_t modal_open;
bool game_has_focus;
bool unknown9;
bool unknown10;
/// Yet another place for some buttons in some random order, too tired to make another enum for them
std::array<SomeInput*, 12> some_input;
std::array<InputDevice*, 12> input_device;

/// Input index for players 1-4 and maybe for the menu controls. -1: disabled, 0..3: keyboards, 4..7: Xinput, 8..11: other controllers
std::array<int8_t, 5> input_index;
Expand Down
42 changes: 31 additions & 11 deletions src/game_api/script/usertypes/game_manager_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,51 @@ void register_usertypes(sol::state& lua)
&JournalPopupUI::timer,
"slide_position",
&JournalPopupUI::slide_position);
lua.new_usertype<SomeInput>(
"SomeInput",
lua.new_usertype<InputDevice>(
"InputDevice",
"disabled",
&InputDevice::disabled,
"enabled",
&SomeInput::enabled,
&InputDevice::enabled,
"menu_input",
&InputDevice::menu_input,
"connected",
&InputDevice::connected,
"input_index",
&SomeInput::input_index,
&InputDevice::input_index,
"buttons",
&SomeInput::buttons);
&InputDevice::buttons);
lua.new_usertype<GameProps>(
"GameProps",
"buttons",
&GameProps::buttons,
"buttons_extra",
&GameProps::buttons_extra,
[](GameProps& gp) -> uint32_t
{
return gp.buttons[1];
},
"buttons_previous",
[](GameProps& gp) -> uint32_t
{
return gp.buttons_previous[1];
},
"buttons_menu",
&GameProps::buttons_menu,
"buttons_menu_previous",
&GameProps::buttons_menu_previous,
"buttons_menu",
"input",
&GameProps::buttons,
"input_previous",
&GameProps::buttons_previous,
"input_menu",
&GameProps::buttons_menu,
"input_menu_previous",
&GameProps::buttons_menu_previous,
"game_has_focus",
&GameProps::game_has_focus,
"modal_open",
sol::property([](GameProps& gp)
{ return gp.modal_open == 0; }),
"some_input",
&GameProps::some_input,
"input_device",
&GameProps::input_device,
"input_index",
&GameProps::input_index);
lua.new_usertype<RawInput>(
Expand Down

0 comments on commit f5561d5

Please sign in to comment.