diff --git a/CHANGELOG.md b/CHANGELOG.md index 9810d13..9740fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [v2.3.0-beta] - 2024-06-06 + +### Added + +- MacOS support :o + +### Changed + +- Target Geode version (v2.0.0-beta.27 -> v3.0.0-alpha.1) + ## [2.2.1-beta] - 2024-06-01 ### Changed diff --git a/CMakeLists.txt b/CMakeLists.txt index f6434da..cfab817 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.21) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_OSX_ARCHITECTURES "x86_64") +set(CMAKE_OSX_ARCHITECTURES "x64") set(CMAKE_CXX_VISIBILITY_PRESET hidden) project(BetterInputs VERSION 1.0.0) @@ -16,6 +16,8 @@ else() message(STATUS "Found Geode: $ENV{GEODE_SDK}") endif() +set(GEODE_LINK_NIGHTLY ON) + add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode) setup_geode_mod(${PROJECT_NAME}) diff --git a/mod.json b/mod.json index 75d4e95..0bb1e2a 100644 --- a/mod.json +++ b/mod.json @@ -1,13 +1,15 @@ { - "geode": "2.0.0-beta.27", + "geode": "3.0.0-alpha.1", "gd": { - "win": "2.204" + "win": "2.206", + "mac": "2.206" }, - "version": "v2.2.1-beta", + "version": "v2.3.0-beta", "id": "spaghettdev.betterinputs", "name": "BetterInputs", "developer": "SpaghettDev", "description": "Makes inputs behave like on Windows (text highlighting, Ctrl+A, Ctrl+Arrow hotkeys, etc...)", + "tags": ["enhancement"], "repository": "https://github.com/SpaghettDev/BetterInputs", "links": { "community": "https://discord.gg/3bShQb6Jz3", @@ -28,7 +30,7 @@ "type": "bool", "default": true, "name": "Allow any character", - "description": "Allows inputting any character (even ones not allowed) into input nodes. This is ignored if you have a mod menu that already has this enabled!" + "description": "Allows inputting any character (even ones not allowed) into input nodes." } } } \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 8682a2d..9ad52df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -137,6 +137,16 @@ struct BetterTextInputNode : Modify this->m_cursor->setVisible(false); } + void onStringEmpty() + { + if (this->m_placeholderLabel) + this->m_placeholderLabel->setString(""); + else + this->m_textArea->setString(""); + updateBlinkLabelToCharForced(-1); + showTextOrPlaceholder(false); + } + // Left and Right arrow events void onRightArrow(bool isCtrl, bool isShift) @@ -342,14 +352,7 @@ struct BetterTextInputNode : Modify ); if (m_fields->m_string.empty()) - { - if (this->m_placeholderLabel) - this->m_placeholderLabel->setString(""); - else - this->m_textArea->setString(""); - updateBlinkLabelToCharForced(-1); - showTextOrPlaceholder(false); - } + onStringEmpty(); } @@ -596,14 +599,7 @@ struct BetterTextInputNode : Modify ); if (m_fields->m_string.empty()) - { - if (this->m_placeholderLabel) - this->m_placeholderLabel->setString(""); - else - this->m_textArea->setString(""); - updateBlinkLabelToCharForced(-1); - showTextOrPlaceholder(false); - } + onStringEmpty(); return; } @@ -622,14 +618,7 @@ struct BetterTextInputNode : Modify updateBlinkLabelToCharForced(pos - 1 == m_fields->m_string.length() ? -1 : pos - 1); if (m_fields->m_string.empty()) - { - if (this->m_placeholderLabel) - this->m_placeholderLabel->setString(""); - else - this->m_textArea->setString(""); - updateBlinkLabelToCharForced(-1); - showTextOrPlaceholder(false); - } + onStringEmpty(); } /** @@ -958,15 +947,15 @@ struct BetterCCEGLView : Modify case GLFW_KEY_RIGHT: g_selectedInput->onRightArrow( - BI::windows::keyDown(VK_CONTROL), - BI::windows::keyDown(VK_SHIFT) + BI::platform::keyDown(BI::PlatformKey::LEFT_CONTROL), + BI::platform::keyDown(BI::PlatformKey::LEFT_SHIFT) ); break; case GLFW_KEY_LEFT: g_selectedInput->onLeftArrow( - BI::windows::keyDown(VK_CONTROL), - BI::windows::keyDown(VK_SHIFT) + BI::platform::keyDown(BI::PlatformKey::LEFT_CONTROL), + BI::platform::keyDown(BI::PlatformKey::LEFT_SHIFT) ); break; @@ -976,7 +965,7 @@ struct BetterCCEGLView : Modify } // this is what onGLFWKeyCallback actually does to check for control lol - if (action == 1 && BI::windows::keyDown(VK_CONTROL)) + if (action == 1 && BI::platform::keyDown(BI::PlatformKey::LEFT_CONTROL)) { switch (key) { diff --git a/src/utils.hpp b/src/utils.hpp index 12a8870..523ae0a 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -1,7 +1,11 @@ #include #include -#include +#include + +#ifdef GEODE_IS_WINDOWS +#include // virtual keys +#endif #include @@ -106,11 +110,32 @@ namespace BI } } - namespace windows + enum class PlatformKey + { + LEFT_CONTROL, + LEFT_SHIFT + }; + namespace platform { - inline bool keyDown(unsigned int vk) + inline bool keyDown(PlatformKey key) { - return GetKeyState(vk) & 0x8000; +#ifdef GEODE_IS_WINDOWS + switch (key) + { + case BI::PlatformKey::LEFT_CONTROL: + return GetKeyState(VK_CONTROL) & 0x8000; + case BI::PlatformKey::LEFT_SHIFT: + return GetKeyState(VK_SHIFT) & 0x8000; + } +#elif defined(GEODE_IS_MACOS) + switch (key) + { + case BI::PlatformKey::LEFT_CONTROL: + return cocos2d::CCKeyboardDispatcher::get()->getControlKeyPressed(); + case BI::PlatformKey::LEFT_SHIFT: + return cocos2d::CCKeyboardDispatcher::get()->getShiftKeyPressed(); + } +#endif } } @@ -118,11 +143,15 @@ namespace BI { inline bool isVanillaInput() { - std::uintptr_t readMemory; - - std::memcpy(&readMemory, reinterpret_cast(geode::base::get() + 0x2F974), 1); - - return readMemory == 0x0475; + return true; +// std::uintptr_t readMemory; + +// #ifdef GEODE_IS_WINDOWS +// std::memcpy(&readMemory, reinterpret_cast(geode::base::get() + 0x2F974), 1); +// #elif defined(GEODE_IS_MACOS) +// std::memcpy(&readMemory, reinterpret_cast(geode::base::get() + 0x2F974), 1); +// #endif +// return readMemory == 0x0475; } }