Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added more options to redefine common keys in AppSettings

  • Loading branch information...
commit c6ee7cd0fee5f5339dbef3568c43ab60cd10805a 1 parent 831ee2d
Sergii Pylypenko authored
24  alienblaster/ChangeAppSettings.sh
@@ -48,7 +48,7 @@ if [ -n "$var" ] ; then
48 48
 	NeedDepthBuffer="$var"
49 49
 fi
50 50
 
51  
-echo -n "\nApplication uses mouse (y) or (n), if (n) the screen touch will be mapped to Enter ($AppUsesMouse): "
  51
+echo -n "\nApplication uses mouse (y) or (n) or (KEYCODE), if (KEYCODE) the screen touch will be mapped to KEYCODE ($AppUsesMouse): "
52 52
 read var
53 53
 if [ -n "$var" ] ; then
54 54
 	AppUsesMouse="$var"
@@ -66,6 +66,12 @@ if [ -n "$var" ] ; then
66 66
 	AppUsesJoystick="$var"
67 67
 fi
68 68
 
  69
+echo -n "\nRedefine common keys - MENU SEARCH VOLUMEUP VOLUMEDOWN ($RedefinedKeys): "
  70
+read var
  71
+if [ -n "$var" ] ; then
  72
+	RedefinedKeys="$var"
  73
+fi
  74
+
69 75
 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): "
70 76
 read var
71 77
 if [ -n "$var" ] ; then
@@ -131,6 +137,7 @@ echo NeedDepthBuffer=$NeedDepthBuffer >> AppSettings.cfg
131 137
 echo AppUsesMouse=$AppUsesMouse >> AppSettings.cfg
132 138
 echo AppNeedsArrowKeys=$AppNeedsArrowKeys >> AppSettings.cfg
133 139
 echo AppUsesJoystick=$AppUsesJoystick >> AppSettings.cfg
  140
+echo RedefinedKeys=\"$RedefinedKeys\" >> AppSettings.cfg
134 141
 echo MultiABI=$MultiABI >> AppSettings.cfg
135 142
 echo AppVersionCode=$AppVersionCode >> AppSettings.cfg
136 143
 echo AppVersionName=\"$AppVersionName\" >> AppSettings.cfg
@@ -159,9 +166,13 @@ if [ "$NeedDepthBuffer" = "y" ] ; then
159 166
 else
160 167
 	NeedDepthBuffer=false
161 168
 fi
  169
+MouseKeycode=UNKNOWN
162 170
 if [ "$AppUsesMouse" = "y" ] ; then
163 171
 	AppUsesMouse=true
  172
+elif [ "$AppUsesMouse" = "n" ] ; then
  173
+	AppUsesMouse=false
164 174
 else
  175
+	MouseKeycode=$AppUsesMouse
165 176
 	AppUsesMouse=false
166 177
 fi
167 178
 if [ "$AppNeedsArrowKeys" = "y" ] ; then
@@ -175,6 +186,14 @@ else
175 186
 	AppUsesJoystick=false
176 187
 fi
177 188
 
  189
+
  190
+RedefinedKeycodes="-DSDL_ANDROID_KEYCODE_MOUSE=$MouseKeycode"
  191
+KEY2=0
  192
+for KEY in $RedefinedKeys; do
  193
+	RedefinedKeycodes="$RedefinedKeycodes -DSDL_ANDROID_KEYCODE_$KEY2=$KEY"
  194
+	KEY2=`expr $KEY2 '+' 1`
  195
+done
  196
+
178 197
 if [ "$MultiABI" = "y" ] ; then
179 198
 	MultiABI="armeabi armeabi-v7a"
180 199
 else
@@ -230,7 +249,8 @@ cat project/jni/Android.mk | \
230 249
 	sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
231 250
 	sed "s^SDL_VIDEO_RENDER_RESIZE := .*^SDL_VIDEO_RENDER_RESIZE := $SdlVideoResize^" | \
232 251
 	sed "s^COMPILED_LIBRARIES := .*^COMPILED_LIBRARIES := $CompiledLibraries^" |
233  
-	sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" > \
  252
+	sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
  253
+	sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes^" > \
234 254
 	project/jni/Android.mk.1
235 255
 if [ -n "`diff -w project/jni/Android.mk.1 project/jni/Android.mk`" ] ; then
236 256
 	mv -f project/jni/Android.mk.1 project/jni/Android.mk
1  alienblaster/project/jni/Android.mk
@@ -26,6 +26,7 @@ SDL_VIDEO_RENDER_RESIZE := 1
26 26
 COMPILED_LIBRARIES := sdl_net
27 27
 
28 28
 APPLICATION_ADDITIONAL_CFLAGS := -finline-functions -O2
  29
+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
29 30
 
30 31
 # If SDL_Mixer should link to libMAD
31 32
 SDL_MIXER_USE_LIBMAD :=
3  alienblaster/project/jni/application/opentyrian/AppSettings.cfg
@@ -5,9 +5,10 @@ ScreenOrientation=h
5 5
 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"
6 6
 SdlVideoResize=y
7 7
 NeedDepthBuffer=n
8  
-AppUsesMouse=n
  8
+AppUsesMouse=SPACE
9 9
 AppNeedsArrowKeys=y
10 10
 AppUsesJoystick=n
  11
+RedefinedKeys="LCTRL LALT RETURN RETURN"
11 12
 MultiABI=n
12 13
 AppVersionCode=2101
13 14
 AppVersionName="2.1.01"
2  alienblaster/project/jni/application/opentyrian/src/destruct.cpp
@@ -836,7 +836,7 @@ enum de_mode_t JE_modeSelect( void )
836 836
 			mode = MODE_NONE; /* User is quitting, return failure */
837 837
 			break;
838 838
 		}
839  
-		if (keysactive[SDLK_RETURN])
  839
+		if (keysactive[SDLK_RETURN] || keysactive[SDLK_SPACE])
840 840
 		{
841 841
 			break; /* User has selected, return choice */
842 842
 		}
13  alienblaster/project/jni/application/opentyrian/src/mainint.cpp
@@ -288,9 +288,9 @@ void JE_helpSystem( JE_byte startTopic )
288 288
 								break;
289 289
 						}
290 290
 					}
291  
-				} while (!(lastkey_sym == SDLK_ESCAPE || lastkey_sym == SDLK_RETURN));
  291
+				} while (!(lastkey_sym == SDLK_ESCAPE || lastkey_sym == SDLK_RETURN || lastkey_sym == SDLK_SPACE));
292 292
 
293  
-				if (lastkey_sym == SDLK_RETURN)
  293
+				if (lastkey_sym == SDLK_RETURN || lastkey_sym == SDLK_SPACE)
294 294
 				{
295 295
 					page = topicStart[menu-1];
296 296
 					JE_playSampleNum(S_CLICK);
@@ -655,6 +655,7 @@ void JE_loadScreen( void )
655 655
 				}
656 656
 				break;
657 657
 			case SDLK_RETURN:
  658
+			case SDLK_SPACE:
658 659
 				if (sel < max)
659 660
 				{
660 661
 					if (saveFiles[sel - 1].level > 0)
@@ -994,6 +995,7 @@ void JE_highScoreScreen( void )
994 995
 			switch (lastkey_sym)
995 996
 			{
996 997
 			case SDLK_RETURN:
  998
+			case SDLK_SPACE:
997 999
 			case SDLK_ESCAPE:
998 1000
 				quit = true;
999 1001
 				break;
@@ -1215,6 +1217,7 @@ JE_boolean JE_inGameSetup( void )
1215 1217
 			switch (lastkey_sym)
1216 1218
 			{
1217 1219
 				case SDLK_RETURN:
  1220
+				case SDLK_SPACE:
1218 1221
 					JE_playSampleNum(S_SELECT);
1219 1222
 					switch (sel)
1220 1223
 					{
@@ -1597,7 +1600,7 @@ void JE_highScoreCheck( void )
1597 1600
 						lastkey_char = toupper(lastkey_char);
1598 1601
 						switch(lastkey_char)
1599 1602
 						{
1600  
-							case ' ':
  1603
+							//case ' ':
1601 1604
 							case '-':
1602 1605
 							case '.':
1603 1606
 							case ',':
@@ -1640,6 +1643,7 @@ void JE_highScoreCheck( void )
1640 1643
 								cancel = true;
1641 1644
 								break;
1642 1645
 							case SDLK_RETURN:
  1646
+							case SDLK_SPACE:
1643 1647
 								quit = true;
1644 1648
 								break;
1645 1649
 						}
@@ -2428,7 +2432,7 @@ void JE_operation( JE_byte slot )
2428 2432
 				lastkey_char = toupper(lastkey_char);
2429 2433
 				switch (lastkey_char)
2430 2434
 				{
2431  
-					case ' ':
  2435
+					//case ' ':
2432 2436
 					case '-':
2433 2437
 					case '.':
2434 2438
 					case ',':
@@ -2473,6 +2477,7 @@ void JE_operation( JE_byte slot )
2473 2477
 						JE_playSampleNum(S_SPRING);
2474 2478
 						break;
2475 2479
 					case SDLK_RETURN:
  2480
+					case SDLK_SPACE:
2476 2481
 						quit = true;
2477 2482
 						JE_saveGame(slot, stemp);
2478 2483
 						JE_playSampleNum(S_SELECT);
3  alienblaster/project/jni/application/opentyrian/src/menus.cpp
@@ -79,6 +79,7 @@ bool select_gameplay( void )
79 79
 				break;
80 80
 
81 81
 			case SDLK_RETURN:
  82
+			case SDLK_SPACE:
82 83
 				if (gameplay == 4)
83 84
 				{
84 85
 					JE_playSampleNum(S_SPRING);
@@ -155,6 +156,7 @@ bool select_episode( void )
155 156
 				break;
156 157
 
157 158
 			case SDLK_RETURN:
  159
+			case SDLK_SPACE:
158 160
 				if (!episodeAvail[episode - 1])
159 161
 				{
160 162
 					JE_playSampleNum(S_SPRING);
@@ -240,6 +242,7 @@ bool select_difficulty( void )
240 242
 				break;
241 243
 
242 244
 			case SDLK_RETURN:
  245
+			case SDLK_SPACE:
243 246
 				JE_playSampleNum(S_SELECT);
244 247
 				/* fading handled elsewhere
245 248
 				fade_black(10); */
6  alienblaster/project/jni/application/opentyrian/src/mouse.cpp
@@ -22,12 +22,16 @@
22 22
 #include "video.h"
23 23
 #include "vga256d.h"
24 24
 
25  
-#if defined(TARGET_GP2X) || defined(TARGET_DINGUX) || defined(ANDROID)
  25
+#if defined(TARGET_GP2X) || defined(TARGET_DINGUX)
26 26
 bool has_mouse = false;
27 27
 #else
28 28
 bool has_mouse = true;
29 29
 #endif
  30
+#if defined(ANDROID)
  31
+bool mouse_has_three_buttons = false;
  32
+#else
30 33
 bool mouse_has_three_buttons = true;
  34
+#endif
31 35
 
32 36
 JE_word lastMouseX, lastMouseY;
33 37
 JE_byte mouseCursor;
1  alienblaster/project/jni/application/opentyrian/src/opentyr.cpp
@@ -168,6 +168,7 @@ void opentyrian_menu( void )
168 168
 					}
169 169
 					break;
170 170
 				case SDLK_RETURN:
  171
+				case SDLK_SPACE:
171 172
 					switch (sel)
172 173
 					{
173 174
 						case 0: /* About */
1  alienblaster/project/jni/application/opentyrian/src/tyrian2.cpp
@@ -3678,6 +3678,7 @@ bool JE_titleScreen( JE_boolean animate )
3678 3678
 					quit = true;
3679 3679
 					break;
3680 3680
 				case SDLK_RETURN:
  3681
+				case SDLK_SPACE:
3681 3682
 					JE_playSampleNum(S_SELECT);
3682 3683
 					switch (menu)
3683 3684
 					{
1  alienblaster/project/jni/application/opentyrian/src/xmas.cpp
@@ -81,6 +81,7 @@ bool xmas_prompt( void )
81 81
 					break;
82 82
 					
83 83
 				case SDLK_RETURN:
  84
+				case SDLK_SPACE:
84 85
 					decided = true;
85 86
 					break;
86 87
 				case SDLK_ESCAPE:
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,
290 290
 				SDL_free(current->pixels);
291 291
 				current->pixels = NULL;
292 292
 				SDL_OutOfMemory();
293  
-				return(-1);
  293
+				return(NULL);
294 294
 			}
295 295
 		}
296 296
 	}
3  alienblaster/project/sdl/sdl-1.3/Android.mk
@@ -12,7 +12,8 @@ LOCAL_CFLAGS := -I$(LOCAL_PATH)/include \
12 12
 	-DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) \
13 13
 	-DSDL_CURDIR_PATH=\"$(SDL_CURDIR_PATH)\" \
14 14
 	-DSDL_TRACKBALL_KEYUP_DELAY=$(SDL_TRACKBALL_KEYUP_DELAY) \
15  
-	-DSDL_VIDEO_RENDER_RESIZE=$(SDL_VIDEO_RENDER_RESIZE)
  15
+	-DSDL_VIDEO_RENDER_RESIZE=$(SDL_VIDEO_RENDER_RESIZE) \
  16
+	$(SDL_ADDITIONAL_CFLAGS)
16 17
 
17 18
 
18 19
 SDL_SRCS := \
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)
76 76
 	return keymap[scancode];
77 77
 }
78 78
 
  79
+static SDL_scancode GetKeysym(SDL_scancode scancode, SDL_keysym *keysym)
  80
+{
  81
+	return scancode;
  82
+}
  83
+
79 84
 #define SDL_SendKeyboardKey(X, Y) SDL_SendKeyboardKey(X, Y, SDL_FALSE)
80 85
 
81 86
 #else
@@ -150,8 +155,28 @@ static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
150 155
 	return(keysym);
151 156
 }
152 157
 
  158
+static SDL_keysym *GetKeysym(SDLKey scancode, SDL_keysym *keysym)
  159
+{
  160
+	/* Sanity check */
  161
+
  162
+	/* Set the keysym information */
  163
+	keysym->scancode = scancode;
  164
+	keysym->sym = scancode;
  165
+	keysym->mod = KMOD_NONE;
  166
+
  167
+	/* If UNICODE is on, get the UNICODE value for the key */
  168
+	keysym->unicode = 0;
  169
+	if ( SDL_TranslateUNICODE ) {
  170
+		/* Populate the unicode field with the ASCII value */
  171
+		keysym->unicode = scancode;
  172
+	}
  173
+	return(keysym);
  174
+}
  175
+
153 176
 #endif
154 177
 
  178
+#define SDL_KEY_VAL(X) X
  179
+
155 180
 static int isTrackballUsed = 0;
156 181
 static int isMouseUsed = 0;
157 182
 static int isJoystickUsed = 0;
@@ -164,9 +189,13 @@ JAVA_EXPORT_NAME(DemoGLSurfaceView_nativeMouse) ( JNIEnv*  env, jobject  thiz, j
164 189
 {
165 190
 	if( !isMouseUsed )
166 191
 	{
  192
+		#ifndef SDL_ANDROID_KEYCODE_MOUSE
  193
+		#define SDL_ANDROID_KEYCODE_MOUSE RETURN
  194
+		#endif
167 195
 		SDL_keysym keysym;
168  
-		if( action != MOUSE_MOVE )
169  
-			SDL_SendKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, TranslateKey(KEYCODE_ENTER ,&keysym) );
  196
+		if( action != MOUSE_MOVE && SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_MOUSE)) != SDL_KEY(UNKNOWN) )
  197
+			SDL_SendKeyboardKey( action == MOUSE_DOWN ? SDL_PRESSED : SDL_RELEASED, GetKeysym(SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_MOUSE)) ,&keysym) );
  198
+		return;
170 199
 	}
171 200
 #if SDL_VIDEO_RENDER_RESIZE
172 201
 	// Translate mouse coordinates
@@ -274,13 +303,28 @@ void ANDROID_InitOSKeymap()
274 303
 
275 304
   keymap[KEYCODE_BACK] = SDL_KEY(ESCAPE);
276 305
 
277  
-  // HTC Evo has only two keys - Menu and Back, and all games require Enter. (Also Volume Up/Down, but they are hard to reach) 
  306
+#ifndef SDL_ANDROID_KEYCODE_0
  307
+#define SDL_ANDROID_KEYCODE_0 LCTRL
  308
+#define SDL_ANDROID_KEYCODE_1 END
  309
+#define SDL_ANDROID_KEYCODE_2 PAGEUP
  310
+#define SDL_ANDROID_KEYCODE_3 PAGEDOWN
  311
+#endif
  312
+
278 313
   // TODO: make this configurable
279  
-  keymap[KEYCODE_MENU] = SDL_KEY(RETURN);
280  
-  if( !isMouseUsed )
281  
-    keymap[KEYCODE_MENU] = SDL_KEY(LCTRL);
  314
+  keymap[KEYCODE_MENU] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_0));
  315
+
  316
+  keymap[KEYCODE_SEARCH] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
  317
+  keymap[KEYCODE_CALL] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
  318
+  keymap[KEYCODE_DPAD_CENTER] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_1));
  319
+
  320
+  //keymap[KEYCODE_CALL] = SDL_KEY(RCTRL);
  321
+  //keymap[KEYCODE_DPAD_CENTER] = SDL_KEY(LALT);
  322
+  
  323
+  keymap[KEYCODE_VOLUME_UP] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_2));
  324
+  keymap[KEYCODE_VOLUME_DOWN] = SDL_KEY(SDL_KEY_VAL(SDL_ANDROID_KEYCODE_3));
  325
+  
  326
+  keymap[KEYCODE_HOME] = SDL_KEY(HOME); // Cannot be used in application
282 327
 
283  
-  keymap[KEYCODE_CALL] = SDL_KEY(RCTRL);
284 328
   keymap[KEYCODE_ENDCALL] = SDL_KEY(LSHIFT);
285 329
   keymap[KEYCODE_CAMERA] = SDL_KEY(RSHIFT);
286 330
   keymap[KEYCODE_POWER] = SDL_KEY(RALT);
@@ -302,16 +346,11 @@ void ANDROID_InitOSKeymap()
302 346
   keymap[KEYCODE_DPAD_DOWN] = SDL_KEY(DOWN);
303 347
   keymap[KEYCODE_DPAD_LEFT] = SDL_KEY(LEFT);
304 348
   keymap[KEYCODE_DPAD_RIGHT] = SDL_KEY(RIGHT);
305  
-  keymap[KEYCODE_DPAD_CENTER] = SDL_KEY(LALT);
306 349
 
307 350
   keymap[KEYCODE_SOFT_LEFT] = SDL_KEY(KP_4);
308 351
   keymap[KEYCODE_SOFT_RIGHT] = SDL_KEY(KP_6);
309 352
   keymap[KEYCODE_ENTER] = SDL_KEY(RETURN); //SDL_KEY(KP_ENTER);
310 353
 
311  
-  keymap[KEYCODE_VOLUME_UP] = SDL_KEY(PAGEUP);
312  
-  keymap[KEYCODE_VOLUME_DOWN] = SDL_KEY(PAGEDOWN);
313  
-  keymap[KEYCODE_SEARCH] = SDL_KEY(END);
314  
-  keymap[KEYCODE_HOME] = SDL_KEY(HOME);
315 354
 
316 355
   keymap[KEYCODE_CLEAR] = SDL_KEY(BACKSPACE);
317 356
   keymap[KEYCODE_A] = SDL_KEY(A);
@@ -368,8 +407,8 @@ void ANDROID_InitOSKeymap()
368 407
   keymap[KEYCODE_SYM] = SDL_KEY(LGUI);
369 408
   keymap[KEYCODE_NUM] = SDL_KEY(NUMLOCKCLEAR);
370 409
 
371  
-  keymap[KEYCODE_ALT_LEFT] = SDL_KEY(KP_7); // Used by orientation sensor code, do not change
372  
-  keymap[KEYCODE_ALT_RIGHT] = SDL_KEY(KP_9); // Used by orientation sensor code, do not change
  410
+  keymap[KEYCODE_ALT_LEFT] = SDL_KEY(KP_7);
  411
+  keymap[KEYCODE_ALT_RIGHT] = SDL_KEY(KP_9);
373 412
 
374 413
   keymap[KEYCODE_SHIFT_LEFT] = SDL_KEY(F1);
375 414
   keymap[KEYCODE_SHIFT_RIGHT] = SDL_KEY(F2);

0 notes on commit c6ee7cd

Please sign in to comment.
Something went wrong with that request. Please try again.