diff --git a/polymer/eduke32/Android.mk b/polymer/eduke32/Android.mk index 952993454..592b6a9b3 100644 --- a/polymer/eduke32/Android.mk +++ b/polymer/eduke32/Android.mk @@ -21,8 +21,9 @@ include $(CLEAR_VARS) LOCAL_MODULE := duke +# -O2 -fvisibility=hidden -LOCAL_CFLAGS := -fPIC -Wimplicit -Wdeclaration-after-statement -O2 -funswitch-loops -fomit-frame-pointer -DNDEBUG -DUSING_LTO -flto -fno-stack-protector -W -Werror-implicit-function-declaration -Wpointer-arith -Wextra -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 -fjump-tables -Wno-unused-result -Wno-char-subscripts -DUSE_LIBPNG -pthread -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -DHAVE_INTTYPES -D_GNU_SOURCE=1 -D_REENTRANT -DRENDERTYPESDL=1 -Wno-strict-overflow -DUSE_OPENGL -Wno-attributes +LOCAL_CFLAGS := -fvisibility=hidden -fPIC -Wimplicit -Wdeclaration-after-statement -O2 -funswitch-loops -fomit-frame-pointer -DNDEBUG -DUSING_LTO -flto -fno-stack-protector -W -Werror-implicit-function-declaration -Wpointer-arith -Wextra -funsigned-char -fno-strict-aliasing -DNO_GCC_BUILTINS -D_FORTIFY_SOURCE=2 -fjump-tables -Wno-unused-result -Wno-char-subscripts -DUSE_LIBPNG -pthread -DHAVE_INTTYPES -D_GNU_SOURCE=1 -D_REENTRANT -DRENDERTYPESDL=1 -Wno-strict-overflow -DUSE_OPENGL -Wno-attributes #Needed my jaudiolib LOCAL_CFLAGS += -DHAVE_SDL @@ -35,7 +36,9 @@ LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp LOCAL_LDLIBS += -Wl,--fix-cortex-a8 -LOCAL_C_INCLUDES := $(LOCAL_PATH)/source $(LOCAL_PATH)/source/jmact $(LOCAL_PATH)/source/jaudiolib/include $(LOCAL_PATH)/source/enet/include $(LOCAL_PATH)/build/include $(TOP_DIR)/SDL2/include $(TOP_DIR)/SDL2_mixer $(IDTECH_DIR)/libpng $(IDTECH_DIR)/TinyXML $(IDTECH_DIR)/TouchControls $(IDTECH_DIR)/ +LOCAL_C_INCLUDES := $(LOCAL_PATH)/source $(LOCAL_PATH)/source/jmact $(LOCAL_PATH)/source/jaudiolib/include $(LOCAL_PATH)/source/enet/include $(LOCAL_PATH)/build/include + +LOCAL_C_INCLUDES += $(TOP_DIR)/ $(TOP_DIR)/Libraries/ $(TOP_DIR)/Libraries/SDL2/include $(TOP_DIR)/Libraries/SDL2_mixer/include $(TOP_DIR)/Libraries/libpng/include $(TOP_DIR)/Libraries/TinyXML/include $(TOP_DIR)/TouchControls ANDROID_SRC = \ source/android/android-jni.cpp \ @@ -135,6 +138,11 @@ LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lOpenSLES -lz LOCAL_STATIC_LIBRARIES := nanogl SDL2_net libjpeg libpng LOCAL_SHARED_LIBRARIES := touchcontrols openal SDL2 SDL2_mixer SDL2_image +ifeq ($(GP_LIC),1) +LOCAL_STATIC_LIBRARIES += s-setup +LOCAL_CFLAGS += -DGP_LIC +endif + include $(BUILD_SHARED_LIBRARY) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index b4da0ae08..e9ee45ae0 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -163,6 +163,9 @@ int32_t wm_msgbox(char *name, char *fmt, ...) #elif defined _WIN32 MessageBox(win_gethwnd(),buf,name,MB_OK|MB_TASKMODAL); return 0; +#elif defined __ANDROID__ + initprintf("wm_msgbox called. Message: %s: %s",name,buf); + return 0; #elif SDL_MAJOR_VERSION==2 # if !defined _WIN32 // Replace all tab chars with spaces because the hand-rolled SDL message @@ -206,6 +209,10 @@ int32_t wm_ynbox(char *name, char *fmt, ...) r = MessageBox(win_gethwnd(),buf,name,MB_YESNO|MB_ICONQUESTION|MB_TASKMODAL); if (r==IDYES) return 1; return 0; +#elif defined __ANDROID__ + initprintf("wm_ynbox called, this is bad! Message: %s: %s",name,buf); + initprintf("Returning false.."); + return 0; #endif puts(buf); puts(" (type 'Y' or 'N', and press Return or Enter to continue)"); @@ -217,6 +224,11 @@ int32_t wm_ynbox(char *name, char *fmt, ...) void wm_setapptitle(char *name) { +#ifdef __ANDROID__ + initprintf("wm_setapptitle called"); + return; +#endif + if (name) Bstrncpyz(apptitle, name, sizeof(apptitle)); @@ -504,6 +516,9 @@ void system_getcvars(void) #endif } +#ifdef __ANDROID__ +#include +#endif // // initprintf() -- prints a string to the intitialization window @@ -518,6 +533,9 @@ void initprintf(const char *f, ...) Bvsnprintf(buf, sizeof(buf), f, va); va_end(va); +#ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_INFO,"DUKE", "%s",buf); +#endif OSD_Printf("%s", buf); // Bprintf("%s", buf); @@ -2011,6 +2029,8 @@ int32_t getpalette(int32_t start, int32_t num, char *dapal) // int32_t setgamma(void) { + //return 0; + int32_t i; uint16_t gammaTable[768]; float gamma = max(0.1f,min(4.f,vid_gamma)); @@ -2047,8 +2067,10 @@ int32_t setgamma(void) if (i < 0) { +#ifndef __ANDROID__ //Don't do this check, it is really supported, TODO if (i != INT32_MIN) initprintf("Unable to set gamma: SDL_SetWindowGammaRamp failed: %s\n", SDL_GetError()); +#endif } else #endif diff --git a/polymer/eduke32/source/android.h b/polymer/eduke32/source/android.h index 2b20319bc..7c150ca6c 100644 --- a/polymer/eduke32/source/android.h +++ b/polymer/eduke32/source/android.h @@ -28,6 +28,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "control.h" #include "android/in_android.h" +//extern int android_sample_rate; + +//extern int android_audio_buffer_size; + + extern void CONTROL_Android_ClearButton(int32_t whichbutton); extern void CONTROL_Android_PollDevices(ControlInfo *info); extern void CONTROL_Android_SetLastWeapon(int w); diff --git a/polymer/eduke32/source/android/android-jni.cpp b/polymer/eduke32/source/android/android-jni.cpp index f64b019a5..ddbe5511e 100644 --- a/polymer/eduke32/source/android/android-jni.cpp +++ b/polymer/eduke32/source/android/android-jni.cpp @@ -16,6 +16,10 @@ #include "TouchControlsContainer.h" #include "JNITouchControlsUtils.h" +#ifdef GP_LIC +#include "s-setup/s-setup.h" +#endif + extern "C" { @@ -29,6 +33,13 @@ extern void SDL_SetSwapBufferCallBack(void (*pt2Func)(void)); #include "../GL/gl.h" #include "../GL/nano_gl.h" +//Copied from build.h, which didnt include here +enum rendmode_t { + REND_CLASSIC, + REND_POLYMOST = 3, + REND_POLYMER +}; + #ifndef LOGI #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO,"DUKE", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "DUKE", __VA_ARGS__)) @@ -48,7 +59,7 @@ bool invertLook = false; bool precisionShoot = false; bool showSticks = true; bool hideTouchControls = true; -bool toggleCrouch = true; +char toggleCrouch = true; bool shooting = false; @@ -287,19 +298,21 @@ void right_double_tap(int state) void mouseMove(int action, float x, float y, float dx, float dy) { - //LOGI(" mouse dx = %f",dx); + //LOGI(" mouse dx = %f, dy = %f",dx,dy); if (weaponWheelVisible) return; double scale = (shooting && precisionShoot) ? PRECISIONSHOOTFACTOR : 1.f; - PortableLook(dx * 2 * droidinput.yaw_sens * scale, - -dy * droidinput.pitch_sens * scale * invertLook ? -1 : 1); + PortableLook(dx * droidinput.yaw_sens * scale, + -dy * droidinput.pitch_sens * scale * (invertLook ? -1.f : 1.f)); } void left_stick(float joy_x, float joy_y, float mouse_x, float mouse_y) { + //LOGI("left_stick joy_x = %f, joy_y = %f",joy_x,joy_y); + joy_x *=10; float strafe = joy_x*joy_x; //float strafe = joy_x; @@ -359,8 +372,8 @@ void initControls(int width, int height, const char * graphics_path, const char tcGameLook = new touchcontrols::TouchControls("mouse",true,false); //controlsContainer.dukeHack = 1; -// tcGameMain->signal_settingsButton.connect( sigc::ptr_fun(&gameSettingsButton) ); - tcMenuMain->signal_settingsButton.connect( sigc::ptr_fun(&gameSettingsButton) ); + tcGameMain->signal_settingsButton.connect( sigc::ptr_fun(&gameSettingsButton) ); + //tcMenuMain->signal_settingsButton.connect( sigc::ptr_fun(&gameSettingsButton) ); //Menu tcMenuMain->addControl(new touchcontrols::Button("down_arrow", touchcontrols::RectF(20,13,23,16), "arrow_down", SDL_SCANCODE_DOWN, true)); //Repeating buttons @@ -368,7 +381,7 @@ void initControls(int width, int height, const char * graphics_path, const char tcMenuMain->addControl(new touchcontrols::Button("left_arrow", touchcontrols::RectF(17,13,20,16), "arrow_left", SDL_SCANCODE_LEFT, true)); tcMenuMain->addControl(new touchcontrols::Button("right_arrow", touchcontrols::RectF(23,13,26,16), "arrow_right", SDL_SCANCODE_RIGHT, true)); tcMenuMain->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(0,13,3,16), "enter", SDL_SCANCODE_RETURN)); - tcMenuMain->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(0,9,3,12), "esc", SDL_SCANCODE_ESCAPE)); + tcMenuMain->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(0,10,3,13), "esc", SDL_SCANCODE_ESCAPE)); tcMenuMain->signal_button.connect( sigc::ptr_fun(&menuButton) ); @@ -401,21 +414,21 @@ void initControls(int width, int height, const char * graphics_path, const char //Game tcGameMain->setAlpha(gameControlsAlpha); controlsContainer.editButtonAlpha = gameControlsAlpha; - tcGameMain->addControl(new touchcontrols::Button("use", touchcontrols::RectF(23,4,26,7), "use", gamefunc_Open)); + tcGameMain->addControl(new touchcontrols::Button("use", touchcontrols::RectF(23,3,26,6), "use", gamefunc_Open)); tcGameMain->addControl(new touchcontrols::Button("attack", touchcontrols::RectF(20,7,23,10), "fire2", gamefunc_Fire)); - tcGameMain->addControl(new touchcontrols::Button("jump", touchcontrols::RectF(23,7,26,10), "jump", gamefunc_Jump)); + tcGameMain->addControl(new touchcontrols::Button("jump", touchcontrols::RectF(23,6,26,9), "jump", gamefunc_Jump)); tcGameMain->addControl(new touchcontrols::Button("crouch", touchcontrols::RectF(24,12,26,14), "crouch", gamefunc_Crouch)); tcGameMain->addControl(new touchcontrols::Button("kick", touchcontrols::RectF(20,4,23,7), "boot", gamefunc_Quick_Kick,false,true)); - tcGameMain->addControl(new touchcontrols::Button("quick_save", touchcontrols::RectF(24,0,26,2), "save", KEY_QUICK_SAVE)); - tcGameMain->addControl(new touchcontrols::Button("quick_load", touchcontrols::RectF(20,0,22,2), "load", KEY_QUICK_LOAD)); + tcGameMain->addControl(new touchcontrols::Button("quick_save", touchcontrols::RectF(24,0,26,2), "save", KEY_QUICK_SAVE,false,true)); + tcGameMain->addControl(new touchcontrols::Button("quick_load", touchcontrols::RectF(20,0,22,2), "load", KEY_QUICK_LOAD,false,true)); tcGameMain->addControl(new touchcontrols::Button("map", touchcontrols::RectF(4,0,6,2), "map", gamefunc_Map, false,true)); tcGameMain->addControl(new touchcontrols::Button("keyboard", touchcontrols::RectF(8,0,10,2), "keyboard", KEY_SHOW_KBRD, false,true)); tcGameMain->addControl(new touchcontrols::Button("show_inventory",touchcontrols::RectF(2,0,4,2), "inv", KEY_SHOW_INVEN)); - tcGameMain->addControl(new touchcontrols::Button("next_weapon", touchcontrols::RectF(0,3,3,5), "next_weap",gamefunc_Next_Weapon)); - tcGameMain->addControl(new touchcontrols::Button("prev_weapon", touchcontrols::RectF(0,7,3,9), "prev_weap",gamefunc_Previous_Weapon)); + tcGameMain->addControl(new touchcontrols::Button("next_weapon", touchcontrols::RectF(0,3,3,5), "next_weap",gamefunc_Next_Weapon,false,true)); + tcGameMain->addControl(new touchcontrols::Button("prev_weapon", touchcontrols::RectF(0,5,3,7), "prev_weap",gamefunc_Previous_Weapon,false,true)); /* //quick actions binds tcGameMain->addControl(new touchcontrols::Button("quick_key_1",touchcontrols::RectF(4,3,6,5),"quick_key_1",KEY_QUICK_KEY1,false,true)); @@ -479,6 +492,12 @@ void initControls(int width, int height, const char * graphics_path, const char //controlsContainer.initGL(); } + +#ifdef GP_LIC +#define GP_LIC_INC 1 +#include "s-setup/gp_lic_include.h" +#endif + void frameControls() { static int loadedGLImages = 0; @@ -533,6 +552,12 @@ void frameControls() setHideSticks(!showSticks); controlsContainer.draw(); + +#ifdef GP_LIC +#define GP_LIC_INC 2 +#include "s-setup/gp_lic_include.h" +#endif + } void setTouchSettings(float alpha,float strafe,float fwd,float pitch,float yaw,int other) @@ -605,6 +630,10 @@ Java_com_beloko_duke_engine_NativeLib_init( JNIEnv* env, { env_ = env; +#ifdef GP_LIC + getGlobalClasses(env_); +#endif + droidinfo.audio_sample_rate = audio_rate; droidinfo.audio_buffer_size = audio_buffer_size; @@ -698,7 +727,7 @@ Java_com_beloko_duke_engine_NativeLib_keypress(JNIEnv *env, jobject obj, void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_touchEvent(JNIEnv *env, jobject obj, - jint action, jint pid, jfloat x, jfloat y) + jint action, jint pid, jdouble x, jdouble y) { //LOGI("TOUCHED"); controlsContainer.processPointer(action,pid,x,y); @@ -726,25 +755,25 @@ void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_doAction(JNIEnv *env, jobje void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_analogFwd(JNIEnv *env, jobject obj, jfloat v) { - PortableMove(v, 0.f); + PortableMove(v, NAN); } void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_analogSide(JNIEnv *env, jobject obj, jfloat v) { - PortableMove(0.f, v); + PortableMove(NAN, v); } void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_analogPitch(JNIEnv *env, jobject obj, jint mode,jfloat v) { - PortableLook(0.f, v); + PortableLookJoystick(NAN, v); } void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_analogYaw(JNIEnv *env, jobject obj, jint mode,jfloat v) { - PortableLook(v, 0.f); + PortableLookJoystick(v, NAN); } void EXPORT_ME Java_com_beloko_duke_engine_NativeLib_setTouchSettings(JNIEnv *env, jobject obj, @@ -785,4 +814,8 @@ void EXPORT_ME Java_org_libsdl_app_SDLActivity_nativeInit(JNIEnv* env, jclass c // SDL_EventState(SDL_TEXTINPUT,SDL_ENABLE); } +#ifdef GP_LIC +#define GP_LIC_INC 3 +#include "s-setup/gp_lic_include.h" +#endif } diff --git a/polymer/eduke32/source/android/in_android.c b/polymer/eduke32/source/android/in_android.c index 0e9f83d56..61ad9bf73 100644 --- a/polymer/eduke32/source/android/in_android.c +++ b/polymer/eduke32/source/android/in_android.c @@ -70,6 +70,11 @@ void changeActionState(int state, int action) droidinput.functionHeld &= ~((uint64_t) 1<<((uint64_t) (action))); } +#ifdef GP_LIC +#define GP_LIC_INC 4 +#include "s-setup/gp_lic_include.h" +#endif + void PortableAction(int state, int action) { LOGI("PortableAction action = %d, state = %d", action, state); @@ -79,7 +84,7 @@ void PortableAction(int state, int action) if (PortableRead(READ_MENU)) { int sdl_code [] = { SDL_SCANCODE_UP, SDL_SCANCODE_DOWN, SDL_SCANCODE_LEFT, - SDL_SCANCODE_RIGHT, SDL_SCANCODE_RETURN, SDL_SCANCODE_ESCAPE }; + SDL_SCANCODE_RIGHT, SDL_SCANCODE_RETURN, SDL_SCANCODE_ESCAPE }; PortableKeyEvent(state, sdl_code[action-MENU_UP], 0); return; } @@ -89,6 +94,11 @@ void PortableAction(int state, int action) if (PortableRead(READ_MENU)) //If in the menu, dont do any game actions return; +#ifdef GP_LIC +#define GP_LIC_INC 5 +#include "s-setup/gp_lic_include.h" +#endif + //Special toggle for crouch, NOT when using jetpack or in water if (!g_player[myconnectindex].ps->jetpack_on && g_player[myconnectindex].ps->on_ground && @@ -109,29 +119,45 @@ void PortableAction(int state, int action) //Check if jumping while crouched if (action == gamefunc_Jump) { - crouchToggleState = 0; + droidinput.crouchToggleState = 0; changeActionState(0, gamefunc_Crouch); } changeActionState(state, action); - LOGI("PortableAction state = 0x%016llX", CONTROL_ButtonState); + if (state == 2) + PortableAction(0,action); + + // LOGI("PortableAction state = 0x%016llX", CONTROL_ButtonState); } } +//Need these NAN check as not cumulative. void PortableMove(float fwd, float strafe) { - droidinput.forwardmove = fclamp2(fwd + droidinput.forwardmove, -1.f, 1.f); - droidinput.sidemove = fclamp2(strafe + droidinput.sidemove, -1.f, 1.f); + if (!isnan(fwd)) + droidinput.forwardmove = fclamp2(fwd, -1.f, 1.f); + + if (!isnan(strafe)) + droidinput.sidemove = fclamp2(strafe, -1.f, 1.f); } void PortableLook(double yaw, double pitch) { - //LOGI("PortableLookPitch %d %f",mode, pitch); + // LOGI("PortableLookPitch %f %f",yaw, pitch); droidinput.pitch += pitch; droidinput.yaw += yaw; } +void PortableLookJoystick(double yaw, double pitch) +{ + if (!isnan(pitch)) + droidinput.pitch_joystick = pitch; + + if (!isnan(yaw)) + droidinput.yaw_joystick = yaw; +} + void PortableCommand(const char * cmd) { OSD_Dispatch(cmd); @@ -154,7 +180,7 @@ int32_t PortableRead(portableread_t r) case READ_WEAPONS: return g_player[myconnectindex].ps->gotweapon; case READ_AUTOMAP: - return ud.overhead_on != 0; // ud.overhead_on ranges from 0-2 + return ud.overhead_on != 0; // ud.overhead_on ranges from 0-2 case READ_MAPFOLLOWMODE: return ud.scrollmode; case READ_RENDERER: @@ -185,13 +211,16 @@ void CONTROL_Android_ClearButton(int32_t whichbutton) void CONTROL_Android_PollDevices(ControlInfo *info) { //LOGI("CONTROL_Android_PollDevices %f %f",forwardmove,sidemove); + //LOGI("CONTROL_Android_PollDevices %f %f",droidinput.pitch,droidinput.yaw); info->dz = (int32_t)nearbyintf(-droidinput.forwardmove * ANDROIDFORWARDMOVEFACTOR); info->dx = (int32_t)nearbyintf(droidinput.sidemove * ANDROIDSIDEMOVEFACTOR); - info->dpitch = (int32_t)nearbyint(droidinput.pitch * ANDROIDPITCHFACTOR); - info->dyaw = (int32_t)nearbyint(-droidinput.yaw * ANDROIDYAWFACTOR); + info->dpitch = (int32_t)nearbyint(droidinput.pitch * ANDROIDPITCHFACTOR + + droidinput.pitch_joystick * ANDROIDPITCHFACTORJOYSTICK); + info->dyaw = (int32_t)nearbyint(-droidinput.yaw * ANDROIDYAWFACTOR - + droidinput.yaw_joystick * ANDROIDYAWFACTORJOYSTICK); - droidinput.forwardmove = droidinput.sidemove = 0.f; + //droidinput.forwardmove = droidinput.sidemove = 0.f; droidinput.pitch = droidinput.yaw = 0.f; CONTROL_ButtonState = 0; diff --git a/polymer/eduke32/source/android/in_android.h b/polymer/eduke32/source/android/in_android.h index 1ae16be98..18e373f29 100644 --- a/polymer/eduke32/source/android/in_android.h +++ b/polymer/eduke32/source/android/in_android.h @@ -33,7 +33,11 @@ extern "C" #define ANDROIDFORWARDMOVEFACTOR 5000 #define ANDROIDSIDEMOVEFACTOR 200 #define ANDROIDPITCHFACTOR 100000 -#define ANDROIDYAWFACTOR 80000 +#define ANDROIDYAWFACTOR 160000 + +#define ANDROIDPITCHFACTORJOYSTICK 2000 +#define ANDROIDYAWFACTORJOYSTICK 4000 + #define MINCONTROLALPHA 0.25f @@ -59,6 +63,7 @@ typedef struct int32_t right_double_action; double pitch, yaw; + double pitch_joystick, yaw_joystick; float forwardmove, sidemove; // set by configuration UI @@ -75,6 +80,7 @@ typedef struct extern droidinput_t droidinput; extern droidsysinfo_t droidinfo; +extern char toggleCrouch; int PortableKeyEvent(int state, int code, int unicode); int PortableRead(portableread_t r); @@ -83,6 +89,7 @@ void PortableAction(int state, int action); void PortableMove(float fwd, float strafe); void PortableLook(double yaw, double pitch); +void PortableLookJoystick(double yaw, double pitch); void PortableCommand(const char * cmd); void PortableInit(int argc, const char ** argv); diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index 2f1ae3f56..5cec4cef0 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -40,6 +40,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "winlayer.h" #endif +#ifdef __ANDROID__ +#include "android.h" +#endif + // we load this in to get default button and key assignments // as well as setting up function mappings @@ -570,6 +574,7 @@ int32_t CONFIG_ReadSetup(void) ud.config.setupread = 1; pathsearchmode = 1; +#ifndef __ANDROID__ if (SafeFileExists(setupfilename) && ud.config.scripthandle < 0) // JBF 20031211 ud.config.scripthandle = SCRIPT_Load(setupfilename); else if (SafeFileExists(SETUPFILENAME) && ud.config.scripthandle < 0) @@ -584,6 +589,8 @@ int32_t CONFIG_ReadSetup(void) "Import configuration data from \"duke3d.cfg\"?",setupfilename); if (i) ud.config.scripthandle = SCRIPT_Load("duke3d.cfg"); } +#endif + pathsearchmode = 0; if (ud.config.scripthandle < 0) return -1; diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 10784688a..27870811c 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -2571,9 +2571,10 @@ static void G_PrintCoords(int32_t snum) { if (rendmode==3) printcoordsline("r_usenewshading = %d", r_usenewshading); +# ifdef POLYMER else printcoordsline("r_pr_artmapping = %d", pr_artmapping); - +#endif printcoordsline("r_usetileshades = %d", r_usetileshades); } } @@ -2846,6 +2847,9 @@ static void fadepaltile(int32_t r, int32_t g, int32_t b, int32_t start, int32_t // (end-start)/step + 1 iterations do { +#ifdef __ANDROID__ //Needed for N7 2013 to stop corruption while fading video + clearallviews(0); +#endif if (KB_KeyPressed(sc_Space)) { KB_ClearKeyDown(sc_Space); @@ -4401,11 +4405,14 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio) #ifdef __ANDROID__ // HACK: this is needed or else we get leftover UI texture crap where we'd get HOM on PC - if (getrendermode() == REND_POLYMOST) - { - static int32_t col = getclosestcol(4, 4, 4); - clearallviews(col); - } + if (getrendermode() == REND_POLYMOST) + { + static int32_t col = -1; + if (col == -1) + col = getclosestcol(4, 4, 4); + + clearallviews(col); + } #endif if (pub > 0 || getrendermode() >= REND_POLYMOST) // JBF 20040101: redraw background always diff --git a/polymer/eduke32/source/jaudiolib/src/driver_sdl.c b/polymer/eduke32/source/jaudiolib/src/driver_sdl.c index 8106c3bb8..e94fe42ea 100644 --- a/polymer/eduke32/source/jaudiolib/src/driver_sdl.c +++ b/polymer/eduke32/source/jaudiolib/src/driver_sdl.c @@ -28,6 +28,11 @@ #include "driver_sdl.h" #include "multivoc.h" +#ifdef __ANDROID__ +#include "duke3d.h" +#include "android.h" +#endif + enum { SDLErr_Warning = -2, SDLErr_Error = -1, @@ -151,6 +156,9 @@ int32_t SDLDrv_PCM_Init(int32_t *mixrate, int32_t *numchannels, int32_t *sampleb } chunksize = 512; +#ifdef __ANDROID__ + chunksize = droidinfo.audio_buffer_size; +#endif if (*mixrate >= 16000) chunksize *= 2; if (*mixrate >= 32000) chunksize *= 2; diff --git a/polymer/eduke32/source/jmact/control.c b/polymer/eduke32/source/jmact/control.c index e2794146c..4658eeff8 100644 --- a/polymer/eduke32/source/jmact/control.c +++ b/polymer/eduke32/source/jmact/control.c @@ -745,9 +745,14 @@ static void CONTROL_ButtonFunctionState(int32_t *p1) void CONTROL_ClearButton(int32_t whichbutton) { + +#ifdef __ANDROID__ + CONTROL_Android_ClearButton(whichbutton); +#else if (CONTROL_CheckRange(whichbutton)) return; BUTTONCLEAR(whichbutton); CONTROL_Flags[whichbutton].cleared = TRUE; +#endif } void CONTROL_ProcessBinds(void) @@ -796,11 +801,16 @@ static void CONTROL_GetFunctionInput(void) void CONTROL_GetInput(ControlInfo *info) { +#ifdef __ANDROID__ + CONTROL_Android_PollDevices(info); +#else CONTROL_PollDevices(info); CONTROL_GetFunctionInput(); inputchecked = 1; +#endif + } int32_t CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ticspersecond) diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index 1d48af276..fb9fa2849 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -27,6 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "demo.h" #include "enet/enet.h" +#ifdef __ANDROID__ +#include "android.h" +#endif + int32_t lastvisinc; hudweapon_t hudweap; diff --git a/polymer/eduke32/source/sdlmusic.c b/polymer/eduke32/source/sdlmusic.c index 8199d3122..3ab653aff 100644 --- a/polymer/eduke32/source/sdlmusic.c +++ b/polymer/eduke32/source/sdlmusic.c @@ -58,7 +58,7 @@ static int8_t external_midi_restart=0; #endif #ifdef __ANDROID__ //TODO fix -static char *external_midi_tempfn = "/sdcard/eduke32-music.mid"; +static char *external_midi_tempfn = "eduke32-music.mid"; #else static char *external_midi_tempfn = "/tmp/eduke32-music.mid"; #endif @@ -128,6 +128,10 @@ const char *MUSIC_ErrorString(int32_t ErrorNumber) int32_t MUSIC_Init(int32_t SoundCard, int32_t Address) { +#ifdef __ANDROID__ + music_initialized = 1; + return(MUSIC_Ok); +#endif // Use an external MIDI player if the user has specified to do so char *command = getenv("EDUKE32_MUSIC_CMD"); const SDL_version *linked = Mix_Linked_Version(); @@ -450,6 +454,7 @@ static void sigchld_handler(int signo) // void MUSIC_PlayMusic(char *_filename) int32_t MUSIC_PlaySong(char *song, int32_t loopflag) { +// initprintf("MUSIC_PlaySong"); MUSIC_StopSong(); if (external_midi)