refs #453 Refactor CInputManger and low level input handlers

This commit is contained in:
Roland Winklmeier
2015-08-14 20:21:27 +02:00
committed by Mathew Sutcliffe
parent 63c7c6be0d
commit 199a1e5fcb
31 changed files with 609 additions and 1086 deletions

View File

@@ -18,7 +18,7 @@
#include <fcntl.h>
using namespace BlackMisc;
using namespace BlackMisc::Hardware;
using namespace BlackMisc::Input;
namespace
{
@@ -42,17 +42,6 @@ namespace BlackInput
ps_directoryChanged(inputDevicesDir());
}
void CJoystickLinux::startCapture()
{
}
void CJoystickLinux::triggerButton(const CJoystickButton button, bool isPressed)
{
if (!isPressed) emit buttonUp(button);
else emit buttonDown(button);
}
void CJoystickLinux::cleanupJoysticks()
{
for (auto it = m_joysticks.begin(); it != m_joysticks.end();)
@@ -123,17 +112,27 @@ namespace BlackInput
QFile *joystick = qobject_cast<QFile *>(object);
Q_ASSERT(joystick);
struct js_event event;
while (joystick->read(reinterpret_cast<char *>(&event), sizeof(event)) == sizeof(event))
{
BlackMisc::Input::CHotkeyCombination oldCombination(m_buttonCombination);
switch (event.type & ~JS_EVENT_INIT)
{
case JS_EVENT_BUTTON:
if (event.value)
emit buttonDown(CJoystickButton(event.number));
{
m_buttonCombination.addJoystickButton(event.number);
}
else
emit buttonUp(CJoystickButton(event.number));
{
m_buttonCombination.removeJoystickButton(event.number);
}
if (oldCombination != m_buttonCombination)
{
emit buttonCombinationChanged(m_buttonCombination);
}
break;
}
}