Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Touch support #27

Draft
wants to merge 3 commits into
base: experiment-main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ That repository served as a great source of code and inspiration to get 'Experim
- **Lua Scripting**: Write your mod in Lua, a powerful and easy-to-learn scripting language.
- **Garry's Mod compatibility**: Use Garry's Mod addons, gamemodes, scripts and binary modules in your mod.
- **Game Content mounting**: Mount content from other Source Engine games, like Half-Life 2, Counter-Strike: Source and more.
- **Native Android Support**: You can now run experiment-source on your Android phone! (NOTE: This feature is not ready yet)

[» Visit the Developer Portal for our full Goals & Roadmap.](https://experiment-games.github.io/experiment-source/general/goals-and-roadmap/)

Expand Down Expand Up @@ -235,3 +236,32 @@ Setup the debugger with the following values:
> - Working Directory: `C:\Program Files %28x86%29\Steam\steamapps\common\Source SDK Base 2013 Multiplayer`

</details>

### Installation for Android
1. Install vs-android from [Source4Android Project](https://github.com/GuestSneezeOSDev/source4android) or [vs-android GitHub repo](https://github.com/gavinpugh/vs-android)
2. Edit your `server.vcxproj` and `client.vcxproj` and add this between line 5 or 12 or somewhere else. [1](https://github.com/GuestSneezeOSDev/source4android)
```xml
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Android'">
<OutputPath>$(SolutionDir)bin\$(Configuration)\android\</OutputPath>
</PropertyGroup>
```
3. Now convert your `client.vcxproj` and `server.vcxproj` to compile as a shared library (aka `.so`), you can do this by renaming the `.vcxproj` to `.vcitems`
Heres an example `.vcitems`
```xml
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<ItemsProjectGuid>{0c903c63-3ab9-49bf-b59f-0d0862db414a}</ItemsProjectGuid>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
</Project>
```
22 changes: 21 additions & 1 deletion src/game/client/cdll_client_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ extern vgui::IInputInternal *g_InputInternal;
#include <lColor.h>
#endif

#include "touch.h"

#ifdef PORTAL
#include "PortalRender.h"
#endif
Expand Down Expand Up @@ -809,7 +811,8 @@ class CHLClient : public IBaseClientDLL
// Returns true if the disconnect command has been handled by the client
virtual bool DisconnectAttempt( void );

public:
virtual void IN_TouchEvent( int type, int fingerId, int x, int y );

void PrecacheMaterial( const char *pMaterialName );

virtual bool IsConnectedUserInfoChangeAllowed( IConVar *pCvar );
Expand Down Expand Up @@ -1191,6 +1194,8 @@ int CHLClient::Init( CreateInterfaceFn appSystemFactory,

gHUD.Init();

gTouch.Init();

g_pClientMode->Init();

if ( !IGameSystem::InitAllSystems() )
Expand Down Expand Up @@ -1600,6 +1605,21 @@ 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 )
{
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() );
Expand Down
6 changes: 6 additions & 0 deletions src/game/client/client_experiment.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ $Project "Client (Experiment)"
$File "experiment\ui\experimenttextwindow.cpp"
$File "experiment\ui\experimenttextwindow.h"

$Folder "Android"
{
$File "experiment\ui\touch.cpp"
$File "experiment\ui\touch.cpp"
}

$File "experiment\ui\createmultiplayergamedialog.cpp"
$File "experiment\ui\createmultiplayergamedialog.h"
$File "experiment\ui\createmultiplayergamegameplaypage.cpp"
Expand Down
Loading