2021-04-19 18:56:11 -04:00
|
|
|
#include <stdinc.hpp>
|
2021-04-23 14:57:21 -04:00
|
|
|
#include "loader/component_loader.hpp"
|
2021-04-19 18:56:11 -04:00
|
|
|
|
|
|
|
#include "game/game.hpp"
|
|
|
|
|
|
|
|
#include "game_console.hpp"
|
|
|
|
|
|
|
|
#include <utils/hook.hpp>
|
|
|
|
|
|
|
|
namespace input
|
|
|
|
{
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
utils::hook::detour cl_char_event_hook;
|
|
|
|
utils::hook::detour cl_key_event_hook;
|
|
|
|
|
|
|
|
void cl_char_event_stub(const int local_client_num, const int key)
|
|
|
|
{
|
|
|
|
if (!game_console::console_char_event(local_client_num, key))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl_char_event_hook.invoke<void>(local_client_num, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cl_key_event_stub(const int local_client_num, const int key, const int down)
|
|
|
|
{
|
|
|
|
if (!game_console::console_key_event(local_client_num, key, down))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl_key_event_hook.invoke<void>(local_client_num, key, down);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-23 14:57:21 -04:00
|
|
|
class component final : public component_interface
|
2021-04-19 18:56:11 -04:00
|
|
|
{
|
2021-04-23 14:57:21 -04:00
|
|
|
public:
|
|
|
|
void post_unpack() override
|
|
|
|
{
|
|
|
|
cl_char_event_hook.create(game::base_address + 0x3D27B0, cl_char_event_stub);
|
|
|
|
cl_key_event_hook.create(game::base_address + 0x3D2AE0, cl_key_event_stub);
|
|
|
|
}
|
|
|
|
};
|
2021-04-19 18:56:11 -04:00
|
|
|
}
|
2021-04-23 14:57:21 -04:00
|
|
|
|
|
|
|
REGISTER_COMPONENT(input::component)
|