int x = event->x * overlay.grid_xsize;
int y = event->y * overlay.grid_ysize;
int grid_button = overlay.grid_button[x][y];
+ int grid_button_action = GET_ACTION_FROM_GRID_BUTTON(grid_button);
Key key = (grid_button == CHAR_GRID_BUTTON_LEFT ? setup.input[0].key.left :
grid_button == CHAR_GRID_BUTTON_RIGHT ? setup.input[0].key.right :
grid_button == CHAR_GRID_BUTTON_UP ? setup.input[0].key.up :
Error(ERR_DEBUG, "::: key '%s' was '%s' [fingerId: %lld]",
getKeyNameFromKey(key), key_status_name, event->fingerId);
+ if (key_status == KEY_PRESSED)
+ overlay.grid_button_action |= grid_button_action;
+ else
+ overlay.grid_button_action &= ~grid_button_action;
+
// check if we already know this touch event's finger id
for (i = 0; i < NUM_TOUCH_FINGERS; i++)
{
#define SETUP_TOKEN_TOUCH_DROP_DISTANCE 43
#define SETUP_TOKEN_TOUCH_TRANSPARENCY 44
#define SETUP_TOKEN_TOUCH_DRAW_OUTLINED 45
-#define SETUP_TOKEN_TOUCH_GRID_XSIZE_0 46
-#define SETUP_TOKEN_TOUCH_GRID_YSIZE_0 47
-#define SETUP_TOKEN_TOUCH_GRID_XSIZE_1 48
-#define SETUP_TOKEN_TOUCH_GRID_YSIZE_1 49
+#define SETUP_TOKEN_TOUCH_DRAW_PRESSED 46
+#define SETUP_TOKEN_TOUCH_GRID_XSIZE_0 47
+#define SETUP_TOKEN_TOUCH_GRID_YSIZE_0 48
+#define SETUP_TOKEN_TOUCH_GRID_XSIZE_1 49
+#define SETUP_TOKEN_TOUCH_GRID_YSIZE_1 50
-#define NUM_GLOBAL_SETUP_TOKENS 50
+#define NUM_GLOBAL_SETUP_TOKENS 51
/* auto setup */
#define SETUP_TOKEN_AUTO_EDITOR_ZOOM_TILESIZE 0
{ TYPE_INTEGER,&si.touch.drop_distance, "touch.drop_distance" },
{ TYPE_INTEGER,&si.touch.transparency, "touch.transparency" },
{ TYPE_INTEGER,&si.touch.draw_outlined, "touch.draw_outlined" },
+ { TYPE_INTEGER,&si.touch.draw_pressed, "touch.draw_pressed" },
{ TYPE_INTEGER,&si.touch.grid_xsize[0], "touch.virtual_buttons.0.xsize" },
{ TYPE_INTEGER,&si.touch.grid_ysize[0], "touch.virtual_buttons.0.ysize" },
{ TYPE_INTEGER,&si.touch.grid_xsize[1], "touch.virtual_buttons.1.xsize" },
si->touch.drop_distance = TOUCH_DROP_DISTANCE_DEFAULT; /* percent */
si->touch.transparency = TOUCH_TRANSPARENCY_DEFAULT; /* percent */
si->touch.draw_outlined = TRUE;
+ si->touch.draw_pressed = TRUE;
for (i = 0; i < 2; i++)
{
for (y = 0; y < grid_ysize; y++)
{
int grid_button = overlay.grid_button[x][y];
+ int grid_button_action = GET_ACTION_FROM_GRID_BUTTON(grid_button);
int alpha_draw = alpha;
int outline_border = MV_NONE;
int border_size = 2;
boolean draw_outlined = setup.touch.draw_outlined;
+ boolean draw_pressed = setup.touch.draw_pressed;
if (grid_button == CHAR_GRID_BUTTON_NONE)
continue;
if (grid_button == overlay.grid_button_highlight)
alpha_draw = alpha_highlight;
+ if (draw_pressed && overlay.grid_button_action & grid_button_action)
+ {
+ if (draw_outlined)
+ draw_outlined = FALSE;
+ else
+ alpha_draw = MIN((float)alpha_draw * 1.5, SDL_ALPHA_OPAQUE);
+ }
+
SDL_SetRenderDrawColor(sdl_renderer, 255, 255, 255, alpha_draw);
rect.x = (x + 0) * video.screen_width / grid_xsize;
overlay.grid_button[x][y] = setup.touch.grid_button[nr][x][y];
overlay.grid_button_highlight = CHAR_GRID_BUTTON_NONE;
+ overlay.grid_button_action = JOY_NO_ACTION;
#if defined(USE_TOUCH_INPUT_OVERLAY)
if (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS))
#define CHAR_GRID_BUTTON_SNAP '1'
#define CHAR_GRID_BUTTON_DROP '2'
+#define GET_ACTION_FROM_GRID_BUTTON(c) ((c) == CHAR_GRID_BUTTON_LEFT ? \
+ JOY_LEFT : \
+ (c) == CHAR_GRID_BUTTON_RIGHT ? \
+ JOY_RIGHT : \
+ (c) == CHAR_GRID_BUTTON_UP ? \
+ JOY_UP : \
+ (c) == CHAR_GRID_BUTTON_DOWN ? \
+ JOY_DOWN : \
+ (c) == CHAR_GRID_BUTTON_SNAP ? \
+ JOY_BUTTON_1 : \
+ (c) == CHAR_GRID_BUTTON_DROP ? \
+ JOY_BUTTON_2 : \
+ JOY_NO_ACTION)
+
/* default name for empty highscore entry */
#define EMPTY_PLAYER_NAME "no name"
int grid_ysize;
char grid_button[MAX_GRID_XSIZE][MAX_GRID_YSIZE];
-
char grid_button_highlight;
+
+ int grid_button_action;
};
struct JoystickInfo
int transparency; /* in percent (0 == opaque, 100 == invisible) */
boolean draw_outlined;
+ boolean draw_pressed;
boolean grid_initialized;
};
{ TYPE_ENTER_LIST, execSetupChooseTransparency, "Button Transparency:" },
{ TYPE_STRING, &transparency_text, "" },
{ TYPE_SWITCH, &setup.touch.draw_outlined, "Draw Buttons Outlined:" },
+ { TYPE_SWITCH, &setup.touch.draw_pressed, "Highlight Pressed Buttons:" },
{ TYPE_EMPTY, NULL, "" },
{ TYPE_ENTER_LIST, execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
{ TYPE_EMPTY, NULL, "" },
{ TYPE_ENTER_LIST, execSetupChooseTransparency, "Button Transparency:" },
{ TYPE_STRING, &transparency_text, "" },
{ TYPE_SWITCH, &setup.touch.draw_outlined, "Draw Buttons Outlined:" },
+ { TYPE_SWITCH, &setup.touch.draw_pressed, "Highlight Pressed Buttons:" },
{ TYPE_EMPTY, NULL, "" },
{ TYPE_ENTER_LIST, execSetupConfigureVirtualButtons, "Configure Virtual Buttons" },
{ TYPE_EMPTY, NULL, "" },