--- a/QTfrontend/util/SDLInteraction.cpp Thu Jul 19 22:19:44 2018 +0200
+++ b/QTfrontend/util/SDLInteraction.cpp Fri Jul 20 02:22:12 2018 +0200
@@ -25,6 +25,7 @@
#include "SDL_mixer.h"
#include "HWApplication.h"
+#include "sdlkeys.h"
#include "hwform.h" /* you know, we could just put a config singleton lookup function in gameuiconfig or something... */
#include "gameuiconfig.h"
@@ -32,12 +33,6 @@
#include "physfsrwops.h"
-extern char sdlkeys[1024][2][128];
-extern char xb360buttons[][128];
-extern char xb360dpad[128];
-extern char xbox360axes[][128];
-
-
SDLInteraction & SDLInteraction::instance()
{
static SDLInteraction instance;
@@ -133,39 +128,38 @@
// Register entries for missing axes not assigned to sticks of this joystick/gamepad
for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++)
{
- // Again store the part of the string not changing for multiple uses
- QString axis = prefix + HWApplication::translate("binds (keys)", "Axis") + QString(" %1 ").arg(aid + 1);
+ QString axis = prefix + HWApplication::translate("binds (keys)", controlleraxis).arg(aid + 1);
// Entry for "Axis Up"
sprintf(sdlkeys[i][0], "j%da%du", jid, aid);
- sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2])) : axis + HWApplication::translate("binds (keys)", "(Up)")).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2])) : (axis.arg(HWApplication::translate("binds (keys)", controllerup)))).toUtf8().constData());
// Entry for "Axis Down"
sprintf(sdlkeys[i][0], "j%da%dd", jid, aid);
- sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2 + 1])) : axis + HWApplication::translate("binds (keys)", "(Down)")).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2 + 1])) : (axis.arg(HWApplication::translate("binds (keys)", controllerdown)))).toUtf8().constData());
}
// Register entries for all coolie hats of this joystick/gamepad
for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++)
{
// Again store the part of the string not changing for multiple uses
- QString hat = prefix + (isxb ? (HWApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : HWApplication::translate("binds (keys)", "Hat") + QString(" %1 ").arg(hid + 1));
+ QString hat = prefix + (isxb ? (HWApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : HWApplication::translate("binds (keys)", controllerhat).arg(hid + 1));
// Entry for "Hat Up"
sprintf(sdlkeys[i][0], "j%dh%du", jid, hid);
- sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Up)")).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerup)).toUtf8().constData());
// Entry for "Hat Down"
sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid);
- sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Down)")).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerdown)).toUtf8().constData());
// Entry for "Hat Left"
sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid);
- sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Left)")).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerleft)).toUtf8().constData());
// Entry for "Hat Right"
sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid);
- sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Right)")).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerright)).toUtf8().constData());
}
// Register entries for all buttons of this joystick/gamepad
@@ -173,7 +167,7 @@
{
// Buttons
sprintf(sdlkeys[i][0], "j%db%d", jid, bid);
- sprintf(sdlkeys[i++][1], "%s", (prefix + ((isxb && bid < 10) ? (HWApplication::translate("binds (keys)", xb360buttons[bid]) + QString(" ")) : HWApplication::translate("binds (keys)", "Button") + QString(" %1").arg(bid + 1))).toUtf8().constData());
+ sprintf(sdlkeys[i++][1], "%s", (prefix + ((isxb && bid < 10) ? (HWApplication::translate("binds (keys)", xb360buttons[bid]) + QString(" ")) : HWApplication::translate("binds (keys)", controllerbutton).arg(bid + 1))).toUtf8().constData());
}
// Close the game controller as we no longer need it
SDL_JoystickClose(joy);