2018-09-30 20:41:32 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QEvent>
|
|
|
|
|
|
|
|
#include <SDL.h>
|
|
|
|
|
|
|
|
class SdlGamepadKeyNavigation : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
SdlGamepadKeyNavigation();
|
|
|
|
|
|
|
|
~SdlGamepadKeyNavigation();
|
|
|
|
|
|
|
|
Q_INVOKABLE void enable();
|
|
|
|
|
|
|
|
Q_INVOKABLE void disable();
|
|
|
|
|
|
|
|
Q_INVOKABLE void setSettingsMode(bool settingsMode);
|
|
|
|
|
2018-10-29 00:59:07 +00:00
|
|
|
Q_INVOKABLE int getConnectedGamepads();
|
|
|
|
|
2018-09-30 20:41:32 +00:00
|
|
|
private:
|
|
|
|
void sendKey(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onPollingTimerFired();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer* m_PollingTimer;
|
|
|
|
QList<SDL_GameController*> m_Gamepads;
|
|
|
|
bool m_Enabled;
|
|
|
|
bool m_SettingsMode;
|
2018-09-30 21:30:12 +00:00
|
|
|
Uint32 m_LastAxisNavigationEventTime;
|
2018-09-30 20:41:32 +00:00
|
|
|
};
|