Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SpaghettDev/BetterInputs
Browse files Browse the repository at this point in the history
…into mac
  • Loading branch information
SpaghettDev committed Jun 8, 2024
2 parents e223e53 + 4b5c658 commit eaccc72
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/geode-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ jobs:
- name: Windows
os: windows-latest

- name: macOS
os: macos-latest

name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ 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/).

## [v3.1.0-beta] - 2024-06-08

### Fixed

- Dragging input in the index crashing the game
- Some mouse issues

## [v3.0.0-beta] - 2024-06-06

### Added
Expand Down
5 changes: 2 additions & 3 deletions mod.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
"geode": "3.0.0-alpha.1",
"gd": {
"win": "2.206",
"mac": "2.206"
"win": "2.206"
},
"version": "v3.0.0-beta",
"version": "v3.1.0-beta",
"id": "spaghettdev.betterinputs",
"name": "BetterInputs",
"developer": "SpaghettDev",
Expand Down
50 changes: 27 additions & 23 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,8 @@ struct AlertLayerFix : Modify<AlertLayerFix, CCScene>
{
struct Fields
{
// its not like the input will change parents...
CCLayer* m_outermostInputParent = nullptr;
std::size_t m_previous_scene_children_count = 0;
CCLayer* m_outermost_input_parent;
};

static CCScene* create()
Expand All @@ -852,27 +852,28 @@ struct AlertLayerFix : Modify<AlertLayerFix, CCScene>

void onUpdateTick(float)
{
const std::size_t currentChildrenCount = this->getChildrenCount();

if (
!g_selectedInput ||
!BI::geode::get<bool>("auto-deselect") ||
typeinfo_cast<geode::Notification*>(this->getChildren()->lastObject()) ||
typeinfo_cast<LoadingCircle*>(this->getChildren()->lastObject())
) {
m_fields->m_outermostInputParent = nullptr;
currentChildrenCount == 1 ||
currentChildrenCount == m_fields->m_previous_scene_children_count
)
return;
}

if (!m_fields->m_outermostInputParent)
if (!m_fields->m_outermost_input_parent)
{
CCLayer* outermostInputParent = static_cast<CCLayer*>(g_selectedInput->getParent());
while (outermostInputParent->getParent() != this)
outermostInputParent = static_cast<CCLayer*>(outermostInputParent->getParent());

m_fields->m_outermostInputParent = outermostInputParent;
m_fields->m_outermost_input_parent = outermostInputParent;
}

if (static_cast<CCLayer*>(this->getChildren()->lastObject())->getZOrder() > m_fields->m_outermostInputParent->getZOrder())
if (static_cast<CCLayer*>(this->getChildren()->lastObject())->getZOrder() > m_fields->m_outermost_input_parent->getZOrder())
g_selectedInput->deselectInput();

m_fields->m_previous_scene_children_count = currentChildrenCount;
}
};

Expand Down Expand Up @@ -999,22 +1000,25 @@ struct BetterCCEGLView : Modify<BetterCCEGLView, CCEGLView>
{
CCEGLView::onGLFWMouseCallBack(window, button, action, mods);

if (!g_selectedInput || button != GLFW_MOUSE_BUTTON_1 || action == 1) return;
if (!g_selectedInput || button != GLFW_MOUSE_BUTTON_1 || action == 2) return;

CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCPoint mousePos = BI::cocos::getMousePosition();

// OpenGL's mouse origin is the bottom left
// CCTouch's mouse origin is top left (because of course it is)
CCTouch touch{};
touch.setTouchInfo(0, mousePos.x, winSize.height - mousePos.y);
if (action == 1)
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
CCPoint mousePos = BI::cocos::getMousePosition();

g_selectedInput->useUpdateBlinkPos(true);
// OpenGL's mouse origin is the bottom left
// CCTouch's mouse origin is top left (because of course it is)
CCTouch touch{};
touch.setTouchInfo(0, mousePos.x, winSize.height - mousePos.y);

// 🥰
g_selectedInput->ccTouchBegan(&touch, nullptr);
g_selectedInput->useUpdateBlinkPos(true);

g_selectedInput->useUpdateBlinkPos(false);
// 🥰
g_selectedInput->ccTouchBegan(&touch, nullptr);
}
else
g_selectedInput->useUpdateBlinkPos(false);
}
};

Expand Down

0 comments on commit eaccc72

Please sign in to comment.