mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-02 23:27:09 +08:00
Add method to get joystick button name including a device prefix
This commit is contained in:
committed by
Mat Sutcliffe
parent
e5c435f281
commit
68907258a5
@@ -89,5 +89,20 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return sl.join('+');
|
return sl.join('+');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CHotkeyCombination::asStringWithDeviceNames() const
|
||||||
|
{
|
||||||
|
QStringList sl;
|
||||||
|
sl.reserve(m_keyboardKeys.size() + m_joystickButtons.size());
|
||||||
|
for (const auto &key : m_keyboardKeys)
|
||||||
|
{
|
||||||
|
sl << key.toQString();
|
||||||
|
}
|
||||||
|
for (const auto &button : m_joystickButtons)
|
||||||
|
{
|
||||||
|
sl << button.getButtonAsStringWithDeviceName();
|
||||||
|
}
|
||||||
|
return sl.join('+');
|
||||||
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
|
//! Returns the button name with the device name prefix
|
||||||
|
QString asStringWithDeviceNames() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CKeyboardKeyList m_keyboardKeys;
|
CKeyboardKeyList m_keyboardKeys;
|
||||||
CJoystickButtonList m_joystickButtons;
|
CJoystickButtonList m_joystickButtons;
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace BlackMisc
|
|||||||
m_deviceName(deviceName), m_buttonIndex(index)
|
m_deviceName(deviceName), m_buttonIndex(index)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
QString CJoystickButton::getButtonAsStringWithDeviceName() const
|
||||||
|
{
|
||||||
|
return QString("%1 Button%2").arg(m_deviceName).arg(m_buttonIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void CJoystickButton::setButtonIndex(int buttonIndex)
|
void CJoystickButton::setButtonIndex(int buttonIndex)
|
||||||
{
|
{
|
||||||
m_buttonIndex = buttonIndex;
|
m_buttonIndex = buttonIndex;
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ namespace BlackMisc
|
|||||||
//! Get button as String
|
//! Get button as String
|
||||||
QString getButtonAsString() const { return buttonIndexToString(m_buttonIndex); }
|
QString getButtonAsString() const { return buttonIndexToString(m_buttonIndex); }
|
||||||
|
|
||||||
|
//! Get button as String including its device name
|
||||||
|
QString getButtonAsStringWithDeviceName() const;
|
||||||
|
|
||||||
//! Set owning device name
|
//! Set owning device name
|
||||||
void setDeviceName(const QString &deviceName) { m_deviceName = deviceName; }
|
void setDeviceName(const QString &deviceName) { m_deviceName = deviceName; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user