131 QString prefix = QString("%1 (%2): ").arg(joyname).arg(jid + 1); |
126 QString prefix = QString("%1 (%2): ").arg(joyname).arg(jid + 1); |
132 |
127 |
133 // Register entries for missing axes not assigned to sticks of this joystick/gamepad |
128 // Register entries for missing axes not assigned to sticks of this joystick/gamepad |
134 for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++) |
129 for(int aid = 0; aid < SDL_JoystickNumAxes(joy) && i < 1021; aid++) |
135 { |
130 { |
136 // Again store the part of the string not changing for multiple uses |
131 QString axis = prefix + HWApplication::translate("binds (keys)", controlleraxis).arg(aid + 1); |
137 QString axis = prefix + HWApplication::translate("binds (keys)", "Axis") + QString(" %1 ").arg(aid + 1); |
|
138 |
132 |
139 // Entry for "Axis Up" |
133 // Entry for "Axis Up" |
140 sprintf(sdlkeys[i][0], "j%da%du", jid, aid); |
134 sprintf(sdlkeys[i][0], "j%da%du", jid, aid); |
141 sprintf(sdlkeys[i++][1], "%s", ((isxb && aid < 5) ? (prefix + HWApplication::translate("binds (keys)", xbox360axes[aid * 2])) : axis + HWApplication::translate("binds (keys)", "(Up)")).toUtf8().constData()); |
135 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()); |
142 |
136 |
143 // Entry for "Axis Down" |
137 // Entry for "Axis Down" |
144 sprintf(sdlkeys[i][0], "j%da%dd", jid, aid); |
138 sprintf(sdlkeys[i][0], "j%da%dd", jid, aid); |
145 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()); |
139 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()); |
146 } |
140 } |
147 |
141 |
148 // Register entries for all coolie hats of this joystick/gamepad |
142 // Register entries for all coolie hats of this joystick/gamepad |
149 for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++) |
143 for(int hid = 0; hid < SDL_JoystickNumHats(joy) && i < 1019; hid++) |
150 { |
144 { |
151 // Again store the part of the string not changing for multiple uses |
145 // Again store the part of the string not changing for multiple uses |
152 QString hat = prefix + (isxb ? (HWApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : HWApplication::translate("binds (keys)", "Hat") + QString(" %1 ").arg(hid + 1)); |
146 QString hat = prefix + (isxb ? (HWApplication::translate("binds (keys)", xb360dpad) + QString(" ")) : HWApplication::translate("binds (keys)", controllerhat).arg(hid + 1)); |
153 |
147 |
154 // Entry for "Hat Up" |
148 // Entry for "Hat Up" |
155 sprintf(sdlkeys[i][0], "j%dh%du", jid, hid); |
149 sprintf(sdlkeys[i][0], "j%dh%du", jid, hid); |
156 sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Up)")).toUtf8().constData()); |
150 sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerup)).toUtf8().constData()); |
157 |
151 |
158 // Entry for "Hat Down" |
152 // Entry for "Hat Down" |
159 sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid); |
153 sprintf(sdlkeys[i][0], "j%dh%dd", jid, hid); |
160 sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Down)")).toUtf8().constData()); |
154 sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerdown)).toUtf8().constData()); |
161 |
155 |
162 // Entry for "Hat Left" |
156 // Entry for "Hat Left" |
163 sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid); |
157 sprintf(sdlkeys[i][0], "j%dh%dl", jid, hid); |
164 sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Left)")).toUtf8().constData()); |
158 sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerleft)).toUtf8().constData()); |
165 |
159 |
166 // Entry for "Hat Right" |
160 // Entry for "Hat Right" |
167 sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid); |
161 sprintf(sdlkeys[i][0], "j%dh%dr", jid, hid); |
168 sprintf(sdlkeys[i++][1], "%s", (hat + HWApplication::translate("binds (keys)", "(Right)")).toUtf8().constData()); |
162 sprintf(sdlkeys[i++][1], "%s", hat.arg(HWApplication::translate("binds (keys)", controllerright)).toUtf8().constData()); |
169 } |
163 } |
170 |
164 |
171 // Register entries for all buttons of this joystick/gamepad |
165 // Register entries for all buttons of this joystick/gamepad |
172 for(int bid = 0; bid < SDL_JoystickNumButtons(joy) && i < 1022; bid++) |
166 for(int bid = 0; bid < SDL_JoystickNumButtons(joy) && i < 1022; bid++) |
173 { |
167 { |
174 // Buttons |
168 // Buttons |
175 sprintf(sdlkeys[i][0], "j%db%d", jid, bid); |
169 sprintf(sdlkeys[i][0], "j%db%d", jid, bid); |
176 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()); |
170 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()); |
177 } |
171 } |
178 // Close the game controller as we no longer need it |
172 // Close the game controller as we no longer need it |
179 SDL_JoystickClose(joy); |
173 SDL_JoystickClose(joy); |
180 } |
174 } |
181 |
175 |