(Android) Added shoulder and trigger buttons to the touch overlay

This commit is contained in:
Leon Styhre 2024-01-13 19:44:42 +01:00
parent 2fd58b3052
commit 183e8a1f93
6 changed files with 84 additions and 3 deletions

View file

@ -38,7 +38,6 @@
#include <SDL2/SDL_timer.h>
#if defined(__ANDROID__)
#include "InputOverlay.h"
#include "utils/PlatformUtilAndroid.h"
#endif

View file

@ -731,6 +731,7 @@ void InputManager::loadDefaultControllerConfig(SDL_JoystickID deviceIndex)
void InputManager::loadTouchConfig()
{
#if defined(__ANDROID__)
InputConfig* cfg {mTouchInputConfig.get()};
if (cfg->isConfigured())
@ -749,9 +750,10 @@ void InputManager::loadTouchConfig()
cfg->mapInput("Y", Input(DEVICE_TOUCH, TYPE_TOUCH, SDL_CONTROLLER_BUTTON_Y, 1, true));
cfg->mapInput("LeftShoulder", Input(DEVICE_TOUCH, TYPE_TOUCH, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, 1, true));
cfg->mapInput("RightShoulder", Input(DEVICE_TOUCH, TYPE_TOUCH, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, 1, true));
cfg->mapInput("LeftTrigger", Input(DEVICE_TOUCH, TYPE_TOUCH, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 1, true));
cfg->mapInput("RightTrigger", Input(DEVICE_TOUCH, TYPE_TOUCH, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 1, true));
cfg->mapInput("LeftTrigger", Input(DEVICE_TOUCH, TYPE_TOUCH, InputOverlay::TriggerButtons::TRIGGER_LEFT, 1, true));
cfg->mapInput("RightTrigger", Input(DEVICE_TOUCH, TYPE_TOUCH, InputOverlay::TriggerButtons::TRIGGER_RIGHT, 1, true));
// clang-format on
#endif
}
void InputManager::addControllerByDeviceIndex(Window* window, int deviceIndex)

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="78"
height="30"
version="1.1"
viewBox="0 0 78 30"
id="svg4"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs8" />
<path
id="rect937"
style="fill:#ffffff;fill-opacity:0.25;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers stroke fill;stop-color:#000000"
d="m 36.509606,0.90095117 h 31.604561 c 5.116384,0 8.984872,3.83116943 8.984872,8.59006573 V 20.508983 c 0,4.758895 -4.118967,8.590066 -9.235352,8.590066 H 10.227443 c -5.1163843,0 -9.1392613,-3.511398 -9.3226916,-8.240203 C 1.2071606,12.737574 16.990737,1.386344 36.509606,0.90095117 Z" />
<path
id="button_l"
d="m 34.088311,6.433594 v 17.132812 h 9.823377 V 19.554635 H 38.189871 V 6.433594 Z"
style="fill:#ffffff;fill-opacity:0.2;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="78"
height="30"
version="1.1"
viewBox="0 0 78 30"
id="svg4"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs8" />
<path
id="rect937"
style="fill:#ffffff;fill-opacity:0.25;fill-rule:evenodd;stroke:#ffffff;stroke-width:1.5;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;paint-order:markers stroke fill;stop-color:#000000"
d="M 41.493643,0.90095117 H 9.8890819 c -5.116384,0 -8.98487196,3.83116943 -8.98487196,8.59006573 V 20.508983 c 0,4.758895 4.11896696,8.590066 9.23535206,8.590066 h 57.636244 c 5.116384,0 9.139261,-3.511398 9.322692,-8.240203 C 76.796088,12.737574 61.012512,1.386344 41.493643,0.90095117 Z" />
<path
id="button_r"
d="m 33.20307,6.433594 v 17.132812 h 4.089843 v -6.46875 h 0.210938 l 2.625,6.46875 h 4.324219 l -3.28125,-7.5 c 1.398437,-0.921875 2.097656,-2.402344 2.097656,-4.441406 0,-1.757812 -0.449219,-3.062501 -1.347656,-3.914063 C 41.023382,6.859374 39.632757,6.433594 37.749945,6.433594 Z m 4.089843,3.175781 h 0.28125 c 0.539063,0 0.933594,0.164063 1.183594,0.492187 0.257813,0.328126 0.386719,0.867188 0.386719,1.617188 0,0.742188 -0.125,1.296875 -0.375,1.664062 -0.242187,0.367188 -0.632812,0.550782 -1.171875,0.550782 h -0.304688 z"
style="fill:#ffffff;fill-opacity:0.2;stroke:#ffffff;stroke-width:1.3;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="78"
height="30"
version="1.1"
viewBox="0 0 78 30"
id="svg4"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs8" />
<path
id="button_lt"
style="fill:#ffffff;fill-opacity:0.2;stroke:#ffffff;stroke-width:1.44965;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.72482408,0.72482408 V 15 A 16.58591,14.275176 0 0 0 17.311117,29.275176 H 60.688883 A 16.58591,14.275176 0 0 0 77.275176,15 V 0.72482408 Z" />
<path
id="button_lt-3"
style="fill:#ffffff;fill-opacity:0.2;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 25.920898,5.115234 V 24.884766 H 37.394646 V 20.44724 H 31.252929 V 5.115234 Z m 12.568359,0 v 3.71875 h 4.144532 V 24.884766 H 47.93457 V 8.833984 h 4.144531 v -3.71875 z" />
</svg>

After

Width:  |  Height:  |  Size: 928 B

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="78"
height="30"
version="1.1"
viewBox="0 0 78 30"
id="svg4"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs8" />
<path
id="button_lt"
style="fill:#ffffff;fill-opacity:0.2;stroke:#ffffff;stroke-width:1.44965;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 0.72482408,0.72482408 V 15 A 16.58591,14.275176 0 0 0 17.311117,29.275176 H 60.688883 A 16.58591,14.275176 0 0 0 77.275176,15 V 0.72482408 Z" />
<path
id="button_rt"
style="fill:#ffffff;fill-opacity:0.2;stroke:#ffffff;stroke-width:1.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 25.970111,5.1152347 h 5.24804 c 2.17248,0 3.77583,0.492036 4.8125,1.474609 1.03666,0.982571 1.55469,2.48738 1.55469,4.5156253 0,2.352763 -0.80633,4.061298 -2.41992,5.124999 l 3.78711,8.654297 h -4.990229 l -3.029301,-7.464844 h -0.242189 v 7.464844 h -4.7207 z m 13.997278,0 h 12.062499 v 3.71875 h -3.67969 V 24.884765 h -4.70508 V 8.8339847 h -3.67773 z m -9.276578,3.664062 v 4.9902343 h 0.35156 c 0.62199,0 1.07213,-0.211086 1.35157,-0.634765 0.28847,-0.423677 0.43164,-1.063553 0.43164,-1.919922 0,-0.865386 -0.14785,-1.4885813 -0.44532,-1.8671873 -0.28846,-0.378606 -0.74322,-0.56836 -1.36523,-0.56836 z" />
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB