SDL: Add SDL_SCANCODE_SOFTLEFT and SDL_SCANCODE_SOFTRIGHT

From 2bc373622be9acd184cc6f9a19e4f528ac471d07 Mon Sep 17 00:00:00 2001
From: Cameron Cawley <[EMAIL REDACTED]>
Date: Thu, 5 May 2022 13:31:26 +0100
Subject: [PATCH] Add SDL_SCANCODE_SOFTLEFT and SDL_SCANCODE_SOFTRIGHT

---
 include/SDL_keycode.h                   |  5 ++++-
 include/SDL_scancode.h                  | 18 ++++++++++++++++++
 src/events/SDL_keyboard.c               |  4 ++++
 src/video/android/SDL_androidkeyboard.c |  4 ++--
 src/video/ngage/SDL_ngageevents.cpp     |  4 ++--
 5 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/include/SDL_keycode.h b/include/SDL_keycode.h
index 35602541a58..5e8edcb9f31 100644
--- a/include/SDL_keycode.h
+++ b/include/SDL_keycode.h
@@ -318,7 +318,10 @@ typedef enum
     SDLK_APP2 = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_APP2),
 
     SDLK_AUDIOREWIND = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOREWIND),
-    SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD)
+    SDLK_AUDIOFASTFORWARD = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_AUDIOFASTFORWARD),
+
+    SDLK_SOFTLEFT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTLEFT),
+    SDLK_SOFTRIGHT = SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_SOFTRIGHT)
 } SDL_KeyCode;
 
 /**
diff --git a/include/SDL_scancode.h b/include/SDL_scancode.h
index 5b2c67c8fc0..f203e30e177 100644
--- a/include/SDL_scancode.h
+++ b/include/SDL_scancode.h
@@ -402,6 +402,24 @@ typedef enum
 
     /* @} *//* Usage page 0x0C (additional media keys) */
 
+    /**
+     *  \name Mobile keys
+     *
+     *  These are values that are often used on mobile phones.
+     */
+    /* @{ */
+
+    SDL_SCANCODE_SOFTLEFT = 287, /**< Usually situated below the display on phones and
+                                      used as a multi-function feature key for selecting
+                                      a software defined function shown on the bottom left
+                                      of the display. */
+    SDL_SCANCODE_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
+                                       used as a multi-function feature key for selecting
+                                       a software defined function shown on the bottom right
+                                       of the display. */
+
+    /* @} *//* Mobile keys */
+
     /* Add any other keys here. */
 
     SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index 14e79ca49cd..100e6aaefe7 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -282,6 +282,8 @@ static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = {
     SDLK_APP2,
     SDLK_AUDIOREWIND,
     SDLK_AUDIOFASTFORWARD,
+    SDLK_SOFTLEFT,
+    SDLK_SOFTRIGHT,
 };
 
 static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
@@ -518,6 +520,8 @@ static const char *SDL_scancode_names[SDL_NUM_SCANCODES] = {
     "App2",
     "AudioRewind",
     "AudioFastForward",
+    "SoftLeft",
+    "SoftRight",
 };
 
 /* Taken from SDL_iconv() */
diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c
index 635a22ead6b..ce79883c67a 100644
--- a/src/video/android/SDL_androidkeyboard.c
+++ b/src/video/android/SDL_androidkeyboard.c
@@ -41,8 +41,8 @@ void Android_InitKeyboard(void)
 
 static SDL_Scancode Android_Keycodes[] = {
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
-    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
-    SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
+    SDL_SCANCODE_SOFTLEFT, /* AKEYCODE_SOFT_LEFT */
+    SDL_SCANCODE_SOFTRIGHT, /* AKEYCODE_SOFT_RIGHT */
     SDL_SCANCODE_AC_HOME, /* AKEYCODE_HOME */
     SDL_SCANCODE_AC_BACK, /* AKEYCODE_BACK */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_CALL */
diff --git a/src/video/ngage/SDL_ngageevents.cpp b/src/video/ngage/SDL_ngageevents.cpp
index 239f6b62c59..49093541568 100644
--- a/src/video/ngage/SDL_ngageevents.cpp
+++ b/src/video/ngage/SDL_ngageevents.cpp
@@ -116,10 +116,10 @@ static SDL_Scancode ConvertScancode(_THIS, int key)
             keycode = SDLK_SLASH;
             break;
         case EStdKeyDevice0:      // Left softkey
-            keycode = SDLK_F1;
+            keycode = SDLK_SOFTLEFT;
             break;
         case EStdKeyDevice1:      // Right softkey
-            keycode = SDLK_F2;
+            keycode = SDLK_SOFTRIGHT;
             break;
         case EStdKeyApplication0: // Green softkey
             keycode = SDLK_F3;