QTfrontend/SDLs.cpp
changeset 5252 ded882439548
parent 5238 46ddaf14509d
child 5747 65006a679352
equal deleted inserted replaced
5251:f31d1073345e 5252:ded882439548
    19 #include "SDLs.h"
    19 #include "SDLs.h"
    20 
    20 
    21 #include "SDL.h"
    21 #include "SDL.h"
    22 #include "SDL_mixer.h"
    22 #include "SDL_mixer.h"
    23 #include "hwconsts.h"
    23 #include "hwconsts.h"
    24 
    24 #include "HWApplication.h"
    25 #include <QApplication>
       
    26 
    25 
    27 
    26 
    28 extern char sdlkeys[1024][2][128];
    27 extern char sdlkeys[1024][2][128];
    29 extern char xb360buttons[][128];
    28 extern char xb360buttons[][128];
    30 extern char xb360dpad[128];
    29 extern char xb360dpad[128];
    99 
    98 
   100         // Register entries for missing axes not assigned to sticks of this joystick/gamepad
    99         // Register entries for missing axes not assigned to sticks of this joystick/gamepad
   101         for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++)
   100         for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++)
   102         {
   101         {
   103             // Again store the part of the string not changing for multiple uses
   102             // Again store the part of the string not changing for multiple uses
   104             QString axis = prefix + QApplication::translate("binds (keys)", "Axis") + QString(" %1 ").arg(aid + 1);
   103             QString axis = prefix + HWApplication::translate("binds (keys)", "Axis") + QString(" %1 ").arg(aid + 1);
   105 
   104 
   106             // Entry for "Axis Up"
   105             // Entry for "Axis Up"
   107             sprintf(sdlkeys[i][0], "j%da%du", jid, aid);
   106             sprintf(sdlkeys[i][0], "j%da%du", jid, aid);
   108             sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + QApplication::translate("binds (keys)", xbox360axes[aid * 2])) : axis + QApplication::translate("binds (keys)", "(Up)")).toStdString().c_str());
   107             sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2])) : axis + HWApplication::translate("binds (keys)", "(Up)")).toStdString().c_str());
   109 
   108 
   110             // Entry for "Axis Down"
   109             // Entry for "Axis Down"
   111             sprintf(sdlkeys[i][0], "j%da%dd", jid, aid);
   110             sprintf(sdlkeys[i][0], "j%da%dd", jid, aid);
   112             sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + QApplication::translate("binds (keys)", xbox360axes[aid * 2 + 1])) : axis + QApplication::translate("binds (keys)", "(Down)")).toStdString().c_str());
   111             sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2 + 1])) : axis + HWApplication::translate("binds (keys)", "(Down)")).toStdString().c_str());
   113         }
   112         }
   114 
   113 
   115         // Register entries for all coolie hats of this joystick/gamepad
   114         // Register entries for all coolie hats of this joystick/gamepad
   116         for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++)
   115         for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++)
   117         {
   116         {
   118             // Again store the part of the string not changing for multiple uses
   117             // Again store the part of the string not changing for multiple uses
   119             QString hat = prefix + (isxb ? (QApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : QApplication::translate("binds (keys)", "Hat") + QString(" %1 ").arg(hid + 1));
   118             QString hat = prefix + (isxb ? (HWApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : HWApplication::translate("binds (keys)", "Hat") + QString(" %1 ").arg(hid + 1));
   120 
   119 
   121             // Entry for "Hat Up"
   120             // Entry for "Hat Up"
   122             sprintf(sdlkeys[i][0], "j%dh%du", jid, hid);
   121             sprintf(sdlkeys[i][0], "j%dh%du", jid, hid);
   123             sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Up)")).toStdString().c_str());
   122             sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Up)")).toStdString().c_str());
   124 
   123 
   125             // Entry for "Hat Down"
   124             // Entry for "Hat Down"
   126             sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid);
   125             sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid);
   127             sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Down)")).toStdString().c_str());
   126             sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Down)")).toStdString().c_str());
   128 
   127 
   129             // Entry for "Hat Left"
   128             // Entry for "Hat Left"
   130             sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid);
   129             sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid);
   131             sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Left)")).toStdString().c_str());
   130             sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Left)")).toStdString().c_str());
   132 
   131 
   133             // Entry for "Hat Right"
   132             // Entry for "Hat Right"
   134             sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid);
   133             sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid);
   135             sprintf(sdlkeys[i++][1], "%s", (hat + QApplication::translate("binds (keys)", "(Right)")).toStdString().c_str());
   134             sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Right)")).toStdString().c_str());
   136         }
   135         }
   137 
   136 
   138         // Register entries for all buttons of this joystick/gamepad
   137         // Register entries for all buttons of this joystick/gamepad
   139         for(int bid = 0; bid < SDL_JoystickNumButtons(joy) && i < 1022; bid++)
   138         for(int bid = 0; bid < SDL_JoystickNumButtons(joy) && i < 1022; bid++)
   140         {
   139         {
   141             // Buttons
   140             // Buttons
   142             sprintf(sdlkeys[i][0], "j%db%d", jid, bid);
   141             sprintf(sdlkeys[i][0], "j%db%d", jid, bid);
   143             sprintf(sdlkeys[i++][1], "%s", (prefix + ((isxb && bid < 10) ? (QApplication::translate("binds (keys)", xb360buttons[bid]) + QString(" ")) : QApplication::translate("binds (keys)", "Button") + QString(" %1").arg(bid + 1))).toStdString().c_str());
   142             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))).toStdString().c_str());
   144         }
   143         }
   145         // Close the game controller as we no longer need it
   144         // Close the game controller as we no longer need it
   146         SDL_JoystickClose(joy);
   145         SDL_JoystickClose(joy);
   147     }
   146     }
   148 
   147