Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into android
Browse files Browse the repository at this point in the history
  • Loading branch information
Velaron committed Nov 7, 2023
2 parents 5f65c92 + 0aa8a28 commit fee9a66
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 46 deletions.
10 changes: 4 additions & 6 deletions engine/client/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,6 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
if( newstate == oldstate )
return;

if( m_ignore.value )
{
host.mouse_visible = newstate == key_menu || newstate == key_console;
return;
}

// since SetCursorType controls cursor visibility
// execute it first, and then check mouse grab state
if( newstate == key_menu || newstate == key_console )
Expand All @@ -198,6 +192,10 @@ void IN_ToggleClientMouse( int newstate, int oldstate )
#endif
}

// don't leave the user without cursor if they enabled m_ignore
if( m_ignore.value )
return;

if( oldstate == key_game )
{
IN_DeactivateMouse();
Expand Down
6 changes: 6 additions & 0 deletions engine/client/ref_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,9 @@ static void R_CollectRendererNames( void )
#if XASH_REF_GL4ES_ENABLED
"gl4es",
#endif
#if XASH_REF_GLES3COMPAT_ENABLED
"gles3compat",
#endif
#if XASH_REF_SOFT_ENABLED
"soft",
#endif
Expand All @@ -589,6 +592,9 @@ static void R_CollectRendererNames( void )
#if XASH_REF_GL4ES_ENABLED
"GL4ES",
#endif
#if XASH_REF_GLES3COMPAT_ENABLED
"GLES3 (gl2_shim)"
#endif
#if XASH_REF_SOFT_ENABLED
"Software",
#endif
Expand Down
3 changes: 3 additions & 0 deletions engine/common/host.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ void Sys_PrintUsage( void )
O("-sdl_joy_old_api ","use SDL legacy joystick API")
O("-sdl_renderer <n>","use alternative SDL_Renderer for software")
#endif // XASH_SDL
#if XASH_ANDROID && !XASH_SDL
O("-nativeegl ","use native egl implementation. Use if screen does not update or black")
#endif // XASH_ANDROID
#if XASH_DOS
O("-novesa ","disable vesa")
#endif // XASH_DOS
Expand Down
29 changes: 10 additions & 19 deletions filesystem/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,6 @@ struct android_assets_s
AAssetDir *dir;
};

/*
struct android_saf_s
{
};
*/

struct jni_methods_s
{
JNIEnv *env;
Expand All @@ -57,15 +50,14 @@ struct jni_methods_s
jmethodID getPackageName;
jmethodID getCallingPackage;
jmethodID getAssetsList;
jmethodID getAssets;
} jni;

static void Android_GetAssetManager( android_assets_t *assets )
{
jmethodID getAssets;
jobject assetManager;

getAssets = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssets", "(Z)Landroid/content/res/AssetManager;" );
assetManager = (*jni.env)->CallObjectMethod( jni.env, jni.activity, getAssets, assets->engine );
assetManager = (*jni.env)->CallObjectMethod( jni.env, jni.activity, jni.getAssets, assets->engine );

if( assetManager )
assets->asset_manager = AAssetManager_fromJava( jni.env, assetManager );
Expand Down Expand Up @@ -117,8 +109,7 @@ static void FS_CloseAndroidAssets( android_assets_t *assets )

static android_assets_t *FS_LoadAndroidAssets( qboolean engine )
{
android_assets_t *assets = (android_assets_t *)Mem_Calloc( fs_mempool, sizeof( android_assets_t ));
memset( assets, 0, sizeof( android_assets_t ));
android_assets_t *assets = Mem_Calloc( fs_mempool, sizeof( *assets ));

assets->engine = engine;

Expand Down Expand Up @@ -229,7 +220,7 @@ static void FS_Search_AndroidAssets( searchpath_t *search, stringlist_t *list, c

static file_t *FS_OpenFile_AndroidAssets( searchpath_t *search, const char *filename, const char *mode, int pack_ind )
{
file_t *file = (file_t *)Mem_Calloc( fs_mempool, sizeof( file_t ));
file_t *file = Mem_Calloc( fs_mempool, sizeof( *file ));
AAsset *assets = AAssetManager_open( search->assets->asset_manager, filename, AASSET_MODE_RANDOM );

file->handle = AAsset_openFileDescriptor( assets, &file->offset, &file->real_length );
Expand Down Expand Up @@ -279,29 +270,28 @@ searchpath_t *FS_AddAndroidAssets_Fullpath( const char *path, int flags )
android_assets_t *assets = NULL;
qboolean engine = true;

if(( flags & FS_STATIC_PATH ) || ( flags & FS_CUSTOM_PATH ))
if( FBitSet( flags, FS_STATIC_PATH | FS_CUSTOM_PATH ))
return NULL;

if(( flags & FS_GAMEDIR_PATH ) && Q_stricmp( GI->basedir, GI->gamefolder ))
if( FBitSet( flags, FS_GAMEDIR_PATH ) && Q_stricmp( GI->basedir, GI->gamefolder ))
engine = false;

assets = FS_LoadAndroidAssets( engine );

if( !assets )
{
Con_Reportf( S_ERROR "%s: unable to load Android assets \"%s\"\n", __FUNCTION__, Android_GetPackageName( engine ) );
Con_Reportf( S_ERROR "%s: unable to load Android assets \"%s\"\n", __FUNCTION__, Android_GetPackageName( engine ));
return NULL;
}

Q_strncpy( assets->package_name, Android_GetPackageName( engine ), sizeof( assets->package_name ));

search = (searchpath_t *)Mem_Calloc( fs_mempool, sizeof( searchpath_t ));
memset( search, 0, sizeof( searchpath_t ));
search = Mem_Calloc( fs_mempool, sizeof( *search ));

Q_strncpy( search->filename, assets->package_name, sizeof( search->filename ));
search->assets = assets;
search->type = SEARCHPATH_ANDROID_ASSETS;
search->flags = FS_NOWRITE_PATH | FS_CUSTOM_PATH;
SetBits( search->flags, FS_NOWRITE_PATH | FS_CUSTOM_PATH );

search->pfnPrintInfo = FS_PrintInfo_AndroidAssets;
search->pfnClose = FS_Close_AndroidAssets;
Expand Down Expand Up @@ -329,6 +319,7 @@ void FS_InitAndroid( void )
jni.getPackageName = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getPackageName", "()Ljava/lang/String;" );
jni.getCallingPackage = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getCallingPackage", "()Ljava/lang/String;" );
jni.getAssetsList = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssetsList", "(ZLjava/lang/String;)[Ljava/lang/String;" );
jni.getAssets = (*jni.env)->GetMethodID( jni.env, jni.activity_class, "getAssets", "(Z)Landroid/content/res/AssetManager;" );
}

#endif // XASH_ANDROID
2 changes: 1 addition & 1 deletion filesystem/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void stringlistfreecontents( stringlist_t *list )
list->strings = NULL;
}

void stringlistappend( stringlist_t *list, char *text )
void stringlistappend( stringlist_t *list, const char *text )
{
size_t textlen;

Expand Down
2 changes: 1 addition & 1 deletion filesystem/filesystem_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ qboolean MD5_HashFile( byte digest[16], const char *pszFileName, uint seed[4] );
// stringlist ops
void stringlistinit( stringlist_t *list );
void stringlistfreecontents( stringlist_t *list );
void stringlistappend( stringlist_t *list, char *text );
void stringlistappend( stringlist_t *list, const char *text );
void stringlistsort( stringlist_t *list );
void listdirectory( stringlist_t *list, const char *path );

Expand Down
15 changes: 5 additions & 10 deletions filesystem/wscript
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,17 @@ def configure(conf):

if conf.env.DEST_OS == 'android':
conf.check_cc(lib='android')

if conf.env.DEST_OS != 'android':
if conf.env.cxxshlib_PATTERN.startswith('lib'):
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
elif conf.env.cxxshlib_PATTERN.startswith('lib'): # remove lib prefix for other systems than Android
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]

def build(bld):
bld(name = 'filesystem_includes', export_includes = '.')

libs = [ 'filesystem_includes' ]
libs = [ 'filesystem_includes', 'sdk_includes' ]

# on PSVita do not link any libraries that are already in the main executable, but add the includes target
if bld.env.DEST_OS == 'psvita':
libs += [ 'sdk_includes' ]
elif bld.env.DEST_OS == 'android':
if bld.env.DEST_OS != 'psvita':
libs += [ 'public', 'ANDROID' ]
else:
libs += [ 'public' ]

bld.shlib(target = 'filesystem_stdio',
features = 'cxx seq',
Expand Down
11 changes: 8 additions & 3 deletions scripts/waifulib/compiler_optimizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
'''

VALID_BUILD_TYPES = ['fastnative', 'fast', 'release', 'debug', 'sanitize', 'msan', 'none']
VALID_BUILD_TYPES = ['fastnative', 'fast', 'humanrights', 'debug', 'sanitize', 'msan', 'none']

LINKFLAGS = {
'common': {
Expand Down Expand Up @@ -75,7 +75,7 @@
'clang': ['-Ofast', '-march=native'],
'default': ['-O3']
},
'release': {
'humanrights': {
'msvc': ['/O2', '/Zi'],
'owcc': ['-O3', '-foptimize-sibling-calls', '-fomit-leaf-frame-pointer', '-fomit-frame-pointer', '-fschedule-insns', '-funsafe-math-optimizations', '-funroll-loops', '-frerun-optimizer', '-finline-functions', '-finline-limit=512', '-fguess-branch-probability', '-fno-strict-aliasing', '-floop-optimize'],
'gcc': ['-O3', '-fno-semantic-interposition'],
Expand Down Expand Up @@ -119,7 +119,7 @@
def options(opt):
grp = opt.add_option_group('Compiler optimization options')

grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default='release',
grp.add_option('-T', '--build-type', action='store', dest='BUILD_TYPE', default='humanrights',
help = 'build type: debug, release or none(custom flags)')

grp.add_option('--enable-lto', action = 'store_true', dest = 'LTO', default = False,
Expand All @@ -131,6 +131,11 @@ def options(opt):
def configure(conf):
conf.start_msg('Build type')

# legacy naming for default release build
# https://chaos.social/@karolherbst/111340511652012860
if conf.options.BUILD_TYPE == 'release':
conf.options.BUILD_TYPE = 'humanrights'

if not conf.options.BUILD_TYPE in VALID_BUILD_TYPES:
conf.end_msg(conf.options.BUILD_TYPE, color='RED')
conf.fatal('Invalid build type. Valid are: %s' % ', '.join(VALID_BUILD_TYPES))
Expand Down
13 changes: 7 additions & 6 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,13 @@ def configure(conf):

# modify options dictionary early
if conf.env.DEST_OS == 'android':
conf.options.NO_VGUI = True # skip vgui
conf.options.NANOGL = True
conf.options.GLWES = True
conf.options.GL4ES = True
conf.options.GL = False
conf.options.SINGLE_BINARY = True
conf.options.NO_VGUI = True # skip vgui
conf.options.NANOGL = True
conf.options.GLWES = True
conf.options.GL4ES = True
conf.options.GLES3COMPAT = True
conf.options.GL = False
conf.options.SINGLE_BINARY = True
conf.define('XASH_SDLMAIN', 1)
elif conf.env.MAGX:
conf.options.SDL12 = True
Expand Down

0 comments on commit fee9a66

Please sign in to comment.