mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-12 07:15:34 +08:00
refs #453 Refactor CInputManger and low level input handlers
This commit is contained in:
committed by
Mathew Sutcliffe
parent
63c7c6be0d
commit
199a1e5fcb
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user