Fix Various Input Bugs
This commit is contained in:
parent
989dd7983b
commit
0c0a61cd23
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**2.0.7**
|
||||||
|
* Fix Sign Text Not Updating In Multiplayer When Exiting Editing UI Using Escape Button
|
||||||
|
* Fix Item Dropping Not Working
|
||||||
|
|
||||||
**2.0.6**
|
**2.0.6**
|
||||||
* Fix Toolbar Size In Normal GUI
|
* Fix Toolbar Size In Normal GUI
|
||||||
|
|
||||||
|
@ -110,6 +110,9 @@ static Minecraft_grabMouse_t Minecraft_grabMouse = (Minecraft_grabMouse_t) 0x15d
|
|||||||
typedef void (*Minecraft_leaveGame_t)(unsigned char *minecraft, bool save_remote_level);
|
typedef void (*Minecraft_leaveGame_t)(unsigned char *minecraft, bool save_remote_level);
|
||||||
static Minecraft_leaveGame_t Minecraft_leaveGame = (Minecraft_leaveGame_t) 0x15ea0;
|
static Minecraft_leaveGame_t Minecraft_leaveGame = (Minecraft_leaveGame_t) 0x15ea0;
|
||||||
|
|
||||||
|
typedef void (*Minecraft_handleBack_t)(unsigned char *minecraft, bool param_1);
|
||||||
|
static uint32_t Minecraft_handleBack_vtable_offset = 0x34;
|
||||||
|
|
||||||
static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t
|
static uint32_t Minecraft_screen_width_property_offset = 0x20; // int32_t
|
||||||
static uint32_t Minecraft_network_handler_property_offset = 0x174; // NetEventCallback *
|
static uint32_t Minecraft_network_handler_property_offset = 0x174; // NetEventCallback *
|
||||||
static uint32_t Minecraft_rak_net_instance_property_offset = 0x170; // RakNetInstance *
|
static uint32_t Minecraft_rak_net_instance_property_offset = 0x170; // RakNetInstance *
|
||||||
|
@ -8,7 +8,7 @@ add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
|
|||||||
## Mods
|
## Mods
|
||||||
|
|
||||||
add_library(compat SHARED src/compat/compat.c src/compat/egl.c src/compat/x11.c)
|
add_library(compat SHARED src/compat/compat.c src/compat/egl.c src/compat/x11.c)
|
||||||
target_link_libraries(compat feature input media-layer-core dl)
|
target_link_libraries(compat feature input sign media-layer-core dl)
|
||||||
|
|
||||||
add_library(readdir SHARED src/readdir/readdir.c)
|
add_library(readdir SHARED src/readdir/readdir.c)
|
||||||
|
|
||||||
@ -32,8 +32,11 @@ target_link_libraries(camera reborn media-layer-core)
|
|||||||
add_library(game-mode SHARED src/game-mode/game-mode.c src/game-mode/game-mode.cpp)
|
add_library(game-mode SHARED src/game-mode/game-mode.c src/game-mode/game-mode.cpp)
|
||||||
target_link_libraries(game-mode reborn)
|
target_link_libraries(game-mode reborn)
|
||||||
|
|
||||||
add_library(input SHARED src/input/input.c src/input/input.cpp)
|
add_library(sign SHARED src/sign/sign.cpp)
|
||||||
target_link_libraries(input reborn feature media-layer-core chat)
|
target_link_libraries(sign reborn feature)
|
||||||
|
|
||||||
|
add_library(input SHARED src/input/input.c)
|
||||||
|
target_link_libraries(input reborn feature media-layer-core chat sign)
|
||||||
|
|
||||||
add_library(death SHARED src/death/death.cpp)
|
add_library(death SHARED src/death/death.cpp)
|
||||||
target_link_libraries(death reborn)
|
target_link_libraries(death reborn)
|
||||||
@ -63,7 +66,7 @@ add_library(test SHARED src/test/test.c)
|
|||||||
target_link_libraries(test reborn home)
|
target_link_libraries(test reborn home)
|
||||||
|
|
||||||
add_library(init SHARED src/init/init.c)
|
add_library(init SHARED src/init/init.c)
|
||||||
target_link_libraries(init compat game-mode camera input misc death options touch textures chat home version test)
|
target_link_libraries(init compat game-mode camera input sign misc death options touch textures chat home version test)
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
target_link_libraries(init server)
|
target_link_libraries(init server)
|
||||||
else()
|
else()
|
||||||
@ -71,7 +74,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
## Install Mods
|
## Install Mods
|
||||||
install(TARGETS init compat readdir feature override game-mode camera input misc death options touch textures chat home version test DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
install(TARGETS init compat readdir feature override game-mode camera input sign misc death options touch textures chat home version test DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
install(TARGETS server DESTINATION "${MCPI_INSTALL_DIR}/mods")
|
||||||
else()
|
else()
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "../feature/feature.h"
|
#include "../feature/feature.h"
|
||||||
#include "../input/input.h"
|
#include "../input/input.h"
|
||||||
|
#include "../sign/sign.h"
|
||||||
#include "../chat/chat.h"
|
#include "../chat/chat.h"
|
||||||
#include "../init/init.h"
|
#include "../init/init.h"
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
@ -71,6 +72,10 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) {
|
|||||||
}
|
}
|
||||||
// Mark Handled
|
// Mark Handled
|
||||||
handled = 1;
|
handled = 1;
|
||||||
|
} else if (event->key.keysym.sym == SDLK_ESCAPE) {
|
||||||
|
// Treat Escape As Back Button Press (This Fixes Issues With Signs)
|
||||||
|
input_back();
|
||||||
|
handled = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -86,7 +91,7 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) {
|
|||||||
}
|
}
|
||||||
case SDL_USEREVENT: {
|
case SDL_USEREVENT: {
|
||||||
// SDL_UserEvent Is Never Used In MCPI, So It Is Repurposed For Character Events
|
// SDL_UserEvent Is Never Used In MCPI, So It Is Repurposed For Character Events
|
||||||
input_key_press((char) event->user.code);
|
sign_key_press((char) event->user.code);
|
||||||
handled = 1;
|
handled = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -55,4 +55,5 @@ void _init_game_mode_cpp() {
|
|||||||
// Make The SimpleChooseLevelScreen Back Button Go To SelectWorldScreen Instead Of StartMenuScreen
|
// Make The SimpleChooseLevelScreen Back Button Go To SelectWorldScreen Instead Of StartMenuScreen
|
||||||
unsigned char simple_choose_level_screen_back_button_patch[4] = {0x05, 0x10, 0xa0, 0xe3}; // "mov r1, #0x5"
|
unsigned char simple_choose_level_screen_back_button_patch[4] = {0x05, 0x10, 0xa0, 0xe3}; // "mov r1, #0x5"
|
||||||
patch((void *) 0x31144, simple_choose_level_screen_back_button_patch);
|
patch((void *) 0x31144, simple_choose_level_screen_back_button_patch);
|
||||||
|
patch((void *) 0x3134c, simple_choose_level_screen_back_button_patch);
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ __attribute__((constructor)) static void init() {
|
|||||||
#endif
|
#endif
|
||||||
init_game_mode();
|
init_game_mode();
|
||||||
init_input();
|
init_input();
|
||||||
|
init_sign();
|
||||||
init_misc();
|
init_misc();
|
||||||
init_death();
|
init_death();
|
||||||
init_camera();
|
init_camera();
|
||||||
|
@ -13,6 +13,7 @@ void init_multiplayer();
|
|||||||
#endif
|
#endif
|
||||||
void init_game_mode();
|
void init_game_mode();
|
||||||
void init_input();
|
void init_input();
|
||||||
|
void init_sign();
|
||||||
void init_misc();
|
void init_misc();
|
||||||
void init_death();
|
void init_death();
|
||||||
void init_camera();
|
void init_camera();
|
||||||
|
@ -3,7 +3,6 @@ This mod fixes various input-related bugs, including:
|
|||||||
- Bows being broken.
|
- Bows being broken.
|
||||||
- The cursor interacting with the hotbar while the it is locked.
|
- The cursor interacting with the hotbar while the it is locked.
|
||||||
- Being unable to attack mobs.
|
- Being unable to attack mobs.
|
||||||
- Being unable to specify sign text.
|
|
||||||
|
|
||||||
It also adds various features, including:
|
It also adds various features, including:
|
||||||
- Hide GUI and third person toggle keys.
|
- Hide GUI and third person toggle keys.
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
|
#include <libreborn/minecraft.h>
|
||||||
|
|
||||||
#include "../feature/feature.h"
|
#include "../feature/feature.h"
|
||||||
#include "input.h"
|
|
||||||
#include "../init/init.h"
|
#include "../init/init.h"
|
||||||
#include "../chat/chat.h"
|
#include "../chat/chat.h"
|
||||||
|
#include "../sign/sign.h"
|
||||||
#include <libreborn/minecraft.h>
|
|
||||||
|
|
||||||
// Store Right-Click Status
|
// Store Right-Click Status
|
||||||
static int is_right_click = 0;
|
static int is_right_click = 0;
|
||||||
@ -26,12 +25,18 @@ void input_third_person() {
|
|||||||
third_person_toggle++;
|
third_person_toggle++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set mouse Grab State
|
// Set Mouse Grab State
|
||||||
static int mouse_grab_state = 0;
|
static int mouse_grab_state = 0;
|
||||||
void input_set_mouse_grab_state(int state) {
|
void input_set_mouse_grab_state(int state) {
|
||||||
mouse_grab_state = state;
|
mouse_grab_state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store Back Button Presses
|
||||||
|
static int back_button_presses =0;
|
||||||
|
void input_back() {
|
||||||
|
back_button_presses++;
|
||||||
|
}
|
||||||
|
|
||||||
// Handle Input Fixes
|
// Handle Input Fixes
|
||||||
static void Minecraft_tickInput_injection(unsigned char *minecraft) {
|
static void Minecraft_tickInput_injection(unsigned char *minecraft) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
@ -50,7 +55,7 @@ static void Minecraft_tickInput_injection(unsigned char *minecraft) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear Unused Sign Input
|
// Clear Unused Sign Input
|
||||||
input_clear_input();
|
sign_clear_input();
|
||||||
|
|
||||||
// Handle Functions
|
// Handle Functions
|
||||||
unsigned char *options = minecraft + Minecraft_options_property_offset;
|
unsigned char *options = minecraft + Minecraft_options_property_offset;
|
||||||
@ -77,13 +82,21 @@ static void Minecraft_tickInput_injection(unsigned char *minecraft) {
|
|||||||
(*Minecraft_releaseMouse)(minecraft);
|
(*Minecraft_releaseMouse)(minecraft);
|
||||||
}
|
}
|
||||||
mouse_grab_state = 0;
|
mouse_grab_state = 0;
|
||||||
|
|
||||||
|
// Handle Back Button
|
||||||
|
unsigned char *minecraft_vtable = *(unsigned char **) minecraft;
|
||||||
|
Minecraft_handleBack_t Minecraft_handleBack = *(Minecraft_handleBack_t *) (minecraft_vtable + Minecraft_handleBack_vtable_offset);
|
||||||
|
for (int i = 0; i < back_button_presses; i++) {
|
||||||
|
(*Minecraft_handleBack)(minecraft, 0);
|
||||||
|
}
|
||||||
|
back_button_presses = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|
||||||
// Block UI Interaction When Mouse Is Locked
|
// Block UI Interaction When Mouse Is Locked
|
||||||
static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(unsigned char *minecraft) {
|
static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(unsigned char *minecraft) {
|
||||||
if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
return (*Minecraft_isCreativeMode)(minecraft);
|
return (*Minecraft_isCreativeMode)(minecraft);
|
||||||
} else {
|
} else {
|
||||||
@ -94,7 +107,7 @@ static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(unsigned ch
|
|||||||
|
|
||||||
// Block UI Interaction When Mouse Is Locked
|
// Block UI Interaction When Mouse Is Locked
|
||||||
static void Gui_handleClick_injection(unsigned char *this, int32_t param_2, int32_t param_3, int32_t param_4) {
|
static void Gui_handleClick_injection(unsigned char *this, int32_t param_2, int32_t param_3, int32_t param_4) {
|
||||||
if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
|
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
(*Gui_handleClick)(this, param_2, param_3, param_4);
|
(*Gui_handleClick)(this, param_2, param_3, param_4);
|
||||||
}
|
}
|
||||||
@ -147,7 +160,4 @@ void init_input() {
|
|||||||
// Allow Attacking Mobs
|
// Allow Attacking Mobs
|
||||||
patch_address(MouseBuildInput_tickBuild_vtable_addr, (void *) MouseBuildInput_tickBuild_injection);
|
patch_address(MouseBuildInput_tickBuild_vtable_addr, (void *) MouseBuildInput_tickBuild_injection);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init C++
|
|
||||||
_init_input_cpp();
|
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,15 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void input_key_press(char key);
|
|
||||||
void input_clear_input();
|
|
||||||
|
|
||||||
void input_set_is_right_click(int val);
|
void input_set_is_right_click(int val);
|
||||||
void input_hide_gui();
|
void input_hide_gui();
|
||||||
void input_third_person();
|
void input_third_person();
|
||||||
|
void input_back();
|
||||||
|
|
||||||
void input_set_is_left_click(int val);
|
void input_set_is_left_click(int val);
|
||||||
|
|
||||||
void input_set_mouse_grab_state(int state);
|
void input_set_mouse_grab_state(int state);
|
||||||
|
|
||||||
__attribute__((visibility("internal"))) void _init_input_cpp();
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -103,8 +103,8 @@ void _init_misc_cpp() {
|
|||||||
// Implement AppPlatform::readAssetFile So Translations Work
|
// Implement AppPlatform::readAssetFile So Translations Work
|
||||||
overwrite((void *) AppPlatform_readAssetFile, (void *) AppPlatform_readAssetFile_injection);
|
overwrite((void *) AppPlatform_readAssetFile, (void *) AppPlatform_readAssetFile_injection);
|
||||||
|
|
||||||
|
// Add Extra Items To Creative Inventory (Only Replace Specific Function Call)
|
||||||
if (feature_has("Expand Creative Inventory")) {
|
if (feature_has("Expand Creative Inventory")) {
|
||||||
// Add Extra Items To Creative Inventory (Only Replace Specific Function Call)
|
|
||||||
overwrite_call((void *) 0x8e0fc, (void *) Inventory_setupDefault_FillingContainer_addItem_call_injection);
|
overwrite_call((void *) 0x8e0fc, (void *) Inventory_setupDefault_FillingContainer_addItem_call_injection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
mods/src/sign/README.md
Normal file
2
mods/src/sign/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# ``sign`` Mod
|
||||||
|
This mod fixes sign placement.
|
@ -1,12 +1,12 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
|
|
||||||
#include "../feature/feature.h"
|
|
||||||
#include "input.h"
|
|
||||||
|
|
||||||
#include <libreborn/minecraft.h>
|
#include <libreborn/minecraft.h>
|
||||||
|
|
||||||
|
#include "../init/init.h"
|
||||||
|
#include "../feature/feature.h"
|
||||||
|
#include "sign.h"
|
||||||
|
|
||||||
// Open Sign Screen
|
// Open Sign Screen
|
||||||
static void LocalPlayer_openTextEdit_injection(unsigned char *local_player, unsigned char *sign) {
|
static void LocalPlayer_openTextEdit_injection(unsigned char *local_player, unsigned char *sign) {
|
||||||
if (*(int32_t *) (sign + TileEntity_id_property_offset) == 4) {
|
if (*(int32_t *) (sign + TileEntity_id_property_offset) == 4) {
|
||||||
@ -26,12 +26,12 @@ static int is_valid_key(char key) {
|
|||||||
|
|
||||||
// Store Text Input
|
// Store Text Input
|
||||||
std::vector<char> input;
|
std::vector<char> input;
|
||||||
void input_key_press(char key) {
|
void sign_key_press(char key) {
|
||||||
if (is_valid_key(key)) {
|
if (is_valid_key(key)) {
|
||||||
input.push_back(key);
|
input.push_back(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void input_clear_input() {
|
void sign_clear_input() {
|
||||||
input.clear();
|
input.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,13 +52,14 @@ static void TextEditScreen_updateEvents_injection(unsigned char *screen) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
input_clear_input();
|
sign_clear_input();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _init_input_cpp() {
|
// Init
|
||||||
|
void init_sign() {
|
||||||
if (feature_has("Fix Sign Placement")) {
|
if (feature_has("Fix Sign Placement")) {
|
||||||
// Fix Signs
|
// Fix Signs
|
||||||
patch_address(LocalPlayer_openTextEdit_vtable_addr, (void *) LocalPlayer_openTextEdit_injection);
|
patch_address(LocalPlayer_openTextEdit_vtable_addr, (void *) LocalPlayer_openTextEdit_injection);
|
||||||
patch_address(TextEditScreen_updateEvents_vtable_addr, (void *) TextEditScreen_updateEvents_injection);
|
patch_address(TextEditScreen_updateEvents_vtable_addr, (void *) TextEditScreen_updateEvents_injection);
|
||||||
}
|
}
|
||||||
}
|
}
|
12
mods/src/sign/sign.h
Normal file
12
mods/src/sign/sign.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void sign_key_press(char key);
|
||||||
|
void sign_clear_input();
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user