mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T784, joystick (PTT) buttons
* style * more detailed logs
This commit is contained in:
committed by
Mat Sutcliffe
parent
3099464668
commit
8d51c42cfc
@@ -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 <QAbstractItemModel>
|
||||
@@ -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<CActionHotkey>(), Q_FUNC_INFO, "No action hotkey");
|
||||
CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>();
|
||||
|
||||
const CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>();
|
||||
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<CActionHotkey>();
|
||||
const CActionHotkey actionHotkey = index.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>();
|
||||
removeHotkeyFromSettings(actionHotkey);
|
||||
m_model.removeRows(index.row(), 1, QModelIndex());
|
||||
}
|
||||
|
||||
@@ -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<CJoystickWindows *>(nullptr)).debug() << "Found joystick button" << QString::fromWCharArray(dev->tszName);
|
||||
CLogMessage(static_cast<CJoystickWindows *>(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<LPCWSTR>(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<DEV_BROADCAST_HDR *>(lParam); ???
|
||||
DEV_BROADCAST_HDR *dbh = (DEV_BROADCAST_HDR *) lParam;
|
||||
DEV_BROADCAST_HDR *dbh = reinterpret_cast<DEV_BROADCAST_HDR *>(lParam);
|
||||
// DEV_BROADCAST_HDR *dbh = (DEV_BROADCAST_HDR *) lParam;
|
||||
if (dbh && dbh->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE)
|
||||
{
|
||||
joystickWindows->enumJoystickDevices();
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user