Merge pull request #11 from bkaindl/opentyrian-android

Changes for supporting direct intuitive touch input to navigate all OpenTyrian menus.
This commit is contained in:
pelya
2012-08-07 16:06:50 -07:00
17 changed files with 256 additions and 44 deletions

View File

@@ -1,4 +1,10 @@
#!/bin/sh
set -eu
if [ $# -gt 0 -a $1 = "-r" ]; then
shift
run_apk=true
fi
# Set here your own NDK path if needed
# export PATH=$PATH:~/src/endless_space/android-ndk-r7
@@ -39,7 +45,15 @@ cd project && env PATH=$NDKBUILDPATH nice -n19 ndk-build V=1 -j$NCPU && \
|| true ; } && \
ant debug && \
[ -n "`adb devices | tail -n +2`" ] && \
test -z "$1" && cd bin && \
if [ $# -eq 0 ]; then # It seems peyla wanted build.sh to not install if an arg is given..
cd bin
{ adb install -r MainActivity-debug.apk | grep 'Failure' && \
adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; true ; } && \
true # adb shell am start -n `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity
if [ "$run_apk" = true ]; then
ActivityName="`grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'`/.MainActivity"
RUN_APK="adb shell am start -n $ActivityName"
echo "Running $ActivityName on the USB-connected device:"
echo "$RUN_APK"
eval $RUN_APK
fi
fi

View File

@@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.package.name"
android:versionCode="100"
android:versionName="1.0.0 - intiial version"
android:versionName="1.0.0 - initial version"
android:installLocation="auto"
>
<application android:label="@string/app_name"
@@ -12,6 +12,7 @@
<activity android:name=".MainActivity"
android:label="@string/app_name"
android:alwaysRetainTaskState="true"
android:launchMode="singleInstance"
android:screenOrientation="landscape"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|fontScale|uiMode|screenSize|smallestScreenSize"
android:windowSoftInputMode="stateUnspecified|adjustPan"

View File

@@ -285,6 +285,17 @@ public class MainActivity extends Activity {
}
_isPaused = false;
}
@Override
public void onWindowFocusChanged (boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus == false) {
synchronized(textInput) {
// Send 'SDLK_PAUSE' (to enter pause mode) to native code:
DemoRenderer.nativeTextInput( 19, 19 );
}
}
}
public boolean isPaused()
{
@@ -307,6 +318,12 @@ public class MainActivity extends Activity {
System.exit(0);
}
public void togglePlainAndroidSoftKeyboardInput()
{
InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
public void showScreenKeyboard(final String oldText, boolean sendBackspace)
{
if(Globals.CompatibilityHacksTextInputEmulatesHwKeyboard)

View File

@@ -524,6 +524,21 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer
return 1;
}
public void togglePlainAndroidSoftKeyboardInput() // Called from native code
{
class Callback implements Runnable
{
public MainActivity parent;
public void run()
{
parent.togglePlainAndroidSoftKeyboardInput();
}
}
Callback cb = new Callback();
cb.parent = context;
context.runOnUiThread(cb);
}
public void showScreenKeyboard(final String oldText, int sendBackspace) // Called from native code
{
class Callback implements Runnable

View File

@@ -15,6 +15,7 @@ SdlVideoResize=y
SdlVideoResizeKeepAspect=n
CompatibilityHacks=n
CompatibilityHacksStaticInit=n
CompatibilityHacksTextInputEmulatesHwKeyboard=n
AppUsesMouse=y
AppNeedsTwoButtonMouse=n
ShowMouseCursor=n

View File

@@ -101,8 +101,13 @@ void jukebox( void )
const int x = VGAScreen->w / 2;
#ifdef ANDROID
draw_font_hv(VGAScreen, x, 170, "Press the Back button to quit the jukebox.", small_font, centered, 1, 0);
draw_font_hv(VGAScreen, x, 180, "Touch to change the song being played.", small_font, centered, 1, 0);
#else
draw_font_hv(VGAScreen, x, 170, "Press ESC to quit the jukebox.", small_font, centered, 1, 0);
draw_font_hv(VGAScreen, x, 180, "Arrow keys change the song being played.", small_font, centered, 1, 0);
#endif
draw_font_hv(VGAScreen, x, 190, buffer, small_font, centered, 1, 4);
}
@@ -113,10 +118,22 @@ void jukebox( void )
wait_delay();
#ifdef ANDROID
if (mousedown)
{
wait_noinput(true, true, true);
newkey = true;
if (mouse_x < 160)
lastkey_sym = SDLK_LEFT;
else
lastkey_sym = SDLK_RIGHT;
}
#else
// quit on mouse click
Uint16 x, y;
if (JE_mousePosition(&x, &y) > 0)
trigger_quit = true;
#endif
if (newkey)
{

View File

@@ -16,6 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "joystick.h"
#include "keyboard.h"
#include "network.h"
@@ -128,6 +129,10 @@ void set_mouse_position( int x, int y )
}
}
JE_boolean handle_pause_key = true;
void JE_pauseGame( void );
void service_SDL_events( JE_boolean clear_new )
{
SDL_Event ev;
@@ -144,6 +149,14 @@ void service_SDL_events( JE_boolean clear_new )
mouse_y = ev.motion.y * vga_height / scalers[scaler].height;
break;
case SDL_KEYDOWN:
if (handle_pause_key && ev.key.keysym.sym == SDLK_PAUSE)
{
JE_boolean superPause_save = superPause;
superPause = true;
JE_pauseGame();
superPause = superPause_save;
break;
}
if (ev.key.keysym.mod & KMOD_CTRL)
{
/* <ctrl><bksp> emergency kill */

View File

@@ -50,6 +50,16 @@ void set_mouse_position( int x, int y );
void service_SDL_events( JE_boolean clear_new );
extern JE_boolean handle_pause_key;
static inline
void service_SDL_events_ignore_pause( JE_boolean clear_new )
{
handle_pause_key = false;
service_SDL_events( clear_new );
handle_pause_key = true;
}
void sleep_game( void );
void JE_clearKeyboard( void );

View File

@@ -48,6 +48,8 @@
#include "vga256d.h"
#include "video.h"
#include "SDL_screenkeyboard.h"
#include <assert.h>
#include <ctype.h>
@@ -1167,22 +1169,21 @@ void JE_doInGameSetup( void )
JE_boolean JE_inGameSetup( void )
{
const JE_byte menu_top = 20, menu_spacing = 20;
const JE_shortint menu_items = 6;
JE_shortint sel = 1;
SDL_Surface *temp_surface = VGAScreen;
VGAScreen = VGAScreenSeg; /* side-effect of game_screen */
JE_boolean returnvalue = false;
const JE_byte help[6] /* [1..6] */ = {15, 15, 28, 29, 26, 27};
JE_byte sel;
JE_boolean quit;
JE_boolean quit = false;
bool first = true;
//tempScreenSeg = VGAScreenSeg; /* <MXD> ? should work as VGAScreen */
quit = false;
sel = 1;
JE_barShade(VGAScreen, 3, 13, 217, 137); /*Main Box*/
JE_barShade(VGAScreen, 5, 15, 215, 135);
@@ -1194,9 +1195,9 @@ JE_boolean JE_inGameSetup( void )
{
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
for (x = 0; x < 6; x++)
for (x = 0; x < menu_items; x++)
{
JE_outTextAdjust(VGAScreen, 10, (x + 1) * 20, inGameText[x], 15, ((sel == x+1) << 1) - 4, SMALL_FONT_SHAPES, true);
JE_outTextAdjust(VGAScreen, 10, menu_top + x*menu_spacing, inGameText[x], 15, ((sel == x+1) << 1) - 4, SMALL_FONT_SHAPES, true);
}
JE_outTextAdjust(VGAScreen, 120, 3 * 20, detailLevel[processorType-1], 15, ((sel == 3) << 1) - 4, SMALL_FONT_SHAPES, true);
@@ -1204,11 +1205,14 @@ JE_boolean JE_inGameSetup( void )
JE_outTextAdjust(VGAScreen, 10, 147, mainMenuHelp[help[sel-1]-1], 14, 6, TINY_FONT, true);
JE_barDrawShadow(VGAScreen, 120, 20, 1, 16, tyrMusicVolume / 12, 3, 13);
JE_barDrawShadow(VGAScreen, 120, 40, 1, 16, fxVolume / 12, 3, 13);
JE_barDrawShadow(VGAScreen, 120, 20, 1, music_disabled ? 12 : 16, tyrMusicVolume / 12, 3, 13);
JE_barDrawShadow(VGAScreen, 120, 40, 1, samples_disabled ? 12 : 16, fxVolume / 12, 3, 13);
JE_showVGA();
if (mousedown && sel >= 3 && sel <= 4)
wait_noinput(true, true, true);
if (first)
{
first = false;
@@ -1218,6 +1222,22 @@ JE_boolean JE_inGameSetup( void )
tempW = 0;
JE_textMenuWait(&tempW, true);
sel--;
if (select_menuitem_by_touch(menu_top, menu_spacing, menu_items, &sel))
{
sel++;
continue;
}
sel++;
if (mousedown && sel < 5)
{
if (lastmouse_x > 160)
lastkey_sym = SDLK_RIGHT;
else
lastkey_sym = SDLK_LEFT;
}
if (inputDetected)
{
switch (lastkey_sym)
@@ -2383,7 +2403,9 @@ void JE_operation( JE_byte slot )
wait_noinput(false, true, false);
JE_barShade(VGAScreen, 65, 55, 255, 155);
#ifdef ANDROID
SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
#endif
bool quit = false;
while (!quit)
{
@@ -2495,6 +2517,9 @@ void JE_operation( JE_byte slot )
case SDLK_RETURN:
case SDLK_SPACE:
quit = true;
#ifdef ANDROID
SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
#endif
JE_saveGame(slot, stemp);
JE_playSampleNum(S_SELECT);
break;
@@ -2503,8 +2528,9 @@ void JE_operation( JE_byte slot )
}
}
}
#ifndef ANDROID // This hangs on input stuff with touch-emulated mouse:
wait_noinput(false, true, false);
#endif
}
void JE_inGameDisplays( void )
@@ -2761,7 +2787,7 @@ void JE_mainKeyboardInput( void )
}
/* pause game */
pause_pressed = pause_pressed || keysactive[SDLK_p];
pause_pressed = pause_pressed || keysactive[SDLK_p] || keysactive[SDLK_PAUSE];
/* in-game setup */
ingamemenu_pressed = ingamemenu_pressed || keysactive[SDLK_ESCAPE];
@@ -2851,6 +2877,14 @@ void JE_pauseGame( void )
{
JE_boolean done = false;
JE_word mouseX, mouseY;
#ifdef ANDROID
bool saved_music_disabled = music_disabled, saved_samples_disabled = samples_disabled;
music_disabled = samples_disabled = true;
SDL_ANDROID_PauseAudioPlayback();
#else
set_volume(tyrMusicVolume / 2, fxVolume);
#endif
//tempScreenSeg = VGAScreenSeg; // sega000
if (!superPause)
@@ -2861,8 +2895,6 @@ void JE_pauseGame( void )
JE_showVGA();
}
set_volume(tyrMusicVolume / 2, fxVolume);
if (isNetworkGame)
{
network_prepare(PACKET_GAME_PAUSE);
@@ -2893,6 +2925,7 @@ void JE_pauseGame( void )
push_joysticks_as_keyboard();
service_SDL_events(true);
JE_showVGA();
if ((newkey && lastkey_sym != SDLK_LCTRL && lastkey_sym != SDLK_RCTRL && lastkey_sym != SDLK_LALT && lastkey_sym != SDLK_RALT)
|| JE_mousePosition(&mouseX, &mouseY) > 0)
@@ -2916,6 +2949,8 @@ void JE_pauseGame( void )
done = true;
}
}
else
SDL_Delay(300);
wait_delay();
} while (!done);
@@ -2931,7 +2966,13 @@ void JE_pauseGame( void )
}
}
#ifdef ANDROID
music_disabled = saved_music_disabled;
samples_disabled = saved_samples_disabled;
SDL_ANDROID_ResumeAudioPlayback();
#else
set_volume(tyrMusicVolume, fxVolume);
#endif
//skipStarShowVGA = true;
}
@@ -3150,10 +3191,10 @@ redo:
}
}
service_SDL_events(false);
service_SDL_events_ignore_pause(false);
/* mouse input */
/*
/* mouse input algorithm which is not suitable for touch-emulated mouse */
#ifndef ANDROID
if ((inputDevice == 0 || inputDevice == 2) && has_mouse)
{
button[0] |= mouse_pressed[0];
@@ -3172,9 +3213,7 @@ redo:
set_mouse_position(159, 100);
}
}
*/
#endif
/* keyboard input */
if ((inputDevice == 0 || inputDevice == 1 || inputDevice == 2) && !play_demo)
{

View File

@@ -31,12 +31,33 @@
char episode_name[6][31], difficulty_name[7][21], gameplay_name[5][26];
bool
select_menuitem_by_touch(JE_byte menu_top, JE_byte menu_spacing, JE_shortint menu_item_count, JE_shortint *current_item)
{
if (!mousedown)
return false;
char new_item = (mouse_y - menu_top) / menu_spacing;
if (mouse_y >= menu_top && mouse_y < menu_top + (menu_item_count+1) * menu_spacing)
{
if (new_item == *current_item)
return false;
JE_playSampleNum(S_CURSOR);
*current_item = new_item;
}
return true;
}
bool select_gameplay( void )
{
JE_loadPic(VGAScreen, 2, false);
JE_dString(VGAScreen, JE_fontCenter(gameplay_name[0], FONT_SHAPES), 20, gameplay_name[0], FONT_SHAPES);
int gameplay = 1,
const JE_byte menu_top = 30, menu_spacing = 24;
JE_shortint gameplay = 1,
gameplay_max = 4;
bool fade_in = true;
@@ -44,7 +65,7 @@ bool select_gameplay( void )
{
for (int i = 1; i <= gameplay_max; i++)
{
JE_outTextAdjust(VGAScreen, JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * 24 + 30, gameplay_name[i], 15, - 4 + (i == gameplay ? 2 : 0) - (i == 4 ? 4 : 0), SMALL_FONT_SHAPES, true);
JE_outTextAdjust(VGAScreen, JE_fontCenter(gameplay_name[i], SMALL_FONT_SHAPES), i * menu_spacing + menu_top, gameplay_name[i], 15, - 4 + (i == gameplay ? 2 : 0) - (i == 4 ? 4 : 0), SMALL_FONT_SHAPES, true);
}
JE_showVGA();
@@ -57,6 +78,9 @@ bool select_gameplay( void )
JE_word temp = 0;
JE_textMenuWait(&temp, false);
if (select_menuitem_by_touch(menu_top, menu_spacing, gameplay_max, &gameplay))
continue;
if (newkey)
{
switch (lastkey_sym)
@@ -115,7 +139,8 @@ bool select_episode( void )
JE_loadPic(VGAScreen, 2, false);
JE_dString(VGAScreen, JE_fontCenter(episode_name[0], FONT_SHAPES), 20, episode_name[0], FONT_SHAPES);
int episode = 1,
const JE_byte menu_top = 20, menu_spacing = 30;
JE_shortint episode = 1,
episode_max = EPISODE_MAX - 1;
bool fade_in = true;
@@ -123,7 +148,7 @@ bool select_episode( void )
{
for (int i = 1; i <= episode_max; i++)
{
JE_outTextAdjust(VGAScreen, 20, i * 30 + 20, episode_name[i], 15, -4 + (i == episode ? 2 : 0) - (!episodeAvail[i - 1] ? 4 : 0), SMALL_FONT_SHAPES, true);
JE_outTextAdjust(VGAScreen, 20, i * menu_spacing + menu_top, episode_name[i], 15, -4 + (i == episode ? 2 : 0) - (!episodeAvail[i - 1] ? 4 : 0), SMALL_FONT_SHAPES, true);
}
JE_showVGA();
@@ -136,6 +161,9 @@ bool select_episode( void )
JE_word temp = 0;
JE_textMenuWait(&temp, false);
if (select_menuitem_by_touch(menu_top, menu_spacing, episode_max, &episode))
continue;
if (newkey)
{
switch (lastkey_sym)
@@ -192,15 +220,16 @@ bool select_difficulty( void )
JE_loadPic(VGAScreen, 2, false);
JE_dString(VGAScreen, JE_fontCenter(difficulty_name[0], FONT_SHAPES), 20, difficulty_name[0], FONT_SHAPES);
const JE_byte menu_top = 30, menu_spacing = 24;
difficultyLevel = 2;
int difficulty_max = 3;
JE_shortint difficulty_max = 3;
bool fade_in = true;
for (; ; )
{
for (int i = 1; i <= difficulty_max; i++)
{
JE_outTextAdjust(VGAScreen, JE_fontCenter(difficulty_name[i], SMALL_FONT_SHAPES), i * 24 + 30, difficulty_name[i], 15, -4 + (i == difficultyLevel ? 2 : 0), SMALL_FONT_SHAPES, true);
JE_outTextAdjust(VGAScreen, JE_fontCenter(difficulty_name[i], SMALL_FONT_SHAPES), i * menu_spacing + menu_top, difficulty_name[i], 15, -4 + (i == difficultyLevel ? 2 : 0), SMALL_FONT_SHAPES, true);
}
JE_showVGA();
@@ -213,6 +242,9 @@ bool select_difficulty( void )
JE_word temp = 0;
JE_textMenuWait(&temp, false);
if (select_menuitem_by_touch(menu_top, menu_spacing, difficulty_max, &difficultyLevel))
continue;
if (SDL_GetModState() & KMOD_SHIFT)
{
if ((difficulty_max < 4 && keysactive[SDLK_g]) ||

View File

@@ -26,6 +26,7 @@ extern char episode_name[6][31], difficulty_name[7][21], gameplay_name[5][26];
bool select_gameplay( void );
bool select_episode( void );
bool select_difficulty( void );
bool select_menuitem_by_touch(JE_byte menu_top, JE_byte menu_spacing, JE_shortint menu_item_count, JE_shortint *current_item);
#endif /* MENUS_H */

View File

@@ -28,6 +28,7 @@
#include "jukebox.h"
#include "keyboard.h"
#include "loudness.h"
#include "menus.h"
#include "mainint.h"
#include "mtrand.h"
#include "musmast.h"
@@ -61,7 +62,9 @@ const char *opentyrian_str = "OpenTyrian",
const char *opentyrian_menu_items[] =
{
"About OpenTyrian",
#ifndef ANDROID
"Toggle Fullscreen",
#endif
"Scaler: None",
"Jukebox",
#ifdef ANDROID
@@ -70,6 +73,15 @@ const char *opentyrian_menu_items[] =
"Return to Main Menu"
};
#ifndef ANDROID
const int menu_item_scaler = 2;
const int menu_item_jukebox = 3;
#else
const int menu_item_scaler = 1;
const int menu_item_jukebox = 2;
const int menu_item_destruct = 3;
#endif
/* zero-terminated strncpy */
char *strnztcpy( char *to, const char *from, size_t count )
{
@@ -79,7 +91,8 @@ char *strnztcpy( char *to, const char *from, size_t count )
void opentyrian_menu( void )
{
int sel = 0;
const JE_byte menu_top = 36, menu_spacing = 20;
JE_shortint sel = 0;
const int maxSel = COUNTOF(opentyrian_menu_items) - 1;
bool quit = false, fade_in = true;
@@ -105,13 +118,16 @@ void opentyrian_menu( void )
const char *text = opentyrian_menu_items[i];
char buffer[100];
if (i == 2) /* Scaler */
if (i == menu_item_scaler) /* Scaler */
{
snprintf(buffer, sizeof(buffer), "Scaler: %s", scalers[temp_scaler].name);
text = buffer;
}
draw_font_hv_shadow(VGAScreen, VGAScreen->w / 2, (i != maxSel) ? i * 16 + 32 : 118, text, normal_font, centered, 15, (i != sel) ? -4 : -2, false, 2);
// Destruct is not adapted for touch input, so we show it only if keyboard is used:
if (i == menu_item_destruct && (mousedown || lastkey_sym == SDLK_ESCAPE))
continue;
draw_font_hv_shadow(VGAScreen, VGAScreen->w / 2, (i != maxSel) ? i * menu_spacing + menu_top : 118, text, normal_font, centered, 15, (i != sel) ? -4 : -2, false, 2);
}
JE_showVGA();
@@ -126,6 +142,9 @@ void opentyrian_menu( void )
tempW = 0;
JE_textMenuWait(&tempW, false);
if (select_menuitem_by_touch(menu_top, menu_spacing, maxSel, &sel))
continue;
if (newkey)
{
switch (lastkey_sym)
@@ -149,7 +168,7 @@ void opentyrian_menu( void )
JE_playSampleNum(S_CURSOR);
break;
case SDLK_LEFT:
if (sel == 2)
if (sel == menu_item_scaler)
{
do
{
@@ -162,7 +181,10 @@ void opentyrian_menu( void )
}
break;
case SDLK_RIGHT:
if (sel == 2)
#ifdef ANDROID
case SDLK_RETURN:
#endif
if (sel == menu_item_scaler)
{
do
{
@@ -173,8 +195,10 @@ void opentyrian_menu( void )
while (!can_init_scaler(temp_scaler, fullscreen_enabled));
JE_playSampleNum(S_CURSOR);
}
#ifndef ANDROID
break;
case SDLK_RETURN:
#endif
case SDLK_SPACE:
switch (sel)
{
@@ -187,6 +211,7 @@ void opentyrian_menu( void )
JE_showVGA();
fade_in = true;
break;
#ifndef ANDROID
case 1: /* Fullscreen */
JE_playSampleNum(S_SELECT);
@@ -198,7 +223,8 @@ void opentyrian_menu( void )
}
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
break;
case 2: /* Scaler */
#endif
case menu_item_scaler: /* Scaler */
JE_playSampleNum(S_SELECT);
if (scaler != temp_scaler)
@@ -212,7 +238,7 @@ void opentyrian_menu( void )
set_palette(colors, 0, 255); // for switching between 8 bpp scalers
}
break;
case 3: /* Jukebox */
case menu_item_jukebox: /* Jukebox */
JE_playSampleNum(S_SELECT);
fade_black(10);
@@ -223,7 +249,7 @@ void opentyrian_menu( void )
fade_in = true;
break;
#ifdef ANDROID
case 4: /* Destruct */
case menu_item_destruct: /* Destruct */
JE_playSampleNum(S_SELECT);
loadDestruct = true;
fade_black(10);

View File

@@ -31,7 +31,9 @@
void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
{
#ifdef MENU_SELECT_BY_MOUSE_MOVE
set_mouse_position(160, 100);
#endif
do
{
@@ -58,6 +60,11 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
if (has_mouse && input_grabbed)
{
#ifdef MENU_SELECT_BY_MOUSE_MOVE
/* Whacky hack which changes menu selecton based on
* relative mouse movement does not work with touch
* when a touch tiggers a mousedown which gets mapped
* to SDLK_RETURN above */
if (abs(mouse_y - 100) > 10)
{
inputDetected = true;
@@ -80,6 +87,7 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
}
newkey = true;
}
#endif
}
NETWORK_KEEP_ALIVE();

View File

@@ -2377,7 +2377,7 @@ draw_player_shot_loop_end:
}
else // input handling for pausing, menu, cheats
{
service_SDL_events(false);
service_SDL_events_ignore_pause(false);
if (newkey)
{
@@ -3352,13 +3352,18 @@ new_game:
bool JE_titleScreen( JE_boolean animate )
{
bool quit = false;
const int menunum = 7;
#ifdef ANDROID
const JE_shortint menunum = 5; // Quit not possible, Android manages life cycle!
const JE_byte menu_top = 96, menu_spacing = 16;
#else
const JE_shortint menunum = 6;
const JE_byte menu_top = 96, menu_spacing = 14;
#endif
unsigned int arcade_code_i[SA_ENGAGE] = { 0 };
JE_word waitForDemo;
JE_byte menu = 0;
JE_shortint menu = 0;
JE_boolean redraw = true,
fadeIn = false;
@@ -3505,9 +3510,9 @@ bool JE_titleScreen( JE_boolean animate )
strcpy(menuText[4], opentyrian_str); // OpenTyrian override
/* Draw Menu Text on Screen */
for (int i = 0; i < menunum; ++i)
for (int i = 0; i <= menunum; ++i)
{
int x = VGAScreen->w / 2, y = 104 + i * 13;
int x = VGAScreen->w / 2, y = menu_top + i * menu_spacing;
draw_font_hv(VGAScreen, x - 1, y - 1, menuText[i], normal_font, centered, 15, -10);
draw_font_hv(VGAScreen, x + 1, y + 1, menuText[i], normal_font, centered, 15, -10);
@@ -3527,7 +3532,7 @@ bool JE_titleScreen( JE_boolean animate )
memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h);
// highlight selected menu item
draw_font_hv(VGAScreen, VGAScreen->w / 2, 104 + menu * 13, menuText[menu], normal_font, centered, 15, -1);
draw_font_hv(VGAScreen, VGAScreen->w / 2, menu_top + menu * menu_spacing, menuText[menu], normal_font, centered, 15, -1);
JE_showVGA();
@@ -3543,6 +3548,8 @@ bool JE_titleScreen( JE_boolean animate )
if (waitForDemo == 1)
play_demo = true;
if (select_menuitem_by_touch(menu_top, menu_spacing, menunum, &menu))
continue;
if (newkey)
{
switch (lastkey_sym)

View File

@@ -105,6 +105,9 @@ extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardTextInput(char * textBu
/* Whether user redefined on-screen keyboard layout via SDL menu, app should not enforce it's own layout in that case */
extern DECLSPEC int SDLCALL SDL_ANDROID_GetScreenKeyboardRedefinedByUser();
/* Show only the bare Android on-screen keyboard without any text input field */
extern DECLSPEC void SDLCALL SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
#ifdef __cplusplus
}
#endif

View File

@@ -61,6 +61,7 @@ static jclass JavaRendererClass = NULL;
static jobject JavaRenderer = NULL;
static jmethodID JavaSwapBuffers = NULL;
static jmethodID JavaShowScreenKeyboard = NULL;
static jmethodID JavaTogglePlainAndroidSoftKeyboardInput = NULL;
static int glContextLost = 0;
static int showScreenKeyboardDeferred = 0;
static const char * showScreenKeyboardOldText = "";
@@ -225,6 +226,11 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextRecreated) ( JNIEnv* env, jobject
#endif
}
void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput()
{
(*JavaEnv)->CallVoidMethod( JavaEnv, JavaRenderer, JavaTogglePlainAndroidSoftKeyboardInput );
}
volatile static textInputFinished = 0;
void SDL_ANDROID_TextInputFinished()
{
@@ -283,6 +289,7 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeInitJavaCallbacks) ( JNIEnv* env, jobject t
JavaRendererClass = (*JavaEnv)->GetObjectClass(JavaEnv, thiz);
JavaSwapBuffers = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "swapBuffers", "()I");
JavaShowScreenKeyboard = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "showScreenKeyboard", "(Ljava/lang/String;I)V");
JavaTogglePlainAndroidSoftKeyboardInput = (*JavaEnv)->GetMethodID(JavaEnv, JavaRendererClass, "togglePlainAndroidSoftKeyboardInput", "()V");
ANDROID_InitOSKeymap();
}

View File

@@ -68,6 +68,7 @@ extern void SDL_ANDROID_ProcessDeferredEvents();
extern void SDL_ANDROID_WarpMouse(int x, int y);
extern void SDL_ANDROID_DrawMouseCursor(int x, int y, int size, int alpha);
extern void SDL_ANDROID_DrawMouseCursorIfNeeded();
extern void SDL_ANDROID_CallJavaTogglePlainAndroidSoftKeyboardInput();
#if SDL_VERSION_ATLEAST(1,3,0)