OpenTyrian: allow to configure screen joystick in settings
This commit is contained in:
2
bugs.txt
2
bugs.txt
@@ -30,6 +30,8 @@ Requested features, might never get implemented, see todo.txt for features that
|
||||
|
||||
- Resize default on-screen buttons for different screen sizes.
|
||||
|
||||
- Cloud save support.
|
||||
|
||||
- OpenArena: chat text input should be faster.
|
||||
|
||||
- OpenArena: Shift and Ctrl keys on USB keyboard do not work for text input.
|
||||
|
||||
@@ -7,10 +7,10 @@ AppName="OpenTyrian"
|
||||
AppFullName=com.googlecode.opentyrian
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=2124
|
||||
AppVersionCode=2125
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="2.1.24"
|
||||
AppVersionName="2.1.25"
|
||||
|
||||
# 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
|
||||
|
||||
@@ -212,8 +212,7 @@ JE_SaveFilesType saveFiles; /*array[1..saveLevelnum] of savefiletype;*/
|
||||
JE_SaveGameTemp saveTemp;
|
||||
|
||||
JE_word editorLevel; /*Initial value 800*/
|
||||
AutoFireMode_t autoFireMode = AUTOFIRE_TOUCHSCREEN;
|
||||
TouchscreenMode_t touchscreenMode = TOUCHSCREEN_SHIP_ABOVE_FINGER;
|
||||
TouchscreenControlMode_t touchscreenControlMode = TOUCHSCREEN_CONTROL_FINGER;
|
||||
|
||||
cJSON *load_json( const char *filename )
|
||||
{
|
||||
@@ -274,11 +273,8 @@ bool load_opentyrian_config( void )
|
||||
if ((setting = cJSON_GetObjectItem(section, "scaler")))
|
||||
set_scaler_by_name(setting->valuestring);
|
||||
|
||||
if ((setting = cJSON_GetObjectItem(section, "autofire")))
|
||||
autoFireMode = (AutoFireMode_t)setting->valueint;
|
||||
|
||||
if ((setting = cJSON_GetObjectItem(section, "touchscreen")))
|
||||
touchscreenMode = (TouchscreenMode_t)setting->valueint;
|
||||
if ((setting = cJSON_GetObjectItem(section, "touchscreenmode")))
|
||||
touchscreenControlMode = setting->valueint;
|
||||
}
|
||||
|
||||
cJSON_Delete(root);
|
||||
@@ -306,11 +302,8 @@ bool save_opentyrian_config( void )
|
||||
setting = cJSON_CreateOrGetObjectItem(section, "scaler");
|
||||
cJSON_SetString(setting, scalers[scaler].name);
|
||||
|
||||
setting = cJSON_CreateOrGetObjectItem(section, "autofire");
|
||||
cJSON_SetNumber(setting, autoFireMode);
|
||||
|
||||
setting = cJSON_CreateOrGetObjectItem(section, "touchscreen");
|
||||
cJSON_SetNumber(setting, touchscreenMode);
|
||||
setting = cJSON_CreateOrGetObjectItem(section, "touchscreenmode");
|
||||
cJSON_SetNumber(setting, touchscreenControlMode);
|
||||
}
|
||||
|
||||
save_json(root, "opentyrian.conf");
|
||||
|
||||
@@ -129,17 +129,8 @@ extern JE_byte processorType;
|
||||
extern JE_SaveFilesType saveFiles;
|
||||
extern JE_SaveGameTemp saveTemp;
|
||||
extern JE_word editorLevel;
|
||||
typedef enum { AUTOFIRE_TOUCHSCREEN, AUTOFIRE_BUTTON, AUTOFIRE_BUTTON_TOUCH, AUTOFIRE_NONE, AUTOFIRE_LAST } AutoFireMode_t;
|
||||
extern AutoFireMode_t autoFireMode;
|
||||
typedef enum {
|
||||
TOUCHSCREEN_SHIP_ABOVE_FINGER,
|
||||
TOUCHSCREEN_SHIP_TO_THE_LEFT,
|
||||
TOUCHSCREEN_SHIP_BELOW_FINGER,
|
||||
TOUCHSCREEN_FIRE_ONLY,
|
||||
TOUCHSCREEN_NONE,
|
||||
TOUCHSCREEN_LAST } TouchscreenMode_t;
|
||||
extern TouchscreenMode_t touchscreenMode;
|
||||
|
||||
typedef enum { TOUCHSCREEN_CONTROL_FINGER, TOUCHSCREEN_CONTROL_JOYSTICK, TOUCHSCREEN_CONTROL_BOTH, TOUCHSCREEN_CONTROL_LAST } TouchscreenControlMode_t;
|
||||
extern TouchscreenControlMode_t touchscreenControlMode;
|
||||
|
||||
void JE_initProcessorType( void );
|
||||
void JE_setNewGameSpeed( void );
|
||||
|
||||
@@ -324,7 +324,7 @@ void JE_itemScreen( void )
|
||||
else
|
||||
{
|
||||
min = 2;
|
||||
max = 13;
|
||||
max = 12;
|
||||
}
|
||||
|
||||
for (int x = min; x <= max; x++)
|
||||
@@ -380,7 +380,7 @@ void JE_itemScreen( void )
|
||||
/* keyboard settings menu */
|
||||
if (curMenu == 5)
|
||||
{
|
||||
for (int x = 2; x <= 13; x++)
|
||||
for (int x = 2; x <= 12; x++)
|
||||
{
|
||||
if (x == curSel[curMenu])
|
||||
{
|
||||
@@ -395,15 +395,9 @@ void JE_itemScreen( void )
|
||||
|
||||
if( x == 12 )
|
||||
{
|
||||
char *AutoFireNames[] = { "Touchscreen", "Fire button", "Touch and Button", "None" };
|
||||
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, "Auto-Fire", temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
JE_textShade(VGAScreen, 230, 38 + (x - 2)*12, AutoFireNames[autoFireMode], temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
}
|
||||
else if( x == 13 )
|
||||
{
|
||||
char *TouchscreenNames[] = { "Ship above finger", "Ship to the left", "Ship below finger", "Fire only", "None" };
|
||||
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, "Touchscreen", temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
JE_textShade(VGAScreen, 230, 38 + (x - 2)*12, TouchscreenNames[touchscreenMode], temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
char *touchscreenControlNames[] = { "Ship follows touch", "Joystick + buttons", "Both" };
|
||||
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, "Touch mode", temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
JE_textShade(VGAScreen, 230, 38 + (x - 2)*12, touchscreenControlNames[touchscreenControlMode], temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
}
|
||||
else
|
||||
JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, menuInt[curMenu + 1][x-1], temp2 / 16, temp2 % 16 - 8, DARKEN);
|
||||
@@ -415,7 +409,7 @@ void JE_itemScreen( void )
|
||||
}
|
||||
}
|
||||
|
||||
menuChoices[5] = 13;
|
||||
menuChoices[5] = 12;
|
||||
}
|
||||
|
||||
/* Joystick settings menu */
|
||||
@@ -2665,18 +2659,11 @@ void JE_menuFunction( JE_byte select )
|
||||
break;
|
||||
|
||||
case 5: /* keyboard settings */
|
||||
if (curSelect == 12) /* Auto-Fire mode */
|
||||
if (curSelect == 12) /* Touchscreen mode */
|
||||
{
|
||||
autoFireMode = (AutoFireMode_t)(autoFireMode + 1);
|
||||
if(autoFireMode >= AUTOFIRE_LAST)
|
||||
autoFireMode = AUTOFIRE_TOUCHSCREEN;
|
||||
JE_saveConfiguration();
|
||||
}
|
||||
else if (curSelect == 13) /* Touchscreen mode */
|
||||
{
|
||||
touchscreenMode = (TouchscreenMode_t)(touchscreenMode + 1);
|
||||
if(touchscreenMode >= TOUCHSCREEN_LAST)
|
||||
touchscreenMode = TOUCHSCREEN_SHIP_ABOVE_FINGER;
|
||||
touchscreenControlMode = touchscreenControlMode + 1;
|
||||
if(touchscreenControlMode >= TOUCHSCREEN_CONTROL_LAST)
|
||||
touchscreenControlMode = TOUCHSCREEN_CONTROL_FINGER;
|
||||
JE_saveConfiguration();
|
||||
}
|
||||
else if (curSelect == 10) /* reset to defaults */
|
||||
|
||||
@@ -3133,8 +3133,7 @@ redo:
|
||||
{
|
||||
*mouseX_ = this_player->x;
|
||||
*mouseY_ = this_player->y;
|
||||
if(autoFireMode != AUTOFIRE_BUTTON && autoFireMode != AUTOFIRE_BUTTON_TOUCH)
|
||||
button[1-1] = false;
|
||||
button[1-1] = false;
|
||||
button[2-1] = false;
|
||||
button[3-1] = false;
|
||||
button[4-1] = false;
|
||||
@@ -3223,51 +3222,26 @@ redo:
|
||||
/* Move ship above user finger */
|
||||
int shifted_mouse_x = mouse_x + 15;
|
||||
int shifted_mouse_y = mouse_y;
|
||||
if( touchscreenMode == TOUCHSCREEN_SHIP_ABOVE_FINGER )
|
||||
{
|
||||
if( shifted_mouse_y > 160 )
|
||||
shifted_mouse_y += shifted_mouse_y - 160;
|
||||
shifted_mouse_y -= 45;
|
||||
}
|
||||
if( touchscreenMode == TOUCHSCREEN_SHIP_TO_THE_LEFT )
|
||||
{
|
||||
shifted_mouse_x -= 30;
|
||||
}
|
||||
/* Ship above finger */
|
||||
if( shifted_mouse_y > 160 )
|
||||
shifted_mouse_y += shifted_mouse_y - 160;
|
||||
shifted_mouse_y -= 45;
|
||||
|
||||
if (keysactive[keySettings[0]] ||
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_y < this_player->y && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_y < this_player->y && touchscreenControlMode != TOUCHSCREEN_CONTROL_JOYSTICK)))
|
||||
this_player->y -= CURRENT_KEY_SPEED;
|
||||
if (keysactive[keySettings[1]] ||
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_y > this_player->y && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_y > this_player->y && touchscreenControlMode != TOUCHSCREEN_CONTROL_JOYSTICK)))
|
||||
this_player->y += CURRENT_KEY_SPEED;
|
||||
|
||||
if (keysactive[keySettings[2]] ||
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_x < this_player->x && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_x < this_player->x && touchscreenControlMode != TOUCHSCREEN_CONTROL_JOYSTICK)))
|
||||
this_player->x -= CURRENT_KEY_SPEED;
|
||||
if (keysactive[keySettings[3]] ||
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_x > this_player->x && touchscreenMode < TOUCHSCREEN_FIRE_ONLY)))
|
||||
(has_mouse && mouse_pressed[0] && (shifted_mouse_x > this_player->x && touchscreenControlMode != TOUCHSCREEN_CONTROL_JOYSTICK)))
|
||||
this_player->x += CURRENT_KEY_SPEED;
|
||||
|
||||
if( autoFireMode == AUTOFIRE_BUTTON || autoFireMode == AUTOFIRE_BUTTON_TOUCH )
|
||||
{
|
||||
if(newkey && keydown && lastkey_sym == keySettings[4])
|
||||
button[0] = ! button[0];
|
||||
else if (autoFireMode == AUTOFIRE_BUTTON_TOUCH)
|
||||
{
|
||||
static int prevState = 0;
|
||||
if( mouse_pressed[0] && prevState != button[0] )
|
||||
{
|
||||
button[0] = ! button[0];
|
||||
prevState = button[0];
|
||||
}
|
||||
else if( ! mouse_pressed[0] )
|
||||
prevState = ! button[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
button[0] = button[0] || keysactive[keySettings[4]] || ( mouse_pressed[0] && ( touchscreenMode != TOUCHSCREEN_NONE ) );
|
||||
}
|
||||
button[0] = button[0] || keysactive[keySettings[4]] || (mouse_pressed[0] && touchscreenControlMode != TOUCHSCREEN_CONTROL_JOYSTICK);
|
||||
|
||||
button[3] = button[3] || keysactive[keySettings[5]];
|
||||
button[1] = button[1] || keysactive[keySettings[6]];
|
||||
|
||||
@@ -62,35 +62,43 @@ select_menuitem_by_touch(int menu_top, int menu_spacing, int menu_item_count, in
|
||||
|
||||
void android_setup_screen_keys( void )
|
||||
{
|
||||
int W = SDL_ListModes(NULL, 0)[0]->w;
|
||||
int H = SDL_ListModes(NULL, 0)[0]->h;
|
||||
SDL_Rect r;
|
||||
if (touchscreenControlMode == TOUCHSCREEN_CONTROL_FINGER)
|
||||
{
|
||||
int W = SDL_ListModes(NULL, 0)[0]->w;
|
||||
int H = SDL_ListModes(NULL, 0)[0]->h;
|
||||
SDL_Rect r;
|
||||
|
||||
// Rear gun mode button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 46 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &r);
|
||||
// Rear gun mode button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 46 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_1, &r);
|
||||
|
||||
// Left sidekick button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 104 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &r);
|
||||
// Left sidekick button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 104 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &r);
|
||||
|
||||
// Right sidekick button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 162 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &r);
|
||||
// Right sidekick button
|
||||
r.x = 558 * W / 640;
|
||||
r.y = 162 * H / 400;
|
||||
r.w = 82 * W / 640;
|
||||
r.h = 58 * H / 400;
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &r);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonImagePos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_2, &r);
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(SDL_ALPHA_TRANSPARENT);
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(SDL_ALPHA_TRANSPARENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Setup joystick with buttons */
|
||||
android_setup_screen_keys_destruct();
|
||||
}
|
||||
}
|
||||
|
||||
void android_cleanup_screen_keys( void )
|
||||
@@ -122,7 +130,7 @@ void android_setup_screen_keys_destruct( void )
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_3, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_3]);
|
||||
SDL_ANDROID_SetScreenKeyboardButtonPos(SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD, &screen_button_pos_destruct[SDL_ANDROID_SCREENKEYBOARD_BUTTON_DPAD]);
|
||||
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(192); // Text input button should not be totally transparent
|
||||
SDL_ANDROID_SetScreenKeyboardTransparency(192);
|
||||
}
|
||||
|
||||
void android_show_tutorial( void )
|
||||
|
||||
2
todo.txt
2
todo.txt
@@ -15,8 +15,6 @@ TODO, which will get actually done
|
||||
|
||||
- SuperTux: Update, enable OpenGL renderer, add touchscreen jump helper, add gamepad support, fix zoom in settings.
|
||||
|
||||
- SDL: cloud save support.
|
||||
|
||||
- SDL: make sub-frame touch events as an user-configurable option.
|
||||
|
||||
- SDL: control mouse with right analog gamepad stick.
|
||||
|
||||
Reference in New Issue
Block a user