Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added more options to redefine common keys in AppSettings

  • Loading branch information...
commit c6ee7cd0fee5f5339dbef3568c43ab60cd10805a 1 parent 831ee2d
@pelya pelya authored
View
24 alienblaster/ChangeAppSettings.sh
@@ -48,7 +48,7 @@ if [ -n "$var" ] ; then
NeedDepthBuffer="$var"
fi
-echo -n "\nApplication uses mouse (y) or (n), if (n) the screen touch will be mapped to Enter ($AppUsesMouse): "
+echo -n "\nApplication uses mouse (y) or (n) or (KEYCODE), if (KEYCODE) the screen touch will be mapped to KEYCODE ($AppUsesMouse): "
read var
if [ -n "$var" ] ; then
AppUsesMouse="$var"
@@ -66,6 +66,12 @@ if [ -n "$var" ] ; then
AppUsesJoystick="$var"
fi
+echo -n "\nRedefine common keys - MENU SEARCH VOLUMEUP VOLUMEDOWN ($RedefinedKeys): "
+read var
+if [ -n "$var" ] ; then
+ RedefinedKeys="$var"
+fi
+
echo -n "\nEnable multi-ABI binary, with hardware FPU support - \nit will also work on old devices, but .apk size is 2x bigger (y) or (n) ($MultiABI): "
read var
if [ -n "$var" ] ; then
@@ -131,6 +137,7 @@ echo NeedDepthBuffer=$NeedDepthBuffer >> AppSettings.cfg
echo AppUsesMouse=$AppUsesMouse >> AppSettings.cfg
echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AppSettings.cfg
echo AppUsesJoystick=$AppUsesJoystick >> AppSettings.cfg
+echo RedefinedKeys=\"$RedefinedKeys\" >> AppSettings.cfg
echo MultiABI=$MultiABI >> AppSettings.cfg
echo AppVersionCode=$AppVersionCode >> AppSettings.cfg
echo AppVersionName=\"$AppVersionName\" >> AppSettings.cfg
@@ -159,9 +166,13 @@ if [ "$NeedDepthBuffer" = "y" ] ; then
else
NeedDepthBuffer=false
fi
+MouseKeycode=UNKNOWN
if [ "$AppUsesMouse" = "y" ] ; then
AppUsesMouse=true
+elif [ "$AppUsesMouse" = "n" ] ; then
+ AppUsesMouse=false
else
+ MouseKeycode=$AppUsesMouse
AppUsesMouse=false
fi
if [ "$AppNeedsArrowKeys" = "y" ] ; then
@@ -175,6 +186,14 @@ else
AppUsesJoystick=false
fi
+
+RedefinedKeycodes="-DSDL_ANDROID_KEYCODE_MOUSE=$MouseKeycode"
+KEY2=0
+for KEY in $RedefinedKeys; do
+ RedefinedKeycodes="$RedefinedKeycodes -DSDL_ANDROID_KEYCODE_$KEY2=$KEY"
+ KEY2=`expr $KEY2 '+' 1`
+done
+
if [ "$MultiABI" = "y" ] ; then
MultiABI="armeabi armeabi-v7a"
else
@@ -230,7 +249,8 @@ cat project/jni/Android.mk | \
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
sed "s^SDL_VIDEO_RENDER_RESIZE := .*^SDL_VIDEO_RENDER_RESIZE := $SdlVideoResize^" | \
sed "s^COMPILED_LIBRARIES := .*^COMPILED_LIBRARIES := $CompiledLibraries^" |
- sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" > \
+ sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
+ sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes^" > \
project/jni/Android.mk.1
if [ -n "`diff -w project/jni/Android.mk.1 project/jni/Android.mk`" ] ; then
mv -f project/jni/Android.mk.1 project/jni/Android.mk
View
1  alienblaster/project/jni/Android.mk
@@ -26,6 +26,7 @@ SDL_VIDEO_RENDER_RESIZE := 1
COMPILED_LIBRARIES := sdl_net
APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2
+SDL_ADDITIONAL_CFLAGS := -DSDL_ANDROID_KEYCODE_MOUSE=SPACE -DSDL_ANDROID_KEYCODE_0=LCTRL -DSDL_ANDROID_KEYCODE_1=LALT -DSDL_ANDROID_KEYCODE_2=RETURN -DSDL_ANDROID_KEYCODE_3=RETURN
# If SDL_Mixer should link to libMAD
SDL_MIXER_USE_LIBMAD :=
View
3  alienblaster/project/jni/application/opentyrian/AppSettings.cfg
@@ -5,9 +5,10 @@ ScreenOrientation=h
AppDataDownloadUrl="http://sites.google.com/site/xpelyax/Home/tyrian21-data.zip?attredirects=0&d=1|http://sitesproxy.goapk.com/site/xpelyax/Home/tyrian21-data.zip"
SdlVideoResize=y
NeedDepthBuffer=n
-AppUsesMouse=n
+AppUsesMouse=SPACE
AppNeedsArrowKeys=y
AppUsesJoystick=n
+RedefinedKeys="LCTRL LALT RETURN RETURN"
MultiABI=n
AppVersionCode=2101
AppVersionName="2.1.01"
View
2  alienblaster/project/jni/application/opentyrian/src/destruct.cpp
@@ -836,7 +836,7 @@ enum de_mode_t JE_modeSelect( void )
mode = MODE_NONE; /* User is quitting, return failure */
break;
}
- if (keysactive[SDLK_RETURN])
+ if (keysactive[SDLK_RETURN] || keysactive[SDLK_SPACE])
{
break; /* User has selected, return choice */
}
View
13 alienblaster/project/jni/application/opentyrian/src/mainint.cpp
@@ -288,9 +288,9 @@ void JE_helpSystem( JE_byte startTopic )
break;
}
}
- } while (!(lastkey_sym == SDLK_ESCAPE || lastkey_sym == SDLK_RETURN));
+ } while (!(lastkey_sym == SDLK_ESCAPE || lastkey_sym == SDLK_RETURN || lastkey_sym == SDLK_SPACE));
- if (lastkey_sym == SDLK_RETURN)
+ if (lastkey_sym == SDLK_RETURN || lastkey_sym == SDLK_SPACE)
{
page = topicStart[menu-1];
JE_playSampleNum(S_CLICK);
@@ -655,6 +655,7 @@ void JE_loadScreen( void )
}
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
if (sel < max)
{
if (saveFiles[sel - 1].level > 0)
@@ -994,6 +995,7 @@ void JE_highScoreScreen( void )
switch (lastkey_sym)
{
case SDLK_RETURN:
+ case SDLK_SPACE:
case SDLK_ESCAPE:
quit = true;
break;
@@ -1215,6 +1217,7 @@ JE_boolean JE_inGameSetup( void )
switch (lastkey_sym)
{
case SDLK_RETURN:
+ case SDLK_SPACE:
JE_playSampleNum(S_SELECT);
switch (sel)
{
@@ -1597,7 +1600,7 @@ void JE_highScoreCheck( void )
lastkey_char = toupper(lastkey_char);
switch(lastkey_char)
{
- case ' ':
+ //case ' ':
case '-':
case '.':
case ',':
@@ -1640,6 +1643,7 @@ void JE_highScoreCheck( void )
cancel = true;
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
quit = true;
break;
}
@@ -2428,7 +2432,7 @@ void JE_operation( JE_byte slot )
lastkey_char = toupper(lastkey_char);
switch (lastkey_char)
{
- case ' ':
+ //case ' ':
case '-':
case '.':
case ',':
@@ -2473,6 +2477,7 @@ void JE_operation( JE_byte slot )
JE_playSampleNum(S_SPRING);
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
quit = true;
JE_saveGame(slot, stemp);
JE_playSampleNum(S_SELECT);
View
3  alienblaster/project/jni/application/opentyrian/src/menus.cpp
@@ -79,6 +79,7 @@ bool select_gameplay( void )
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
if (gameplay == 4)
{
JE_playSampleNum(S_SPRING);
@@ -155,6 +156,7 @@ bool select_episode( void )
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
if (!episodeAvail[episode - 1])
{
JE_playSampleNum(S_SPRING);
@@ -240,6 +242,7 @@ bool select_difficulty( void )
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
JE_playSampleNum(S_SELECT);
/* fading handled elsewhere
fade_black(10); */
View
6 alienblaster/project/jni/application/opentyrian/src/mouse.cpp
@@ -22,12 +22,16 @@
#include "video.h"
#include "vga256d.h"
-#if defined(TARGET_GP2X) || defined(TARGET_DINGUX) || defined(ANDROID)
+#if defined(TARGET_GP2X) || defined(TARGET_DINGUX)
bool has_mouse = false;
#else
bool has_mouse = true;
#endif
+#if defined(ANDROID)
+bool mouse_has_three_buttons = false;
+#else
bool mouse_has_three_buttons = true;
+#endif
JE_word lastMouseX, lastMouseY;
JE_byte mouseCursor;
View
1  alienblaster/project/jni/application/opentyrian/src/opentyr.cpp
@@ -168,6 +168,7 @@ void opentyrian_menu( void )
}
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
switch (sel)
{
case 0: /* About */
View
1  alienblaster/project/jni/application/opentyrian/src/tyrian2.cpp
@@ -3678,6 +3678,7 @@ bool JE_titleScreen( JE_boolean animate )
quit = true;
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
JE_playSampleNum(S_SELECT);
switch (menu)
{
View
1  alienblaster/project/jni/application/opentyrian/src/xmas.cpp
@@ -81,6 +81,7 @@ bool xmas_prompt( void )
break;
case SDLK_RETURN:
+ case SDLK_SPACE:
decided = true;
break;
case SDLK_ESCAPE:
View
2  alienblaster/project/sdl/sdl-1.2/src/video/android/SDL_androidvideo-1.2.c
@@ -290,7 +290,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
SDL_free(current->pixels);
current->pixels = NULL;
SDL_OutOfMemory();
- return(-1);
+ return(NULL);
}
}
}
View
3  alienblaster/project/sdl/sdl-1.3/Android.mk
@@ -12,7 +12,8 @@ LOCAL_CFLAGS := -I$(LOCAL_PATH)/include \
-DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) \
-DSDL_CURDIR_PATH=\"$(SDL_CURDIR_PATH)\" \
-DSDL_TRACKBALL_KEYUP_DELAY=$(SDL_TRACKBALL_KEYUP_DELAY) \
- -DSDL_VIDEO_RENDER_RESIZE=$(SDL_VIDEO_RENDER_RESIZE)
+ -DSDL_VIDEO_RENDER_RESIZE=$(SDL_VIDEO_RENDER_RESIZE) \
+ $(SDL_ADDITIONAL_CFLAGS)
SDL_SRCS := \
View
67 alienblaster/project/sdl/sdl-1.3/src/video/android/SDL_androidinput.c
@@ -76,6 +76,11 @@ static SDL_scancode TranslateKey(int scancode, SDL_keysym *keysym)
return keymap[scancode];
}
+static SDL_scancode GetKeysym(SDL_scancode scancode, SDL_keysym *keysym)
+{
+ return scancode;
+}
+
#define SDL_SendKeyboardKey(X, Y) SDL_SendKeyboardKey(X, Y, SDL_FALSE)
#else
@@ -150,8 +155,28 @@ static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
return(keysym);
}
+static SDL_keysym *GetKeysym(SDLKey scancode, SDL_keysym *keysym)
+{
+ /* Sanity check */
+
+ /* Set the keysym information */
+ keysym->scancode = scancode;
+ keysym->sym = scancode;
+ keysym->mod = KMOD_NONE;
+
+ /* If UNICODE is on, get the UNICODE value for the key */
+ keysym->unicode = 0;
+ if ( SDL_TranslateUNICODE ) {
+ /* Populate the unicode field with the ASCII value */
+ keysym->unicode = scancode;
+ }
+ return(keysym);
+}
+
#endif
+#define SDL_KEY_VAL(X) X
+
static int isTrackballUsed = 0;
static int isMouseUsed = 0;
static int isJoystickUsed = 0;
@@ -164,9 +189,13 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv* env, jobject thiz, j
{
if( !isMouseUsed )
{
+ #ifndef SDL_ANDROID_KEYCODE_MOUSE
+ #define SDL_ANDROID_KEYCODE_MOUSE RETURN
+ #endif
SDL_keysym keysym;
- if( action != MOUSE_MOVE )
- SDL_SendKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, TranslateKey(KEYCODE_ENTER ,&keysym) );
+ if( action != MOUSE_MOVE && SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_MOUSE)) != SDL_KEY(UNKNOWN) )
+ SDL_SendKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, GetKeysym(SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_MOUSE)) ,&keysym) );
+ return;
}
#if SDL_VIDEO_RENDER_RESIZE
// Translate mouse coordinates
@@ -274,13 +303,28 @@ void ANDROID_InitOSKeymap()
keymap[KEYCODE_BACK] = SDL_KEY(ESCAPE);
- // HTC Evo has only two keys - Menu and Back, and all games require Enter. (Also Volume Up/Down, but they are hard to reach)
+#ifndef SDL_ANDROID_KEYCODE_0
+#define SDL_ANDROID_KEYCODE_0 LCTRL
+#define SDL_ANDROID_KEYCODE_1 END
+#define SDL_ANDROID_KEYCODE_2 PAGEUP
+#define SDL_ANDROID_KEYCODE_3 PAGEDOWN
+#endif
+
// TODO: make this configurable
- keymap[KEYCODE_MENU] = SDL_KEY(RETURN);
- if( !isMouseUsed )
- keymap[KEYCODE_MENU] = SDL_KEY(LCTRL);
+ keymap[KEYCODE_MENU] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0));
+
+ keymap[KEYCODE_SEARCH] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
+ keymap[KEYCODE_CALL] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
+ keymap[KEYCODE_DPAD_CENTER] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
+
+ //keymap[KEYCODE_CALL] = SDL_KEY(RCTRL);
+ //keymap[KEYCODE_DPAD_CENTER] = SDL_KEY(LALT);
+
+ keymap[KEYCODE_VOLUME_UP] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_2));
+ keymap[KEYCODE_VOLUME_DOWN] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_3));
+
+ keymap[KEYCODE_HOME] = SDL_KEY(HOME); // Cannot be used in application
- keymap[KEYCODE_CALL] = SDL_KEY(RCTRL);
keymap[KEYCODE_ENDCALL] = SDL_KEY(LSHIFT);
keymap[KEYCODE_CAMERA] = SDL_KEY(RSHIFT);
keymap[KEYCODE_POWER] = SDL_KEY(RALT);
@@ -302,16 +346,11 @@ void ANDROID_InitOSKeymap()
keymap[KEYCODE_DPAD_DOWN] = SDL_KEY(DOWN);
keymap[KEYCODE_DPAD_LEFT] = SDL_KEY(LEFT);
keymap[KEYCODE_DPAD_RIGHT] = SDL_KEY(RIGHT);
- keymap[KEYCODE_DPAD_CENTER] = SDL_KEY(LALT);
keymap[KEYCODE_SOFT_LEFT] = SDL_KEY(KP_4);
keymap[KEYCODE_SOFT_RIGHT] = SDL_KEY(KP_6);
keymap[KEYCODE_ENTER] = SDL_KEY(RETURN); //SDL_KEY(KP_ENTER);
- keymap[KEYCODE_VOLUME_UP] = SDL_KEY(PAGEUP);
- keymap[KEYCODE_VOLUME_DOWN] = SDL_KEY(PAGEDOWN);
- keymap[KEYCODE_SEARCH] = SDL_KEY(END);
- keymap[KEYCODE_HOME] = SDL_KEY(HOME);
keymap[KEYCODE_CLEAR] = SDL_KEY(BACKSPACE);
keymap[KEYCODE_A] = SDL_KEY(A);
@@ -368,8 +407,8 @@ void ANDROID_InitOSKeymap()
keymap[KEYCODE_SYM] = SDL_KEY(LGUI);
keymap[KEYCODE_NUM] = SDL_KEY(NUMLOCKCLEAR);
- keymap[KEYCODE_ALT_LEFT] = SDL_KEY(KP_7); // Used by orientation sensor code, do not change
- keymap[KEYCODE_ALT_RIGHT] = SDL_KEY(KP_9); // Used by orientation sensor code, do not change
+ keymap[KEYCODE_ALT_LEFT] = SDL_KEY(KP_7);
+ keymap[KEYCODE_ALT_RIGHT] = SDL_KEY(KP_9);
keymap[KEYCODE_SHIFT_LEFT] = SDL_KEY(F1);
keymap[KEYCODE_SHIFT_RIGHT] = SDL_KEY(F2);
Please sign in to comment.
Something went wrong with that request. Please try again.