refs #317 Adding joystick support to input manager

This commit is contained in:
Roland Winklmeier
2014-07-31 01:15:41 +02:00
parent 78cab16a3d
commit 9283ecdd9d
3 changed files with 36 additions and 1 deletions

View File

@@ -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;