mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
refs #317 Add stub Linux and OSX IJoystick implementations
This commit is contained in:
35
src/blackinput/linux/joystick_linux.cpp
Normal file
35
src/blackinput/linux/joystick_linux.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "joystick_linux.h"
|
||||
|
||||
using namespace BlackMisc::Hardware;
|
||||
|
||||
namespace BlackInput
|
||||
{
|
||||
CJoystickLinux::CJoystickLinux(QObject *parent) :
|
||||
IJoystick(parent)
|
||||
{
|
||||
}
|
||||
|
||||
CJoystickLinux::~CJoystickLinux()
|
||||
{
|
||||
}
|
||||
|
||||
void CJoystickLinux::startCapture()
|
||||
{
|
||||
}
|
||||
|
||||
void CJoystickLinux::triggerButton(const CJoystickButton button, bool isPressed)
|
||||
{
|
||||
if(!isPressed) emit buttonUp(button);
|
||||
else emit buttonDown(button);
|
||||
}
|
||||
|
||||
} // namespace BlackInput
|
||||
56
src/blackinput/linux/joystick_linux.h
Normal file
56
src/blackinput/linux/joystick_linux.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKINPUT_JOYSTICKLINUX_H
|
||||
#define BLACKINPUT_JOYSTICKLINUX_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackinput/joystick.h"
|
||||
#include "blackmisc/hwjoystickbutton.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include <QSet>
|
||||
|
||||
namespace BlackInput
|
||||
{
|
||||
//! Linux implemenation of IJoystick with DirectInput
|
||||
class CJoystickLinux : public IJoystick
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Copy Constructor
|
||||
CJoystickLinux(CJoystickLinux const &) = delete;
|
||||
|
||||
//! Assignment operator
|
||||
void operator=(CJoystickLinux const &) = delete;
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CJoystickLinux();
|
||||
|
||||
//! \copydoc IJoystick::startCapture()
|
||||
virtual void startCapture() override;
|
||||
|
||||
//! \copydoc IJoystick::triggerButton()
|
||||
virtual void triggerButton(const BlackMisc::Hardware::CJoystickButton button, bool isPressed) override;
|
||||
|
||||
private:
|
||||
|
||||
friend class IJoystick;
|
||||
|
||||
//! Destructor
|
||||
CJoystickLinux(QObject *parent = nullptr);
|
||||
|
||||
IJoystick::Mode m_mode = ModeNominal; //!< Current working mode
|
||||
};
|
||||
|
||||
} // namespace BlackInput
|
||||
|
||||
#endif // BLACKINPUT_JOYSTICKLINUX_H
|
||||
35
src/blackinput/osx/joystick_mac.cpp
Normal file
35
src/blackinput/osx/joystick_mac.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#include "joystick_mac.h"
|
||||
|
||||
using namespace BlackMisc::Hardware;
|
||||
|
||||
namespace BlackInput
|
||||
{
|
||||
CJoystickMac::CJoystickMac(QObject *parent) :
|
||||
IJoystick(parent)
|
||||
{
|
||||
}
|
||||
|
||||
CJoystickMac::~CJoystickMac()
|
||||
{
|
||||
}
|
||||
|
||||
void CJoystickMac::startCapture()
|
||||
{
|
||||
}
|
||||
|
||||
void CJoystickMac::triggerButton(const CJoystickButton button, bool isPressed)
|
||||
{
|
||||
if(!isPressed) emit buttonUp(button);
|
||||
else emit buttonDown(button);
|
||||
}
|
||||
|
||||
} // namespace BlackInput
|
||||
56
src/blackinput/osx/joystick_mac.h
Normal file
56
src/blackinput/osx/joystick_mac.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
#ifndef BLACKINPUT_JOYSTICKMAC_H
|
||||
#define BLACKINPUT_JOYSTICKMAC_H
|
||||
|
||||
//! \file
|
||||
|
||||
#include "blackinput/joystick.h"
|
||||
#include "blackmisc/hwjoystickbutton.h"
|
||||
#include "blackmisc/collection.h"
|
||||
#include <QSet>
|
||||
|
||||
namespace BlackInput
|
||||
{
|
||||
//! Linux implemenation of IJoystick with DirectInput
|
||||
class CJoystickMac : public IJoystick
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
//! Copy Constructor
|
||||
CJoystickMac(CJoystickMac const &) = delete;
|
||||
|
||||
//! Assignment operator
|
||||
void operator=(CJoystickMac const &) = delete;
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CJoystickMac();
|
||||
|
||||
//! \copydoc IJoystick::startCapture()
|
||||
virtual void startCapture() override;
|
||||
|
||||
//! \copydoc IJoystick::triggerButton()
|
||||
virtual void triggerButton(const BlackMisc::Hardware::CJoystickButton button, bool isPressed) override;
|
||||
|
||||
private:
|
||||
|
||||
friend class IJoystick;
|
||||
|
||||
//! Destructor
|
||||
CJoystickMac(QObject *parent = nullptr);
|
||||
|
||||
IJoystick::Mode m_mode = ModeNominal; //!< Current working mode
|
||||
};
|
||||
|
||||
} // namespace BlackInput
|
||||
|
||||
#endif // BLACKINPUT_JOYSTICKMAC_H
|
||||
@@ -52,6 +52,12 @@ namespace BlackInput
|
||||
|
||||
public:
|
||||
|
||||
//! Copy Constructor
|
||||
CJoystickWindows(CJoystickWindows const &) = delete;
|
||||
|
||||
//! Assignment operator
|
||||
void operator=(CJoystickWindows const &) = delete;
|
||||
|
||||
//! \brief Destructor
|
||||
virtual ~CJoystickWindows();
|
||||
|
||||
@@ -63,22 +69,16 @@ namespace BlackInput
|
||||
|
||||
protected:
|
||||
|
||||
friend class IJoystick;
|
||||
|
||||
//! Destructor
|
||||
CJoystickWindows(QObject *parent = nullptr);
|
||||
|
||||
//! Copy Constructor
|
||||
CJoystickWindows(CJoystickWindows const &);
|
||||
|
||||
//! Assignment operator
|
||||
void operator=(CJoystickWindows const &);
|
||||
|
||||
//! Timer based updates
|
||||
virtual void timerEvent(QTimerEvent *event);
|
||||
virtual void timerEvent(QTimerEvent *event) override;
|
||||
|
||||
private:
|
||||
|
||||
friend class IJoystick;
|
||||
|
||||
//! Constructor
|
||||
CJoystickWindows(QObject *parent = nullptr);
|
||||
|
||||
//! Initialize DirectInput
|
||||
HRESULT initDirectInput();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user