minecraft-pi-reborn/mods/src/input/input.cpp

56 lines
1.3 KiB
C++
Raw Normal View History

2021-07-04 23:02:45 +00:00
#include <vector>
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2022-03-07 01:07:49 +00:00
#include <media-layer/core.h>
2021-07-04 23:02:45 +00:00
#include "../feature/feature.h"
#include "../init/init.h"
#include "input.h"
// Run Functions On Input Tick
static std::vector<input_tick_function_t> &get_input_tick_functions() {
static std::vector<input_tick_function_t> functions;
return functions;
}
void input_run_on_tick(input_tick_function_t function) {
get_input_tick_functions().push_back(function);
}
// Handle Input Fixes
static void Minecraft_tickInput_injection(unsigned char *minecraft) {
// Call Original Method
(*Minecraft_tickInput)(minecraft);
// Run Input Tick Functions
for (input_tick_function_t function : get_input_tick_functions()) {
(*function)(minecraft);
}
}
// Init
void init_input() {
// Miscellaneous
_init_misc();
// Toggleable Options
_init_toggle();
// Item Dropping
_init_drop();
// Enable Bow & Arrow Fix
_init_bow();
// Loop
overwrite_calls((void *) Minecraft_tickInput, (void *) Minecraft_tickInput_injection);
// Allow Attacking Mobs
_init_attack();
2022-03-07 01:07:49 +00:00
// Disable Raw Mouse Motion
2022-04-10 00:01:16 +00:00
if (feature_has("Disable Raw Mouse Motion (Not Recommended)", server_disabled)) {
2022-03-07 01:07:49 +00:00
media_set_raw_mouse_motion_enabled(0);
}
2021-07-04 23:02:45 +00:00
}