mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
refs #396 BlackMisc: nw* goes to network/, hw* goes to hardware/
This commit is contained in:
committed by
Roland Winklmeier
parent
2363fab8c1
commit
985a1caecf
87
src/blackmisc/hardware/joystickbutton.h
Normal file
87
src/blackmisc/hardware/joystickbutton.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* Copyright (C) 2014
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of Swift Project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKMISC_HARDWARE_JOYSTICKBUTTON_H
|
||||
#define BLACKMISC_HARDWARE_JOYSTICKBUTTON_H
|
||||
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Hardware
|
||||
{
|
||||
//! Value object representing a joystick button
|
||||
class CJoystickButton : public CValueObject<CJoystickButton>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
enum ColumnIndex
|
||||
{
|
||||
IndexButton = 0,
|
||||
IndexButtonAsString,
|
||||
IndeButtonObject, // just for updates
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
CJoystickButton() = default;
|
||||
|
||||
//! Constructor
|
||||
CJoystickButton(qint32 buttonIndex);
|
||||
|
||||
//! Get button index
|
||||
qint32 getButtonIndex() const { return m_buttonIndex; }
|
||||
|
||||
//! Get button as String
|
||||
QString getButtonAsString() const { return buttonIndexToString(m_buttonIndex); }
|
||||
|
||||
//! Set button index
|
||||
void setButtonIndex(qint32 buttonIndex);
|
||||
|
||||
//! Is valid?
|
||||
bool isValid() const { return m_buttonIndex >= 0 ? true : false; }
|
||||
|
||||
//! Set button object
|
||||
void setButtonObject(const BlackMisc::Hardware::CJoystickButton &button);
|
||||
|
||||
//! \copydoc CValueObject::setPropertyByIndex
|
||||
virtual void setPropertyByIndex(const CVariant &variant, const BlackMisc::CPropertyIndex &index);
|
||||
|
||||
//! \copydoc CValueObject::propertyByIndex
|
||||
virtual CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
//! Button index to string
|
||||
static QString buttonIndexToString(qint32 buttonIndex);
|
||||
|
||||
//! Button index from string
|
||||
static qint32 buttonIndexFromString(const QString &button);
|
||||
|
||||
//! Invalid button index
|
||||
static qint32 getInvalidIndex() { return m_invalidIndex; }
|
||||
|
||||
protected:
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
private:
|
||||
BLACK_ENABLE_TUPLE_CONVERSION(CJoystickButton)
|
||||
qint32 m_buttonIndex = m_invalidIndex; //!< code similar to Qt::Key
|
||||
|
||||
static const qint32 m_invalidIndex = -1;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Hardware::CJoystickButton, (o.m_buttonIndex))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Hardware::CJoystickButton)
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user