diff --git a/src/blackgui/components/settingshotkeycomponent.cpp b/src/blackgui/components/settingshotkeycomponent.cpp index 39571177c..b65613100 100644 --- a/src/blackgui/components/settingshotkeycomponent.cpp +++ b/src/blackgui/components/settingshotkeycomponent.cpp @@ -14,6 +14,7 @@ #include "blackcore/context/contextaudio.h" #include "blackcore/inputmanager.h" #include "blackmisc/input/actionhotkeydefs.h" +#include "blackmisc/metadatautils.h" #include "ui_settingshotkeycomponent.h" #include @@ -81,6 +82,9 @@ namespace BlackGui m_model.insertRows(position, 1, QModelIndex()); const QModelIndex index = m_model.index(position, 0, QModelIndex()); m_model.setData(index, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole); + + // T784, further info about the "key"/button + CLogMessage(this).debug(u"%1, added key: '%2'") << classNameShort(this) << selectedActionHotkey.toQString(true); } this->resizeView(); } @@ -88,18 +92,20 @@ namespace BlackGui void CSettingsHotkeyComponent::editEntry() { const auto index = ui->tv_Hotkeys->selectionModel()->currentIndex(); - if (!index.isValid()) return; + if (!index.isValid()) { return; } const auto model = ui->tv_Hotkeys->model(); const QModelIndex indexHotkey = model->index(index.row(), 0, QModelIndex()); Q_ASSERT_X(indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).canConvert(), Q_FUNC_INFO, "No action hotkey"); - CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value(); - + const CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value(); const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(actionHotkey, getAllIdentifiers(), this); if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey, { actionHotkey })) { updateHotkeyInSettings(actionHotkey, selectedActionHotkey); m_model.setData(indexHotkey, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole); + + // T784, further info about the "key"/button + CLogMessage(this).debug(u"%1, edited key: '%2'") << classNameShort(this) << selectedActionHotkey.toQString(true); } this->resizeView(); } @@ -109,7 +115,7 @@ namespace BlackGui const QModelIndexList indexes = ui->tv_Hotkeys->selectionModel()->selectedRows(); for (const auto &index : indexes) { - CActionHotkey actionHotkey = index.data(CActionHotkeyListModel::ActionHotkeyRole).value(); + const CActionHotkey actionHotkey = index.data(CActionHotkeyListModel::ActionHotkeyRole).value(); removeHotkeyFromSettings(actionHotkey); m_model.removeRows(index.row(), 1, QModelIndex()); } diff --git a/src/blackinput/win/joystickwindows.cpp b/src/blackinput/win/joystickwindows.cpp index f55d2f51d..e8f51e9a0 100644 --- a/src/blackinput/win/joystickwindows.cpp +++ b/src/blackinput/win/joystickwindows.cpp @@ -8,6 +8,8 @@ #include "joystickwindows.h" #include "blackmisc/logmessage.h" +#include "blackmisc/metadatautils.h" + #include "comdef.h" #include "Dbt.h" @@ -25,11 +27,11 @@ namespace BlackInput QObject(parent), m_guidDevice(pdidInstance->guidInstance), m_guidProduct(pdidInstance->guidProduct), - m_deviceName(QString::fromWCharArray(pdidInstance->tszInstanceName)), - m_productName(QString::fromWCharArray(pdidInstance->tszProductName)), + m_deviceName(QString::fromWCharArray(pdidInstance->tszInstanceName).simplified()), + m_productName(QString::fromWCharArray(pdidInstance->tszProductName).simplified()), m_directInput(directInputPtr) { - this->setObjectName("CJoystickDevice"); + this->setObjectName(classNameShort(this)); } bool CJoystickDevice::init(HWND helperWindow) @@ -98,7 +100,7 @@ namespace BlackInput void CJoystickDevice::timerEvent(QTimerEvent *event) { - Q_UNUSED(event); + Q_UNUSED(event) pollDeviceState(); } @@ -126,11 +128,8 @@ namespace BlackInput for (const CJoystickDeviceInput &input : as_const(m_joystickDeviceInputs)) { const qint32 buttonIndex = input.m_offset - DIJOFS_BUTTON0; - bool isPressed = state.rgbButtons[buttonIndex] & 0x80; - - if (isPressed) { emit buttonChanged(input.m_button, true); } - else { emit buttonChanged(input.m_button, false); } - + const bool isPressed = state.rgbButtons[buttonIndex] & 0x80; + emit this->buttonChanged(input.m_button, isPressed); } return hr; } @@ -151,12 +150,12 @@ namespace BlackInput if (dev->guidType != GUID_Button) return DIENUM_CONTINUE; CJoystickDeviceInput deviceInput; - int number = joystickDevice->m_joystickDeviceInputs.size(); + const int number = joystickDevice->m_joystickDeviceInputs.size(); deviceInput.m_offset = DIJOFS_BUTTON(number); deviceInput.m_button = CJoystickButton(joystickDevice->m_deviceName, DIJOFS_BUTTON(number) - DIJOFS_BUTTON0); joystickDevice->m_joystickDeviceInputs.append(deviceInput); - CLogMessage(static_cast(nullptr)).debug() << "Found joystick button" << QString::fromWCharArray(dev->tszName); + CLogMessage(static_cast(nullptr)).debug() << "Found joystick button" << QString::fromWCharArray(dev->tszName) << joystickDevice->m_deviceName; return DIENUM_CONTINUE; } @@ -273,7 +272,7 @@ namespace BlackInput ZeroMemory(&wce, sizeof(wce)); wce.cbSize = sizeof(wce); wce.lpfnWndProc = windowProc; - wce.lpszClassName = (LPCWSTR) helperWindowClassName; + wce.lpszClassName = static_cast(helperWindowClassName); wce.hInstance = hInstance; /* Register the class. */ @@ -376,6 +375,7 @@ namespace BlackInput } } + // // Window callback function (handles window messages) // LRESULT CALLBACK CJoystickWindows::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) @@ -390,8 +390,8 @@ namespace BlackInput { if (wParam == DBT_DEVICEARRIVAL) { - // DEV_BROADCAST_HDR *dbh = reinterpret_cast(lParam); ??? - DEV_BROADCAST_HDR *dbh = (DEV_BROADCAST_HDR *) lParam; + DEV_BROADCAST_HDR *dbh = reinterpret_cast(lParam); + // DEV_BROADCAST_HDR *dbh = (DEV_BROADCAST_HDR *) lParam; if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) { joystickWindows->enumJoystickDevices(); diff --git a/src/blackmisc/input/actionhotkey.cpp b/src/blackmisc/input/actionhotkey.cpp index d5a3a3131..a8ccc27fe 100644 --- a/src/blackmisc/input/actionhotkey.cpp +++ b/src/blackmisc/input/actionhotkey.cpp @@ -26,7 +26,8 @@ namespace BlackMisc const QString s = m_identifier.getMachineName() % u' ' % - m_combination.toQString() % + m_combination.asStringWithDeviceNames() % + // m_combination.toQString() % u' ' % m_action; return s;