diff --git a/polymer/eduke32/Android.mk b/polymer/eduke32/Android.mk index 592b6a9b3..48baeb119 100644 --- a/polymer/eduke32/Android.mk +++ b/polymer/eduke32/Android.mk @@ -23,22 +23,23 @@ LOCAL_MODULE := duke # -O2 -fvisibility=hidden -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 +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 -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 +#-DUSE_LIBPNG + +LOCAL_CFLAGS += -DHAVE_SDL -DHAVE_VORBIS -DDROIDMENU + +#LOCAL_CFLAGS += -mhard-float -D_NDK_MATH_NO_SOFTFP=1 + +LOCAL_ARM_NEON = true LOCAL_LDLIBS += -lGLESv1_CM -lEGL LOCAL_LDLIBS += -llog -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 -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 +LOCAL_C_INCLUDES += $(TOP_DIR)/ $(TOP_DIR)/Libraries/liboggvorbis/include $(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 \ @@ -64,7 +65,11 @@ BUILD_SRC = \ build/src/pragmas.c \ build/src/scriptfile.c \ build/src/mutex.c \ - build/src/xxhash.c + build/src/xxhash.c \ + build/src/mmulti_null.c \ + build/src/voxmodel.c \ + build/src/common.c \ + GL_SRC = \ build/src/mdsprite.c \ @@ -107,6 +112,7 @@ GAME_SRC=source/game.c \ source/sounds.c \ source/soundsdyn.c \ source/sdlmusic.c \ + source/rev.c JAUDIO_SRC=source/jaudiolib/src/drivers.c \ source/jaudiolib/src//fx_man.c \ @@ -134,9 +140,9 @@ GAME_SRC=source/game.c \ LOCAL_SRC_FILES = $(ANDROID_SRC) $(ENET_SRC) $(JAUDIO_SRC) $(JMACT_SRC) $(GAME_SRC) $(BUILD_SRC) $(GL_SRC) $(SDL_SRC) -LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lOpenSLES -lz +LOCAL_LDLIBS := -lGLESv1_CM -lEGL -ldl -llog -lOpenSLES -lz -L$(TOP_DIR)/openssl/libs/ -lcrypto LOCAL_STATIC_LIBRARIES := nanogl SDL2_net libjpeg libpng -LOCAL_SHARED_LIBRARIES := touchcontrols openal SDL2 SDL2_mixer SDL2_image +LOCAL_SHARED_LIBRARIES := touchcontrols openal ogg vorbis SDL2 SDL2_mixer SDL2_image ifeq ($(GP_LIC),1) LOCAL_STATIC_LIBRARIES += s-setup diff --git a/polymer/eduke32/source/android/android-jni.cpp b/polymer/eduke32/source/android/android-jni.cpp index c84ee3502..929c0195c 100644 --- a/polymer/eduke32/source/android/android-jni.cpp +++ b/polymer/eduke32/source/android/android-jni.cpp @@ -57,13 +57,17 @@ static int curRenderer; float gameControlsAlpha = 0.5; -bool invertLook = false; -bool precisionShoot = false; -bool showSticks = true; -bool hideTouchControls = true; +static bool invertLook = false; +static bool precisionShoot = false; +static bool showSticks = true; +static bool hideTouchControls = true; char toggleCrouch = true; +static bool selectLastWeap = true; + +static bool shooting = false; + +static int weaponWheelVisible = false; -bool shooting = false; static int controlsCreated = 0; touchcontrols::TouchControlsContainer controlsContainer; @@ -73,12 +77,11 @@ touchcontrols::TouchControls *tcYesNo=0; touchcontrols::TouchControls *tcMenuMain=0; touchcontrols::TouchControls *tcGameMain=0; touchcontrols::TouchControls *tcGameWeapons=0; -touchcontrols::TouchControls *tcInventory=0; +//touchcontrols::TouchControls *tcInventory=0; touchcontrols::TouchControls *tcAutomap=0; touchcontrols::TouchJoy *touchJoyLeft; -touchcontrols::TouchJoy *touchJoyRight; touchcontrols::WheelSelect *weaponWheel; extern JNIEnv* env_; @@ -172,6 +175,33 @@ void swapBuffers() env_->CallStaticVoidMethod(NativeLibClass, checkPauseMethod); } +//This is a bit of a hack, if the weapon wheel was selected, then an inv chosen instead, we need to cancel the weapon selection +//NOT needed actually, weapon wheel disabled before is get finger up anyway +//static bool invWasSelected = false; + +void showWeaponsInventory(bool show) +{ + if (show) + { + for (int n=0; n<10; n++) + { + weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1); + } + + //Show inventory buttons + tcGameWeapons->setAllButtonsEnable(true); + + tcGameWeapons->fade(touchcontrols::FADE_IN, 5); //fade in + weaponWheelVisible = true; + } + else //hide + { + tcGameWeapons->setAllButtonsEnable(false); + weaponWheel->setTapMode(false); + weaponWheelVisible = false; + } +} + void gameButton(int state, int code) { switch (code) @@ -194,22 +224,16 @@ void gameButton(int state, int code) break; case KEY_SHOW_INVEN: - if (state != 1) - break; - - if (!tcInventory->isEnabled()) + if (state) { - tcInventory->setEnabled(true); - tcInventory->fade(touchcontrols::FADE_IN, 5); - //disable weapon wheel so it does not show, enabled again after inventory cleared - tcGameWeapons->setEnabled(false); + if (!weaponWheelVisible) + { + weaponWheel->setTapMode(true); + showWeaponsInventory(true); + } + else + showWeaponsInventory(false); } - else - { - tcInventory->setEnabled(false); - tcGameWeapons->setEnabled(true); - } - break; case KEY_QUICK_SAVE: @@ -238,8 +262,8 @@ void inventoryButton(int state,int code) PortableAction(state,code); if (state == 0) { - tcGameWeapons->setEnabled(true); - tcInventory->setEnabled(false); + //Inventory chosen, hide them and wheel + showWeaponsInventory(false); } } @@ -248,61 +272,58 @@ void menuButton(int state,int code) PortableKeyEvent(state, code,code); } -static int weaponWheelVisible = false; +void blankTapButton(int state,int code) +{ + if (PortableRead(READ_IS_DEAD)) //if the player is dead we need to send a 'open' button + { + if (state) + { + PortableAction(1, gamefunc_Open); + PortableAction(0, gamefunc_Open); + } + } + else //everything else send a return key + { + PortableKeyEvent(state, SDL_SCANCODE_RETURN,0); + } + +} void weaponWheelSelected(int enabled) { - if (!enabled) - { - //tcGameWeapons->fade(touchcontrols::FADE_OUT, 5); - weaponWheelVisible = false; - } - else - { - for (int n=0; n<10; n++) - { - weaponWheel->setSegmentEnabled(n, (PortableRead(READ_WEAPONS) >> n) & 0x1); - } - - tcGameWeapons->fade(touchcontrols::FADE_IN, 5); //fade in - weaponWheelVisible = true; - } - if (enabled) { - tcInventory->setEnabled(true); - tcInventory->fade(touchcontrols::FADE_IN, 5); - //disable weapon wheel so it does not show, enabled again after inventory cleared - // tcGameWeapons->setEnabled(false); + showWeaponsInventory(true); } else { - tcInventory->setEnabled(false); - // tcGameWeapons->setEnabled(true); + showWeaponsInventory(false); } - } void weaponWheelChosen(int segment) { - LOGI("weaponWheel %d",segment); + //LOGI("weaponWheel %d",segment); if (segment == -1) //Nothing was selected { - int32_t lw = PortableRead(READ_LASTWEAPON); + if (selectLastWeap) + { + int32_t lw = PortableRead(READ_LASTWEAPON); - if (lw != -1) - PortableAction(2, gamefunc_Weapon_1 + lw); - - return; + if (lw != -1) + PortableAction(2, gamefunc_Weapon_1 + lw); + } + } + else + { + PortableAction(2, gamefunc_Weapon_1 + segment); } - - PortableAction(2, gamefunc_Weapon_1 + segment); } void left_double_tap(int state) { - LOGI("L double %d, droidinput.left_double_action = %d",state,droidinput.left_double_action); + //LOGI("L double %d, droidinput.left_double_action = %d",state,droidinput.left_double_action); if (droidinput.left_double_action != -1) PortableAction(state, droidinput.left_double_action); } @@ -317,7 +338,6 @@ void right_double_tap(int state) void mouseMove(int action, float x, float y, float dx, float dy) { //LOGI(" mouse dx = %f, dy = %f",dx,dy); - if (weaponWheelVisible) return; @@ -327,10 +347,22 @@ void mouseMove(int action, float x, float y, float dx, float dy) -dy * droidinput.pitch_sens * scale * (invertLook ? -1.f : 1.f)); } +void automap_multitouch_mouse_move(int action,float x, float y,float dx, float dy) +{ + + if (action == MULTITOUCHMOUSE_MOVE) + { + PortableAutomapControl(0,dx,dy); + } + else if (action == MULTITOUCHMOUSE_ZOOM) + { + PortableAutomapControl(x,0,0); + } +} + 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; @@ -342,15 +374,12 @@ void left_stick(float joy_x, float joy_y, float mouse_x, float mouse_y) void right_stick(float joy_x, float joy_y, float mouse_x, float mouse_y) { - //LOGI(" mouse x = %f",mouse_x); - mouseMove(0, joy_x, joy_y, mouse_x, mouse_y); } void setHideSticks(bool v) { if (touchJoyLeft) touchJoyLeft->setHideGraphics(v); - if (touchJoyRight) touchJoyRight->setHideGraphics(v); } void touchSettingsButton(int state) @@ -385,24 +414,24 @@ void initControls(int width, int height, const char * graphics_path, const char tcBlankTap = new touchcontrols::TouchControls("blank_tap", false, false); tcYesNo = new touchcontrols::TouchControls("yes_no", false, false); - tcMenuMain = new touchcontrols::TouchControls("menu", false, true,1,false); + tcMenuMain = new touchcontrols::TouchControls("menu", false, false); tcGameMain = new touchcontrols::TouchControls("game", false,true,1,true); tcGameWeapons = new touchcontrols::TouchControls("weapons", false,true,1,false); - tcAutomap = new touchcontrols::TouchControls("automap", false,true,1,false); - tcInventory = new touchcontrols::TouchControls("inventory", false,true,1,false); + tcAutomap = new touchcontrols::TouchControls("automap", false,false); + // tcInventory = new touchcontrols::TouchControls("inventory", false,true,1,false); ///////////////////////// BLANK TAP SCREEN ////////////////////// //One button on whole screen with no graphic, send a return key - tcBlankTap->addControl(new touchcontrols::Button("whole_screen", touchcontrols::RectF(0,0,26,16), "", SDL_SCANCODE_RETURN)); - tcBlankTap->signal_button.connect( sigc::ptr_fun(&menuButton) ); //Just reuse the menuButton function + tcBlankTap->addControl(new touchcontrols::Button("whole_screen", touchcontrols::RectF(0,0,26,16), std::string("test"), SDL_SCANCODE_RETURN)); + tcBlankTap->signal_button.connect( sigc::ptr_fun(&blankTapButton) ); //Just reuse the menuButton function ///////////////////////// YES NO SCREEN ///////////////////// - tcYesNo->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(8,10,11,13), "enter", SDL_SCANCODE_RETURN)); - tcYesNo->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(14,10,17,13), "esc", SDL_SCANCODE_ESCAPE)); + tcYesNo->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(8,10,11,13), "yes", SDL_SCANCODE_RETURN)); + tcYesNo->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(14,10,17,13), "no", SDL_SCANCODE_ESCAPE)); tcYesNo->signal_button.connect( sigc::ptr_fun(&menuButton) ); //Just reuse the menuButton function @@ -410,50 +439,48 @@ void initControls(int width, int height, const char * graphics_path, const char ///////////////////////// MAIN MENU SCREEN ///////////////////// //Menu + /* 3x3 tcMenuMain->addControl(new touchcontrols::Button("down_arrow", touchcontrols::RectF(20,13,23,16), "arrow_down", SDL_SCANCODE_DOWN, true)); //Repeating buttons tcMenuMain->addControl(new touchcontrols::Button("up_arrow", touchcontrols::RectF(20,10,23,13), "arrow_up", SDL_SCANCODE_UP, true)); 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,10,3,13), "esc", SDL_SCANCODE_ESCAPE)); + */ + + tcMenuMain->addControl(new touchcontrols::Button("down_arrow", touchcontrols::RectF(22,14,24,16), "arrow_down", SDL_SCANCODE_DOWN, true)); //Repeating buttons + tcMenuMain->addControl(new touchcontrols::Button("up_arrow", touchcontrols::RectF(22,12,24,14), "arrow_up", SDL_SCANCODE_UP, true)); + tcMenuMain->addControl(new touchcontrols::Button("left_arrow", touchcontrols::RectF(20,14,22,16), "arrow_left", SDL_SCANCODE_LEFT, true)); + tcMenuMain->addControl(new touchcontrols::Button("right_arrow", touchcontrols::RectF(24,14,26,16), "arrow_right", SDL_SCANCODE_RIGHT, true)); + tcMenuMain->addControl(new touchcontrols::Button("enter", touchcontrols::RectF(0,14,2,16), "enter", SDL_SCANCODE_RETURN)); + tcMenuMain->addControl(new touchcontrols::Button("esc", touchcontrols::RectF(0,12,2,14), "esc", SDL_SCANCODE_ESCAPE)); + tcMenuMain->signal_button.connect( sigc::ptr_fun(&menuButton) ); tcMenuMain->setAlpha(1); - ///////////////////////// AUTO MAP SCREEN /////////////////////// - /* FIXME: definitely hook this up - //Automap - tcAutomap->addControl(new touchcontrols::Button("down_arrow",touchcontrols::RectF(2,14,4,16),"arrow_down",PORT_ACT_MAP_DOWN)); - tcAutomap->addControl(new touchcontrols::Button("up_arrow",touchcontrols::RectF(2,10,4,12),"arrow_up",PORT_ACT_MAP_UP)); - tcAutomap->addControl(new touchcontrols::Button("left_arrow",touchcontrols::RectF(0,12,2,14),"arrow_left",PORT_ACT_MAP_LEFT)); - tcAutomap->addControl(new touchcontrols::Button("right_arrow",touchcontrols::RectF(4,12,6,14),"arrow_right",PORT_ACT_MAP_RIGHT)); - tcAutomap->addControl(new touchcontrols::Button("zoom_in",touchcontrols::RectF(4,10,6,12),"zoom_in",PORT_ACT_MAP_ZOOM_IN)); - tcAutomap->addControl(new touchcontrols::Button("zoom_out",touchcontrols::RectF(4,14,6,16),"zoom_out",PORT_ACT_MAP_ZOOM_OUT)); - - tcAutomap->signal_button.connect( sigc::ptr_fun(&automapButton) ); - tcAutomap->setAlpha(0.5); - */ //////////////////////////// GAME SCREEN ///////////////////// tcGameMain->setAlpha(gameControlsAlpha); controlsContainer.editButtonAlpha = gameControlsAlpha; - 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,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("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,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","Mighty Foot", 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,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("quick_save","Quick Save", touchcontrols::RectF(22,0,24,2), "save", KEY_QUICK_SAVE,false,true)); + tcGameMain->addControl(new touchcontrols::Button("quick_load","Quick Load", touchcontrols::RectF(20,0,22,2), "load", KEY_QUICK_LOAD,false,true)); + touchcontrols::Button *map_button = new touchcontrols::Button("map","Autotmap", touchcontrols::RectF(6,0,8,2), "map", gamefunc_Map, false,true); + tcGameMain->addControl(map_button); + tcGameMain->addControl(new touchcontrols::Button("keyboard","Show Console", 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("show_inventory","Show Inventory",touchcontrols::RectF(24,0,26,2), "inv", KEY_SHOW_INVEN)); - 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)); + tcGameMain->addControl(new touchcontrols::Button("next_weapon","Next Weapon", touchcontrols::RectF(0,3,3,5), "next_weap",gamefunc_Next_Weapon,false,true)); + tcGameMain->addControl(new touchcontrols::Button("prev_weapon","Previous 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)); @@ -467,13 +494,12 @@ void initControls(int width, int height, const char * graphics_path, const char touchJoyLeft->signal_move.connect(sigc::ptr_fun(&left_stick) ); touchJoyLeft->signal_double_tap.connect(sigc::ptr_fun(&left_double_tap) ); - //Right stick - touchJoyRight = new touchcontrols::TouchJoy("touch",touchcontrols::RectF(17,7,26,16),"look_arrow"); - tcGameMain->addControl(touchJoyRight); - touchJoyRight->signal_move.connect(sigc::ptr_fun(&right_stick) ); - touchJoyRight->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap) ); - touchJoyRight->setEnabled(false); - + //Right stick (not used) + //touchJoyRight = new touchcontrols::TouchJoy("touch",touchcontrols::RectF(17,7,26,16),"look_arrow"); + //tcGameMain->addControl(touchJoyRight); + //touchJoyRight->signal_move.connect(sigc::ptr_fun(&right_stick) ); + //touchJoyRight->signal_double_tap.connect(sigc::ptr_fun(&right_double_tap) ); + //touchJoyRight->setEnabled(false); //Mouse look for whole screen @@ -487,6 +513,31 @@ void initControls(int width, int height, const char * graphics_path, const char tcGameMain->signal_button.connect( sigc::ptr_fun(&gameButton) ); tcGameMain->signal_settingsButton.connect( sigc::ptr_fun(&gameSettingsButton) ); + ///////////////////////// AUTO MAP SCREEN /////////////////////// + + + //Automap + touchcontrols::MultitouchMouse *multimouse = new touchcontrols::MultitouchMouse("gamemouse",touchcontrols::RectF(0,0,26,16),""); + multimouse->setHideGraphics(true); + tcAutomap->addControl(multimouse); + multimouse->signal_action.connect(sigc::ptr_fun(&automap_multitouch_mouse_move) ); + tcAutomap->addControl(map_button); + tcAutomap->signal_button.connect( sigc::ptr_fun(&gameButton) ); + tcAutomap->setAlpha(0.5); + + + + + + //Now inventory in the weapons control group! + tcGameWeapons->addControl(new touchcontrols::Button("jetpack", touchcontrols::RectF(0,3,2,5),"jetpack",gamefunc_Jetpack,false,false,true)); + tcGameWeapons->addControl(new touchcontrols::Button("medkit", touchcontrols::RectF(0,5,2,7),"medkit",gamefunc_MedKit,false,false,true)); + tcGameWeapons->addControl(new touchcontrols::Button("nightv", touchcontrols::RectF(0,7,2,9),"nightvision",gamefunc_NightVision,false,false,true)); + tcGameWeapons->addControl(new touchcontrols::Button("holoduke",touchcontrols::RectF(0,9,2,11),"holoduke",gamefunc_Holo_Duke,false,false,true)); + tcGameWeapons->addControl(new touchcontrols::Button("steroids",touchcontrols::RectF(0,11,2,13),"steroids",gamefunc_Steroids,false,false,true)); + //Inventory are the only buttons so safe to do this + tcGameWeapons->signal_button.connect( sigc::ptr_fun(&inventoryButton) ); + //Weapons weaponWheel = new touchcontrols::WheelSelect("weapon_wheel",touchcontrols::RectF(7,2,19,14),"weapon_wheel_orange_blank",10); @@ -495,6 +546,7 @@ void initControls(int width, int height, const char * graphics_path, const char tcGameWeapons->addControl(weaponWheel); tcGameWeapons->setAlpha(0.9); + /* tcInventory->addControl(new touchcontrols::Button("jetpack", touchcontrols::RectF(0,3,2,5),"jetpack",gamefunc_Jetpack)); tcInventory->addControl(new touchcontrols::Button("medkit", touchcontrols::RectF(0,5,2,7),"medkit",gamefunc_MedKit)); tcInventory->addControl(new touchcontrols::Button("nightv", touchcontrols::RectF(0,7,2,9),"nightvision",gamefunc_NightVision)); @@ -503,15 +555,17 @@ void initControls(int width, int height, const char * graphics_path, const char tcInventory->setAlpha(1); tcInventory->signal_button.connect( sigc::ptr_fun(&inventoryButton)); + */ + ///////////////////////////////////////////////////////////// controlsContainer.addControlGroup(tcMenuMain); controlsContainer.addControlGroup(tcGameMain); - controlsContainer.addControlGroup(tcInventory);//Need to be above tcGameMain incase buttons over stick + // controlsContainer.addControlGroup(tcInventory);//Need to be above tcGameMain incase buttons over stick controlsContainer.addControlGroup(tcGameWeapons); - //controlsContainer.addControlGroup(tcAutomap); + controlsContainer.addControlGroup(tcAutomap); controlsContainer.addControlGroup(tcYesNo); controlsContainer.addControlGroup(tcBlankTap); controlsCreated = 1; @@ -525,8 +579,9 @@ void initControls(int width, int height, const char * graphics_path, const char tcGameMain->setXMLFile((std::string)graphics_path + "/game.xml"); tcGameWeapons->setXMLFile((std::string)graphics_path + "/weapons.xml"); tcAutomap->setXMLFile((std::string)graphics_path + "/automap.xml"); - tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml"); + // tcInventory->setXMLFile((std::string)graphics_path + "/inventory.xml"); + setControlsContainer(&controlsContainer); } else LOGI("NOT creating controls"); @@ -536,7 +591,7 @@ void initControls(int width, int height, const char * graphics_path, const char void updateTouchScreenMode(touchscreemode_t mode) { - // LOGI("updateTouchScreenModeA %d",mode); + // LOGI("updateTouchScreenModeA %d",mode); static touchscreemode_t lastMode = TOUCH_SCREEN_BLANK; @@ -565,9 +620,11 @@ void updateTouchScreenMode(touchscreemode_t mode) tcGameMain->fade(touchcontrols::FADE_OUT,DEFAULT_FADE_FRAMES); tcGameWeapons->setEnabled(false); - tcInventory->setEnabled(false); + break; case TOUCH_SCREEN_AUTOMAP: + tcAutomap->resetOutput(); + tcAutomap->fade(touchcontrols::FADE_OUT,DEFAULT_FADE_FRAMES); break; case TOUCH_SCREEN_CONSOLE: break; @@ -588,14 +645,20 @@ void updateTouchScreenMode(touchscreemode_t mode) case TOUCH_SCREEN_MENU: tcMenuMain->setEnabled(true); tcMenuMain->fade(touchcontrols::FADE_IN,DEFAULT_FADE_FRAMES); + + //This is a bit of a hack, we need to enable the inventory buttons so they can be edited, they will not be seen anyway + showWeaponsInventory(true); break; case TOUCH_SCREEN_GAME: tcGameMain->setEnabled(true); tcGameMain->fade(touchcontrols::FADE_IN,DEFAULT_FADE_FRAMES); tcGameWeapons->setEnabled(true); - tcInventory->setEnabled(false); + showWeaponsInventory(false); break; case TOUCH_SCREEN_AUTOMAP: + tcAutomap->setEnabled(true); + tcAutomap->fade(touchcontrols::FADE_IN,DEFAULT_FADE_FRAMES); + break; case TOUCH_SCREEN_CONSOLE: break; @@ -612,19 +675,16 @@ void updateTouchScreenMode(touchscreemode_t mode) #include "s-setup/gp_lic_include.h" #endif -extern int clearCtrl; void frameControls() { static int loadedGLImages = 0; - //LOGI("frameControls"); - clearCtrl ++; + LOGI("frameControls"); + //We need to do this here now because duke loads a new gl context if (!loadedGLImages) { - touchJoyRight->setEnabled(false); - controlsContainer.initGL(); loadedGLImages = 1; } @@ -634,40 +694,6 @@ void frameControls() updateTouchScreenMode((touchscreemode_t)PortableRead(READ_SCREEN_MODE)); - /* - int inMenuNew = PortableRead(READ_MENU); - if (inMenuLast != inMenuNew) - { - inMenuLast = inMenuNew; - if (!inMenuNew) - { - tcGameMain->setEnabled(true); - tcGameWeapons->setEnabled(true); - tcGameWeapons->fade(1,DEFAULT_FADE_FRAMES); - tcMenuMain->setEnabled(false); - } - else - { - tcGameMain->setEnabled(false); - tcGameWeapons->setEnabled(false); - tcMenuMain->setEnabled(true); - } - } - - int inAutomapNew = PortableRead(READ_AUTOMAP) && !inMenuLast; //Dont show if menu comes up - if (inAutomapLast != inAutomapNew) - { - inAutomapLast = inAutomapNew; - if (inAutomapNew) - { - tcAutomap->animateIn(5); - } - else - { - tcAutomap->animateOut(5); - } - } - */ setHideSticks(!showSticks); controlsContainer.draw(); @@ -695,6 +721,7 @@ void setTouchSettings(float alpha,float strafe,float fwd,float pitch,float yaw,i } // TODO: defined names for these values + selectLastWeap = other & 0x1 ? true : false; toggleCrouch = other & 0x2 ? true : false; invertLook = other & 0x4 ? true : false; precisionShoot = other & 0x8 ? true : false; @@ -702,29 +729,11 @@ void setTouchSettings(float alpha,float strafe,float fwd,float pitch,float yaw,i hideTouchControls = other & 0x80000000 ? true : false; - switch ((other>>4) & 0xF) - { - case 1: - droidinput.left_double_action = gamefunc_Fire; - break; - case 2: - droidinput.left_double_action = gamefunc_Jump; - break; - default: - droidinput.left_double_action = -1; - } + int doubletap_options[6] = {0,gamefunc_Fire,gamefunc_Jump,gamefunc_Quick_Kick,gamefunc_MedKit,gamefunc_Jetpack}; + + droidinput.left_double_action = doubletap_options[((other>>4) & 0xF)]; + droidinput.right_double_action = doubletap_options[((other>>8) & 0xF)]; - switch ((other>>8) & 0xF) - { - case 1: - droidinput.right_double_action = gamefunc_Fire; - break; - case 2: - droidinput.right_double_action = gamefunc_Jump; - break; - default: - droidinput.right_double_action = -1; - } droidinput.strafe_sens = strafe; droidinput.forward_sens = fwd; @@ -734,7 +743,7 @@ void setTouchSettings(float alpha,float strafe,float fwd,float pitch,float yaw,i LOGI("setTouchSettings alpha = %f, left_double_action = %d",alpha,droidinput.left_double_action); } -#define EXPORT_ME __attribute__ ((visibility("default"))) +#define EXPORT_ME __NDK_FPABI__ __attribute__ ((visibility("default"))) JNIEnv* env_; @@ -748,6 +757,7 @@ static const char * getGamePath() return doom_path.c_str(); } + jint EXPORT_ME Java_com_beloko_duke_engine_NativeLib_init( JNIEnv* env, jobject thiz,jstring graphics_dir,jint audio_rate,jint audio_buffer_size,jobjectArray argsArray,jint renderer,jstring doom_path_ ) diff --git a/polymer/eduke32/source/android/in_android.c b/polymer/eduke32/source/android/in_android.c index 1e40a5a81..9112e75bc 100644 --- a/polymer/eduke32/source/android/in_android.c +++ b/polymer/eduke32/source/android/in_android.c @@ -37,8 +37,8 @@ int PortableKeyEvent(int state, int code,int unicode) SDL_SendKeyboardKey(state ? SDL_PRESSED : SDL_RELEASED, code); SDL_EventState(SDL_TEXTINPUT, SDL_ENABLE); - if (code == 42) - unicode = 42; + // if (code == 42) + // unicode = 42; if (state) { @@ -94,7 +94,7 @@ void PortableAction(int state, int action) else { //if (PortableRead(READ_SCREEN_MODE) != TOUCH_SCREEN_GAME) //If not in game don't do any of this - /// return; + /// return; #ifdef GP_LIC #define GP_LIC_INC 5 @@ -173,9 +173,14 @@ void PortableInit(int argc, const char ** argv) main(argc, argv); } +int consoleShown = 0; +void AndroidSetConsoleShown(int onf) +{ + consoleShown = onf; +} extern int animation_playing; - +extern int inExtraScreens; //In game.c int32_t PortableRead(portableread_t r) { switch (r) @@ -184,25 +189,32 @@ int32_t PortableRead(portableread_t r) if (animation_playing) return TOUCH_SCREEN_BLANK_TAP; + else if (inExtraScreens) + return TOUCH_SCREEN_BLANK_TAP; + else if (consoleShown) + return TOUCH_SCREEN_CONSOLE; else if ((g_player[myconnectindex].ps->gm & MODE_MENU) == MODE_MENU) { //Then check if Yes/No menu if ((g_currentMenu == MENU_QUITTOTITLE) || (g_currentMenu == MENU_RESETPLAYER ) || - (g_currentMenu == MENU_RESETPLAYER2 ) || - ((g_currentMenu >= MENU_LOADVERIFY ) && (g_currentMenu <= MENU_LOADVERIFY10 )) || + ((g_currentMenu == MENU_LOADVERIFY )) || (g_currentMenu == MENU_NEWVERIFY ) || - ((g_currentMenu >= MENU_SAVEVERIFY ) && (g_currentMenu <= MENU_SAVEVERIFY10 )) || + ((g_currentMenu == MENU_SAVEVERIFY )) || (g_currentMenu == MENU_QUIT ) || - (g_currentMenu == MENU_QUIT2) || (g_currentMenu == MENU_QUITTOTITLE ) ) return TOUCH_SCREEN_YES_NO; else return TOUCH_SCREEN_MENU; } + else if (ud.overhead_on == 2) + return TOUCH_SCREEN_AUTOMAP; else if ((g_player[myconnectindex].ps->gm & MODE_GAME)) - return TOUCH_SCREEN_GAME; + if (PortableRead(READ_IS_DEAD)) + return TOUCH_SCREEN_BLANK_TAP; + else + return TOUCH_SCREEN_GAME; else return TOUCH_SCREEN_BLANK_TAP; @@ -218,13 +230,35 @@ int32_t PortableRead(portableread_t r) return droidinput.lastWeapon; case READ_PAUSED: return ud.pause_on != 0; + case READ_IS_DEAD: + return g_player[myconnectindex].ps->dead_flag; default: return 0; } } +static float map_zoom,map_dx,map_dy = 0; + +void PortableAutomapControl(float zoom,float dx,float dy) +{ + map_zoom += zoom; + map_dx += dx; + map_dy += dy; +} + ///This stuff is called from the game/engine +extern void CONTROL_Android_ScrollMap(int32_t *angle,int32_t *x, int32_t *y, uint16_t *zoom ) +{ + + *x += ((int)(map_dx * -30000)*sintable[(512+2048-*angle)&2047])>>14; + *y += ((int)(map_dy * -30000)*sintable[(512+1024-512-*angle)&2047])>>14; + + *zoom += map_zoom * 2000; + //*angle = 0; + map_dx = map_dy = map_zoom = 0; +} + void CONTROL_Android_SetLastWeapon(int w) { LOGI("setLastWeapon %d",w); @@ -243,11 +277,11 @@ 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)Blrintf(-droidinput.forwardmove * ANDROIDFORWARDMOVEFACTOR); - info->dx = (int32_t)Blrintf(droidinput.sidemove * ANDROIDSIDEMOVEFACTOR); - info->dpitch = (int32_t)Blrintf(droidinput.pitch * ANDROIDPITCHFACTOR + + info->dz = (int32_t)nearbyintf(-droidinput.forwardmove * ANDROIDFORWARDMOVEFACTOR); + info->dx = (int32_t)nearbyintf(droidinput.sidemove * ANDROIDSIDEMOVEFACTOR); + info->dpitch = (int32_t)nearbyint(droidinput.pitch * ANDROIDPITCHFACTOR + droidinput.pitch_joystick * ANDROIDPITCHFACTORJOYSTICK); - info->dyaw = (int32_t)Blrintf(-droidinput.yaw * ANDROIDYAWFACTOR - + info->dyaw = (int32_t)nearbyint(-droidinput.yaw * ANDROIDYAWFACTOR - droidinput.yaw_joystick * ANDROIDYAWFACTORJOYSTICK); /* diff --git a/polymer/eduke32/source/android/in_android.h b/polymer/eduke32/source/android/in_android.h index 68b56f69f..c9b55f3e5 100644 --- a/polymer/eduke32/source/android/in_android.h +++ b/polymer/eduke32/source/android/in_android.h @@ -48,7 +48,8 @@ typedef enum { READ_MAPFOLLOWMODE, READ_RENDERER, READ_LASTWEAPON, - READ_PAUSED + READ_PAUSED, + READ_IS_DEAD } portableread_t; @@ -94,6 +95,8 @@ extern droidinput_t droidinput; extern droidsysinfo_t droidinfo; extern char toggleCrouch; + + int PortableKeyEvent(int state, int code, int unicode); int PortableRead(portableread_t r); @@ -104,8 +107,13 @@ void PortableLook(double yaw, double pitch); void PortableLookJoystick(double yaw, double pitch); void PortableCommand(const char * cmd); +void PortableAutomapControl(float zoom,float dx,float dy); + void PortableInit(int argc, const char ** argv); +void AndroidSetConsoleShown(int onf); + + #ifdef __cplusplus } #endif