From: Holger Schemel Date: Wed, 9 May 2018 19:51:23 +0000 (+0200) Subject: added using configurable virtual buttons while playing X-Git-Tag: 4.1.1.0~167 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=164e6c72eba4eac8002bd6b334579e78e5010d0f added using configurable virtual buttons while playing Note: Virtual buttons can be configured (for both screen orientations) and are also used when playing the game now, but are not saved yet. --- diff --git a/src/events.c b/src/events.c index 5a4023ec..4fcbd199 100644 --- a/src/events.c +++ b/src/events.c @@ -683,6 +683,18 @@ static struct void HandleFingerEvent_VirtualButtons(FingerEvent *event) { +#if 1 + int x = event->x * overlay.grid_xsize; + int y = event->y * overlay.grid_ysize; + int grid_button = overlay.grid_button[x][y]; + 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 : + grid_button == CHAR_GRID_BUTTON_DOWN ? setup.input[0].key.down : + grid_button == CHAR_GRID_BUTTON_SNAP ? setup.input[0].key.snap : + grid_button == CHAR_GRID_BUTTON_DROP ? setup.input[0].key.drop : + KSYM_UNDEFINED); +#else float ypos = 1.0 - 1.0 / 3.0 * video.display_width / video.display_height; float event_x = (event->x); float event_y = (event->y - ypos) / (1 - ypos); @@ -705,6 +717,7 @@ void HandleFingerEvent_VirtualButtons(FingerEvent *event) event_y > 2.0 / 3.0 && event_y < 1 ? setup.input[0].key.down : KSYM_UNDEFINED); +#endif int key_status = (event->type == EVENT_FINGERRELEASE ? KEY_RELEASED : KEY_PRESSED); char *key_status_name = (key_status == KEY_RELEASED ? "KEY_RELEASED" : diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index d1d14a82..877bb16e 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -3077,7 +3077,6 @@ static void DrawTouchInputOverlay() static boolean initialized = FALSE; static boolean deactivated = TRUE; static boolean show_grid = FALSE; - static boolean show_grid_buttons = FALSE; static int width = 0, height = 0; static int alpha_max = SDL_ALPHA_OPAQUE / 2; static int alpha_step = 5; @@ -3108,19 +3107,15 @@ static void DrawTouchInputOverlay() else if (deactivated) show_grid = FALSE; - if (overlay.show_grid_buttons) - show_grid_buttons = TRUE; - else if (deactivated) - show_grid_buttons = FALSE; - if (show_grid) DrawTouchInputOverlay_ShowGrid(alpha); - if (show_grid_buttons) - DrawTouchInputOverlay_ShowGridButtons(alpha); + DrawTouchInputOverlay_ShowGridButtons(alpha); - if (show_grid || show_grid_buttons) - return; + return; + + + // !!! VIRTUAL BUTTONS FROM IMAGE FILE NOT USED ANYMORE !!! if (!initialized) { diff --git a/src/libgame/system.c b/src/libgame/system.c index 5b7cede4..3363ac2b 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -341,7 +341,6 @@ void InitOverlayInfo() overlay.active = FALSE; overlay.show_grid = FALSE; - overlay.show_grid_buttons = FALSE; for (i = 0; i < 2; i++) { @@ -439,7 +438,6 @@ void SetOverlayActive(boolean active) void SetOverlayShowGrid(boolean show_grid) { overlay.show_grid = show_grid; - overlay.show_grid_buttons = show_grid; SetOverlayActive(show_grid); diff --git a/src/libgame/system.h b/src/libgame/system.h index b5c5fcee..480ef0d4 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -1016,7 +1016,6 @@ struct OverlayInfo boolean active; /* overlay activated (depending on game mode) */ boolean show_grid; - boolean show_grid_buttons; int grid_xsize_all[2]; int grid_ysize_all[2];