Skip to content

Commit

Permalink
steamcompmgr: Add workaround for Disgaea PC (405900)
Browse files Browse the repository at this point in the history
This app doesn't like using the controller unless its clicked on first.
  • Loading branch information
misyltoad committed Feb 23, 2023
1 parent 9600bba commit a3dc37f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
46 changes: 34 additions & 12 deletions src/steamcompmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,25 +990,32 @@ void MouseCursor::checkSuspension()

bool bWasHidden = m_hideForMovement;

if (buttonMask & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )) {
m_hideForMovement = false;
m_lastMovedTime = get_time_in_milliseconds();
steamcompmgr_win_t *window = m_ctx->focus.inputFocusWindow;
if (window && window->ignoreNextClickForVisibility)
{
window->ignoreNextClickForVisibility--;
m_hideForMovement = true;
return;
}
else
{
if (buttonMask & ( Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask )) {
m_hideForMovement = false;
m_lastMovedTime = get_time_in_milliseconds();

// Move the cursor back to where we left it if the window didn't want us to give
// it hover/focus where we left it and we moved it before.
steamcompmgr_win_t *window = m_ctx->focus.inputFocusWindow;
if (window_wants_no_focus_when_mouse_hidden(window) && bWasHidden)
{
XWarpPointer(m_ctx->dpy, None, x11_win(m_ctx->focus.inputFocusWindow), 0, 0, 0, 0, m_lastX, m_lastY);
// Move the cursor back to where we left it if the window didn't want us to give
// it hover/focus where we left it and we moved it before.
if (window_wants_no_focus_when_mouse_hidden(window) && bWasHidden)
{
XWarpPointer(m_ctx->dpy, None, x11_win(m_ctx->focus.inputFocusWindow), 0, 0, 0, 0, m_lastX, m_lastY);
}
}
}

const bool suspended = get_time_in_milliseconds() - m_lastMovedTime > cursorHideTime;
if (!m_hideForMovement && suspended) {
m_hideForMovement = true;

steamcompmgr_win_t *window = m_ctx->focus.inputFocusWindow;

// Rearm warp count
if (window) {
window->mouseMoved = 0;
Expand Down Expand Up @@ -3176,7 +3183,22 @@ determine_and_apply_focus()
}

sdlwindow_visible( global_focus.focusWindow != nullptr );


// Some games such as Disagea PC (405900) don't take controller input until
// the window is first clicked on despite it having focus.
if ( global_focus.inputFocusWindow && global_focus.inputFocusWindow->appID == 405900 )
{
global_focus.inputFocusWindow->mouseMoved = 0;
global_focus.inputFocusWindow->ignoreNextClickForVisibility = 2;

auto now = get_time_in_milliseconds();

wlserver_lock();
wlserver_touchdown( 0.5, 0.5, 0, now );
wlserver_touchup( 0, now + 1 );
wlserver_unlock();
}

focusDirty = false;
}

Expand Down
1 change: 1 addition & 0 deletions src/steamcompmgr_shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct steamcompmgr_win_t {
bool hasHwndStyle;
uint32_t hwndStyle;
bool hasHwndStyleEx;
int ignoreNextClickForVisibility;
uint32_t hwndStyleEx;

motif_hints_t *motif_hints;
Expand Down

0 comments on commit a3dc37f

Please sign in to comment.