Skip to content

Commit 04ed76b

Browse files
committed
yeah
1 parent b4d3d84 commit 04ed76b

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

mod.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"geode": "4.1.2",
2+
"geode": "4.2.0",
33
"gd": {
44
"win": "2.2074",
55
"mac": "2.2074"
@@ -10,14 +10,14 @@
1010
"developer": "SpaghettDev",
1111
"description": "Makes inputs behave like they should.",
1212
"tags": ["enhancement"],
13-
"links": {
14-
"community": "https://discord.gg/3bShQb6Jz3",
15-
"source": "https://github.com/SpaghettDev/BetterInputs"
16-
},
17-
"issues": {
18-
"info": "Report any bugs/suggestions here.",
19-
"url": "https://github.com/SpaghettDev/BetterInputs/issues"
20-
},
13+
"links": {
14+
"community": "https://discord.gg/3bShQb6Jz3",
15+
"source": "https://github.com/SpaghettDev/BetterInputs"
16+
},
17+
"issues": {
18+
"info": "Report any bugs/suggestions here.",
19+
"url": "https://github.com/SpaghettDev/BetterInputs/issues"
20+
},
2121
"settings": {
2222
"allow-any-character": {
2323
"type": "bool",

src/macos.mm

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ inline bool keyDown(PlatformKey key, NSEvent* event)
3737

3838
namespace cocos
3939
{
40-
// TODO: fix
41-
// inline cocos2d::CCPoint getMousePosition(NSEvent* event)
42-
// {
43-
// auto windowFrame = [[event window] frame];
44-
// auto viewFrame = [[[event window] contentView] frame];
45-
// auto winSize = cocos2d::CCDirector::get()->getWinSize();
46-
// auto scaleFactor = cocos2d::CCPoint(winSize) / ccp(viewFrame.size.width, viewFrame.size.height);
47-
// auto mouse = [event locationInWindow];
48-
49-
// return ccp(mouse.x - windowFrame.origin.x, winSize.height - (mouse.y - windowFrame.origin.y)) * scaleFactor;
50-
// }
40+
inline cocos2d::CCPoint getMousePosition(NSEvent* event)
41+
{
42+
auto windowFrame = [[event window] frame];
43+
auto viewFrame = [[[event window] contentView] frame];
44+
auto winSize = cocos2d::CCDirector::get()->getWinSize();
45+
auto scaleFactor = cocos2d::CCPoint(winSize) / ccp(viewFrame.size.width, viewFrame.size.height);
46+
auto mouse = [event locationInWindow];
47+
48+
return ccp(mouse.x - windowFrame.origin.x, winSize.height - (mouse.y - windowFrame.origin.y)) * scaleFactor;
49+
}
5150
}
5251
}
5352

@@ -204,13 +203,17 @@ void mouseDownExec(EAGLView* self, SEL sel, NSEvent* event)
204203
if (!g_selectedInput)
205204
return mouseDownExecOIMP(self, sel, event);
206205

207-
// cocos2d::CCPoint mousePos = BI::cocos::getMousePosition(event);
208-
cocos2d::CCPoint mousePos = BI::cocos::getMousePosition();
206+
NSPoint m = [event locationInWindow];
207+
208+
geode::log::debug("mouse pos is ({}, {})", m.x, m.y);
209+
210+
cocos2d::CCSize winSize = cocos2d::CCDirector::sharedDirector()->getWinSize();
211+
cocos2d::CCPoint mousePos = cocos2d::CCpoint{ m.x, m.y };
209212

210213
// NSWindow's mouse origin is the bottom left
211214
// CCTouch's mouse origin is top left (because of course it is)
212215
cocos2d::CCTouch touch{};
213-
touch.setTouchInfo(0, mousePos.x, mousePos.y);
216+
touch.setTouchInfo(0, mousePos.x, winSize.height - mousePos.y);
214217

215218
g_selectedInput->useUpdateBlinkPos(true);
216219

src/utils.hpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,18 @@ namespace BI
9999

100100
namespace cocos
101101
{
102+
#ifdef GEODE_IS_WINDOWS
102103
inline cocos2d::CCPoint getMousePosition()
103104
{
104-
#ifdef GEODE_IS_WINDOWS
105105
auto* director = cocos2d::CCDirector::sharedDirector();
106106
auto* gl = director->getOpenGLView();
107107
auto winSize = director->getWinSize();
108108
auto frameSize = gl->getFrameSize();
109109
auto mouse = gl->getMousePosition() / frameSize;
110110

111111
return cocos2d::CCPoint{ mouse.x, 1.f - mouse.y } * winSize;
112-
#elif defined(GEODE_IS_MACOS)
113-
return geode::cocos::getMousePos();
114-
#endif
115112
}
113+
#endif
116114

117115
inline bool isPositionInNode(cocos2d::CCNode* node, const cocos2d::CCPoint& pos)
118116
{

0 commit comments

Comments
 (0)