minecraft-pi-reborn/mods/src/touch/touch.c

30 lines
927 B
C
Raw Normal View History

2021-06-19 23:07:09 +00:00
#include <libreborn/libreborn.h>
#include "../feature/feature.h"
#include "../init/init.h"
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2021-06-19 23:07:09 +00:00
// Enable Touch GUI
static int32_t Minecraft_isTouchscreen_injection(__attribute__((unused)) unsigned char *minecraft) {
return 1;
}
// Init
void init_touch() {
2021-07-04 23:02:45 +00:00
int touch_gui = feature_has("Touch GUI", 0);
2021-06-19 23:07:09 +00:00
if (touch_gui) {
// Main UI
2021-07-05 01:23:12 +00:00
overwrite((void *) Minecraft_isTouchscreen, (void *) Minecraft_isTouchscreen_injection);
2021-06-19 23:07:09 +00:00
2021-06-28 21:10:15 +00:00
// Force Correct Toolbar Size
unsigned char toolbar_patch[4] = {0x01, 0x00, 0x50, 0xe3}; // "cmp r0, #0x1"
patch((void *) 0x257b0, toolbar_patch);
}
2021-06-19 23:07:09 +00:00
// Show Block Outlines
2021-07-04 23:02:45 +00:00
int block_outlines = feature_has("Show Block Outlines", 0);
2021-06-19 23:07:09 +00:00
unsigned char outline_patch[4] = {block_outlines ? !touch_gui : touch_gui, 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0"
patch((void *) 0x4a210, outline_patch);
}