From 0edee15930659256473e0440eee27a2f84321307 Mon Sep 17 00:00:00 2001 From: InviseDivine Date: Fri, 20 Mar 2026 22:59:52 +0200 Subject: [PATCH] FEAT:Raspberry PI cursor in tweaks --- data/lang/en_US.lang | 1 + src/AppPlatform.h | 2 ++ src/AppPlatform_glfw.h | 5 +++++ src/client/Options.cpp | 2 ++ src/client/Options.h | 1 + src/client/gui/screens/OptionsScreen.cpp | 3 ++- src/client/renderer/GameRenderer.cpp | 13 ++++++++----- src/main_glfw.h | 2 +- 8 files changed, 22 insertions(+), 7 deletions(-) diff --git a/data/lang/en_US.lang b/data/lang/en_US.lang index dc643c9..f810e85 100755 --- a/data/lang/en_US.lang +++ b/data/lang/en_US.lang @@ -152,6 +152,7 @@ options.group.graphics=Graphics options.group.tweaks=Tweaks options.allowSprint=Allow sprint options.barOnTop=HUD above inventory +options.rpiCursor=Show Raspberry PI cursor options.autojump=Auto Jump options.thirdperson=Third Person options.servervisible=Server Visible diff --git a/src/AppPlatform.h b/src/AppPlatform.h index 84163b1..d52118a 100755 --- a/src/AppPlatform.h +++ b/src/AppPlatform.h @@ -74,6 +74,8 @@ public: virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); } virtual void playSound(const std::string& fn, float volume, float pitch) {} + + virtual void hideCursor(bool hide) {} virtual void showDialog(int dialogId) {} virtual void createUserInput() {} diff --git a/src/AppPlatform_glfw.h b/src/AppPlatform_glfw.h index 4c7eb72..dcba807 100755 --- a/src/AppPlatform_glfw.h +++ b/src/AppPlatform_glfw.h @@ -139,6 +139,11 @@ public: virtual bool supportsTouchscreen() override { return true; } + virtual void hideCursor(bool hide) { + int isHide = hide ? GLFW_CURSOR_NORMAL : GLFW_CURSOR_HIDDEN; + glfwSetInputMode(window, GLFW_CURSOR, isHide); + } + virtual void openURL(const std::string& url) override { #ifdef _WIN32 ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); diff --git a/src/client/Options.cpp b/src/client/Options.cpp index 7f965e8..478e2ca 100755 --- a/src/client/Options.cpp +++ b/src/client/Options.cpp @@ -20,6 +20,7 @@ OptionBool fixedCamera("fixedCamera", false); OptionBool isFlying("isflying", false); OptionBool barOnTop("barOnTop", false); OptionBool allowSprint("allowSprint", true); +OptionBool rpiCursor("rpiCursor", false); OptionBool autoJump("autoJump", true); @@ -158,6 +159,7 @@ void Options::initTable() { m_options[OPTIONS_BAR_ON_TOP] = &barOnTop; m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint; + m_options[OPTIONS_RPI_CURSOR] = &rpiCursor; m_options[OPTIONS_AUTOJUMP] = &autoJump; m_options[OPTIONS_LAST_IP] = &lastIp; diff --git a/src/client/Options.h b/src/client/Options.h index 6401471..670cca7 100755 --- a/src/client/Options.h +++ b/src/client/Options.h @@ -83,6 +83,7 @@ enum OptionId { OPTIONS_FIRST_LAUNCH, OPTIONS_LAST_IP, + OPTIONS_RPI_CURSOR, // Should be last! OPTIONS_COUNT }; diff --git a/src/client/gui/screens/OptionsScreen.cpp b/src/client/gui/screens/OptionsScreen.cpp index 61d1389..adeb5be 100755 --- a/src/client/gui/screens/OptionsScreen.cpp +++ b/src/client/gui/screens/OptionsScreen.cpp @@ -225,7 +225,8 @@ void OptionsScreen::generateOptionScreens() { .addOptionItem(OPTIONS_AMBIENT_OCCLUSION, minecraft); optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft) - .addOptionItem(OPTIONS_BAR_ON_TOP, minecraft); + .addOptionItem(OPTIONS_BAR_ON_TOP, minecraft) + .addOptionItem(OPTIONS_RPI_CURSOR, minecraft); } void OptionsScreen::mouseClicked(int x, int y, int buttonNum) { diff --git a/src/client/renderer/GameRenderer.cpp b/src/client/renderer/GameRenderer.cpp index 8165793..ca9d388 100755 --- a/src/client/renderer/GameRenderer.cpp +++ b/src/client/renderer/GameRenderer.cpp @@ -1,4 +1,5 @@ #include "GameRenderer.h" +#include "client/Options.h" #include "gles.h" #include "../../util/PerfTimer.h" @@ -214,12 +215,14 @@ void GameRenderer::render(float a) { glDisable2(GL_SCISSOR_TEST); mc->screen->render(xMouse, yMouse, a); -#ifdef RPI + + mc->platform()->hideCursor(!mc->options.getBooleanValue(OPTIONS_RPI_CURSOR)); + if (mc->options.getBooleanValue(OPTIONS_RPI_CURSOR)) renderCursor(xMouse, yMouse, mc); -#endif - // Screen might have been removed, so check it again - if (mc->screen && !mc->screen->isInGameScreen()) - sleepMs(15); + + // Screen might have been removed, so check it again + if (mc->screen && !mc->screen->isInGameScreen()) + sleepMs(15); } } diff --git a/src/main_glfw.h b/src/main_glfw.h index ecee3ad..213c7ad 100755 --- a/src/main_glfw.h +++ b/src/main_glfw.h @@ -166,7 +166,7 @@ int main(void) { AppPlatform_glfw* platform = (AppPlatform_glfw*)appContext.platform; - platform->window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "main", NULL, NULL); + platform->window = glfwCreateWindow(appContext.platform->getScreenWidth(), appContext.platform->getScreenHeight(), "Minecraft PE 0.6.1", NULL, NULL); if (platform->window == NULL) { return 1;