mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-06 18:25:37 +08:00
refs #317 Adding joystick support to input manager
This commit is contained in:
@@ -15,10 +15,13 @@ namespace BlackCore
|
||||
|
||||
CInputManager::CInputManager(QObject *parent) :
|
||||
QObject(parent),
|
||||
m_keyboard(IKeyboard::getInstance())
|
||||
m_keyboard(IKeyboard::getInstance()),
|
||||
m_joystick(IJoystick::getInstance())
|
||||
{
|
||||
connect(m_keyboard, &IKeyboard::keyUp, this, &CInputManager::ps_processKeyboardKeyUp);
|
||||
connect(m_keyboard, &IKeyboard::keyDown, this, &CInputManager::ps_processKeyboardKeyDown);
|
||||
connect(m_joystick, &IJoystick::buttonUp, this, &CInputManager::ps_processJoystickButtonUp);
|
||||
connect(m_joystick, &IJoystick::buttonDown, this, &CInputManager::ps_processJoystickButtonDown);
|
||||
}
|
||||
|
||||
CInputManager *CInputManager::getInstance()
|
||||
@@ -62,6 +65,26 @@ namespace BlackCore
|
||||
callFunctionsBy(hotkeyFunc, false);
|
||||
}
|
||||
|
||||
void CInputManager::ps_processJoystickButtonDown(const CJoystickButton &button)
|
||||
{
|
||||
qDebug() << "Pressed Button" << button.getButtonIndex();
|
||||
if (!m_hashJoystickKeyFunctions.contains(button)) return;
|
||||
|
||||
// Get configured hotkey function
|
||||
CHotkeyFunction hotkeyFunc = m_hashJoystickKeyFunctions.value(button);
|
||||
callFunctionsBy(hotkeyFunc, true);
|
||||
}
|
||||
|
||||
void CInputManager::ps_processJoystickButtonUp(const CJoystickButton &button)
|
||||
{
|
||||
qDebug() << "Released Button" << button.getButtonIndex();
|
||||
if (!m_hashJoystickKeyFunctions.contains(button)) return;
|
||||
|
||||
// Get configured hotkey function
|
||||
CHotkeyFunction hotkeyFunc = m_hashJoystickKeyFunctions.value(button);
|
||||
callFunctionsBy(hotkeyFunc, false);
|
||||
}
|
||||
|
||||
void CInputManager::callFunctionsBy(const CHotkeyFunction &hotkeyFunction, bool isKeyDown)
|
||||
{
|
||||
if (!m_hashRegisteredFunctions.contains(hotkeyFunction)) return;
|
||||
|
||||
Reference in New Issue
Block a user