Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
cpyarger committed Mar 15, 2021
2 parents a17a646 + 4eb1b47 commit 291d774
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ void Events::FinishedLoading()
hookTransitionPlaybackEvents();
startup();
started=true;
Utils::build_hotkey_map();
broadcastUpdate("LoadingFinished");
}
/**
Expand Down
16 changes: 10 additions & 6 deletions src/forms/settings-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ PluginWindow::PluginWindow(QWidget *parent) : QDialog(parent, Qt::Dialog), ui(ne
hide_all_pairs();
connect_ui_signals();
reset_to_defaults();

starting = false;
}
void PluginWindow::configure_table() const
Expand Down Expand Up @@ -701,7 +702,7 @@ void PluginWindow::add_new_mapping()
ui->table_mapping->setItem(row, 1, message_type_item);
ui->table_mapping->setItem(row, 2, norc_item);
ui->table_mapping->setItem(row, 3, action_item);

auto *new_midi_hook = new MidiHook();
new_midi_hook->channel = ui->sb_channel->value();
new_midi_hook->message_type = ui->cb_mtype->currentText();
Expand Down Expand Up @@ -729,8 +730,6 @@ void PluginWindow::add_new_mapping()
ui->table_mapping->setItem(row, 8, item_item);
new_midi_hook->item = ui->cb_obs_output_item->currentText();
}
if (ui->cb_obs_output_hotkey->isVisible())
new_midi_hook->hotkey = ui->cb_obs_output_hotkey->currentText();
if (ui->cb_obs_output_audio_source->isVisible()) {
ui->table_mapping->setItem(row, 9, audio_item);
new_midi_hook->audio_source = ui->cb_obs_output_audio_source->currentText();
Expand All @@ -751,7 +750,12 @@ void PluginWindow::add_new_mapping()
ui->table_mapping->setItem(row, 13, max);
new_midi_hook->range_max.emplace(ui->sb_max->value());
}
ui->table_mapping->setItem(row, 14, hotkey_item);
if (ui->cb_obs_output_hotkey->isVisible()) {
ui->table_mapping->setItem(row, 14, hotkey_item);
auto key = Utils::get_hotkey_key(ui->cb_obs_output_hotkey->currentText());
blog(LOG_DEBUG, "hotkey_key %s", key.toStdString().c_str());
new_midi_hook->hotkey = key;
}
new_midi_hook->setAction();
set_all_cell_colors(row);
if (editmode) {
Expand Down Expand Up @@ -803,7 +807,7 @@ void PluginWindow::add_row_from_hook(const MidiHook *hook) const
auto *item_item = new QTableWidgetItem(hook->item);
auto *audio_item = new QTableWidgetItem(hook->audio_source);
auto *media_item = new QTableWidgetItem(hook->media_source);
auto *hotkey_item = new QTableWidgetItem(hook->hotkey);
auto *hotkey_item = new QTableWidgetItem(Utils::get_hotkey_value(hook->hotkey));
QTableWidgetItem *ioveritem = (hook->int_override) ? new QTableWidgetItem(QString::number(*hook->int_override)) : new QTableWidgetItem();
QTableWidgetItem *min = (hook->range_min) ? new QTableWidgetItem(QString::number(*hook->range_min)) : new QTableWidgetItem();
QTableWidgetItem *max = (hook->range_max) ? new QTableWidgetItem(QString::number(*hook->range_max)) : new QTableWidgetItem();
Expand Down Expand Up @@ -906,7 +910,7 @@ void PluginWindow::edit_mapping()
{
if (ui->table_mapping->rowCount() != 0) {
editmode = true;

ui->btn_add->setText("Save Edits");
ui->btn_reset->setEnabled(true);
const auto dv = GetDeviceManager().get()->get_midi_hooks(ui->mapping_lbl_device_name->text());
Expand Down
41 changes: 29 additions & 12 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,7 @@ obs_hotkey_t *Utils::FindHotkeyByName(const QString &name)
}
QStringList Utils::GetHotkeysList()
{
QStringList *HotkeysList=new QStringList();
obs_enum_hotkeys(
[](void *data, obs_hotkey_id id, obs_hotkey_t *hotkey) {
auto list = static_cast<QStringList *>(data);
QString item(obs_hotkey_get_name(hotkey));
if (item.contains("libobs") || item.contains("MediaSource") || item.contains("OBSBasic"))
return true;
list->append(item);
return true;
},
HotkeysList);
return (QStringList)*HotkeysList;
return QStringList(hotkey_map.values());
}
bool Utils::ReplayBufferEnabled()
{
Expand Down Expand Up @@ -952,6 +941,34 @@ QString Utils::translate_action(ActionsClass::Actions action)
{
return QString(obs_module_text(ActionsClass::action_to_string(action).toStdString().c_str()));
}
void Utils::build_hotkey_map() {
hotkey_map.clear();

obs_enum_hotkeys(
[](void *data, obs_hotkey_id id, obs_hotkey_t *hotkey) {
QString item(obs_hotkey_get_name(hotkey));
if (item.contains("libobs") || item.contains("MediaSource") || item.contains("OBSBasic"))
return true;
blog(LOG_DEBUG, "hotkey_map insert: <%s>,<%s>",obs_hotkey_get_name(hotkey) ,obs_hotkey_get_description(hotkey));
hotkey_map.insert(item, obs_hotkey_get_description(hotkey));
return true;

},
NULL);
blog(LOG_DEBUG, "test_map_get_key %s ",hotkey_map.key("Deactivate capture").toStdString().c_str());

}
QString Utils::get_hotkey_key(QString value)
{

return hotkey_map.key(value);
}
QString Utils::get_hotkey_value(QString key)
{

return hotkey_map.value(key);
}

QString Utils::untranslate(const QString &tstring)
{
return ActionsClass::action_to_string(AllActions_raw.at(TranslateActions().indexOf(tstring)));
Expand Down
7 changes: 7 additions & 0 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,11 @@ const QList<ActionsClass::Actions> not_ready_actions{
};
void alert_popup(const QString &message);
QString translate_action(ActionsClass::Actions action);

static QMap<QString, QString> hotkey_map;
void build_hotkey_map();
QString get_hotkey_key(QString value);
QString get_hotkey_value(QString key);


};

0 comments on commit 291d774

Please sign in to comment.