add more custom screen resolutions, fix build

This commit is contained in:
nillerusr
2022-01-25 00:14:29 +03:00
parent 0fb75b41fd
commit 303b387e76
22 changed files with 189 additions and 803 deletions
-673
View File
File diff suppressed because one or more lines are too long
+13 -6
View File
@@ -735,7 +735,7 @@ public:
virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar );
virtual void IN_TouchEvent( int type, int fingerId, int x, int y );
virtual void IN_TouchEvent( uint data, uint data2, uint data3, uint data4 );
private:
void UncacheAllMaterials( );
void ResetStringTablePointers();
@@ -1424,17 +1424,24 @@ int CHLClient::IN_KeyEvent( int eventcode, ButtonCode_t keynum, const char *pszC
return input->KeyEvent( eventcode, keynum, pszCurrentBinding );
}
void CHLClient::IN_TouchEvent( int type, int fingerId, int x, int y )
void CHLClient::IN_TouchEvent( uint data, uint data2, uint data3, uint data4 )
{
if( enginevgui->IsGameUIVisible() )
return;
touch_event_t ev;
ev.type = type;
ev.fingerid = fingerId;
ev.x = x;
ev.y = y;
ev.type = data & 0xFFFF;
ev.fingerid = (data >> 16) & 0xFFFF;
ev.x = (double)((data2 >> 16) & 0xFFFF) / 0xFFFF;
ev.y = (double)(data2 & 0xFFFF) / 0xFFFF;
union{uint i;float f;} ifconv;
ifconv.i = data3;
ev.dx = ifconv.f;
ifconv.i = data4;
ev.dy = ifconv.f;
gTouch.ProcessEvent( &ev );
}
+41 -30
View File
@@ -62,11 +62,36 @@ CTouchPanel::CTouchPanel( vgui::VPANEL parent ) : BaseClass( NULL, "TouchPanel"
SetVisible( true );
}
void CTouchPanel::Paint()
{
gTouch.Frame();
}
void CTouchPanel::OnScreenSizeChanged(int iOldWide, int iOldTall)
{
BaseClass::OnScreenSizeChanged(iOldWide, iOldTall);
int w,h;
w = ScreenWidth();
h = ScreenHeight();
gTouch.screen_w = ScreenWidth(); gTouch.screen_h = h;
SetBounds( 0, 0, w, h );
}
void CTouchPanel::ApplySchemeSettings(vgui::IScheme *pScheme)
{
BaseClass::ApplySchemeSettings(pScheme);
int w,h;
w = ScreenWidth();
h = ScreenHeight();
gTouch.screen_w = ScreenWidth(); gTouch.screen_h = h;
SetBounds( 0, 0, w, h );
}
CON_COMMAND( touch_addbutton, "add native touch button" )
{
rgba_t color;
@@ -282,7 +307,7 @@ void CTouchControls::Init()
char buf[256];
Q_snprintf(buf, sizeof buf, "exec %s\n", touch_config_file.GetString());
engine->ClientCmd_Unrestricted(buf);
Q_snprintf(buf, sizeof buf, "cfg/%s", touch_config_file.GetString());
if( !filesystem->FileExists(buf) )
WriteConfig();
@@ -530,8 +555,8 @@ void CTouchControls::ProcessEvent(touch_event_t *ev)
void CTouchControls::EditEvent(touch_event_t *ev)
{
float x = ev->x / (float)screen_w;
float y = ev->y / (float)screen_h;
const float x = ev->x;
const float y = ev->y;
//CUtlLinkedList<CTouchButton*>::iterator it;
@@ -556,13 +581,11 @@ void CTouchControls::EditEvent(touch_event_t *ev)
{
move_finger = ev->fingerid;
selection = btn;
dx = x; dy = y;
break;
}
else if( resize_finger == -1 )
{
resize_finger = ev->fingerid;
dx2 = x; dy2 = y;
}
}
}
@@ -574,7 +597,6 @@ void CTouchControls::EditEvent(touch_event_t *ev)
move_finger = -1;
IN_CheckCoords( &selection->x1, &selection->y1, &selection->x2, &selection->y2 );
selection = nullptr;
dx = dy = 0.f;
}
else if( ev->fingerid == resize_finger )
resize_finger = -1;
@@ -586,20 +608,15 @@ void CTouchControls::EditEvent(touch_event_t *ev)
if( move_finger == ev->fingerid )
{
selection->x1 += x-dx;
selection->x2 += x-dx;
selection->y1 += y-dy;
selection->y2 += y-dy;
dx = x;
dy = y;
selection->x1 += ev->dx;
selection->x2 += ev->dx;
selection->y1 += ev->dy;
selection->y2 += ev->dy;
}
else if( resize_finger == ev->fingerid )
{
selection->x2 += x-dx2;
selection->y2 += y-dy2;
dx2 = x; dy2 = y;
selection->x2 += ev->dx;
selection->y2 += ev->dy;
}
}
}
@@ -607,8 +624,8 @@ void CTouchControls::EditEvent(touch_event_t *ev)
void CTouchControls::FingerMotion(touch_event_t *ev) // finger in my ass
{
float x = ev->x / (float)screen_w;
float y = ev->y / (float)screen_h;
const float x = ev->x;
const float y = ev->y;
float f, s;
@@ -627,10 +644,8 @@ void CTouchControls::FingerMotion(touch_event_t *ev) // finger in my ass
}
else if( btn->type == touch_look )
{
yaw += touch_yaw.GetFloat() * ( dx - x ) * sensitivity.GetFloat();
pitch -= touch_pitch.GetFloat() * ( dy - y ) * sensitivity.GetFloat();
dx = x;
dy = y;
yaw -= touch_yaw.GetFloat() * ev->dx * sensitivity.GetFloat();
pitch += touch_pitch.GetFloat() * ev->dy * sensitivity.GetFloat();
}
}
}
@@ -638,8 +653,8 @@ void CTouchControls::FingerMotion(touch_event_t *ev) // finger in my ass
void CTouchControls::FingerPress(touch_event_t *ev)
{
float x = ev->x / (float)screen_w;
float y = ev->y / (float)screen_h;
const float x = ev->x;
const float y = ev->y;
CUtlLinkedList<CTouchButton*>::iterator it;
@@ -668,11 +683,7 @@ void CTouchControls::FingerPress(touch_event_t *ev)
else if( btn->type == touch_look )
{
if( look_finger == -1 )
{
dx = x;
dy = y;
look_finger = ev->fingerid;
}
else
btn->finger = look_finger;
}
@@ -722,7 +733,7 @@ void CTouchControls::EnableTouchEdit(bool enable)
resize_finger = move_finger = look_finger = wheel_finger = -1;
move_button = NULL;
configchanged = true;
AddButton( "close_edit", "vgui/touch/exit", "touch_disableedit", 0.010000, 0.837778, 0.080000, 0.980000, rgba_t(255,255,255,255), 0, 1.f, TOUCH_FL_NOEDIT );
AddButton( "close_edit", "vgui/touch/back", "touch_disableedit", 0.010000, 0.837778, 0.080000, 0.980000, rgba_t(255,255,255,255), 0, 1.f, TOUCH_FL_NOEDIT );
}
else
{
+7 -6
View File
@@ -72,8 +72,7 @@ struct event_clientcmd_t
struct event_s
{
int type;
int x;
int y;
float x,y,dx,dy;
int fingerid;
} typedef touch_event_t;
@@ -110,8 +109,11 @@ class CTouchPanel : public vgui::Panel
public:
CTouchPanel( vgui::VPANEL parent );
virtual ~CTouchPanel( void ) {};
virtual void Paint();
virtual void ApplySchemeSettings(vgui::IScheme *pScheme);
protected:
MESSAGE_FUNC_INT_INT( OnScreenSizeChanged, "OnScreenSizeChanged", oldwide, oldtall );
};
abstract_class ITouchPanel
@@ -189,6 +191,8 @@ public:
void EnableTouchEdit(bool enable);
CTouchPanel *touchPanel;
float screen_h, screen_w;
private:
bool initialized = false;
ETouchState state;
@@ -200,7 +204,6 @@ private:
CTouchButton *move_button;
float move_start_x, move_start_y;
float dx, dy, dx2, dy2;
// editing
CTouchButton *edit;
@@ -221,8 +224,6 @@ private:
bool config_loaded;
vgui::HFont textfont;
int mouse_events;
float screen_h, screen_w;
};
extern CTouchControls gTouch;
+1 -13
View File
@@ -66,19 +66,7 @@ def build(bld):
if bld.env.DEST_OS != 'android':
install_path += '/'+bld.env.GAMES+'/bin'
source = [ 'touch.cpp', 'arch.c' ]
if bld.env.DEST_OS == 'android':
source += [
'third/minizip/mz_zip.c',
'third/minizip/mz_strm.c',
'third/minizip/mz_strm_mem.c',
'third/minizip/mz_strm_buf.c',
'third/minizip/mz_strm_split.c',
'third/minizip/mz_strm_posix.c',
'third/minizip/mz_strm_zlib.c',
'third/minizip/mz_os_posix.c'
]
source = [ 'touch.cpp' ]
source += game["sources"]
includes += game["includes"]