From 7019f132744b49ef3793322b14c5b61200a55b5b Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 13 Oct 2014 21:22:35 +0300 Subject: [PATCH 1/4] Added android_support library from NDK for swprinf and wchar support, updated JA2 project --- .gitignore | 1 + changeAppSettings.sh | 3 ++ project/jni/SettingsTemplate.mk | 2 +- .../ballfield/AndroidAppSettings.cfg | 2 +- .../jni/application/ballfield/ballfield.cpp | 14 +++++++ .../commandergenius/commandergenius | 2 +- .../application/ja2/AndroidAppSettings.cfg | 40 +++++++++---------- project/jni/application/ja2/ja2.patch | 19 +++++++-- project/jni/boost/src | 2 +- project/jni/shmem | 2 +- 10 files changed, 59 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index 4f505d499..1513d14c5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ project/res/drawable/app_icon.png project/proguard-project.txt project/proguard-local.cfg project/themes/converter +project/jni/android-support diff --git a/changeAppSettings.sh b/changeAppSettings.sh index aa21b8a10..2ed5a9507 100755 --- a/changeAppSettings.sh +++ b/changeAppSettings.sh @@ -912,6 +912,9 @@ fi ./copyAssets.sh || exit 1 +rm -rf project/jni/android-support +ln -s "`which ndk-build | sed 's@/ndk-build@@'`/sources/android/support" project/jni/android-support + if uname -s | grep -i "darwin" > /dev/null ; then find project/src -name "*.killme.tmp" -delete fi diff --git a/project/jni/SettingsTemplate.mk b/project/jni/SettingsTemplate.mk index 5eb0c4040..a6e724b75 100644 --- a/project/jni/SettingsTemplate.mk +++ b/project/jni/SettingsTemplate.mk @@ -3,7 +3,7 @@ APP_MODULES := application sdl-1.2 sdl_main sdl_native_helpers jpeg png ogg flac vorbis freetype tremor ogg # To filter out static libs from all libs in makefile -APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc sdl_savepng +APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread boost_locale glu icudata icutest icui18n icuio icule iculx icutu icuuc sdl_savepng android_support APP_ABI := armeabi diff --git a/project/jni/application/ballfield/AndroidAppSettings.cfg b/project/jni/application/ballfield/AndroidAppSettings.cfg index cf9d10beb..2deffa62a 100644 --- a/project/jni/application/ballfield/AndroidAppSettings.cfg +++ b/project/jni/application/ballfield/AndroidAppSettings.cfg @@ -221,7 +221,7 @@ AppMinimumRAM=0 # Optional shared libraries to compile - removing some of them will save space # MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed # Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2 -CompiledLibraries="sdl_image" +CompiledLibraries="sdl_image android_support" # Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) CustomBuildScript=n diff --git a/project/jni/application/ballfield/ballfield.cpp b/project/jni/application/ballfield/ballfield.cpp index b89a87a0c..578feda0b 100644 --- a/project/jni/application/ballfield/ballfield.cpp +++ b/project/jni/application/ballfield/ballfield.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -554,6 +555,19 @@ int main(int argc, char* argv[]) memset(gamepads, 0, sizeof(gamepads)); __android_log_print(ANDROID_LOG_INFO, "Ballfield", "sizeof(int) %d long %d long long %d size_t %d", sizeof(int), sizeof(long), sizeof(long long), sizeof(size_t)); + wchar_t ss[256]; + const wchar_t *ss2 = L"String 2 ЕНГ ---"; + swprintf(ss, 256, L"String ЙЦУК --- %ls", ss2); + char ss3[512] = ""; + char ss4[512] = ""; + for(i = 0; i < wcslen(ss); i++) + { + char tmp[16]; + sprintf(tmp, "%04X ", (int)ss[i]); + strcat(ss3, tmp); + sprintf(ss4, "%ls", ss); + } + __android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "swprintf: len %d data %s: %s", wcslen(ss), ss3, ss4); __android_log_print(ANDROID_LOG_VERBOSE, "Ballfield", "On-screen buttons:"); for(i = 0; i < SDL_ANDROID_SCREENKEYBOARD_BUTTON_NUM; i++) diff --git a/project/jni/application/commandergenius/commandergenius b/project/jni/application/commandergenius/commandergenius index a13813de8..41f402916 160000 --- a/project/jni/application/commandergenius/commandergenius +++ b/project/jni/application/commandergenius/commandergenius @@ -1 +1 @@ -Subproject commit a13813de8c296b918f3be671e15ae8f643753aae +Subproject commit 41f402916f4a092eb06d5c5068a26ac827dedd04 diff --git a/project/jni/application/ja2/AndroidAppSettings.cfg b/project/jni/application/ja2/AndroidAppSettings.cfg index 1260f8532..9e0bd05ce 100644 --- a/project/jni/application/ja2/AndroidAppSettings.cfg +++ b/project/jni/application/ja2/AndroidAppSettings.cfg @@ -7,10 +7,10 @@ AppName="JaggedAlliance2" AppFullName=com.opensourced.ja2 # Application version code (integer) -AppVersionCode=2347 +AppVersionCode=01235202 # Application user-visible version name (string) -AppVersionName="0.12.10" +AppVersionName="0.12.352.02" # Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' # If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu @@ -21,7 +21,7 @@ AppVersionName="0.12.10" AppDataDownloadUrl="!!JaggedAllianceData|ja2.zip" # Reset SDL config when updating application to the new version (y) / (n) -ResetSdlConfigForThisVersion=y +ResetSdlConfigForThisVersion=n # Delete application data files when upgrading (specify file/dir paths separated by spaces) DeleteFilesOnUpgrade="" @@ -75,30 +75,30 @@ CompatibilityHacksForceScreenUpdate=n CompatibilityHacksForceScreenUpdateMouseClick=y # Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n) -CompatibilityHacksStaticInit= +CompatibilityHacksStaticInit=n # On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n) -CompatibilityHacksTextInputEmulatesHwKeyboard= +CompatibilityHacksTextInputEmulatesHwKeyboard=n # Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n) -CompatibilityHacksPreventAudioChopping= +CompatibilityHacksPreventAudioChopping=n # Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n) -CompatibilityHacksAppIgnoresAudioBufferSize= +CompatibilityHacksAppIgnoresAudioBufferSize=n # Hack for VCMI: preload additional shared libraries before aplication start CompatibilityHacksAdditionalPreloadedSharedLibraries="" # Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue - # do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n) -CompatibilityHacksSlowCompatibleEventQueue= +CompatibilityHacksSlowCompatibleEventQueue=n # Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL -CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState= +CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=n # Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects. # This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n) -CompatibilityHacksProperUsageOfSDL_UpdateRects= +CompatibilityHacksProperUsageOfSDL_UpdateRects=n # Application uses mouse (y) or (n), this will show mouse emulation dialog to the user AppUsesMouse=y @@ -108,19 +108,19 @@ AppNeedsTwoButtonMouse=y # Right mouse button can do long-press/drag&drop action, necessary for some games (y) or (n) # If you disable it, swiping with two fingers will send mouse wheel events -RightMouseButtonLongPress= +RightMouseButtonLongPress=y # Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n) -ShowMouseCursor= +ShowMouseCursor=n # Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n) -GenerateSubframeTouchEvents= +GenerateSubframeTouchEvents=n # Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n) ForceRelativeMouseMode=n # Show on-screen dpad/joystick, that will act as arrow keys (y) or (n) -AppNeedsArrowKeys=y +AppNeedsArrowKeys=n # On-screen dpad/joystick will appear under finger when it touches the screen (y) or (n) # Joystick always follows finger, so moving mouse requires touching the screen with other finger @@ -154,16 +154,16 @@ AppUsesMultitouch=n # Application records audio (it will use any available source, such a s microphone) # API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void); # This option will add additional permission to Android manifest (y)/(n) -AppRecordsAudio= +AppRecordsAudio=n # Application needs to access SD card. If your data files are bigger than 5 Mb, enable it. (y) / (n) -AccessSdCard= +AccessSdCard=y # Application needs Internet access. If you disable it, you'll have to bundle all your data files inside .apk (y) / (n) -AccessInternet= +AccessInternet=n # Immersive mode - Android will hide on-screen Home/Back keys. Looks bad if you invoke Android keyboard. (y) / (n) -ImmersiveMode= +ImmersiveMode=y # Application implements Android-specific routines to put to background, and will not draw anything to screen # between SDL_ACTIVEEVENT lost / gained notifications - you should check for them @@ -176,10 +176,10 @@ NonBlockingSwapBuffers=n # SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices # Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th) # Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA -RedefinedKeys="LCTRL RETURN KP_PLUS KP_MINUS LCTRL" +RedefinedKeys="MOUSE_RIGHT" # Number of virtual keyboard keys (currently 6 is maximum) -AppTouchscreenKeyboardKeysAmount=5 +AppTouchscreenKeyboardKeysAmount=1 # Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right) RedefinedKeysScreenKb="LCTRL RETURN KP_PLUS KP_MINUS LCTRL" diff --git a/project/jni/application/ja2/ja2.patch b/project/jni/application/ja2/ja2.patch index 28d548b9d..d9e66c0d6 100644 --- a/project/jni/application/ja2/ja2.patch +++ b/project/jni/application/ja2/ja2.patch @@ -240,8 +240,21 @@ index 263f9b1..57d377c 100644 #define PATH_SEPARATOR '/' #define PATH_SEPARATOR_STR "/" #endif +diff --git a/sgp/PlatformSDL.h b/sgp/PlatformSDL.h +index 7d69ce0..246d80c 100644 +--- a/sgp/PlatformSDL.h ++++ b/sgp/PlatformSDL.h +@@ -15,7 +15,7 @@ + * http://developer.apple.com/library/mac/#technotes/tn2133/_index.html + * + */ +-#ifdef __APPLE__ ++#if defined(__APPLE__) || defined(__ANDROID__) + #define EXPENSIVE_SDL_UPDATE_RECT (1) + #else + #define EXPENSIVE_SDL_UPDATE_RECT (0) diff --git a/sgp/SGP.cc b/sgp/SGP.cc -index d156d73..66d7cf0 100644 +index d156d73..95c4097 100644 --- a/sgp/SGP.cc +++ b/sgp/SGP.cc @@ -13,6 +13,9 @@ @@ -273,7 +286,7 @@ index d156d73..66d7cf0 100644 #if defined BROKEN_SWPRINTF if (setlocale(LC_CTYPE, "UTF-8") == NULL) -@@ -398,7 +401,7 @@ try +@@ -398,7 +398,7 @@ try if(extraDataDir.empty()) { // use location of the exe file @@ -282,7 +295,7 @@ index d156d73..66d7cf0 100644 } std::string externalizedDataPath = FileMan::joinPaths(extraDataDir, "externalized"); -@@ -775,7 +779,7 @@ static void WriteDefaultConfigFile(const char* ConfigFile) +@@ -775,7 +775,7 @@ static void WriteDefaultConfigFile(const char* ConfigFile) #ifdef _WIN32 fprintf(IniFile, "data_dir = C:\\Program Files\\Jagged Alliance 2"); #else diff --git a/project/jni/boost/src b/project/jni/boost/src index 5824acb45..bc9ea9d30 160000 --- a/project/jni/boost/src +++ b/project/jni/boost/src @@ -1 +1 @@ -Subproject commit 5824acb451e671205afeb188576be1dd9a2674bd +Subproject commit bc9ea9d3032eb1e2b095484e2052aa2bc2e91767 diff --git a/project/jni/shmem b/project/jni/shmem index c2a28f528..89c7cb8d0 160000 --- a/project/jni/shmem +++ b/project/jni/shmem @@ -1 +1 @@ -Subproject commit c2a28f528d0b1b2528dda125e8fe8018609e7e9a +Subproject commit 89c7cb8d033412be4fdca551ec39432d5d2d06a6 From aa56c63aeb12b5f3e918feead01ae0a4f9d14d41 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 13 Oct 2014 22:44:27 +0300 Subject: [PATCH 2/4] Updated JA2 --- .../application/ja2/AndroidAppSettings.cfg | 6 +- project/jni/application/ja2/AndroidBuild.sh | 2 +- project/jni/application/ja2/ja2.patch | 55 +++++++++++++++++-- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/project/jni/application/ja2/AndroidAppSettings.cfg b/project/jni/application/ja2/AndroidAppSettings.cfg index 9e0bd05ce..6eafe2770 100644 --- a/project/jni/application/ja2/AndroidAppSettings.cfg +++ b/project/jni/application/ja2/AndroidAppSettings.cfg @@ -7,10 +7,10 @@ AppName="JaggedAlliance2" AppFullName=com.opensourced.ja2 # Application version code (integer) -AppVersionCode=01235202 +AppVersionCode=01235203 # Application user-visible version name (string) -AppVersionName="0.12.352.02" +AppVersionName="0.12.352.03" # Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' # If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu @@ -221,7 +221,7 @@ AppMinimumRAM=0 # Optional shared libraries to compile - removing some of them will save space # MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed # Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2 -CompiledLibraries="jpeg png boost_filesystem boost_system" +CompiledLibraries="jpeg png boost_filesystem boost_system android_support" # Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) CustomBuildScript=y diff --git a/project/jni/application/ja2/AndroidBuild.sh b/project/jni/application/ja2/AndroidBuild.sh index c921742e1..c31fabf57 100755 --- a/project/jni/application/ja2/AndroidBuild.sh +++ b/project/jni/application/ja2/AndroidBuild.sh @@ -5,4 +5,4 @@ patch -p1 -d src-$1 < ja2.patch || exit 1 } || exit 1 -../setEnvironment-$1.sh sh -c "make -j4 -C src-$1 WITH_LPTHREAD=0" && cp -f src-$1/ja2 libapplication-$1.so +../setEnvironment-$1.sh sh -c "make -j4 -C src-$1 WITH_LPTHREAD=0 Q=" && cp -f src-$1/ja2 libapplication-$1.so diff --git a/project/jni/application/ja2/ja2.patch b/project/jni/application/ja2/ja2.patch index d9e66c0d6..046f30472 100644 --- a/project/jni/application/ja2/ja2.patch +++ b/project/jni/application/ja2/ja2.patch @@ -1,5 +1,5 @@ diff --git a/Makefile b/Makefile -index a21c6b5..8a65a69 100644 +index a21c6b5..d6a8e9d 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ endif @@ -21,6 +21,15 @@ index a21c6b5..8a65a69 100644 CFLAGS += -I _build/lib-rapidjson CFLAGS += -I _build/lib-slog CFLAGS += -I _build/lib-smacker/libsmacker +@@ -154,7 +155,7 @@ CCFLAGS += -Wmissing-prototypes + + CXXFLAGS += $(CFLAGS) + +-LDFLAGS += -lm ++LDFLAGS += -lm -landroid_support + + ifeq "$(WITH_LPTHREAD)" "1" + LDFLAGS += -lpthread @@ -522,15 +523,15 @@ SRCS += _build/lib-MicroIni/src/MicroIni/Line.cpp SRCS += _build/lib-MicroIni/src/MicroIni/Section.cpp SRCS += _build/lib-MicroIni/src/MicroIni/Value.cpp @@ -254,7 +263,7 @@ index 7d69ce0..246d80c 100644 #else #define EXPENSIVE_SDL_UPDATE_RECT (0) diff --git a/sgp/SGP.cc b/sgp/SGP.cc -index d156d73..95c4097 100644 +index d156d73..e34ecd8 100644 --- a/sgp/SGP.cc +++ b/sgp/SGP.cc @@ -13,6 +13,9 @@ @@ -267,7 +276,17 @@ index d156d73..95c4097 100644 #include "Button_System.h" #include "Debug.h" -@@ -49,9 +52,6 @@ +@@ -32,6 +35,9 @@ + #include "Video.h" + #include "VSurface.h" + #include ++#ifdef __ANDROID__ ++#include ++#endif + #include "UILayout.h" + #include "GameRes.h" + #include "Logger.h" +@@ -49,9 +55,6 @@ #include "slog/slog.h" #define TAG "SGP" @@ -277,7 +296,15 @@ index d156d73..95c4097 100644 #if defined _WIN32 # define WIN32_LEAN_AND_MEAN -@@ -318,7 +318,7 @@ static BOOLEAN ParseParameters(int argc, char* const argv[], +@@ -273,6 +276,7 @@ static void MainLoop(int msPerGameCycle) + + static int Failure(char const* const msg, bool showInfoIcon=false) + { ++ __android_log_print(ANDROID_LOG_FATAL, "JA2", "%s", msg); + fprintf(stderr, "%s\n", msg); + #if defined _WIN32 + MessageBox(0, msg, APPLICATION_NAME, MB_OK | (showInfoIcon ? MB_ICONINFORMATION : MB_ICONERROR) | MB_TASKMODAL); +@@ -318,7 +322,7 @@ static BOOLEAN ParseParameters(int argc, char* const argv[], int main(int argc, char* argv[]) try { @@ -286,7 +313,23 @@ index d156d73..95c4097 100644 #if defined BROKEN_SWPRINTF if (setlocale(LC_CTYPE, "UTF-8") == NULL) -@@ -398,7 +398,7 @@ try +@@ -365,6 +369,15 @@ try + SDL_Init(SDL_INIT_VIDEO); + SDL_EnableUNICODE(SDL_ENABLE); + ++#ifdef __ANDROID__ ++ SDL_Rect r = { 64 * SDL_ListModes(NULL, 0)[0]->w / 1280, ++ 492 * SDL_ListModes(NULL, 0)[0]->h / 800, ++ (199 - 64) * SDL_ListModes(NULL, 0)[0]->w / 1280, ++ (627 - 492) * SDL_ListModes(NULL, 0)[0]->h / 800}; ++ if (!SDL_ANDROID_GetScreenKeyboardRedefinedByUser()) ++ SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_0, &r); ++#endif ++ + #ifdef __APPLE__ + // Enable 3-button mouse support if the user haven't instructed + // otherwise +@@ -398,7 +411,7 @@ try if(extraDataDir.empty()) { // use location of the exe file @@ -295,7 +338,7 @@ index d156d73..95c4097 100644 } std::string externalizedDataPath = FileMan::joinPaths(extraDataDir, "externalized"); -@@ -775,7 +775,7 @@ static void WriteDefaultConfigFile(const char* ConfigFile) +@@ -775,7 +788,7 @@ static void WriteDefaultConfigFile(const char* ConfigFile) #ifdef _WIN32 fprintf(IniFile, "data_dir = C:\\Program Files\\Jagged Alliance 2"); #else From 867dbe3e1b037e6d7b57879e2dce2d0349065cc7 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Mon, 13 Oct 2014 22:46:37 +0300 Subject: [PATCH 3/4] Updated TODO --- todo.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/todo.txt b/todo.txt index 3a55a5a46..f8646b109 100644 --- a/todo.txt +++ b/todo.txt @@ -30,3 +30,5 @@ TODO, which will get actually done - USB Keyboard: touchpad mode, configurable mouse speed, show keyboard LEDs, show error when root is not installed. - S Planner Killer: options to restore calendar settiongs, and to kill lock-screen widget. + +- GemRB: update. From b6cc574e7750ff807aa8e6dc3c47162c773b532c Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Thu, 16 Oct 2014 17:20:11 +0300 Subject: [PATCH 4/4] Nvidia Shield also sends AXIS_HAT_X/AXIS_HAT_Y events whne pressing gamepad, moved that code to generic joystick handling --- project/java/Video.java | 57 ++++++++----------- .../application/ja2/AndroidAppSettings.cfg | 4 +- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/project/java/Video.java b/project/java/Video.java index dc677099c..52318e1a4 100644 --- a/project/java/Video.java +++ b/project/java/Video.java @@ -362,6 +362,7 @@ abstract class DifferentTouchInput } private static class IcsTouchInput extends GingerbreadTouchInput { + float hatX = 0.0f, hatY = 0.0f; private static class Holder { private static final IcsTouchInput sInstance = new IcsTouchInput(); @@ -391,6 +392,29 @@ abstract class DifferentTouchInput event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y), event.getAxisValue(MotionEvent.AXIS_Z), event.getAxisValue(MotionEvent.AXIS_RZ), event.getAxisValue(MotionEvent.AXIS_RTRIGGER), event.getAxisValue(MotionEvent.AXIS_LTRIGGER) ); + // event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, on Nvidia Shield and some other joysticks + if( event.getAxisValue(MotionEvent.AXIS_HAT_X) != hatX ) + { + hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X); + if( hatX == 0.0f ) + { + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0, 0); + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0, 0); + } + else + DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1, 0); + } + if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY ) + { + hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y); + if( hatY == 0.0f ) + { + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0, 0); + DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0, 0); + } + else + DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1, 0); + } return; } // Process mousewheel @@ -436,41 +460,8 @@ abstract class DifferentTouchInput { private static final CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad sInstance = new CrappyDragonRiseDatexGamepadInputWhichNeedsItsOwnHandlerBecauseImTooCheapAndStupidToBuyProperGamepad(); } - float hatX = 0.0f, hatY = 0.0f; public void processGenericEvent(final MotionEvent event) { - // Joysticks are supported since Honeycomb, but I don't care about it, because very little devices have it - if( (event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == InputDevice.SOURCE_CLASS_JOYSTICK ) - { - // event.getAxisValue(AXIS_HAT_X) and event.getAxisValue(AXIS_HAT_Y) are joystick arrow keys, they also send keyboard events - DemoGLSurfaceView.nativeGamepadAnalogJoystickInput( - event.getAxisValue(MotionEvent.AXIS_X), event.getAxisValue(MotionEvent.AXIS_Y), - event.getAxisValue(MotionEvent.AXIS_RX), event.getAxisValue(MotionEvent.AXIS_RZ), - 0, 0); - if( event.getAxisValue(MotionEvent.AXIS_HAT_X) != hatX ) - { - hatX = event.getAxisValue(MotionEvent.AXIS_HAT_X); - if( hatX == 0.0f ) - { - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_LEFT, 0, 0); - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_RIGHT, 0, 0); - } - else - DemoGLSurfaceView.nativeKey(hatX < 0.0f ? KeyEvent.KEYCODE_DPAD_LEFT : KeyEvent.KEYCODE_DPAD_RIGHT, 1, 0); - } - if( event.getAxisValue(MotionEvent.AXIS_HAT_Y) != hatY ) - { - hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y); - if( hatY == 0.0f ) - { - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_UP, 0, 0); - DemoGLSurfaceView.nativeKey(KeyEvent.KEYCODE_DPAD_DOWN, 0, 0); - } - else - DemoGLSurfaceView.nativeKey(hatY < 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN, 1, 0); - } - return; - } super.processGenericEvent(event); } public boolean detect() diff --git a/project/jni/application/ja2/AndroidAppSettings.cfg b/project/jni/application/ja2/AndroidAppSettings.cfg index 6eafe2770..7878f7c32 100644 --- a/project/jni/application/ja2/AndroidAppSettings.cfg +++ b/project/jni/application/ja2/AndroidAppSettings.cfg @@ -7,10 +7,10 @@ AppName="JaggedAlliance2" AppFullName=com.opensourced.ja2 # Application version code (integer) -AppVersionCode=01235203 +AppVersionCode=01235204 # Application user-visible version name (string) -AppVersionName="0.12.352.03" +AppVersionName="0.12.352.04" # Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...' # If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu