minecraft-pi-docker/mods/src/input/toggle.c

43 lines
1.2 KiB
C
Raw Normal View History

2021-07-04 23:02:45 +00:00
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2021-07-04 23:02:45 +00:00
#include "input.h"
#include "../feature/feature.h"
// Enable Toggles
static int enable_toggles = 0;
// Store Function Input
static int hide_gui_toggle = 0;
void input_hide_gui() {
hide_gui_toggle++;
}
static int third_person_toggle = 0;
void input_third_person() {
third_person_toggle++;
}
// Handle Toggle Options
2021-10-04 23:42:55 +00:00
static void _handle_toggle_options(unsigned char *minecraft) {
2021-07-04 23:02:45 +00:00
if (enable_toggles) {
// Handle Functions
unsigned char *options = minecraft + Minecraft_options_property_offset;
if (hide_gui_toggle % 2 != 0) {
// Toggle Hide GUI
*(options + Options_hide_gui_property_offset) = *(options + Options_hide_gui_property_offset) ^ 1;
}
hide_gui_toggle = 0;
if (third_person_toggle % 2 != 0) {
// Toggle Third Person
*(options + Options_third_person_property_offset) = *(options + Options_third_person_property_offset) ^ 1;
}
third_person_toggle = 0;
}
}
// Init
void _init_toggle() {
enable_toggles = feature_has("Bind Common Toggleable Options To Function Keys", 0);
2021-10-04 23:42:55 +00:00
input_run_on_tick(_handle_toggle_options);
2021-07-04 23:02:45 +00:00
}