add vgui touch panel, touch logic

This commit is contained in:
nillerusr 2021-10-09 15:22:16 +03:00
parent 81b976c384
commit 63e458ef84
12 changed files with 617 additions and 28 deletions

View File

@ -988,10 +988,10 @@ void CSDLMgr::PostEvent( const CCocoaEvent &theEvent, bool debugEvent )
SDLAPP_FUNC;
m_CocoaEventsMutex.Lock();
CUtlLinkedList<CCocoaEvent,int> &queue = debugEvent ? m_CocoaEvents : m_DebugEvents;
queue.AddToTail( theEvent );
m_CocoaEventsMutex.Unlock();
}
@ -1837,6 +1837,8 @@ void CSDLMgr::PumpWindowsMessageLoop()
break;
}
// FIXME(nillerusr): SDL posts SDL_QUIT when map loaded on android, idk why.
#ifndef ANDROID
case SDL_QUIT:
{
CCocoaEvent theEvent;
@ -1844,7 +1846,7 @@ void CSDLMgr::PumpWindowsMessageLoop()
PostEvent( theEvent );
break;
}
#endif
default:
break;
}

View File

@ -364,7 +364,11 @@ void CGame::DispatchInputEvent( const InputEvent_t &event )
case IE_ButtonReleased:
Key_Event( event );
break;
case IE_FingerDown:
case IE_FingerUp:
case IE_FingerMotion:
if( g_ClientDLL )
g_ClientDLL->IN_TouchEvent( event.m_nType, event.m_nData, event.m_nData2, event.m_nData3 );
default:
// Let vgui have the first whack at events
if ( g_pMatSystemSurface && g_pMatSystemSurface->HandleInputEvent( event ) )

View File

@ -126,6 +126,7 @@
#include "client_virtualreality.h"
#include "mumble.h"
#include "vgui_controls/BuildGroup.h"
#include "touch.h"
// NVNT includes
#include "hud_macros.h"
@ -729,11 +730,12 @@ public:
// Returns true if the disconnect command has been handled by the client
virtual bool DisconnectAttempt( void );
public:
void PrecacheMaterial( const char *pMaterialName );
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar );
virtual void IN_TouchEvent( int type, int fingerId, int x, int y );
private:
void UncacheAllMaterials( );
void ResetStringTablePointers();
@ -1039,6 +1041,8 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physi
gHUD.Init();
gTouch.Init();
g_pClientMode->Init();
if ( !IGameSystem::InitAllSystems() )
@ -1419,8 +1423,23 @@ int CHLClient::IN_KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszC
return input->KeyEvent( eventcode, keynum, pszCurrentBinding );
}
void CHLClient::ExtraMouseSample( float frametime, bool active )
void CHLClient::IN_TouchEvent( int type, int fingerId, int x, int y )
{
if( enginevgui->IsGameUIVisible() )
return;
touch_event_t ev;
ev.type = type;
ev.fingerid = fingerId;
ev.x = x;
ev.y = y;
gTouch.ProcessEvent( &ev );
}
void CHLClient::ExtraMouseSample( float frametime, bool active )
{
Assert( C_BaseEntity::IsAbsRecomputationsEnabled() );
Assert( C_BaseEntity::IsAbsQueriesValid() );

View File

@ -19,12 +19,16 @@
#include "bitbuf.h"
#include "checksum_md5.h"
#include "hltvcamera.h"
#include "touch.h"
#include "ienginevgui.h"
#if defined( REPLAY_ENABLED )
#include "replay/replaycamera.h"
#endif
#include <ctype.h> // isalnum()
#include <voice_status.h>
#include "cam_thirdperson.h"
#include "inputsystem/iinputsystem.h"
#ifdef SIXENSE
#include "sixense/in_sixense.h"
@ -289,11 +293,11 @@ Add a kbutton_t * to the list of pointers the engine can retrieve via KB_Find
*/
void CInput::AddKeyButton( const char *name, kbutton_t *pkb )
{
CKeyboardKey *p;
CKeyboardKey *p;
kbutton_t *kb;
kb = FindKey( name );
if ( kb )
return;
@ -307,7 +311,7 @@ void CInput::AddKeyButton( const char *name, kbutton_t *pkb )
}
//-----------------------------------------------------------------------------
// Purpose:
// Purpose:
//-----------------------------------------------------------------------------
CInput::CInput( void )
{
@ -319,7 +323,7 @@ CInput::CInput( void )
}
//-----------------------------------------------------------------------------
// Purpose:
// Purpose:
//-----------------------------------------------------------------------------
CInput::~CInput( void )
{
@ -952,6 +956,7 @@ void CInput::ControllerMove( float frametime, CUserCmd *cmd )
SteamControllerMove( frametime, cmd );
JoyStickMove( frametime, cmd );
gTouch.Move( frametime, cmd );
// NVNT if we have a haptic device..
if(haptics && haptics->HasDevice())
@ -1105,11 +1110,10 @@ void CInput::ExtraMouseSample( float frametime, bool active )
prediction->SetLocalViewAngles( cmd->viewangles );
}
}
}
void CInput::CreateMove ( int sequence_number, float input_sample_frametime, bool active )
{
{
CUserCmd *cmd = &m_pCommands[ sequence_number % MULTIPLAYER_BACKUP ];
CVerifiedUserCmd *pVerified = &m_pVerifiedCommands[ sequence_number % MULTIPLAYER_BACKUP ];
@ -1196,11 +1200,11 @@ void CInput::CreateMove ( int sequence_number, float input_sample_frametime, boo
cmd->buttons = GetButtonBits( 1 );
#endif
// Using joystick?
// Using joystick or touch?
#ifdef SIXENSE
if ( in_joystick.GetInt() || g_pSixenseInput->IsEnabled() )
if ( in_joystick.GetInt() || g_pSixenseInput->IsEnabled() || touch_enable.GetInt() )
#else
if ( in_joystick.GetInt() )
if ( in_joystick.GetInt() || touch_enable.GetInt() )
#endif
{
if ( cmd->forwardmove > 0 )

337
game/client/touch.cpp Normal file
View File

@ -0,0 +1,337 @@
#include "convar.h"
#include <dlfcn.h>
#include <string.h>
#include "vgui/IInputInternal.h"
#include "VGuiMatSurface/IMatSystemSurface.h"
#include "vgui/ISurface.h"
#include "touch.h"
#include "cdll_int.h"
#include "ienginevgui.h"
#include "in_buttons.h"
extern ConVar cl_sidespeed;
extern ConVar cl_forwardspeed;
extern ConVar cl_upspeed;
#ifdef ANDROID
#define TOUCH_DEFAULT "1"
#else
#define TOUCH_DEFAULT "0"
#endif
ConVar touch_enable( "touch_enable", TOUCH_DEFAULT, FCVAR_ARCHIVE );
#define boundmax( num, high ) ( (num) < (high) ? (num) : (high) )
#define boundmin( num, low ) ( (num) >= (low) ? (num) : (low) )
#define bound( low, num, high ) ( boundmin( boundmax(num, high), low ))
#define S
extern IVEngineClient *engine;
extern vgui::IInputInternal *g_pInputInternal;
static int g_LastDefaultButton = 0;
int screen_h, screen_w;
static CTouchButton g_Buttons[512];
static int g_LastButton = 0;
CTouchControls gTouch;
static VTouchPanel g_TouchPanel;
VTouchPanel *touch_panel = &g_TouchPanel;
CTouchPanel::CTouchPanel( vgui::VPANEL parent ) : BaseClass( NULL, "TouchPanel" )
{
SetParent( parent );
int w, h;
engine->GetScreenSize(w, h);
SetBounds( 0, 0, w, h );
SetFgColor( Color( 0, 0, 0, 255 ) );
SetPaintBackgroundEnabled( false );
SetKeyBoardInputEnabled( false );
SetMouseInputEnabled( false );
SetVisible( true );
}
CTouchPanel::~CTouchPanel( void )
{
}
bool CTouchPanel::ShouldDraw( void )
{
return touch_enable.GetBool() && !enginevgui->IsGameUIVisible();
}
void CTouchPanel::Paint()
{
gTouch.Frame();
}
CTouchControls::CTouchControls()
{
}
CTouchControls::~CTouchControls()
{
}
void CTouchControls::Init()
{
engine->GetScreenSize( screen_w, screen_h );
initialized = true;
btns.EnsureCapacity( 64 );
look_finger = move_finger = resize_finger = -1;
forward = side = 0;
scolor = rgba_t( -1, -1, -1, -1 );
state = state_none;
swidth = 1;
move = edit = selection = NULL;
showbuttons = true;
clientonly = false;
precision = false;
mouse_events = 0;
move_start_x = move_start_y = 0.0f;
showtexture = hidetexture = resettexture = closetexture = joytexture = 0;
configchanged = false;
rgba_t color(255, 255, 255, 255);
IN_TouchAddButton( "use", "vgui/touch/use", "+use", touch_command, 0.880000, 0.213333, 1.000000, 0.426667, color );
IN_TouchAddButton( "jump", "vgui/touch/jump", "+jump", touch_command, 0.880000, 0.462222, 1.000000, 0.675556, color );
IN_TouchAddButton( "attack", "vgui/touch/shoot", "+attack", touch_command, 0.760000, 0.583333, 0.880000, 0.796667, color );
IN_TouchAddButton( "attack2", "vgui/touch/shoot_alt", "+attack2", touch_command, 0.760000, 0.320000, 0.880000, 0.533333, color );
IN_TouchAddButton( "duck", "vgui/touch/crouch", "+duck", touch_command, 0.880000, 0.746667, 1.000000, 0.960000, color );
IN_TouchAddButton( "tduck", "vgui/touch/tduck", ";+duck", touch_command, 0.560000, 0.817778, 0.620000, 0.924444, color );
IN_TouchAddButton( "look", "", "", touch_look, 0.5, 0, 1, 1, color );
IN_TouchAddButton( "move", "", "", touch_move, 0, 0, 0.5, 1, color );
IN_TouchAddButton( "zoom", "vgui/touch/zoom", "+zoom", touch_command, 0.680000, 0.00000, 0.760000, 0.142222, color );
IN_TouchAddButton( "speed", "vgui/touch/speed", "+speed", touch_command, 0.180000, 0.568889, 0.280000, 0.746667, color );
IN_TouchAddButton( "loadquick", "vgui/touch/load", "load quick", touch_command, 0.760000, 0.000000, 0.840000, 0.142222, color );
IN_TouchAddButton( "savequick", "vgui/touch/save", "save quick", touch_command, 0.840000, 0.000000, 0.920000, 0.142222, color );
IN_TouchAddButton( "reload", "vgui/touch/reload", "+reload", touch_command, 0.000000, 0.320000, 0.120000, 0.533333, color );
IN_TouchAddButton( "flashlight", "vgui/touch/flash_light_filled", "impulse 100", touch_command, 0.920000, 0.000000, 1.000000, 0.142222, color );
IN_TouchAddButton( "invnext", "vgui/touch/next_weap", "invnext", touch_command, 0.000000, 0.533333, 0.120000, 0.746667, color );
IN_TouchAddButton( "invprev", "vgui/touch/prev_weap", "invprev", touch_command, 0.000000, 0.071111, 0.120000, 0.284444, color );
IN_TouchAddButton( "menu", "vgui/touch/menu", "gameui_activate", touch_command, 0.000000, 0.00000, 0.080000, 0.142222, color );
}
#define GRID_COUNT 50
#define GRID_COUNT_X (GRID_COUNT)
#define GRID_COUNT_Y (GRID_COUNT * screen_h / screen_w)
#define GRID_X (1.0/GRID_COUNT_X)
#define GRID_Y (screen_w/screen_h/GRID_COUNT_X)
#define GRID_ROUND_X(x) ((float)round( x * GRID_COUNT_X ) / GRID_COUNT_X)
#define GRID_ROUND_Y(x) ((float)round( x * GRID_COUNT_Y ) / GRID_COUNT_Y)
static void IN_TouchCheckCoords( float *x1, float *y1, float *x2, float *y2 )
{
/// TODO: grid check here
if( *x2 - *x1 < GRID_X * 2 )
*x2 = *x1 + GRID_X * 2;
if( *y2 - *y1 < GRID_Y * 2)
*y2 = *y1 + GRID_Y * 2;
if( *x1 < 0 )
*x2 -= *x1, *x1 = 0;
if( *y1 < 0 )
*y2 -= *y1, *y1 = 0;
if( *y2 > 1 )
*y1 -= *y2 - 1, *y2 = 1;
if( *x2 > 1 )
*x1 -= *x2 - 1, *x2 = 1;
*x1 = GRID_ROUND_X( *x1 );
*x2 = GRID_ROUND_X( *x2 );
*y1 = GRID_ROUND_Y( *y1 );
*y2 = GRID_ROUND_Y( *y2 );
}
void CTouchControls::VidInit( ) { }
void CTouchControls::Shutdown( ) { }
void CTouchControls::Move( float frametime, CUserCmd *cmd )
{
cmd->sidemove -= cl_sidespeed.GetFloat() * side;
cmd->forwardmove += cl_forwardspeed.GetFloat() * forward;
}
void CTouchControls::IN_Look()
{
if( !pitch && !yaw )
return;
QAngle ang;
engine->GetViewAngles( ang );
ang.x += pitch;
ang.y += yaw;
engine->SetViewAngles( ang );
pitch = yaw = 0;
}
void CTouchControls::Frame()
{
if (!initialized)
return;
IN_Look();
Paint();
}
void CTouchControls::Paint( )
{
if (!initialized)
return;
if ( !enginevgui->IsGameUIVisible() )
{
for (int i = 0; i < g_LastButton; i++)
{
if( g_Buttons[i].type == touch_move || g_Buttons[i].type == touch_look )
continue;
g_pMatSystemSurface->DrawSetColor(255, 255, 255, 155);
g_pMatSystemSurface->DrawSetTexture( g_Buttons[i].textureID );
g_pMatSystemSurface->DrawTexturedRect( g_Buttons[i].x1*screen_w, g_Buttons[i].y1*screen_h, g_Buttons[i].x2*screen_w, g_Buttons[i].y2*screen_h );
}
}
}
void CTouchControls::IN_TouchAddButton( const char *name, const char *texturefile, const char *command, ETouchButtonType type, float x1, float y1, float x2, float y2, rgba_t color )
{
if( g_LastButton >= 64 )
return;
Q_strncpy( g_Buttons[g_LastButton].name, name, 32 );
Q_strncpy( g_Buttons[g_LastButton].texturefile, texturefile, 256 );
Q_strncpy( g_Buttons[g_LastButton].command, command, 256 );
IN_TouchCheckCoords(&x1, &y1, &x2, &y2);
g_Buttons[g_LastButton].x1 = x1;
g_Buttons[g_LastButton].y1 = y1;
g_Buttons[g_LastButton].x2 = x2;
g_Buttons[g_LastButton].y2 = y1 + ( x2 - x1 ) * (((float)screen_w)/screen_h);
IN_TouchCheckCoords(&g_Buttons[g_LastButton].x1, &g_Buttons[g_LastButton].y1, &g_Buttons[g_LastButton].x2, &g_Buttons[g_LastButton].y2);
g_Buttons[g_LastButton].color = color;
g_Buttons[g_LastButton].type = type;
g_Buttons[g_LastButton].finger = -1;
g_Buttons[g_LastButton].textureID = g_pMatSystemSurface->CreateNewTextureID();
g_pMatSystemSurface->DrawSetTextureFile( g_Buttons[g_LastButton].textureID, g_Buttons[g_LastButton].texturefile, true, false);
g_LastButton++;
}
void CTouchControls::ProcessEvent(touch_event_t *ev)
{
if( !touch_enable.GetBool() )
return;
if( ev->type == IE_FingerMotion )
FingerMotion( ev );
else
FingerPress( ev );
}
void CTouchControls::FingerMotion(touch_event_t *ev)
{
float x = ev->x / (float)screen_w;
float y = ev->y / (float)screen_h;
float f, s;
for (int i = 0; i < g_LastButton; i++)
{
if( g_Buttons[i].finger == ev->fingerid )
{
if( g_Buttons[i].type == touch_move )
{
f = ( move_start_y - y ) / touch_settings.sidezone;
s = ( move_start_x - x ) / touch_settings.sidezone;
forward = bound( -1, f, 1 );
side = bound( -1, s, 1 );
}
else if( g_Buttons[i].type == touch_look )
{
yaw += touch_settings.yaw * ( dx - x ) * touch_settings.sensitivity;
pitch -= touch_settings.pitch * ( dy - y ) * touch_settings.sensitivity;
dx = x;
dy = y;
}
}
}
}
void CTouchControls::FingerPress(touch_event_t *ev)
{
float x = ev->x / (float)screen_w;
float y = ev->y / (float)screen_h;
if( ev->type == IE_FingerDown )
{
for (int i = 0; i < g_LastButton; i++)
{
if( x > g_Buttons[i].x1 && x < g_Buttons[i].x2 && y > g_Buttons[i].y1 && y < g_Buttons[i].y2 )
{
g_Buttons[i].finger = ev->fingerid;
if( g_Buttons[i].type == touch_move )
{
if( move_finger == -1 )
{
move_start_x = x;
move_start_y = y;
move_finger = ev->fingerid;
}
else
g_Buttons[i].finger = move_finger;
}
else if( g_Buttons[i].type == touch_look )
{
if( look_finger == -1 )
{
dx = x;
dy = y;
look_finger = ev->fingerid;
}
else
g_Buttons[i].finger = look_finger;
}
else
engine->ClientCmd( g_Buttons[i].command );
}
}
}
else if( ev->type == IE_FingerUp )
{
{
for (int i = 0; i < g_LastButton; i++)
{
if( g_Buttons[i].finger == ev->fingerid )
{
g_Buttons[i].finger = -1;
if( g_Buttons[i].type == touch_move )
{
forward = side = 0;
move_finger = -1;
}
else if( g_Buttons[i].type == touch_look )
look_finger = -1;
else if( g_Buttons[i].command[0] == '+' )
{
char cmd[256];
snprintf( cmd, sizeof cmd, "%s", g_Buttons[i].command );
cmd[0] = '-';
engine->ClientCmd( cmd );
}
}
}
}
}
}

212
game/client/touch.h Normal file
View File

@ -0,0 +1,212 @@
#include "utllinkedlist.h"
#include "vgui/VGUI.h"
#include <vgui_controls/Panel.h>
#include "cbase.h"
#include "kbutton.h"
#include "usercmd.h"
extern ConVar touch_enable;
#define STEAMCONTROLLER_A -3
#define MOUSE_EVENT_PRESS 0x02
#define MOUSE_EVENT_RELEASE 0x04
enum ActivationType_t
{
ACTIVATE_ONPRESSEDANDRELEASED, // normal button behaviour
ACTIVATE_ONPRESSED, // menu buttons, toggle buttons
ACTIVATE_ONRELEASED, // menu items
};
#define CMD_SIZE 64
enum ETouchButtonType
{
touch_command = 0, // Tap button
touch_move, // Like a joystick stick.
touch_joy, // Like a joystick stick, centered.
touch_dpad, // Only two directions.
touch_look, // Like a touchpad.
touch_key
};
enum ETouchState
{
state_none = 0,
state_edit,
state_edit_move
};
enum ETouchRound
{
round_none = 0,
round_grid,
round_aspect
};
struct rgba_t
{
rgba_t( unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255 ) : r( r ), g( g ), b( b ), a( a ) { }
rgba_t() : r( 0 ), g( 0 ), b( 0 ), a( 0 ) { }
rgba_t( unsigned char *x ) : r( x[0] ), g( x[1] ), b( x[2] ), a( x[3] ) { }
operator unsigned char*() { return &r; }
unsigned char r, g, b, a;
};
struct event_clientcmd_t
{
char buf[CMD_SIZE];
};
struct event_s
{
int type;
int x;
int y;
int fingerid;
} typedef touch_event_t;
class CTouchButton
{
public:
// Touch button type: tap, stick or slider
ETouchButtonType type;
// Field of button in pixels
float x1, y1, x2, y2;
// Button texture
int texture;
rgba_t color;
char texturefile[256];
char command[256];
char name[32];
int finger;
int flags;
float fade;
float fadespeed;
float fadeend;
float aspect;
int textureID;
};
struct touch_settings_s
{
float pitch = 90;
float yaw = 120;
float sensitivity = 2;
float forwardzone = 0.8;
float sidezone = 0.12;
};
class CTouchPanel : public vgui::Panel
{
DECLARE_CLASS_SIMPLE( CTouchPanel, vgui::Panel );
public:
CTouchPanel( vgui::VPANEL parent );
virtual ~CTouchPanel( void );
virtual void Paint();
virtual bool ShouldDraw( void );
};
abstract_class ITouchPanel
{
public:
virtual void Create( vgui::VPANEL parent ) = 0;
virtual void Destroy( void ) = 0;
};
class VTouchPanel : public ITouchPanel
{
private:
CTouchPanel *touchPanel;
public:
VTouchPanel( void )
{
touchPanel = NULL;
}
void Create( vgui::VPANEL parent )
{
touchPanel = new CTouchPanel( parent );
}
void Destroy( void )
{
if ( touchPanel )
{
touchPanel->SetParent( (vgui::Panel *)NULL );
touchPanel->MarkForDeletion();
touchPanel = NULL;
}
}
};
class CTouchControls
{
public:
CTouchControls();
~CTouchControls();
void VidInit( );
void Shutdown( );
void Init( );
void Paint( );
void Frame( );
void IN_TouchAddButton( const char *name, const char *texturefile, const char *command, ETouchButtonType type, float x1, float y1, float x2, float y2, rgba_t color );
void Move( float frametime, CUserCmd *cmd );
void IN_Look( );
void ProcessEvent( touch_event_t *ev );
void FingerPress( touch_event_t *ev );
void FingerMotion( touch_event_t *ev );
CTouchPanel *touchPanel;
private:
bool initialized;
ETouchState state;
CUtlLinkedList<CTouchButton> btns;
int look_finger;
int move_finger;
float forward, side, movecount;
float yaw, pitch;
CTouchButton *move;
float move_start_x, move_start_y;
float dx, dy;
// editing
CTouchButton *edit;
CTouchButton *selection;
int resize_finger;
bool showbuttons;
bool clientonly;
rgba_t scolor;
int swidth;
bool precision;
// textures
int showtexture;
int hidetexture;
int resettexture;
int closetexture;
int joytexture; // touch indicator
bool configchanged;
vgui::HFont textfont;
int mouse_events;
struct touch_settings_s touch_settings;
};
extern CTouchControls gTouch;
extern VTouchPanel *touch_panel;

View File

@ -22,6 +22,7 @@
#include <vgui_controls/Panel.h>
#include <KeyValues.h>
#include "filesystem.h"
#include "touch.h"
#include "matsys_controls/matsyscontrols.h"
#ifdef SIXENSE
@ -129,6 +130,7 @@ static void VGui_VideoMode_AdjustForModeChange( void )
fps->Destroy();
messagechars->Destroy();
loadingdisc->Destroy();
touch_panel->Destroy();
// Recreate our panels.
VPANEL gameToolParent = enginevgui->GetPanel( PANEL_CLIENTDLL_TOOLS );
@ -142,6 +144,7 @@ static void VGui_VideoMode_AdjustForModeChange( void )
// Debugging or related tool
fps->Create( toolParent );
touch_panel->Create( toolParent );
#if defined( TRACK_BLOCKING_IO )
iopanel->Create( gameDLLPanel );
#endif
@ -207,6 +210,8 @@ void VGui_CreateGlobalPanels( void )
// Debugging or related tool
fps->Create( toolParent );
touch_panel->Create( toolParent );
#if defined( TRACK_BLOCKING_IO )
iopanel->Create( gameDLLPanel );
#endif
@ -236,6 +241,7 @@ void VGui_Shutdown()
iopanel->Destroy();
#endif
fps->Destroy();
touch_panel->Destroy();
messagechars->Destroy();
loadingdisc->Destroy();

View File

@ -521,7 +521,8 @@ def build(bld):
'hl2/hud_zoom.cpp',
'hl2/shieldproxy.cpp',
'hl2/vgui_rootpanel_hl2.cpp',
'episodic/c_vort_charge_token.cpp'
'episodic/c_vort_charge_token.cpp',
'touch.cpp'
]
includes = [

View File

@ -23,11 +23,11 @@ int TouchSDLWatcher( void *userInfo, SDL_Event *event )
SDL_Window *window = SDL_GetWindowFromID(event->tfinger.windowID);
if( !window )
return 0;
int width, height;
width = height = 0;
SDL_GetWindowSize(window, &width, &height);
switch ( event->type ) {
case SDL_FINGERDOWN:
pInputSystem->FingerDown( event->tfinger.fingerId, event->tfinger.x*width, event->tfinger.y*height );
@ -73,7 +73,7 @@ void CInputSystem::FingerDown(int fingerId, int x, int y)
m_touchAccumFingerId = fingerId;
m_touchAccumX = x;
m_touchAccumY = y;
PostEvent(IE_FingerDown, m_nLastSampleTick, fingerId, x, y);
}
@ -83,16 +83,16 @@ void CInputSystem::FingerUp(int fingerId, int x, int y)
m_touchAccumFingerId = fingerId;
m_touchAccumX = x;
m_touchAccumY = y;
PostEvent(IE_FingerUp, m_nLastSampleTick, fingerId, x, y);
PostEvent(IE_FingerUp, m_nLastSampleTick, fingerId, x, y);
}
void CInputSystem::FingerMotion(int fingerId, int x, int y)
{
m_touchAccumEvent = IE_FingerMotion;
m_touchAccumEvent = IE_FingerMotion;
m_touchAccumFingerId = fingerId;
m_touchAccumX = x;
m_touchAccumY = y;
PostEvent(IE_FingerMotion, m_nLastSampleTick, fingerId, x, y);
PostEvent(IE_FingerMotion, m_nLastSampleTick, fingerId, x, y);
}

View File

@ -18,6 +18,7 @@ def build(bld):
source = [
'inputsystem.cpp',
'joystick_sdl.cpp',
'touch_sdl.cpp',
#'novint.cpp', # [$WIN32]
'key_translation.cpp',
'steamcontroller.cpp'

View File

@ -7,7 +7,7 @@
#include <unistd.h>
#include <stdio.h>
#include <dlfcn.h>
#include <SDL_hints.h>
#include "tier0/threadtools.h"
@ -92,9 +92,9 @@ t_eglGetProcAddress eglGetProcAddress;
void *GetProcAddress( const char *procname )
{
void *result = dlsym(lgles, procname);
if(result)
if( result )
return result;
else
else if( eglGetProcAddress )
return eglGetProcAddress(procname);
}
@ -127,7 +127,7 @@ DLLEXPORT int LauncherMainAndroid( int argc, char **argv )
gl4es_set_getprocaddress = (t_set_getprocaddress)dlsym(lgl4es, "set_getprocaddress");
eglGetProcAddress = (t_eglGetProcAddress)dlsym(lEGL, "eglGetProcAddress");
if( gl4es_set_getprocaddress && eglGetProcAddress )
if( gl4es_set_getprocaddress )
{
gl4es_set_getprocaddress( &GetProcAddress );
}
@ -137,6 +137,7 @@ DLLEXPORT int LauncherMainAndroid( int argc, char **argv )
return 1;
}
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
DeclareCurrentThreadIsMainThread(); // Init thread propertly on Android
return LauncherMain(iLastArgs, LauncherArgv);

View File

@ -789,6 +789,8 @@ public:
virtual bool DisconnectAttempt( void ) = 0;
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar ) = 0;
virtual void IN_TouchEvent( int type, int fingerId, int x, int y ) = 0;
};
#define CLIENT_DLL_INTERFACE_VERSION "VClient017"