| 657 | |
| 658 | |
| 659 | void GameLoop::processInputs(AllInputs &ai) |
| 660 | { |
| 661 | ai.clear(); |
| 662 | |
| 663 | /* Don't record inputs if we are quitting */ |
| 664 | if (context->status == Context::QUITTING) |
| 665 | return; |
| 666 | |
| 667 | /* Record inputs or get inputs from movie file */ |
| 668 | switch (context->config.sc.recording) { |
| 669 | case SharedConfig::NO_RECORDING: |
| 670 | case SharedConfig::RECORDING_WRITE: |
| 671 | |
| 672 | /* Get inputs if we have input focus */ |
| 673 | if (gameEvents->haveFocus()) { |
| 674 | /* Format the keyboard and mouse state and save it in the AllInputs struct */ |
| 675 | context->config.km->buildAllInputs(ai, context->game_window, context->config.sc, context->config.mouse_warp); |
| 676 | } |
| 677 | |
| 678 | /* Scale mouse inputs in case the game window is detached */ |
| 679 | if (context->config.sc.mouse_support && ai.pointer) { |
| 680 | sendMessage(MSGN_SCALE_POINTER_INPUTS); |
| 681 | sendData(ai.pointer.get(), sizeof(MouseInputs)); |
| 682 | receiveData(ai.pointer.get(), sizeof(MouseInputs)); |
| 683 | } |
| 684 | |
| 685 | /* Fill controller inputs from the controller input window. */ |
| 686 | for (int j = 0; j < AllInputs::MAXJOYS; j++) { |
| 687 | if (ai.controllers[j]) { |
| 688 | emit fillControllerInputs(*ai.controllers[j], j); |
| 689 | } |
| 690 | else if (j < context->config.sc.nb_controllers) { |
| 691 | /* If we didn't created an object yet, but if the user |
| 692 | * did set something on the controller panel, then create |
| 693 | * the object. */ |
| 694 | ControllerInputs ci; |
| 695 | /* Clear the controller inputs incase the joystick input editor |
| 696 | * is not open to prevent it from reading garbade data |
| 697 | * and adding the joystick axes to the input editor. */ |
| 698 | ci.clear(); |
| 699 | emit fillControllerInputs(ci, j); |
| 700 | if (!ci.isDefaultController()) |
| 701 | ai.controllers[j].reset(new ControllerInputs(ci)); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | /* Add framerate if necessary */ |
| 706 | if ((context->current_framerate_num != context->config.sc.initial_framerate_num) || |
| 707 | (context->current_framerate_num != context->config.sc.initial_framerate_num)) { |
| 708 | if (!ai.misc) |
| 709 | ai.misc.reset(new MiscInputs{}); |
| 710 | ai.misc->framerate_num = context->current_framerate_num; |
| 711 | ai.misc->framerate_den = context->current_framerate_den; |
| 712 | } |
| 713 | |
| 714 | /* Add realtime if necessary */ |
| 715 | if ((context->new_realtime_sec != context->current_realtime_sec) || |
| 716 | (context->new_realtime_nsec != context->current_realtime_nsec)) { |
nothing calls this directly
no test coverage detected