Skip to content

Commit

Permalink
new windows workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
qimiko committed Jun 22, 2024
1 parent 1aeec66 commit 8b49281
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

- port to 2.206 (thank you mat for Windows offsets)

Note: Windows 2.206 currently has some new compatibility issues (for example, with custom keybinds)

## v1.1.0

- initial Windows support
Expand Down
8 changes: 8 additions & 0 deletions src/async.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "async.hpp"
#include "main.hpp"

#define DEBUG_PROCESSING false

Expand All @@ -12,6 +13,8 @@ void AsyncUILayer::handleKeypress(cocos2d::enumKeyCodes key, bool down) {
m_fields->m_lastTimestamp = extendedInfo->getTimestamp();

UILayer::handleKeypress(key, down);
static_cast<CustomGJBaseGameLayer*>(this->m_gameLayer)->fixUntimedInputs();

m_fields->m_lastTimestamp = 0ull;
}

Expand All @@ -24,6 +27,8 @@ bool AsyncUILayer::ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event
m_fields->m_lastTimestamp = extendedInfo->getTimestamp();

auto r = UILayer::ccTouchBegan(touch, event);
static_cast<CustomGJBaseGameLayer*>(this->m_gameLayer)->fixUntimedInputs();

m_fields->m_lastTimestamp = 0ull;

return r;
Expand Down Expand Up @@ -54,6 +59,7 @@ void AsyncUILayer::ccTouchMoved(cocos2d::CCTouch* touch, cocos2d::CCEvent* event
}
#else
UILayer::ccTouchMoved(touch, event);
static_cast<CustomGJBaseGameLayer*>(this->m_gameLayer)->fixUntimedInputs();
#endif

m_fields->m_lastTimestamp = 0ull;
Expand All @@ -68,6 +74,8 @@ void AsyncUILayer::ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event
m_fields->m_lastTimestamp = extendedInfo->getTimestamp();

UILayer::ccTouchEnded(touch, event);
static_cast<CustomGJBaseGameLayer*>(this->m_gameLayer)->fixUntimedInputs();

m_fields->m_lastTimestamp = 0ull;
}

Expand Down
12 changes: 11 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,15 @@ void CustomGJBaseGameLayer::processCommands(float timeStep) {
GJBaseGameLayer::processCommands(timeStep);
}

// TODO: need a new Windows workaround for 2.206
void CustomGJBaseGameLayer::fixUntimedInputs() {
#ifdef GEODE_IS_WINDOWS
// windows workaround as queueButton and its vector insert is supposedly inlined everywhere!!
// as long as this is called before the timestamp is cleared, it should work
for (const auto& btn : this->m_queuedButtons) {
this->queueButton(static_cast<int>(btn.m_button), btn.m_isPush, btn.m_isPlayer2);
}

this->m_queuedButtons.clear();
#endif
}

3 changes: 3 additions & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct CustomGJBaseGameLayer : geode::Modify<CustomGJBaseGameLayer, GJBaseGameLa

void processTimedInputs();
void dumpInputQueue();

// windows workaround
void fixUntimedInputs();
};


0 comments on commit 8b49281

Please sign in to comment.