mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Add deviceName attribute to CJoystickButton
ref T254
This commit is contained in:
committed by
Klaus Basan
parent
f62ab3266f
commit
fa74f28bca
@@ -15,8 +15,8 @@ namespace BlackMisc
|
|||||||
{
|
{
|
||||||
namespace Input
|
namespace Input
|
||||||
{
|
{
|
||||||
CJoystickButton::CJoystickButton(int buttonIndex) :
|
CJoystickButton::CJoystickButton(const QString deviceName, int index) :
|
||||||
m_buttonIndex(buttonIndex)
|
m_deviceName(deviceName), m_buttonIndex(index)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void CJoystickButton::setButtonIndex(int buttonIndex)
|
void CJoystickButton::setButtonIndex(int buttonIndex)
|
||||||
@@ -35,6 +35,9 @@ namespace BlackMisc
|
|||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
|
case IndexDeviceName:
|
||||||
|
this->setDeviceName(variant.value<QString>());
|
||||||
|
break;
|
||||||
case IndexButton:
|
case IndexButton:
|
||||||
case IndexButtonAsString:
|
case IndexButtonAsString:
|
||||||
this->setButtonIndex(buttonIndexFromString(variant.value<QString>()));
|
this->setButtonIndex(buttonIndexFromString(variant.value<QString>()));
|
||||||
@@ -54,6 +57,8 @@ namespace BlackMisc
|
|||||||
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
|
case IndexDeviceName:
|
||||||
|
return CVariant::from(this->getDeviceName());
|
||||||
case IndexButton:
|
case IndexButton:
|
||||||
return CVariant::from(this->getButtonIndex());
|
return CVariant::from(this->getButtonIndex());
|
||||||
case IndexButtonAsString:
|
case IndexButtonAsString:
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ namespace BlackMisc
|
|||||||
//! Properties by index
|
//! Properties by index
|
||||||
enum ColumnIndex
|
enum ColumnIndex
|
||||||
{
|
{
|
||||||
IndexButton = 0,
|
IndexDeviceName = 0,
|
||||||
|
IndexButton,
|
||||||
IndexButtonAsString,
|
IndexButtonAsString,
|
||||||
IndeButtonObject, // just for updates
|
IndeButtonObject, // just for updates
|
||||||
};
|
};
|
||||||
@@ -42,7 +43,10 @@ namespace BlackMisc
|
|||||||
CJoystickButton() = default;
|
CJoystickButton() = default;
|
||||||
|
|
||||||
//! Constructor
|
//! Constructor
|
||||||
CJoystickButton(int buttonIndex);
|
CJoystickButton(const QString deviceName, int index);
|
||||||
|
|
||||||
|
//! Get device name
|
||||||
|
QString getDeviceName() const { return m_deviceName; }
|
||||||
|
|
||||||
//! Get button index
|
//! Get button index
|
||||||
int getButtonIndex() const { return m_buttonIndex; }
|
int getButtonIndex() const { return m_buttonIndex; }
|
||||||
@@ -50,11 +54,14 @@ namespace BlackMisc
|
|||||||
//! Get button as String
|
//! Get button as String
|
||||||
QString getButtonAsString() const { return buttonIndexToString(m_buttonIndex); }
|
QString getButtonAsString() const { return buttonIndexToString(m_buttonIndex); }
|
||||||
|
|
||||||
|
//! Set owning device name
|
||||||
|
void setDeviceName(const QString &deviceName) { m_deviceName = deviceName; }
|
||||||
|
|
||||||
//! Set button index
|
//! Set button index
|
||||||
void setButtonIndex(int buttonIndex);
|
void setButtonIndex(int buttonIndex);
|
||||||
|
|
||||||
//! Is valid?
|
//! Is valid?
|
||||||
bool isValid() const { return m_buttonIndex >= 0 ? true : false; }
|
bool isValid() const { return !m_deviceName.isEmpty() && m_buttonIndex >= 0 ? true : false; }
|
||||||
|
|
||||||
//! Set button object
|
//! Set button object
|
||||||
void setButtonObject(CJoystickButton button);
|
void setButtonObject(CJoystickButton button);
|
||||||
@@ -78,12 +85,14 @@ namespace BlackMisc
|
|||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString m_deviceName;
|
||||||
int m_buttonIndex = m_invalidIndex;
|
int m_buttonIndex = m_invalidIndex;
|
||||||
|
|
||||||
static constexpr int m_invalidIndex = -1;
|
static constexpr int m_invalidIndex = -1;
|
||||||
|
|
||||||
BLACK_METACLASS(
|
BLACK_METACLASS(
|
||||||
CJoystickButton,
|
CJoystickButton,
|
||||||
|
BLACK_METAMEMBER(deviceName),
|
||||||
BLACK_METAMEMBER(buttonIndex)
|
BLACK_METAMEMBER(buttonIndex)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user