This commit is contained in:
Er2 2023-08-20 10:05:08 +03:00
commit b5a9add343
12 changed files with 101 additions and 54 deletions

View File

@ -404,6 +404,9 @@ private:
int m_MouseButtonDownX; int m_MouseButtonDownX;
int m_MouseButtonDownY; int m_MouseButtonDownY;
bool m_bResetVsync;
int m_nFramesToSkip;
double m_flPrevGLSwapWindowTime; double m_flPrevGLSwapWindowTime;
}; };
@ -584,6 +587,9 @@ InitReturnVal_t CSDLMgr::Init()
m_nWarpDelta = 0; m_nWarpDelta = 0;
m_bRawInput = false; m_bRawInput = false;
m_nFramesToSkip = 0;
m_bResetVsync = false;
m_flPrevGLSwapWindowTime = 0.0f; m_flPrevGLSwapWindowTime = 0.0f;
memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs)); memset(m_pixelFormatAttribs, '\0', sizeof (m_pixelFormatAttribs));
@ -1431,7 +1437,20 @@ void CSDLMgr::ShowPixels( CShowPixelsParams *params )
m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF(); m_flPrevGLSwapWindowTime = tm.GetDurationInProgress().GetMillisecondsF();
#ifdef ANDROID
// ADRENO GPU MOMENT, SKIP 5 FRAMES
if( m_bResetVsync )
{
if( m_nFramesToSkip <= 0 )
{
SDL_GL_SetSwapInterval(swapInterval);
m_bResetVsync = false;
}
else
m_nFramesToSkip--;
}
#endif
CheckGLError( __LINE__ ); CheckGLError( __LINE__ );
} }
#endif // DX_TO_GL_ABSTRACTION #endif // DX_TO_GL_ABSTRACTION
@ -1887,6 +1906,7 @@ void CSDLMgr::PumpWindowsMessageLoop()
} }
case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_FOCUS_GAINED:
{ {
m_bResetVsync = true; m_nFramesToSkip = 3;
m_bHasFocus = true; m_bHasFocus = true;
SDL_ShowCursor( m_bCursorVisible ? 1 : 0 ); SDL_ShowCursor( m_bCursorVisible ? 1 : 0 );
CCocoaEvent theEvent; CCocoaEvent theEvent;

View File

@ -1339,7 +1339,6 @@ void CStaticPropMgr::UnserializeModels( CUtlBuffer& buf )
case 5: UnserializeLump<StaticPropLumpV5_t>(&lump, buf); break; case 5: UnserializeLump<StaticPropLumpV5_t>(&lump, buf); break;
case 6: UnserializeLump<StaticPropLumpV6_t>(&lump, buf); break; case 6: UnserializeLump<StaticPropLumpV6_t>(&lump, buf); break;
case 7: // Falls down to version 10. We promoted TF to version 10 to deal with SFM. case 7: // Falls down to version 10. We promoted TF to version 10 to deal with SFM.
case 9: UnserializeLump<StaticPropLumpV9_t>(&lump, buf); break;
case 10: case 10:
{ {
if( s_MapVersion == 21 ) if( s_MapVersion == 21 )
@ -1348,7 +1347,8 @@ void CStaticPropMgr::UnserializeModels( CUtlBuffer& buf )
UnserializeLump<StaticPropLumpV10_t>(&lump, buf); UnserializeLump<StaticPropLumpV10_t>(&lump, buf);
break; break;
} }
case 11: UnserializeLump<StaticPropLumpV11_t>(&lump, buf); case 9: UnserializeLump<StaticPropLumpV9_t>(&lump, buf); break;
case 11: UnserializeLump<StaticPropLumpV11_t>(&lump, buf); break;
default: default:
Assert("Unexpected version while deserializing lumps."); Assert("Unexpected version while deserializing lumps.");
} }

View File

@ -263,7 +263,6 @@ GameMessageHandler_t g_GameMessageHandlers[] =
{ IE_Quit, &CGame::HandleMsg_Close }, { IE_Quit, &CGame::HandleMsg_Close },
}; };
void CGame::AppActivate( bool fActive ) void CGame::AppActivate( bool fActive )
{ {
// If text mode, force it to be active. // If text mode, force it to be active.
@ -299,8 +298,18 @@ void CGame::AppActivate( bool fActive )
// Clear keyboard states (should be cleared already but...) // Clear keyboard states (should be cleared already but...)
// VGui_ActivateMouse will reactivate the mouse soon. // VGui_ActivateMouse will reactivate the mouse soon.
ClearIOStates(); ClearIOStates();
UpdateMaterialSystemConfig(); UpdateMaterialSystemConfig();
#ifdef ANDROID
ConVarRef mat_queue_mode( "mat_queue_mode" );
// Hack to reset internal queue buffers
int nSavedQueueMode = mat_queue_mode.GetInt();
mat_queue_mode.SetValue( 0 );
materials->BeginFrame( host_frametime );
materials->EndFrame();
mat_queue_mode.SetValue( nSavedQueueMode );
#endif
} }
else else
{ {
@ -355,7 +364,7 @@ void CGame::HandleMsg_Close( const InputEvent_t &event )
void CGame::DispatchInputEvent( const InputEvent_t &event ) void CGame::DispatchInputEvent( const InputEvent_t &event )
{ {
switch( event.m_nType & 0xFFFF ) switch( event.m_nType )
{ {
// Handle button events specially, // Handle button events specially,
// since we have all manner of crazy filtering going on when dealing with them // since we have all manner of crazy filtering going on when dealing with them

View File

@ -729,7 +729,7 @@ public:
void PrecacheMaterial( const char *pMaterialName ); void PrecacheMaterial( const char *pMaterialName );
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar ); 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: private:
void UncacheAllMaterials( ); void UncacheAllMaterials( );
@ -1631,6 +1631,7 @@ void CHLClient::LevelInitPreEntity( char const* pMapName )
g_RagdollLVManager.SetLowViolence( pMapName ); g_RagdollLVManager.SetLowViolence( pMapName );
gHUD.LevelInit(); gHUD.LevelInit();
gTouch.LevelInit();
#if defined( REPLAY_ENABLED ) #if defined( REPLAY_ENABLED )
// Initialize replay ragdoll recorder // Initialize replay ragdoll recorder
@ -2637,24 +2638,20 @@ CSteamID GetSteamIDForPlayerIndex( int iPlayerIndex )
#endif #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() ) if( enginevgui->IsGameUIVisible() )
return; return;
touch_event_t ev; touch_event_t ev;
ev.type = data & 0xFFFF; ev.type = type;
ev.fingerid = (data >> 16) & 0xFFFF; ev.fingerid = fingerId;
ev.x = (double)((data2 >> 16) & 0xFFFF) / 0xFFFF; memcpy( &ev.x, &x, sizeof(ev.x) );
ev.y = (double)(data2 & 0xFFFF) / 0xFFFF; memcpy( &ev.y, &y, sizeof(ev.y) );
union{uint i;float f;} ifconv; if( type == IE_FingerMotion )
ifconv.i = data3; inputsystem->GetTouchAccumulators( fingerId, ev.dx, ev.dy );
ev.dx = ifconv.f;
ifconv.i = data4;
ev.dy = ifconv.f;
gTouch.ProcessEvent( &ev ); gTouch.ProcessEvent( &ev );
} }

View File

@ -425,6 +425,13 @@ void CTouchControls::Init()
initialized = true; initialized = true;
} }
void CTouchControls::LevelInit()
{
m_bCutScene = false;
m_AlphaDiff = 0;
m_flHideTouch = 0;
}
int nextPowerOfTwo(int x) int nextPowerOfTwo(int x)
{ {
if( (x & (x - 1)) == 0) if( (x & (x - 1)) == 0)

View File

@ -161,6 +161,7 @@ class CTouchControls
{ {
public: public:
void Init( ); void Init( );
void LevelInit( );
void Shutdown( ); void Shutdown( );
void Paint( ); void Paint( );

View File

@ -1530,16 +1530,6 @@ bool CInputSystem::GetRawMouseAccumulators( int& accumX, int& accumY )
#endif #endif
} }
bool CInputSystem::GetTouchAccumulators( InputEventType_t &event, int &fingerId, int& accumX, int& accumY )
{
event = m_touchAccumEvent;
fingerId = m_touchAccumFingerId;
accumX = m_touchAccumX;
accumY = m_touchAccumY;
return m_bJoystickInitialized;
}
void CInputSystem::SetConsoleTextMode( bool bConsoleTextMode ) void CInputSystem::SetConsoleTextMode( bool bConsoleTextMode )
{ {
/* If someone calls this after init, shut it down. */ /* If someone calls this after init, shut it down. */

View File

@ -44,6 +44,8 @@
#include "steam/steam_api.h" #include "steam/steam_api.h"
#define TOUCH_FINGER_MAX_COUNT 10
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Implementation of the input system // Implementation of the input system
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -101,7 +103,7 @@ public:
virtual void *GetHapticsInterfaceAddress() const { return NULL;} virtual void *GetHapticsInterfaceAddress() const { return NULL;}
#endif #endif
bool GetRawMouseAccumulators( int& accumX, int& accumY ); bool GetRawMouseAccumulators( int& accumX, int& accumY );
bool GetTouchAccumulators( InputEventType_t &event, int &fingerId, int& accumX, int& accumY ); virtual bool GetTouchAccumulators( int fingerId, float &dx, float &dy );
virtual void SetConsoleTextMode( bool bConsoleTextMode ); virtual void SetConsoleTextMode( bool bConsoleTextMode );
@ -458,8 +460,7 @@ public:
bool m_bRawInputSupported; bool m_bRawInputSupported;
int m_mouseRawAccumX, m_mouseRawAccumY; int m_mouseRawAccumX, m_mouseRawAccumY;
InputEventType_t m_touchAccumEvent; float m_touchAccumX[TOUCH_FINGER_MAX_COUNT], m_touchAccumY[TOUCH_FINGER_MAX_COUNT];
int m_touchAccumFingerId, m_touchAccumX, m_touchAccumY;
// For the 'SleepUntilInput' feature // For the 'SleepUntilInput' feature
HANDLE m_hEvent; HANDLE m_hEvent;

View File

@ -48,6 +48,9 @@ void CInputSystem::InitializeTouch( void )
// abort startup if user requests no touch // abort startup if user requests no touch
if ( CommandLine()->FindParm("-notouch") ) return; if ( CommandLine()->FindParm("-notouch") ) return;
memset( m_touchAccumX, 0, sizeof(m_touchAccumX) );
memset( m_touchAccumY, 0, sizeof(m_touchAccumY) );
m_bJoystickInitialized = true; m_bJoystickInitialized = true;
SDL_AddEventWatch(TouchSDLWatcher, this); SDL_AddEventWatch(TouchSDLWatcher, this);
} }
@ -61,20 +64,35 @@ void CInputSystem::ShutdownTouch()
m_bTouchInitialized = false; m_bTouchInitialized = false;
} }
bool CInputSystem::GetTouchAccumulators( int fingerId, float &dx, float &dy )
{
dx = m_touchAccumX[fingerId];
dy = m_touchAccumY[fingerId];
m_touchAccumX[fingerId] = m_touchAccumY[fingerId] = 0.f;
return true;
}
void CInputSystem::FingerEvent(int eventType, int fingerId, float x, float y, float dx, float dy) void CInputSystem::FingerEvent(int eventType, int fingerId, float x, float y, float dx, float dy)
{ {
// Shit, but should work with arm/x86 if( fingerId >= TOUCH_FINGER_MAX_COUNT )
return;
int data0 = fingerId << 16 | eventType; if( eventType == IE_FingerUp )
int _x = (int)((double)x*0xFFFF); {
int _y = (int)((double)y*0xFFFF); m_touchAccumX[fingerId] = 0.f;
int data1 = _x << 16 | (_y & 0xFFFF); m_touchAccumY[fingerId] = 0.f;
}
else
{
m_touchAccumX[fingerId] += dx;
m_touchAccumY[fingerId] += dy;
}
union{int i;float f;} ifconv; int _x,_y;
ifconv.f = dx; memcpy( &_x, &x, sizeof(float) );
int _dx = ifconv.i; memcpy( &_y, &y, sizeof(float) );
ifconv.f = dy; PostEvent(eventType, m_nLastSampleTick, fingerId, _x, _y);
int _dy = ifconv.i;
PostEvent(data0, m_nLastSampleTick, data1, _dx, _dy);
} }

View File

@ -790,7 +790,7 @@ public:
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar ) = 0; virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar ) = 0;
virtual void IN_TouchEvent( uint data, uint data2, uint data3, uint data4 ) = 0; virtual void IN_TouchEvent( int type, int fingerId, int x, int y ) = 0;
}; };
#define CLIENT_DLL_INTERFACE_VERSION "VClient017" #define CLIENT_DLL_INTERFACE_VERSION "VClient017"

View File

@ -119,6 +119,7 @@ public:
// read and clear accumulated raw input values // read and clear accumulated raw input values
virtual bool GetRawMouseAccumulators( int& accumX, int& accumY ) = 0; virtual bool GetRawMouseAccumulators( int& accumX, int& accumY ) = 0;
virtual bool GetTouchAccumulators( int fingerId, float &dx, float &dy ) = 0;
// tell the input system that we're not a game, we're console text mode. // tell the input system that we're not a game, we're console text mode.
// this is used for dedicated servers to not initialize joystick system. // this is used for dedicated servers to not initialize joystick system.

View File

@ -376,7 +376,7 @@ static vgui::MouseCode ButtonCodeToMouseCode( ButtonCode_t buttonCode )
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
bool InputHandleInputEvent( const InputEvent_t &event ) bool InputHandleInputEvent( const InputEvent_t &event )
{ {
switch( event.m_nType & 0xFFFF ) switch( event.m_nType )
{ {
case IE_ButtonPressed: case IE_ButtonPressed:
{ {
@ -428,9 +428,10 @@ bool InputHandleInputEvent( const InputEvent_t &event )
case IE_FingerDown: case IE_FingerDown:
{ {
int w,h,x,y; g_MatSystemSurface.GetScreenSize(w, h); int w,h,x,y; g_MatSystemSurface.GetScreenSize(w, h);
uint data = (uint)event.m_nData; float _x, _y;
x = w*((double)((data >> 16) & 0xFFFF) / 0xFFFF); memcpy( &_x, &event.m_nData2, sizeof(_x) );
y = h*((double)(data & 0xFFFF) / 0xFFFF); memcpy( &_y, &event.m_nData3, sizeof(_y) );
x = w*_x; y = h*_y;
g_pIInput->UpdateCursorPosInternal( x, y ); g_pIInput->UpdateCursorPosInternal( x, y );
g_pIInput->SetMouseCodeState( MOUSE_LEFT, vgui::BUTTON_PRESSED ); g_pIInput->SetMouseCodeState( MOUSE_LEFT, vgui::BUTTON_PRESSED );
g_pIInput->InternalMousePressed( MOUSE_LEFT ); g_pIInput->InternalMousePressed( MOUSE_LEFT );
@ -439,9 +440,10 @@ bool InputHandleInputEvent( const InputEvent_t &event )
case IE_FingerUp: case IE_FingerUp:
{ {
int w,h,x,y; g_MatSystemSurface.GetScreenSize(w, h); int w,h,x,y; g_MatSystemSurface.GetScreenSize(w, h);
uint data = (uint)event.m_nData; float _x, _y;
x = w*((double)((data >> 16) & 0xFFFF) / 0xFFFF); memcpy( &_x, &event.m_nData2, sizeof(_x) );
y = h*((double)(data & 0xFFFF) / 0xFFFF); memcpy( &_y, &event.m_nData3, sizeof(_y) );
x = w*_x; y = h*_y;
g_pIInput->UpdateCursorPosInternal( x, y ); g_pIInput->UpdateCursorPosInternal( x, y );
g_pIInput->SetMouseCodeState( MOUSE_LEFT, vgui::BUTTON_RELEASED ); g_pIInput->SetMouseCodeState( MOUSE_LEFT, vgui::BUTTON_RELEASED );
g_pIInput->InternalMouseReleased( MOUSE_LEFT ); g_pIInput->InternalMouseReleased( MOUSE_LEFT );
@ -450,9 +452,10 @@ bool InputHandleInputEvent( const InputEvent_t &event )
case IE_FingerMotion: case IE_FingerMotion:
{ {
int w,h,x,y; g_MatSystemSurface.GetScreenSize(w, h); int w,h,x,y; g_MatSystemSurface.GetScreenSize(w, h);
uint data = (uint)event.m_nData; float _x, _y;
x = w*((double)((data >> 16) & 0xFFFF) / 0xFFFF); memcpy( &_x, &event.m_nData2, sizeof(_x) );
y = h*((double)(data & 0xFFFF) / 0xFFFF); memcpy( &_y, &event.m_nData3, sizeof(_y) );
x = w*_x; y = h*_y;
g_pIInput->InternalCursorMoved( x, y ); g_pIInput->InternalCursorMoved( x, y );
} }
return true; return true;