2018-09-30 13:41:32 -07: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();
|
|
|
|
|
2019-05-19 10:16:54 -07:00
|
|
|
Q_INVOKABLE void setUiNavMode(bool settingsMode);
|
2018-09-30 13:41:32 -07:00
|
|
|
|
2018-10-28 17:59:07 -07:00
|
|
|
Q_INVOKABLE int getConnectedGamepads();
|
|
|
|
|
2018-09-30 13:41:32 -07:00
|
|
|
private:
|
|
|
|
void sendKey(QEvent::Type type, Qt::Key key, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
|
2020-05-06 22:38:41 -07:00
|
|
|
void sendWheel(QPoint& angleDelta);
|
2018-09-30 13:41:32 -07:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onPollingTimerFired();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer* m_PollingTimer;
|
|
|
|
QList<SDL_GameController*> m_Gamepads;
|
|
|
|
bool m_Enabled;
|
2019-05-19 10:16:54 -07:00
|
|
|
bool m_UiNavMode;
|
2018-09-30 14:30:12 -07:00
|
|
|
Uint32 m_LastAxisNavigationEventTime;
|
2018-09-30 13:41:32 -07:00
|
|
|
};
|