Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Demos on MacOS #92

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix Demos on MacOS #92

wants to merge 2 commits into from

Conversation

zawata
Copy link

@zawata zawata commented Jan 20, 2024

Hey, I've been trying to implement OIS into my emulator but for reasons I haven't determined yet, it isn't working. Might have another patch for that in the near future when I figure it out.

While digging around in the codebase I learned that the demos barely supported macos so I took a quick stab at fixing them.

The FFDemo just need cocoa to be implemented but the ConsoleDemo was the interesting one. ReceiveNextEvent was actually returning an error -9874 which according to https://www.osstatus.com/ is eventNotHandledErr which explains why the rest of the demo was non-functional.

I assume that the carbon Api's became fully incompatible with Cocoa Objects on an older version of MacOS(I'm on sonoma). So i switched over to the cocoa versions of these functions. Custom event loops like this are not really recommended for Cocoa Apps for several reasons but I don't think any are relevant to this example.

I took some inspiration from wxWidgets for the implementation. you can read more about it here:
https://github.com/wxWidgets/wxWidgets/blob/19aee81c1deb876e965661fd902565615a6a09f3/src/osx/cocoa/evtloop.mm
and here:
https://www.cocoawithlove.com/2009/01/demystifying-nsapplication-by.html

If you think we should instead be a little bit more supportive of Native Cocoa App Architecture then I'll probably need to do it in another PR and it would take some refactors to the demos to accomplish. Just let me know.

closes #35

@zawata
Copy link
Author

zawata commented Jan 20, 2024

Also I haven't actually tested FFDemo, I've only confirmed it doesn't crash anymore. Gotta dig out an xbox controller and get it working with my mac to test it.

@zawata
Copy link
Author

zawata commented Jan 20, 2024

Ok So MacOS doesn't have force-feedback implemented I guess so no point in fixing FFDemo. I can try to implement it but it's a little too complex for this PR so I've backed out the FFDemo changes.

I did however find a bad string conversion that was segfaulting when a controller was attached so I've fixed that. Looks like game controllers are working now mostly. There's some bugs I'm still looking into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement console demo on Mac OS with Cocoa
1 participant