Align input policy startup flow and fix gamepad reconnect handling
This commit is contained in:
parent
3767a9eac3
commit
e88be5dce2
4 changed files with 65 additions and 4 deletions
|
|
@ -890,6 +890,20 @@ void SdlInputHandler::handleJoystickArrivalEvent(SDL_JoyDeviceEvent* event)
|
|||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::handleJoystickRemovalEvent(SDL_JoyDeviceEvent* event)
|
||||
{
|
||||
SDL_assert(event->type == SDL_JOYDEVICEREMOVED);
|
||||
|
||||
if (findStateForGamepad(event->which) == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_ControllerDeviceEvent controllerEvent = {};
|
||||
controllerEvent.type = SDL_CONTROLLERDEVICEREMOVED;
|
||||
controllerEvent.which = event->which;
|
||||
handleControllerDeviceEvent(&controllerEvent);
|
||||
}
|
||||
|
||||
void SdlInputHandler::rumble(unsigned short controllerNumber, unsigned short lowFreqMotor, unsigned short highFreqMotor)
|
||||
{
|
||||
// Make sure the controller number is within our supported count
|
||||
|
|
|
|||
|
|
@ -307,6 +307,41 @@ void SdlInputHandler::raiseAllMouseButtons()
|
|||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2);
|
||||
}
|
||||
|
||||
void SdlInputHandler::raiseAllGamepadInputs()
|
||||
{
|
||||
uint16_t raisedIndexMask = 0;
|
||||
|
||||
for (auto &state : m_GamepadState) {
|
||||
if (state.controller == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
state.buttons = 0;
|
||||
state.lt = 0;
|
||||
state.rt = 0;
|
||||
state.lsX = 0;
|
||||
state.lsY = 0;
|
||||
state.rsX = 0;
|
||||
state.rsY = 0;
|
||||
state.emulatedClickpadButtonDown = false;
|
||||
|
||||
if ((raisedIndexMask & (1 << state.index)) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LiSendMultiControllerEvent(state.index,
|
||||
m_GamepadMask,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0);
|
||||
raisedIndexMask |= (1 << state.index);
|
||||
}
|
||||
}
|
||||
|
||||
void SdlInputHandler::notifyMouseLeave()
|
||||
{
|
||||
// SDL on Windows doesn't send the mouse button up until the mouse re-enters the window
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ public:
|
|||
|
||||
void handleJoystickArrivalEvent(SDL_JoyDeviceEvent* event);
|
||||
|
||||
void handleJoystickRemovalEvent(SDL_JoyDeviceEvent* event);
|
||||
|
||||
void sendText(QString& string);
|
||||
|
||||
void rumble(uint16_t controllerNumber, uint16_t lowFreqMotor, uint16_t highFreqMotor);
|
||||
|
|
@ -136,6 +138,8 @@ public:
|
|||
|
||||
void raiseAllMouseButtons();
|
||||
|
||||
void raiseAllGamepadInputs();
|
||||
|
||||
void notifyMouseLeave();
|
||||
|
||||
void notifyFocusLost();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue