From f47aaaea8e1e396fcfee876a436e304ae8088af0 Mon Sep 17 00:00:00 2001 From: pelya Date: Mon, 6 May 2013 12:42:06 +0300 Subject: [PATCH] Updated readme with info about SDL joystick API --- project/java/Settings.java | 2 +- project/jni/application/openarena/engine | 2 +- project/jni/application/openarena/vm | 2 +- .../jni/sdl-1.2/src/video/android/keymap.c | 6 ++--- readme.txt | 26 +++++++++++++++++-- 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/project/java/Settings.java b/project/java/Settings.java index 95c26d529..70409c7ad 100644 --- a/project/java/Settings.java +++ b/project/java/Settings.java @@ -203,7 +203,7 @@ class Settings idx = ii; Globals.RemapScreenKbKeycode[i] = idx; } - Globals.ScreenKbControlsShown[0] = Globals.AppNeedsArrowKeys; + Globals.ScreenKbControlsShown[0] = (Globals.AppNeedsArrowKeys || Globals.AppUsesJoystick); Globals.ScreenKbControlsShown[1] = Globals.AppNeedsTextInput; for( int i = 2; i < Globals.ScreenKbControlsShown.length; i++ ) Globals.ScreenKbControlsShown[i] = ( i - 2 < Globals.AppTouchscreenKeyboardKeysAmount ); diff --git a/project/jni/application/openarena/engine b/project/jni/application/openarena/engine index 7d4816a25..4d88204db 160000 --- a/project/jni/application/openarena/engine +++ b/project/jni/application/openarena/engine @@ -1 +1 @@ -Subproject commit 7d4816a25a1637106129a1f3c6a2a9e513f6d92d +Subproject commit 4d88204dbe500148fb572d02bcf722d22b75b82c diff --git a/project/jni/application/openarena/vm b/project/jni/application/openarena/vm index c88124ddc..c744424da 160000 --- a/project/jni/application/openarena/vm +++ b/project/jni/application/openarena/vm @@ -1 +1 @@ -Subproject commit c88124ddcb2f6b7857ac72497d30a30459d3545e +Subproject commit c744424da50d09fd44f55ed55dd8654245e974b2 diff --git a/project/jni/sdl-1.2/src/video/android/keymap.c b/project/jni/sdl-1.2/src/video/android/keymap.c index e846e4bf1..a23b4878c 100644 --- a/project/jni/sdl-1.2/src/video/android/keymap.c +++ b/project/jni/sdl-1.2/src/video/android/keymap.c @@ -131,7 +131,7 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap) keymap[KEYCODE_PICTSYMBOLS] = SDL_KEY(LSHIFT); keymap[KEYCODE_SWITCH_CHARSET] = SDL_KEY(LSHIFT); keymap[KEYCODE_BUTTON_A] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_2)); - keymap[KEYCODE_BUTTON_B] = SDL_KEY(ESCAPE); // SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3)); // There's no Back key on Ouya + keymap[KEYCODE_BUTTON_B] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_3)); keymap[KEYCODE_BUTTON_C] = SDL_KEY(C); keymap[KEYCODE_BUTTON_X] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_0)); keymap[KEYCODE_BUTTON_Y] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_1)); @@ -140,8 +140,8 @@ void SDL_android_init_keymap(SDLKey *SDL_android_keymap) keymap[KEYCODE_BUTTON_R1] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_SCREENKB_KEYCODE_4)); keymap[KEYCODE_BUTTON_L2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0)); keymap[KEYCODE_BUTTON_R2] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_6)); - keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1)); - keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_4)); + keymap[KEYCODE_BUTTON_THUMBL] = SDL_KEY(SPACE); + keymap[KEYCODE_BUTTON_THUMBR] = SDL_KEY(RETURN); keymap[KEYCODE_BUTTON_START] = SDL_KEY(RETURN); keymap[KEYCODE_BUTTON_SELECT] = SDL_KEY(ESCAPE); keymap[KEYCODE_BUTTON_MODE] = SDL_KEY(SPACE); diff --git a/readme.txt b/readme.txt index 5b86e6035..28e56d04c 100644 --- a/readme.txt +++ b/readme.txt @@ -51,8 +51,7 @@ Recent Android phone models like HTC Evo have no keyboard at all, on-screen keyb is available for such devices - it has joystick (which can be configured as arrow buttons or analog joystick), and 6 configurable keys, full text input is toggled with 7-th key. Both user and application may redefine button layout and returned keycodes, and also toggle full text input - see SDL_screenkeyboard.h. -Also you can read multitouch events and accelerometer events - they are passed as joystick events, -see Ballfield sample app for the input event handling code. +Also you can read multitouch events and accelerometer events - they are passed as joystick events. This port also supports GL ES + SDL combo - there is GLXGears demo app in project/jni/application/glxgears, to compile it remove project/jni/application/src symlink and make new one pointing to glxgears, and run build.sh @@ -246,6 +245,29 @@ SDL supports AdMob advertisements, you need to set your publisher ID inside Andr see project test-advertisements for details. Also you can hide or reposition your ad from C code, check out file SDL_android.h for details. +SDL reports several joysticks, which are used to pass accelerometer and multitouch events. +On-screen joystick events are sent as SDL_JOYAXISMOTION in event.jaxis.jalue, scaled from -32767 to 32767, +with event.jaxis.which == 0 and event.jaxis.axis from 0 to 1, you will need to set AppUsesJoystick=y +in AndroidAppSettings.cfg and call SDL_JoystickOpen(0) in your code. +Multitouch events are sent as SDL_JOYBALLMOTION in event.jball.xrel and event.jball.yrel, scaled to screen size, +with event.jball.which == 0 and e.jball.ball from 0 to 15, you will need to set AppUsesMultitouch=y +in AndroidAppSettings.cfg and call SDL_JoystickOpen(0). SDL_JOYBUTTONDOWN and SDL_JOYBUTTONUP events +are sent when the screen is touched or released, with e.jbutton.which == 0 and e.jbutton.button from 0 to 15. +Additionally, the touch pressure is sent as SDL_JOYAXISMOTION, scaled from 0 to 32767, +with event.jaxis.which == 0 and event.jaxis.axis from 4 to 19. +Accelerometer events are sent as SDL_JOYAXISMOTION, with event.jaxis.which == 1 and event.jaxis.axis from 0 to 1, +scaled from -32767 to 32767, denoting the device tilt angles from the horizontal. +Raw accelerometer events are sent with event.jaxis.axis from 5 to 7, with Earth gravity having a value 9800. +You will need to set AppUsesAccelerometer=y in AndroidAppSettings.cfg, and call SDL_JoystickOpen(1) in your code. +Gyroscope events are sent as SDL_JOYAXISMOTION, with event.jaxis.which == 1 and event.jaxis.axis from 2 to 4, +with value 32767 equal to 0.25 rad/s. You will need to set AppUsesGyroscope=y in AndroidAppSettings.cfg to use it. +Gyroscope hardware is much more precise and less noisy than accelerometer, it is present on newer devices +starting from Galaxy S II, but older devices do no have it - it is emulated with accelerometer + compass. +SDL also supports gamepad - you can plug PS3/Xbox gamepad to almost any tablet, some devices have built-in gamepad. +Gamepad stick events are sent as SDL_JOYAXISMOTION, with event.jaxis.which == 2 and event.jaxis.axis from 0 to 3. +Gamepad analog L1/R1 buttons are sent as SDL_JOYAXISMOTION, with event.jaxis.which == 2 and event.jaxis.axis from 4 to 5. +Other gamepad buttons generate key events, which are taken from RedefinedKeysScreenKb in AndroidAppSettings.cfg. + How to compile your own application using automake/configure scripts ====================================================================