Skip to content

Commit

Permalink
InputEmulation: Implement scroll_discrete support
Browse files Browse the repository at this point in the history
Fixes scrolling in Steam Input
  • Loading branch information
misyltoad committed May 11, 2024
1 parent 075d36f commit 7439e35
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/InputEmulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ namespace gamescope
}
break;

case EIS_EVENT_SCROLL_DISCRETE:
{
m_flScrollAccum[0] += eis_event_scroll_get_discrete_dx( pEisEvent ) / 120.0;
m_flScrollAccum[1] += eis_event_scroll_get_discrete_dy( pEisEvent ) / 120.0;
}
break;

case EIS_EVENT_KEYBOARD_KEY:
{
wlserver_lock();
Expand All @@ -186,7 +193,17 @@ namespace gamescope

case EIS_EVENT_FRAME:
{
// Not used currently, maybe we want to accum scroll?
double flScrollX = m_flScrollAccum[0];
double flScrollY = m_flScrollAccum[1];
m_flScrollAccum[0] = 0.0;
m_flScrollAccum[1] = 0.0;

if ( flScrollX == 0.0 && flScrollY == 0.0 )
return;

wlserver_lock();
wlserver_mousewheel( flScrollX, flScrollY, ++s_uSequence );
wlserver_unlock();
}
break;

Expand Down
2 changes: 2 additions & 0 deletions src/InputEmulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ namespace gamescope
private:
eis *m_pEis = nullptr;
int m_nFd = -1;

double m_flScrollAccum[2]{};
};
}

0 comments on commit 7439e35

Please sign in to comment.