mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-05 22:09:59 +03:00
inputsystem: fix UB in touch events callback, make touch more responsive
This commit is contained in:
@@ -729,7 +729,7 @@ public:
|
||||
void PrecacheMaterial( const char *pMaterialName );
|
||||
|
||||
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar );
|
||||
virtual void IN_TouchEvent( uint data, uint data2, uint data3, uint data4 );
|
||||
virtual void IN_TouchEvent( int type, int fingerId, int x, int y );
|
||||
|
||||
private:
|
||||
void UncacheAllMaterials( );
|
||||
@@ -2637,24 +2637,20 @@ CSteamID GetSteamIDForPlayerIndex( int iPlayerIndex )
|
||||
#endif
|
||||
|
||||
|
||||
void CHLClient::IN_TouchEvent( uint data, uint data2, uint data3, uint data4 )
|
||||
void CHLClient::IN_TouchEvent( int type, int fingerId, int x, int y )
|
||||
{
|
||||
if( enginevgui->IsGameUIVisible() )
|
||||
return;
|
||||
|
||||
touch_event_t ev;
|
||||
|
||||
ev.type = data & 0xFFFF;
|
||||
ev.fingerid = (data >> 16) & 0xFFFF;
|
||||
ev.x = (double)((data2 >> 16) & 0xFFFF) / 0xFFFF;
|
||||
ev.y = (double)(data2 & 0xFFFF) / 0xFFFF;
|
||||
ev.type = type;
|
||||
ev.fingerid = fingerId;
|
||||
memcpy( &ev.x, &x, sizeof(ev.x) );
|
||||
memcpy( &ev.y, &y, sizeof(ev.y) );
|
||||
|
||||
union{uint i;float f;} ifconv;
|
||||
ifconv.i = data3;
|
||||
ev.dx = ifconv.f;
|
||||
|
||||
ifconv.i = data4;
|
||||
ev.dy = ifconv.f;
|
||||
if( type == IE_FingerMotion )
|
||||
inputsystem->GetTouchAccumulators( fingerId, ev.dx, ev.dy );
|
||||
|
||||
gTouch.ProcessEvent( &ev );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user