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

Requests: Add hotkeys press events #595

Merged
merged 4 commits into from
Sep 30, 2020

Conversation

LorenaGdL
Copy link

@LorenaGdL LorenaGdL commented Sep 30, 2020

Description

This PR adds two new requests that allow triggering hotkeys callback functions over websocket. The hotkey can be defined either by its unique name (the one used during registration) or by specifing the combination of keys associated to trigger it. In the latter, if the same combination has been set for multiple hotkeys, all of them will be triggered.

Note: the requests are named ProcessHotkey and not PressHotkey because no "physical" pressing event is sent/triggered, rather just the underlying callback functions are called/processed. Please let me know if you'd rather name the requests differently.

Motivation and Context

This PR was motivated by the need to trigger script functions remotely. The requests can be easily used to trigger custom hotkeys registered within a script, and of course they also work with the default OBS hotkeys.

Related feature requests: #427, #444, #180

How Has This Been Tested?

Tested OS(s): Windows 7 SP1, Windows 10 2004 (OBS 25.0.8)

The changes were tested by sending the requests via webpage using obs-websocket-js. For ProcessHotkeyByName request, both OBS default hotkeys and custom hotkeys (registered within scripts) were tested. For ProcessHotkeyByCombination request, tests were done with multiple key combinations (with and without modifiers), and associated to a single or multiple hotkey routines.

Types of changes

  • New request/event (non-breaking)
  • Documentation change (a change to documentation pages)

Checklist:

  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Adds a new request called `ProcessHotkeyByName` which calls the routine
associated with a given hotkey. The hotkey is identified by the unique
name set while registering it. Works with both OBS default hotkeys and
hotkeys added by plugins/scripts.
Adds a new request called `ProcessHotkeyByCombination` which calls the
routine associated with a given hotkey. The hotkey is identified by the
combination of keys set by the user to trigger it. Multiple routines
are called if the same combination is bound to different hotkeys.
src/WSRequestHandler.cpp Outdated Show resolved Hide resolved
src/WSRequestHandler_General.cpp Show resolved Hide resolved
src/WSRequestHandler_General.cpp Outdated Show resolved Hide resolved
LorenaGdL and others added 2 commits September 30, 2020 19:15
Changes requests names to "TriggerHotkeyByName" and "TriggerHotkeyBySequence"
@LorenaGdL
Copy link
Author

Thanks for the docs updates and the other fixes, I'll keep them in mind for future PRs

We need to adjust the TriggerHotkeyBySequence/TriggerHotkeyByCombination name, we ended up using different stuff in our PRs. Feel free to update whatever you want

@tt2468 tt2468 merged commit 02c7a7f into obsproject:4.x-current Sep 30, 2020
@LorenaGdL
Copy link
Author

@tt2468 I guess you didn't see my message before merging. New docs refer to TriggerHotkeyByCombination but the request is actually called TriggerHotkeyBySequence. You need to change either of those, whichever you prefer.

Sorry for all the mess :S

@tt2468
Copy link
Member

tt2468 commented Sep 30, 2020

I did read your message, but didn't understand it correctly. Oops

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