Skip to content

Implemented Screenshot and Home buttons custom events - #89

Open
XITRIX wants to merge 3 commits into
xfangfang:wiliwilifrom
XITRIX:screenshot-guide
Open

XITRIX wants to merge 3 commits into
xfangfang:wiliwilifrom
XITRIX:screenshot-guide

Conversation

@XITRIX

@XITRIX XITRIX commented Nov 2, 2024

Copy link
Copy Markdown
Collaborator

Take a note that I added some c++20 specific code, so I've updated c++17 to 20 as well.

I didn't add any public access to replaceScreenshotWithGuideButton property, because I believe that this is highly Switch specific functionality, so to access it, you'l need to check platform first and call directly:

((SwitchInputManager*) brls::Application::getPlatform()->getInputManager())->setReplaceScreenshotWithGuideButton(...)

If you believe that this property could be useful for any other platform, I could move it to InputManager interface as well

@xfangfang

Copy link
Copy Markdown
Owner

It looks great! and I agree that it should be exclusive to Switch.

However, I am not sure if I want to upgrade to C++20. Currently, wiliwili is compatible with some older platforms, such as macOS 10.11. Setting C++ to 20 may inadvertently introduce content that is not supported by these platforms in the future.
If it is not convenient to modify it to C++17, perhaps we can only set the NintendoSwitch to C++20?


Someone previously requested to detect headphone unplugging event, so that we can adjust the volume or pause video playback when the headphones are disconnected. This PR made me think that we might be able to write the relevant implementations together, but I'm not sure if libnx exposed such an event.


By the way, according to the results of CI, it seems that this line raised an error in C++20, maybe you can delete the ({:#x}) to make CI pass.

https://github.com/xfangfang/borealis/blob/wiliwili/library/lib/platforms/switch/switch_video.cpp#L169

(cherry picked from commit 4cf9c53)
@XITRIX

XITRIX commented Nov 3, 2024

Copy link
Copy Markdown
Collaborator Author

I think this PR should be in draft, I already see potential flaws of this solution, I.E. I also implemented Home button capturing, in current implementation they will conflict with each other, so probably they should produce Events and then app can decide what to do with them.

For switch_video I already made a fix, I'll upload it tomorrow (it's 2:30 AM, I need to go to sleep)

But I got your point about C++17, I'll try to exclude C++20 features from PR

@XITRIX XITRIX changed the title Implemented Screenshot button override as Guide button Implemented Screenshot and Home buttons custom events Nov 3, 2024
@XITRIX

XITRIX commented Nov 3, 2024

Copy link
Copy Markdown
Collaborator Author

I've changed implementation a bit, now Screenshot and Home buttons have 3 modes:

  • NONE - aka default
  • CUSTOM_EVENT - boralis will suppress system call, and will start to reroute press events into m_isScreenshotPressed or m_isHomePressed
  • GUIDE_BUTTON - same as CUSTOM_EVENT + will also toggle Guide button for controller state

I think this approach will be more flexible in terms of custom actions for this buttons.

I also tried to find something related to headphones connection, but for now I'm out of luck, maybe it could have some weird name or notifies as part of anything else (if exposed at all)

I could also expose Power button, but it's a bit too much I think :D

(cherry picked from commit ab73b91)
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.

2 participants