* Handle input. * @param input New input. * Upper byte is flags, lower byte is Dune II keycode * Flags : * 0x01 SHIFT * 0x02 ALT * 0x04 ? * 0x08 KEYUP / RELEASE */
| 393 | * 0x08 KEYUP / RELEASE |
| 394 | */ |
| 395 | void Input_HandleInput(uint16 input) |
| 396 | { |
| 397 | uint16 oldTail; |
| 398 | uint16 saveSize = 0; |
| 399 | |
| 400 | uint16 index; |
| 401 | uint16 value; |
| 402 | uint8 bit_value; |
| 403 | |
| 404 | uint16 inputMouseX; |
| 405 | uint16 inputMouseY; |
| 406 | uint16 tempBuffer[4]; |
| 407 | uint16 flags; /* Mask for allowed input types. See InputFlagsEnum. */ |
| 408 | |
| 409 | flags = g_inputFlags; |
| 410 | inputMouseX = g_mouseX; |
| 411 | inputMouseY = g_mouseY; |
| 412 | |
| 413 | if (g_mouseMode == INPUT_MOUSE_MODE_RECORD) { |
| 414 | saveSize = 4; |
| 415 | } |
| 416 | |
| 417 | if (input == 0) return; |
| 418 | |
| 419 | value = input & 0xFF; |
| 420 | if ((flags & INPUT_FLAG_NO_CLICK) != 0 && (input & 0x400) == 0) { |
| 421 | |
| 422 | if (((flags & INPUT_FLAG_UNKNOWN_2000) != 0 && (value == 0x2B || value == 0x3D || value == 0x6C)) || value == 0x63) { |
| 423 | input = 0x41 | (input & 0xFF00); |
| 424 | g_prevButtonState |= 1; |
| 425 | if ((input & 0x800) != 0) { |
| 426 | g_prevButtonState &= 0xFE; /* ~1 */ |
| 427 | } |
| 428 | } else if (value == 0x68) { |
| 429 | input = 0x42 | (input & 0xFF00); |
| 430 | g_prevButtonState |= 2; |
| 431 | if ((input & 0x800) != 0) { |
| 432 | g_prevButtonState &= 0xFD; /* ~2 */ |
| 433 | } |
| 434 | } else if ((input & 0x800) == 0 && (value == 0x61 || (value >= 0x5B && value <= 0x67 && |
| 435 | (value <= 0x5D || value >= 0x65 || value == 0x60 || value == 0x62)))) { |
| 436 | |
| 437 | /* Copied from 29E8:0A9C - 29E8:0AB6 */ |
| 438 | static const int8 data_0A9C[13][2] = |
| 439 | { |
| 440 | {-1, -1}, {-1, 0}, {-1, 1}, { 0, 0}, |
| 441 | { 0, 0}, { 0, -1}, { 0, 0}, { 0, 1}, |
| 442 | { 0, 0}, { 0, 0}, { 1, -1}, { 1, 0}, |
| 443 | { 1, 1}, |
| 444 | }; |
| 445 | int8 dx, dy; |
| 446 | |
| 447 | dx = data_0A9C[value - 0x5B][0]; |
| 448 | dy = data_0A9C[value - 0x5B][1]; |
| 449 | |
| 450 | if ((input & 0x200) != 0) { |
| 451 | /* Copied from 29E8:0AB6 - 29E8:0AD6 */ |
| 452 | static const uint16 data_0AB6[16] = {8, 2, 8, 6, 4, 3, 8, 5, 8, 8, 8, 8, 0, 1, 8, 7}; |
no test coverage detected