@@ -119,7 +119,7 @@ int UInputMan::Initialize() {
119
119
playerMouseControlled++;
120
120
}
121
121
}
122
- m_EnableMultiMouseKeyboard = playerMouseControlled > 1 || m_ForceEnableMultiMouseKeyboard ;
122
+ m_EnableMultiMouseKeyboard = playerMouseControlled > 1 && !m_ForceDisableMultiMouseKeyboard ;
123
123
124
124
m_PlayerScreenMouseBounds = {
125
125
0 ,
@@ -317,15 +317,41 @@ void UInputMan::DisableMouseMoving(bool disable) {
317
317
m_PrepareToEnableMouseMoving = true ;
318
318
}
319
319
}
320
-
321
- bool UInputMan::IsMultiMouseKeyboardEnabled () const {
320
+ bool UInputMan::CheckMultiMouseKeyboardEnabled (std::optional<std::reference_wrapper<const std::vector<int >>> players) {
322
321
int playerMouseControlled{0 };
323
- for (int player = PlayerOne; player < MaxPlayerCount; player++) {
322
+ if (players) {
323
+ for (int player: players->get ()) {
324
+ if (m_ControlScheme[player].GetDevice () == InputDevice::DEVICE_MOUSE_KEYB) {
325
+ playerMouseControlled++;
326
+ }
327
+ }
328
+ } else {
329
+ for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; player++) {
330
+ if (m_ControlScheme[player].GetDevice () == InputDevice::DEVICE_MOUSE_KEYB) {
331
+ playerMouseControlled++;
332
+ }
333
+ }
334
+ }
335
+
336
+ SDL_SetHint (SDL_HINT_WINDOWS_RAW_KEYBOARD, " 1" );
337
+ m_EnableMultiMouseKeyboard = playerMouseControlled > 1 && !m_ForceDisableMultiMouseKeyboard;
338
+ return m_EnableMultiMouseKeyboard;
339
+ }
340
+
341
+ bool UInputMan::AllPlayerInputDevicesKnown (const std::vector<int >& humanPlayers) const {
342
+ if (!m_EnableMultiMouseKeyboard) {
343
+ return true ;
344
+ }
345
+
346
+ for (int player: humanPlayers) {
324
347
if (m_ControlScheme[player].GetDevice () == InputDevice::DEVICE_MOUSE_KEYB) {
325
- playerMouseControlled++;
348
+ DeviceID playerDevice = m_ControlScheme[player].GetDeviceID ();
349
+ if (playerDevice.mouseKeyboard .mouse == 0 || playerDevice.mouseKeyboard .keyboard == 0 ) {
350
+ return false ;
351
+ }
326
352
}
327
353
}
328
- return playerMouseControlled > 1 ;
354
+ return true ;
329
355
}
330
356
331
357
Vector UInputMan::GetAbsoluteMousePosition (int whichPlayer) const {
@@ -394,7 +420,7 @@ void UInputMan::SetMousePos(const Vector& newPos, int whichPlayer) {
394
420
}
395
421
396
422
const std::array<bool , MouseButtons::MAX_MOUSE_BUTTONS>& UInputMan::GetMouseState (int whichPlayer) const {
397
- if (whichPlayer == Players::NoPlayer) {
423
+ if (whichPlayer == Players::NoPlayer || !m_EnableMultiMouseKeyboard ) {
398
424
return s_CurrentMouseButtonStates;
399
425
}
400
426
InputDevice playerInput = m_ControlScheme.at (whichPlayer).GetDevice ();
@@ -407,7 +433,7 @@ const std::array<bool, MouseButtons::MAX_MOUSE_BUTTONS>& UInputMan::GetMouseStat
407
433
return s_CurrentMouseButtonStates;
408
434
}
409
435
const std::array<bool , MouseButtons::MAX_MOUSE_BUTTONS>& UInputMan::GetMouseChange (int whichPlayer) const {
410
- if (whichPlayer == Players::NoPlayer) {
436
+ if (whichPlayer == Players::NoPlayer || !m_EnableMultiMouseKeyboard ) {
411
437
return s_ChangedMouseButtonStates;
412
438
}
413
439
InputDevice playerInput = m_ControlScheme.at (whichPlayer).GetDevice ();
@@ -693,7 +719,7 @@ bool UInputMan::GetMouseButtonState(int whichPlayer, int whichButton, InputState
693
719
if (whichPlayer != Players::NoPlayer) {
694
720
playerDevice = m_ControlScheme.at (whichPlayer).GetDevice ();
695
721
}
696
- if (mouse == 0 && (whichPlayer == Players::NoPlayer || (playerDevice != InputDevice::DEVICE_MOUSE_KEYB))) {
722
+ if (mouse == 0 && (whichPlayer == Players::NoPlayer || !m_EnableMultiMouseKeyboard || (playerDevice != InputDevice::DEVICE_MOUSE_KEYB))) {
697
723
switch (whichState) {
698
724
case InputState::Held:
699
725
return s_CurrentMouseButtonStates[whichButton];
0 commit comments