109 | | |
110 | | if (DOWN(PSP_CTRL_UP)) { |
111 | | newDpadY++; |
112 | | if (DOWN(PSP_CTRL_RTRIGGER)) // Shifting causes diagonals |
| 112 | |
| 113 | if(_lolControlMode) { |
| 114 | //alternative controls for Lands Of Lore control mode |
| 115 | |
| 116 | //don't need diagonals...... |
| 117 | if (DOWN(PSP_CTRL_UP)) { |
| 118 | newDpadY++; |
| 119 | } |
| 120 | if (DOWN(PSP_CTRL_RIGHT)) { |
| 121 | newDpadX++; |
| 122 | } |
| 123 | if (DOWN(PSP_CTRL_DOWN)) { |
| 124 | newDpadY--; |
| 125 | } |
| 126 | if (DOWN(PSP_CTRL_LEFT)) { |
| 127 | newDpadX--; |
| 128 | } |
| 129 | |
| 130 | if(DOWN(PSP_CTRL_SQUARE)) { //if square pressed the d-pad maps to the four fight buttons |
| 131 | if (_dpadX == 0 && _dpadY == 0) { // We were in the middle so we pressed dpad |
| 132 | event.type = Common::EVENT_KEYDOWN; |
| 133 | event.kbd.keycode = translateDpadLol(newDpadX, newDpadY, true); |
| 134 | event.kbd.ascii = event.kbd.keycode + 33; // Get ascii |
| 135 | haveEvent = true; |
| 136 | _dpadX = newDpadX; |
| 137 | _dpadY = newDpadY; |
| 138 | } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad |
| 139 | event.type = Common::EVENT_KEYUP; |
| 140 | event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, true); |
| 141 | event.kbd.ascii = event.kbd.keycode + 33; // Get ascii |
| 142 | haveEvent = true; |
| 143 | _dpadX = newDpadX; |
| 144 | _dpadY = newDpadY; |
| 145 | } else { // we moved from one pressed dpad direction to another one |
| 146 | event.type = Common::EVENT_KEYUP; |
| 147 | event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, true); |
| 148 | event.kbd.ascii = event.kbd.keycode + 33; // Get ascii |
| 149 | haveEvent = true; |
| 150 | _dpadX = 0; |
| 151 | _dpadY = 0; |
| 152 | } |
| 153 | } else { // If square not pressed then dpad maps to movement controls. |
| 154 | if (newDpadX != _dpadX || newDpadY != _dpadY) { |
| 155 | if (_dpadX == 0 && _dpadY == 0) { // We were in the middle so we pressed dpad |
| 156 | event.type = Common::EVENT_KEYDOWN; |
| 157 | event.kbd.keycode = translateDpadLol(newDpadX, newDpadY, false); |
| 158 | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; // Get ascii |
| 159 | _dpadX = newDpadX; |
| 160 | _dpadY = newDpadY; |
| 161 | } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad |
| 162 | event.type = Common::EVENT_KEYUP; |
| 163 | event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, false); |
| 164 | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; |
| 165 | _dpadX = newDpadX; |
| 166 | _dpadY = newDpadY; |
| 167 | } else { // we moved from one pressed dpad direction to another one |
| 168 | event.type = Common::EVENT_KEYUP; // first release the last dpad direction |
| 169 | event.kbd.keycode = translateDpadLol(_dpadX, _dpadY, false); |
| 170 | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; |
| 171 | _dpadX = 0; // so that we'll pick up a new dpad movement the next round |
| 172 | _dpadY = 0; |
| 173 | } |
| 174 | PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY); |
| 175 | haveEvent = true; |
| 176 | } |
| 177 | } |
| 178 | } else { |
| 179 | if (DOWN(PSP_CTRL_UP)) { |
| 180 | newDpadY++; |
| 181 | if (DOWN(PSP_CTRL_RTRIGGER)) // Shifting causes diagonals |
| 182 | newDpadX++; |
| 183 | } |
| 184 | if (DOWN(PSP_CTRL_RIGHT)) { |
124 | | } |
125 | | if (DOWN(PSP_CTRL_LEFT)) { |
126 | | newDpadX--; |
127 | | if (DOWN(PSP_CTRL_RTRIGGER)) |
128 | | newDpadY++; |
129 | | } |
130 | | |
131 | | if (newDpadX != _dpadX || newDpadY != _dpadY) { |
132 | | if (_dpadX == 0 && _dpadY == 0) { // We were in the middle so we pressed dpad |
133 | | event.type = Common::EVENT_KEYDOWN; |
134 | | event.kbd.keycode = translateDpad(newDpadX, newDpadY); |
135 | | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; // Get ascii |
136 | | _dpadX = newDpadX; |
137 | | _dpadY = newDpadY; |
138 | | } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad |
139 | | event.type = Common::EVENT_KEYUP; |
140 | | event.kbd.keycode = translateDpad(_dpadX, _dpadY); |
141 | | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; |
142 | | _dpadX = newDpadX; |
143 | | _dpadY = newDpadY; |
144 | | } else { // we moved from one pressed dpad direction to another one |
145 | | event.type = Common::EVENT_KEYUP; // first release the last dpad direction |
146 | | event.kbd.keycode = translateDpad(_dpadX, _dpadY); |
147 | | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; |
148 | | _dpadX = 0; // so that we'll pick up a new dpad movement the next round |
149 | | _dpadY = 0; |
| 196 | if (DOWN(PSP_CTRL_RTRIGGER)) |
| 197 | newDpadY++; |
151 | | |
152 | | PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY); |
153 | | haveEvent = true; |
154 | | } |
155 | | |
| 199 | |
| 200 | if (newDpadX != _dpadX || newDpadY != _dpadY) { |
| 201 | if (_dpadX == 0 && _dpadY == 0) { // We were in the middle so we pressed dpad |
| 202 | event.type = Common::EVENT_KEYDOWN; |
| 203 | event.kbd.keycode = translateDpad(newDpadX, newDpadY); |
| 204 | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; // Get ascii |
| 205 | _dpadX = newDpadX; |
| 206 | _dpadY = newDpadY; |
| 207 | } else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad |
| 208 | event.type = Common::EVENT_KEYUP; |
| 209 | event.kbd.keycode = translateDpad(_dpadX, _dpadY); |
| 210 | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; |
| 211 | _dpadX = newDpadX; |
| 212 | _dpadY = newDpadY; |
| 213 | } else { // we moved from one pressed dpad direction to another one |
| 214 | event.type = Common::EVENT_KEYUP; // first release the last dpad direction |
| 215 | event.kbd.keycode = translateDpad(_dpadX, _dpadY); |
| 216 | event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; |
| 217 | _dpadX = 0; // so that we'll pick up a new dpad movement the next round |
| 218 | _dpadY = 0; |
| 219 | } |
| 220 | |
| 221 | PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY); |
| 222 | haveEvent = true; |
| 223 | } |
| 224 | } |
| 256 | inline Common::KeyCode InputHandler::translateDpadLol(int x, int y, bool fight) { |
| 257 | DEBUG_ENTER_FUNC(); |
| 258 | Common::KeyCode key; |
| 259 | if(fight) { |
| 260 | if (x == -1) key = Common::KEYCODE_F1; |
| 261 | else if (x == 1) key = Common::KEYCODE_F3; |
| 262 | else if (y == 1) key = Common::KEYCODE_F2; |
| 263 | else if (y == -1) key = Common::KEYCODE_F4; |
| 264 | } else { |
| 265 | if (x == -1) key = Common::KEYCODE_KP7; |
| 266 | else if (x == 1) key = Common::KEYCODE_KP9; |
| 267 | else if (y == 1) key = Common::KEYCODE_KP8; |
| 268 | else if (y == -1) key = Common::KEYCODE_KP2; |
| 269 | } |
| 270 | return key; |
| 271 | } |
195 | | else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) { |
196 | | if (CHANGED(PSP_CTRL_CROSS)) { |
197 | | event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; |
198 | | event.mouse.x = _cursor->getX(); // Could this have to do with SCI enter problem? |
199 | | event.mouse.y = _cursor->getY(); |
200 | | PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp"); |
201 | | } else if (CHANGED(PSP_CTRL_CIRCLE)) { |
202 | | event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; |
203 | | event.mouse.x = _cursor->getX(); |
204 | | event.mouse.y = _cursor->getY(); |
| 281 | if(DOWN(PSP_CTRL_CROSS) && DOWN(PSP_CTRL_SQUARE) && DOWN(PSP_CTRL_CIRCLE) && DOWN(PSP_CTRL_TRIANGLE) && !DOWN(PSP_CTRL_LEFT) && !DOWN(PSP_CTRL_DOWN) && !DOWN(PSP_CTRL_UP) && !DOWN(PSP_CTRL_RIGHT) && !DOWN(PSP_CTRL_LTRIGGER) && !DOWN(PSP_CTRL_START)) { |
| 282 | uint32 time = g_system->getMillis(); |
| 283 | //Only change mode if enough time passed since last change |
| 284 | if(time -_lastControlModeChangeTime > CONTROL_MODE_CHANGE_TIME) { |
| 285 | if(_lolControlMode) { |
| 286 | _lolControlMode=false; |
| 287 | _lastControlModeChangeTime=time; |
| 288 | GUI::TimedMessageDialog dialog("Normal Button Mode", 1500); |
| 289 | dialog.runModal(); |
| 290 | } else { |
| 291 | _lolControlMode=true; |
| 292 | _lastControlModeChangeTime=time; |
| 293 | //send keyup for . which is mapped to square in normal mode |
| 294 | event.type = Common::EVENT_KEYUP; |
| 295 | event.kbd.keycode = Common::KEYCODE_PERIOD; |
| 296 | event.kbd.ascii = '.'; |
| 297 | haveEvent=true; |
| 298 | |
| 299 | GUI::TimedMessageDialog dialog("1st Person Button Mode", 1500); |
| 300 | dialog.runModal(); |
| 301 | } |
| 302 | return haveEvent; |
| 303 | } |
| 304 | } |
| 305 | if(_lolControlMode) { |
| 306 | if (PRESSED(PSP_CTRL_SELECT)) |
| 307 | _keyboard->setVisible(true); |
| 308 | |
| 309 | else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) { |
| 310 | if (CHANGED(PSP_CTRL_CROSS)) { |
| 311 | event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; |
| 312 | event.mouse.x = _cursor->getX(); // Could this have to do with SCI enter problem? |
| 313 | event.mouse.y = _cursor->getY(); |
| 314 | PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp"); |
| 315 | } else if (CHANGED(PSP_CTRL_CIRCLE)) { |
| 316 | event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; |
| 317 | event.mouse.x = _cursor->getX(); |
| 318 | event.mouse.y = _cursor->getY(); |
206 | | } else { |
207 | | //any of the other buttons. |
208 | | event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; |
209 | | event.kbd.ascii = 0; |
210 | | event.kbd.flags = 0; |
211 | | |
212 | | if (CHANGED(PSP_CTRL_LTRIGGER)) { |
213 | | event.kbd.keycode = Common::KEYCODE_ESCAPE; |
214 | | event.kbd.ascii = 27; |
215 | | } else if (CHANGED(PSP_CTRL_START)) { |
216 | | event.kbd.keycode = Common::KEYCODE_F5; |
217 | | event.kbd.ascii = Common::ASCII_F5; |
218 | | if (DOWN(PSP_CTRL_RTRIGGER)) { |
219 | | event.kbd.flags |= Common::KBD_CTRL; // Main menu to allow RTL |
| 320 | } else { |
| 321 | //any of the other buttons. |
| 322 | event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; |
| 323 | event.kbd.ascii = 0; |
| 324 | event.kbd.flags = 0; |
| 325 | |
| 326 | if (CHANGED(PSP_CTRL_LTRIGGER)) { |
| 327 | event.kbd.keycode = Common::KEYCODE_KP4; |
| 328 | event.kbd.ascii = Common::KEYCODE_KP4; |
| 329 | } else if (CHANGED(PSP_CTRL_SQUARE)) { //need to keyup movement/fighting keys to make certain they don't get stuck |
| 330 | if(DOWN(PSP_CTRL_SQUARE)) { |
| 331 | _dpadX = 0; |
| 332 | _dpadY = 0; |
| 333 | if(DOWN(PSP_CTRL_UP)) { |
| 334 | event.type = Common::EVENT_KEYUP; |
| 335 | event.kbd.keycode = Common::KEYCODE_KP8; |
| 336 | event.kbd.ascii = Common::KEYCODE_KP8; |
| 337 | } else if(DOWN(PSP_CTRL_LEFT)) { |
| 338 | event.type = Common::EVENT_KEYUP; |
| 339 | event.kbd.keycode = Common::KEYCODE_KP4; |
| 340 | event.kbd.ascii = Common::KEYCODE_KP4; |
| 341 | } else if(DOWN(PSP_CTRL_RIGHT)) { |
| 342 | event.type = Common::EVENT_KEYUP; |
| 343 | event.kbd.keycode = Common::KEYCODE_KP6; |
| 344 | event.kbd.ascii = Common::KEYCODE_KP6; |
| 345 | } else if(DOWN(PSP_CTRL_DOWN)) { |
| 346 | event.type = Common::EVENT_KEYUP; |
| 347 | event.kbd.keycode = Common::KEYCODE_KP2; |
| 348 | event.kbd.ascii = Common::KEYCODE_KP2; |
| 349 | } else return haveEvent; |
| 350 | } else { |
| 351 | _dpadX = 0; |
| 352 | _dpadY = 0; |
| 353 | if(DOWN(PSP_CTRL_UP)) { |
| 354 | event.type = Common::EVENT_KEYUP; |
| 355 | event.kbd.keycode = Common::KEYCODE_F2; |
| 356 | event.kbd.ascii = Common::ASCII_F2; |
| 357 | } else if(DOWN(PSP_CTRL_LEFT)) { |
| 358 | event.type = Common::EVENT_KEYUP; |
| 359 | event.kbd.keycode = Common::KEYCODE_F1; |
| 360 | event.kbd.ascii = Common::ASCII_F1; |
| 361 | } else if(DOWN(PSP_CTRL_RIGHT)) { |
| 362 | event.type = Common::EVENT_KEYUP; |
| 363 | event.kbd.keycode = Common::KEYCODE_F3; |
| 364 | event.kbd.ascii = Common::ASCII_F3; |
| 365 | } else if(DOWN(PSP_CTRL_DOWN)) { |
| 366 | event.type = Common::EVENT_KEYUP; |
| 367 | event.kbd.keycode = Common::KEYCODE_F4; |
| 368 | event.kbd.ascii = Common::ASCII_F4; |
| 369 | } else return haveEvent; |
| 370 | } |
221 | | } else if (CHANGED(PSP_CTRL_SQUARE)) { |
222 | | event.kbd.keycode = Common::KEYCODE_PERIOD; |
223 | | event.kbd.ascii = '.'; |
224 | | } else if (CHANGED(PSP_CTRL_TRIANGLE)) { |
225 | | event.kbd.keycode = Common::KEYCODE_RETURN; |
226 | | event.kbd.ascii = '\r'; |
227 | | } else if (DOWN(PSP_CTRL_RTRIGGER)) { // An event |
228 | | event.kbd.flags |= Common::KBD_SHIFT; |
| 372 | else if (CHANGED(PSP_CTRL_RTRIGGER)) { // An event |
| 373 | event.kbd.keycode = Common::KEYCODE_KP6; |
| 374 | event.kbd.ascii = Common::KEYCODE_KP6; |
| 375 | } else if (CHANGED(PSP_CTRL_TRIANGLE)) { |
| 376 | event.kbd.keycode = Common::KEYCODE_RETURN; |
| 377 | event.kbd.ascii = '\r'; |
| 378 | } else if (CHANGED(PSP_CTRL_START)) { |
| 379 | event.kbd.keycode = Common::KEYCODE_ESCAPE; |
| 380 | event.kbd.ascii = 27; |
| 381 | } |
| 382 | PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up"); |
230 | | PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up"); |
| 384 | |
| 385 | haveEvent = true; |
| 386 | } |
| 387 | } |
| 388 | else |
| 389 | { |
| 390 | if (PRESSED(PSP_CTRL_SELECT)) |
| 391 | _keyboard->setVisible(true); |
| 392 | |
| 393 | else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) { |
| 394 | if (CHANGED(PSP_CTRL_CROSS)) { |
| 395 | event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; |
| 396 | event.mouse.x = _cursor->getX(); // Could this have to do with SCI enter problem? |
| 397 | event.mouse.y = _cursor->getY(); |
| 398 | PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp"); |
| 399 | } else if (CHANGED(PSP_CTRL_CIRCLE)) { |
| 400 | event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; |
| 401 | event.mouse.x = _cursor->getX(); |
| 402 | event.mouse.y = _cursor->getY(); |
| 403 | PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "RButtonDown" : "RButtonUp"); |
| 404 | } else { |
| 405 | //any of the other buttons. |
| 406 | event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; |
| 407 | event.kbd.ascii = 0; |
| 408 | event.kbd.flags = 0; |
| 409 | |
| 410 | if (CHANGED(PSP_CTRL_LTRIGGER)) { |
| 411 | event.kbd.keycode = Common::KEYCODE_ESCAPE; |
| 412 | event.kbd.ascii = 27; |
| 413 | } else if (CHANGED(PSP_CTRL_START)) { |
| 414 | event.kbd.keycode = Common::KEYCODE_F5; |
| 415 | event.kbd.ascii = Common::ASCII_F5; |
| 416 | if (DOWN(PSP_CTRL_RTRIGGER)) { |
| 417 | event.kbd.flags |= Common::KBD_CTRL; // Main menu to allow RTL |
| 418 | } |
| 419 | } else if (CHANGED(PSP_CTRL_SQUARE)) { |
| 420 | event.kbd.keycode = Common::KEYCODE_PERIOD; |
| 421 | event.kbd.ascii = '.'; |
| 422 | } else if (CHANGED(PSP_CTRL_TRIANGLE)) { |
| 423 | event.kbd.keycode = Common::KEYCODE_RETURN; |
| 424 | event.kbd.ascii = '\r'; |
| 425 | } else if (DOWN(PSP_CTRL_RTRIGGER)) { // An event |
| 426 | event.kbd.flags |= Common::KBD_SHIFT; |
| 427 | } |
| 428 | PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up"); |
| 429 | } |
| 430 | |
| 431 | haveEvent = true; |