2023-04-20 19:03:13 -04:00
|
|
|
#include <cassert>
|
|
|
|
#include "InputProviderQtMouse.h"
|
|
|
|
#include "string_format.h"
|
|
|
|
|
|
|
|
#define PROVIDER_ID 'QtMo'
|
|
|
|
|
|
|
|
uint32 CInputProviderQtMouse::GetId() const
|
|
|
|
{
|
|
|
|
return PROVIDER_ID;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CInputProviderQtMouse::GetTargetDescription(const BINDINGTARGET& target) const
|
|
|
|
{
|
|
|
|
assert(target.providerId == PROVIDER_ID);
|
2023-05-30 21:00:01 -04:00
|
|
|
auto description = [&]() -> std::string {
|
2023-04-20 19:03:13 -04:00
|
|
|
switch(target.keyId)
|
|
|
|
{
|
2023-05-30 21:00:01 -04:00
|
|
|
case Qt::LeftButton:
|
|
|
|
return "Left Button";
|
|
|
|
case Qt::RightButton:
|
|
|
|
return "Right Button";
|
|
|
|
default:
|
|
|
|
return string_format("Unknown button %d", target.keyId);
|
2023-04-20 19:03:13 -04:00
|
|
|
}
|
|
|
|
}();
|
|
|
|
return string_format("Mouse: %s", description.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
BINDINGTARGET CInputProviderQtMouse::MakeBindingTarget(Qt::MouseButton mouseButton)
|
|
|
|
{
|
|
|
|
return BINDINGTARGET(PROVIDER_ID, DeviceIdType{{0}}, mouseButton, BINDINGTARGET::KEYTYPE::BUTTON);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CInputProviderQtMouse::OnMousePress(Qt::MouseButton mouseButton)
|
|
|
|
{
|
|
|
|
OnInput(MakeBindingTarget(mouseButton), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CInputProviderQtMouse::OnMouseRelease(Qt::MouseButton mouseButton)
|
|
|
|
{
|
|
|
|
OnInput(MakeBindingTarget(mouseButton), 0);
|
|
|
|
}
|