Closed lorado closed 3 years ago
For someone, who want to test it locally - here is a build for Windows and mac: https://www.dropbox.com/s/nkq9mhwuv52v2wc/obs-midi-addjusted-by-lorado.zip?dl=0
Dont forget to add a translation for the action name in data/locale/en-us.ini once it is in that file, crowdin will go and add it to the rest of the translation files (:
Once we figure out how to translate the strings for the hotkeys I'll pull this in and make a release
Ok nice, thank you for cleaning the code up. I knew there is a possibility to do only one loop, to create a QStringList for Hotkeys, but as I said, I am not good at c++ :D
About Translations - we don't really need a translation, I guess. Hotkey has a description
property, where human readable text is stored. This description
is defined by obs_hotkey_register_frontend()
as second parameter, which is actually also used in a regular Keyboard-Hotkey-Settings in OBS. We don't have to translate them on our own, but we have to store the name
property of the hotkey object.
I'll try to solve this somehow...
So, there is one big problem I see, The list of triggers contains many duplicates, not just of existing actions which I have implemented, but also
Hi @cpyarger,
as I said, I would not pull description directly. It is not really safe, as after changing UI language in OBS, hotkeys descriptions will be different (I guess, but it makes sense to me). So after switching language, mapping will not work anymore
I am working right now on the solution - using QPair, should work. Give me a time please
No problem, I just was pushing up changes to see if it worked, Also we need to filter out the excess hotkeys, as it currently stands there are way to many extras being added at the moment.
one last push to refix the break i had
The problem with apparently duplicated hotkeys - as I said, it polls all the hotkeys. So you can take a look into Settings -> Hotkey section, to see which hotkeys you actually have. They are there separated into different blocks (see screenshot)
We could probably filter some basic stuff, which you already implemented using other actions. I mean those buttons names start with OBSBasic.*
, libobs.*
.
I will test it ;)
What about triggering scripts, since this is about doing that, instead of having it be a generic "trigger hotkeys" why not filter out everything but script triggers and have it be a "trigger script" action
most everything else I can build into the normal actions if I haven't already (:
I think using hotkeys makes it actually easier to run custom stuff. So to be able to run some script - simply add a hotkey. Also, when you define a hotkey, you define what function should be executed by triggering this hotkey. Also I don't know how to poll script list, and then there is also a question - what function is the entry point of the script? Using hotkey in script you don't have these issues.
How do scripts show up in our hotkeys list? they should be there correct? I dont have any scripts that trigger on a hotkey. so I can't test that
You can take a look into default instant-replay.lua
shipped with current OBS by default.
-- A function named script_load will be called on startup
function script_load(settings)
hotkey_id = obs.obs_hotkey_register_frontend("instant_replay.trigger", "Instant Replay", instant_replay)
local hotkey_save_array = obs.obs_data_get_array(settings, "instant_replay.trigger")
obs.obs_hotkey_load(hotkey_id, hotkey_save_array)
obs.obs_data_array_release(hotkey_save_array)
end
obs_hotkey_register_frontend()
defines a hotkey.
name
, or actually an ID for us, as this is the value, by which we ran the script in Utils::FindHotkeyByName()
- this function is from obs-websocket =)description
, which is a human readable text, which is displayed in Settings -> Hotkeys section, if you install the script, which I also whould use to display in the options listAnd I catched up this idea, because I found a way to tell OBS programmatically, that some hotkey was triggered - obs_hotkey_trigger_routed_callback()
I have cleaned up my aditions and removed description.
I would have been too easy if obs pretended script hotkey names with .script XD
Could you somehow help me to get build working on my macos machine? It is really annoying I am not able to build locally =\
Added the filter
sure want to hop into discord? ill be in the common room https://discord.gg/2QXwwwQS
Since we will be saving the hotkeys by their name, and not description, I am going to pull this in for now, When you have the hotkey description for the ui fixes complete, Just issue a new PR
In #111 and #112, @gdhgdhgdh an me wished the ability to run scripts via MIDI Messages.
This PR is a quick (and probably dirty) solution for this.
There is new action
Trigger_Hotkey_By_Name
defined inutils.h
(I also found actions definition inactions.h
, but they are not used at all, so I extended it only inutils.h
)There is also a new UI row for selection hotkey, which becomes visible, if you select
Trigger_Hotkey_By_Name
action. All Hotkeys, which are defined withobs_hotkey_register_frontend()
function, are available. So if you want to run a script via MIDI Message, you have to define some hotkeys in yourfunction script_load(settings) {...}
. The first argument ofobs_hotkey_register_frontend()
defines the name of the hotkey, which is currently used to display hotkey in the UI options list.So at the end, it acts like Hotkey binding for keyboard, but for MIDI Device.
With this implementation it is actually possible to achieve what we wanted.
I tested it locally on macOs with virtual MIDI Device (StreamDeck), it workes fine
Some possible improvements: