Split keyboard and mouse policy handling
This commit is contained in:
parent
d174341b6d
commit
87f4e90ca2
7 changed files with 75 additions and 43 deletions
|
|
@ -12,10 +12,10 @@ static bool isGamepadInputAllowed()
|
|||
return session == nullptr || session->isGamepadInputAllowed();
|
||||
}
|
||||
|
||||
static bool isKeyboardMouseInputAllowed()
|
||||
static bool isMouseInputAllowed()
|
||||
{
|
||||
auto session = Session::get();
|
||||
return session == nullptr || session->isKeyboardMouseInputAllowed();
|
||||
return session == nullptr || session->isMouseInputAllowed();
|
||||
}
|
||||
|
||||
// How long the Start button must be pressed to toggle mouse emulation
|
||||
|
|
@ -387,7 +387,7 @@ Uint32 SdlInputHandler::mouseEmulationTimerCallback(Uint32 interval, void *param
|
|||
deltaX = qAbs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0;
|
||||
deltaY = qAbs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0;
|
||||
|
||||
if ((deltaX != 0 || deltaY != 0) && isKeyboardMouseInputAllowed()) {
|
||||
if ((deltaX != 0 || deltaY != 0) && isMouseInputAllowed()) {
|
||||
LiSendMouseMoveEvent((short)deltaX, (short)deltaY);
|
||||
}
|
||||
|
||||
|
|
@ -497,47 +497,47 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
|
|||
}
|
||||
else if (state->mouseEmulationTimer != 0) {
|
||||
if (event->button == SDL_CONTROLLER_BUTTON_A) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_MIDDLE);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X1);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X2);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_UP) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendScrollEvent(1);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendScrollEvent(-1);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendHScrollEvent(1);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendHScrollEvent(-1);
|
||||
}
|
||||
}
|
||||
|
|
@ -570,27 +570,27 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
|
|||
}
|
||||
else if (state->mouseEmulationTimer != 0) {
|
||||
if (event->button == SDL_CONTROLLER_BUTTON_A) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MIDDLE);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X1);
|
||||
}
|
||||
}
|
||||
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
|
||||
if (isKeyboardMouseInputAllowed()) {
|
||||
if (isMouseInputAllowed()) {
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue