Skip to content

Commit

Permalink
Merge pull request #19902 from hrydgard/imgui-allow-input-when-unfocused
Browse files Browse the repository at this point in the history
ImDebugger: Send inputs to the game when no windows are focused
  • Loading branch information
hrydgard authored Jan 21, 2025
2 parents aa4311c + 9daa4ea commit a7ce204
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions UI/EmuScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,18 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
// Enable gamepad controls while running imgui (but ignore mouse/keyboard).
switch (key.deviceId) {
case DEVICE_ID_KEYBOARD:
if (!ImGui::GetIO().WantCaptureKeyboard) {
controlMapper_.Key(key, &pauseTrigger_);
}
break;
case DEVICE_ID_MOUSE:
if (!ImGui::GetIO().WantCaptureMouse) {
controlMapper_.Key(key, &pauseTrigger_);
}
break;
default:
controlMapper_.Key(key, &pauseTrigger_);
break;
}
}

Expand All @@ -1035,6 +1043,16 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) {
return controlMapper_.Key(key, &pauseTrigger_);
}

void EmuScreen::UnsyncAxis(const AxisInput *axes, size_t count) {
System_Notify(SystemNotification::ACTIVITY);

if (UI::IsFocusMovementEnabled()) {
return UIScreen::UnsyncAxis(axes, count);
}

return controlMapper_.Axis(axes, count);
}

bool EmuScreen::key(const KeyInput &key) {
bool retval = UIScreen::key(key);

Expand Down Expand Up @@ -1062,16 +1080,6 @@ void EmuScreen::touch(const TouchInput &touch) {
}
}

void EmuScreen::UnsyncAxis(const AxisInput *axes, size_t count) {
System_Notify(SystemNotification::ACTIVITY);

if (UI::IsFocusMovementEnabled()) {
return UIScreen::UnsyncAxis(axes, count);
}

return controlMapper_.Axis(axes, count);
}

class GameInfoBGView : public UI::InertView {
public:
GameInfoBGView(const Path &gamePath, UI::LayoutParams *layoutParams) : InertView(layoutParams), gamePath_(gamePath) {}
Expand Down

0 comments on commit a7ce204

Please sign in to comment.