ptz-controls: Add hotkeys for selection relative preset recall - #337
ptz-controls: Add hotkeys for selection relative preset recall#337EdueskaWeiz wants to merge 1 commit into
Conversation
The numbered PTZ.Recall<n> hotkeys always address a fixed preset, and the only way to trigger the preset currently highlighted in the list is a double click or Enter inside the list itself. PTZJoyButtonMapper only offers named frontend hotkeys, so browsing the preset list with a controller and then activating the highlighted entry is not possible. Register three more frontend hotkeys: PTZ.PresetPrev move the selection up, wrapping around PTZ.PresetNext move the selection down, wrapping around PTZ.PresetRecallSelected recall the highlighted preset Moving the selection deliberately does not recall anything, so a controller can browse the list and trigger it with a separate button. Recalling with nothing selected is a no-op rather than an invalid preset id. Being frontend hotkeys, they are mappable to joystick buttons like every other action. Closes glikely#270 Signed-off-by: Eddy Weiz <eddyweiz@gmail.com>
|
Follow-up: the one thing I listed as unverified — that the three hotkeys reappear in the joystick button dropdown — is now checked, so that gap is closed. I got a joystick without owning one by flipping Build Assigning "Next Preset" to button 0 sticks, exactly like any other frontend hotkey. So the three entries that fell out of the list in v0.18.0 are back where they were, without the joystick code needing to know about presets at all. Unchanged from the description: no physical controller here, so I have not pressed a real button, and no PTZ camera, so a recall still moves nothing I can watch. |
| "PTZ.PresetPrev", obs_module_text("PTZ.Action.Preset.Prev"), | ||
| [](void *ptz_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { | ||
| if (pressed) | ||
| static_cast<PTZControls *>(ptz_data)->presetStep(-1); |
There was a problem hiding this comment.
All the move logic is already implemented in CircularListView. You can drop the presetStep() helper and call static_cast<PTZControls *>(ptz_data)->ui->presetListView->cursorUp() directly.
| [](void *ptz_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { | ||
| if (pressed) | ||
| static_cast<PTZControls *>(ptz_data)->presetStep(1); | ||
| }, |
| "PTZ.PresetRecallSelected", obs_module_text("PTZ.Action.Preset.RecallSelected"), | ||
| [](void *ptz_data, obs_hotkey_id, obs_hotkey_t *, bool pressed) { | ||
| if (pressed) | ||
| static_cast<PTZControls *>(ptz_data)->presetRecallSelected(); |
There was a problem hiding this comment.
There isn't a similar single helper for activating the item, but you could do this:
if (pressed) {
auto ctrls = static_cast<PTZControls *>(ptz_data);
ctrls->on_presetListView_activated(ctrls->ui->presetListView->currentIndex());
}
|
I've made the changes I suggested and pushed out to main. Thanks |
|
Thanks — and your version is better, dropping the two helpers for One thing got lost in the rewrite, though. The commit message still says:
but if (ptz_data && pressed) {
auto ctrls = static_cast<PTZControls *>(ptz_data);
ctrls->on_presetListView_activated(ctrls->ui->presetListView->currentIndex());
}With an empty preset list, or before anything has been selected, Most backends shrug that off: I checked that against Two lines put it back: if (ptz_data && pressed) {
auto ctrls = static_cast<PTZControls *>(ptz_data);
- ctrls->on_presetListView_activated(ctrls->ui->presetListView->currentIndex());
+ auto index = ctrls->ui->presetListView->currentIndex();
+ if (index.isValid())
+ ctrls->on_presetListView_activated(index);
}Happy to send it as a PR with a proper commit message and a |
|
Small heads-up, since v0.19.0-rc1 went out in the meantime: the missing Happy to send the two-liner as a proper pull request with a |
Closes #270.
This is a regression, not a new feature — I had that wrong in the issue at first and corrected it there. Up to v0.17.2 the joystick button dropdown was filled from a fixed list inside the plugin that contained "Previous Preset", "Next Preset" and "Recall Preset".
4b16fd3("joystick: Map hotkeys to buttons") reworked the dropdown to list OBS frontend hotkeys and reducedptz_joy_actionto axis actions. "Previous Camera" and "Next Camera" survived becausePTZ.SelectPrevandPTZ.SelectNextexist as hotkeys; the three preset actions had no hotkey equivalent, so they dropped out. That commit first shipped in v0.18.0.Registering them as frontend hotkeys puts them back in the joystick dropdown by itself, and makes them usable from the keyboard as well, which they never were:
Moving the selection deliberately does not recall anything, so a controller can browse the list and then fire it with a separate button — the workflow described in #270. Recalling with nothing selected is a no-op rather than an invalid preset id.
I named the third one "Recall Selected Preset" rather than the original "Recall Preset" to keep it apart from the numbered "Camera Recall #n" entries in the same list. Happy to restore the old wording.
Testing
Built from source and run against OBS Studio 32.2.1 (Qt 6.11.1) on Windows, plugin version
v0.18.3-rc1-65-g737c0fbconfirmed in the OBS log. Three presets on one device, hotkeys bound to F9 / F10 / F8.What I could not verify here, so that it is not silently claimed:
PTZJoyButtonMapperlisting frontend hotkeys, but I have not watched it happen.presetRecallSelected()goes through the samepresetRecall()as double-clicking an entry in the list.