diff options
| author | 2018-11-03 12:55:39 -0400 | |
|---|---|---|
| committer | 2018-11-18 23:22:36 -0500 | |
| commit | 3a6cd5b3c8dec11cc88c6aebdc4773233f615c91 (patch) | |
| tree | 980ef0304b375ddea0ef83c8786253e1a3548be7 /src | |
| parent | qt: Move controller button config to separate dialog (diff) | |
| download | yuzu-3a6cd5b3c8dec11cc88c6aebdc4773233f615c91.tar.gz yuzu-3a6cd5b3c8dec11cc88c6aebdc4773233f615c91.tar.xz yuzu-3a6cd5b3c8dec11cc88c6aebdc4773233f615c91.zip | |
hid: Use player-defined controller type as PREFERRED_CONTROLLER
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/hid/controllers/keyboard.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 213 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 11 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 6 | ||||
| -rw-r--r-- | src/core/settings.cpp | 50 | ||||
| -rw-r--r-- | src/core/settings.h | 44 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 127 | ||||
| -rw-r--r-- | src/yuzu/configuration/config.h | 10 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input.cpp | 27 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input.h | 2 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_input_player.h | 4 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_mouse_advanced.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_mouse_advanced.h | 4 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_touchscreen_advanced.cpp | 14 | ||||
| -rw-r--r-- | src/yuzu/configuration/configure_touchscreen_advanced.h | 1 |
16 files changed, 234 insertions, 296 deletions
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index 088f00b43..ca75adc2b 100644 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | 10 | ||
| 11 | namespace Service::HID { | 11 | namespace Service::HID { |
| 12 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; | 12 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; |
| 13 | constexpr u8 KEYS_PER_BYTE = 8; | ||
| 13 | 14 | ||
| 14 | Controller_Keyboard::Controller_Keyboard() = default; | 15 | Controller_Keyboard::Controller_Keyboard() = default; |
| 15 | Controller_Keyboard::~Controller_Keyboard() = default; | 16 | Controller_Keyboard::~Controller_Keyboard() = default; |
| @@ -37,8 +38,8 @@ void Controller_Keyboard::OnUpdate(u8* data, std::size_t size) { | |||
| 37 | cur_entry.sampling_number2 = cur_entry.sampling_number; | 38 | cur_entry.sampling_number2 = cur_entry.sampling_number; |
| 38 | 39 | ||
| 39 | for (std::size_t i = 0; i < keyboard_keys.size(); ++i) { | 40 | for (std::size_t i = 0; i < keyboard_keys.size(); ++i) { |
| 40 | for (std::size_t k = 0; k < 8; ++k) { | 41 | for (std::size_t k = 0; k < KEYS_PER_BYTE; ++k) { |
| 41 | cur_entry.key[i / 8] |= (keyboard_keys[i]->GetStatus() << k); | 42 | cur_entry.key[i / KEYS_PER_BYTE] |= (keyboard_keys[i]->GetStatus() << k); |
| 42 | } | 43 | } |
| 43 | } | 44 | } |
| 44 | 45 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 911ba3574..46604887c 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -21,13 +21,9 @@ constexpr s32 HID_JOYSTICK_MAX = 0x7fff; | |||
| 21 | constexpr s32 HID_JOYSTICK_MIN = -0x7fff; | 21 | constexpr s32 HID_JOYSTICK_MIN = -0x7fff; |
| 22 | constexpr std::size_t NPAD_OFFSET = 0x9A00; | 22 | constexpr std::size_t NPAD_OFFSET = 0x9A00; |
| 23 | constexpr u32 BATTERY_FULL = 2; | 23 | constexpr u32 BATTERY_FULL = 2; |
| 24 | constexpr u32 NPAD_HANDHELD = 32; | ||
| 25 | constexpr u32 NPAD_UNKNOWN = 16; // TODO(ogniK): What is this? | ||
| 26 | constexpr u32 MAX_NPAD_ID = 7; | 24 | constexpr u32 MAX_NPAD_ID = 7; |
| 27 | constexpr Controller_NPad::NPadControllerType PREFERRED_CONTROLLER = | ||
| 28 | Controller_NPad::NPadControllerType::JoyDual; | ||
| 29 | constexpr std::array<u32, 10> npad_id_list{ | 25 | constexpr std::array<u32, 10> npad_id_list{ |
| 30 | 0, 1, 2, 3, 4, 5, 6, 7, 32, 16, | 26 | 0, 1, 2, 3, 4, 5, 6, 7, NPAD_HANDHELD, NPAD_UNKNOWN, |
| 31 | }; | 27 | }; |
| 32 | 28 | ||
| 33 | enum class JoystickId : std::size_t { | 29 | enum class JoystickId : std::size_t { |
| @@ -51,7 +47,7 @@ static Controller_NPad::NPadControllerType MapSettingsTypeToNPad(Settings::Contr | |||
| 51 | } | 47 | } |
| 52 | } | 48 | } |
| 53 | 49 | ||
| 54 | static std::size_t NPadIdToIndex(u32 npad_id) { | 50 | std::size_t Controller_NPad::NPadIdToIndex(u32 npad_id) { |
| 55 | switch (npad_id) { | 51 | switch (npad_id) { |
| 56 | case 0: | 52 | case 0: |
| 57 | case 1: | 53 | case 1: |
| @@ -74,6 +70,27 @@ static std::size_t NPadIdToIndex(u32 npad_id) { | |||
| 74 | } | 70 | } |
| 75 | } | 71 | } |
| 76 | 72 | ||
| 73 | u32 Controller_NPad::IndexToNPad(std::size_t index) { | ||
| 74 | switch (index) { | ||
| 75 | case 0: | ||
| 76 | case 1: | ||
| 77 | case 2: | ||
| 78 | case 3: | ||
| 79 | case 4: | ||
| 80 | case 5: | ||
| 81 | case 6: | ||
| 82 | case 7: | ||
| 83 | return static_cast<u32>(index); | ||
| 84 | case 8: | ||
| 85 | return NPAD_HANDHELD; | ||
| 86 | case 9: | ||
| 87 | return NPAD_UNKNOWN; | ||
| 88 | default: | ||
| 89 | UNIMPLEMENTED_MSG("Unknown npad index {}", index); | ||
| 90 | return 0; | ||
| 91 | }; | ||
| 92 | } | ||
| 93 | |||
| 77 | Controller_NPad::Controller_NPad() = default; | 94 | Controller_NPad::Controller_NPad() = default; |
| 78 | Controller_NPad::~Controller_NPad() = default; | 95 | Controller_NPad::~Controller_NPad() = default; |
| 79 | 96 | ||
| @@ -190,7 +207,7 @@ void Controller_NPad::OnInit() { | |||
| 190 | supported_npad_id_types.resize(npad_id_list.size()); | 207 | supported_npad_id_types.resize(npad_id_list.size()); |
| 191 | std::memcpy(supported_npad_id_types.data(), npad_id_list.data(), | 208 | std::memcpy(supported_npad_id_types.data(), npad_id_list.data(), |
| 192 | npad_id_list.size() * sizeof(u32)); | 209 | npad_id_list.size() * sizeof(u32)); |
| 193 | AddNewController(PREFERRED_CONTROLLER); | 210 | AddNewController(NPadControllerType::JoyDual); |
| 194 | } | 211 | } |
| 195 | 212 | ||
| 196 | for (std::size_t i = 0; i < connected_controllers.size(); ++i) { | 213 | for (std::size_t i = 0; i < connected_controllers.size(); ++i) { |
| @@ -391,9 +408,9 @@ void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) { | |||
| 391 | libnx_entry.connection_status.IsRightJoyConnected.Assign(1); | 408 | libnx_entry.connection_status.IsRightJoyConnected.Assign(1); |
| 392 | libnx_entry.connection_status.IsConnected.Assign(1); | 409 | libnx_entry.connection_status.IsConnected.Assign(1); |
| 393 | 410 | ||
| 394 | dual_entry.pad_states.raw = pad_state.raw; | 411 | dual_entry.pad.pad_states.raw = pad_state.pad_states.raw; |
| 395 | dual_entry.l_stick = lstick_entry; | 412 | dual_entry.pad.l_stick = pad_state.l_stick; |
| 396 | dual_entry.r_stick = rstick_entry; | 413 | dual_entry.pad.r_stick = pad_state.r_stick; |
| 397 | break; | 414 | break; |
| 398 | case NPadControllerType::JoyLeft: | 415 | case NPadControllerType::JoyLeft: |
| 399 | left_entry.connection_status.raw = 0; | 416 | left_entry.connection_status.raw = 0; |
| @@ -461,23 +478,24 @@ void Controller_NPad::SetSupportedNPadIdTypes(u8* data, std::size_t length) { | |||
| 461 | if (!controller.is_connected) { | 478 | if (!controller.is_connected) { |
| 462 | continue; | 479 | continue; |
| 463 | } | 480 | } |
| 464 | if (!IsControllerSupported(PREFERRED_CONTROLLER)) { | 481 | const auto requested_controller = |
| 465 | const auto best_type = DecideBestController(PREFERRED_CONTROLLER); | 482 | i <= MAX_NPAD_ID ? MapSettingsTypeToNPad(Settings::values.players[i].type) |
| 466 | const bool is_handheld = (best_type == NPadControllerType::Handheld || | 483 | : NPadControllerType::Handheld; |
| 467 | PREFERRED_CONTROLLER == NPadControllerType::Handheld); | 484 | if (!IsControllerSupported(requested_controller)) { |
| 485 | const auto is_handheld = requested_controller == NPadControllerType::Handheld; | ||
| 468 | if (is_handheld) { | 486 | if (is_handheld) { |
| 469 | controller.type = NPadControllerType::None; | 487 | controller.type = NPadControllerType::None; |
| 470 | controller.is_connected = false; | 488 | controller.is_connected = false; |
| 471 | AddNewController(best_type); | 489 | AddNewController(requested_controller); |
| 472 | } else { | 490 | } else { |
| 473 | controller.type = best_type; | 491 | controller.type = requested_controller; |
| 474 | InitNewlyAddedControler(i); | 492 | InitNewlyAddedControler(i); |
| 475 | } | 493 | } |
| 476 | had_controller_update = true; | 494 | had_controller_update = true; |
| 477 | } | 495 | } |
| 478 | } | 496 | if (had_controller_update) { |
| 479 | if (had_controller_update) { | 497 | styleset_changed_event->Signal(); |
| 480 | styleset_changed_event->Signal(); | 498 | } |
| 481 | } | 499 | } |
| 482 | } | 500 | } |
| 483 | 501 | ||
| @@ -530,50 +548,6 @@ Controller_NPad::Vibration Controller_NPad::GetLastVibration() const { | |||
| 530 | return last_processed_vibration; | 548 | return last_processed_vibration; |
| 531 | } | 549 | } |
| 532 | 550 | ||
| 533 | std::size_t Controller_NPad::NPadIdToIndex(u32 npad_id) { | ||
| 534 | switch (npad_id) { | ||
| 535 | case 0: | ||
| 536 | case 1: | ||
| 537 | case 2: | ||
| 538 | case 3: | ||
| 539 | case 4: | ||
| 540 | case 5: | ||
| 541 | case 6: | ||
| 542 | case 7: | ||
| 543 | return static_cast<std::size_t>(npad_id); | ||
| 544 | case 8: | ||
| 545 | case 32: | ||
| 546 | return 8; | ||
| 547 | case 9: | ||
| 548 | case 16: | ||
| 549 | return 9; | ||
| 550 | default: | ||
| 551 | UNIMPLEMENTED_MSG("Unknown npad id {}", npad_id); | ||
| 552 | return 0; | ||
| 553 | } | ||
| 554 | } | ||
| 555 | |||
| 556 | u32 Controller_NPad::IndexToNPad(std::size_t index) { | ||
| 557 | switch (index) { | ||
| 558 | case 0: | ||
| 559 | case 1: | ||
| 560 | case 2: | ||
| 561 | case 3: | ||
| 562 | case 4: | ||
| 563 | case 5: | ||
| 564 | case 6: | ||
| 565 | case 7: | ||
| 566 | return static_cast<u32>(index); | ||
| 567 | case 8: | ||
| 568 | return 32; | ||
| 569 | case 9: | ||
| 570 | return 16; | ||
| 571 | default: | ||
| 572 | UNIMPLEMENTED_MSG("Unknown npad index {}", index); | ||
| 573 | return 0; | ||
| 574 | }; | ||
| 575 | } | ||
| 576 | |||
| 577 | void Controller_NPad::AddNewController(NPadControllerType controller) { | 551 | void Controller_NPad::AddNewController(NPadControllerType controller) { |
| 578 | controller = DecideBestController(controller); | 552 | controller = DecideBestController(controller); |
| 579 | if (controller == NPadControllerType::Handheld) { | 553 | if (controller == NPadControllerType::Handheld) { |
| @@ -596,13 +570,13 @@ void Controller_NPad::AddNewController(NPadControllerType controller) { | |||
| 596 | void Controller_NPad::AddNewControllerAt(NPadControllerType controller, u32 npad_id) { | 570 | void Controller_NPad::AddNewControllerAt(NPadControllerType controller, u32 npad_id) { |
| 597 | controller = DecideBestController(controller); | 571 | controller = DecideBestController(controller); |
| 598 | if (controller == NPadControllerType::Handheld) { | 572 | if (controller == NPadControllerType::Handheld) { |
| 599 | connected_controllers[8] = {controller, true}; | 573 | connected_controllers[NPadIdToIndex(NPAD_HANDHELD)] = {controller, true}; |
| 600 | InitNewlyAddedControler(8); | 574 | InitNewlyAddedControler(NPadIdToIndex(NPAD_HANDHELD)); |
| 601 | return; | 575 | return; |
| 602 | } | 576 | } |
| 603 | const size_t controller_id = static_cast<std::size_t>(npad_id); | 577 | |
| 604 | connected_controllers[controller_id] = {controller, true}; | 578 | connected_controllers[npad_id] = {controller, true}; |
| 605 | InitNewlyAddedControler(controller_id); | 579 | InitNewlyAddedControler(npad_id); |
| 606 | } | 580 | } |
| 607 | 581 | ||
| 608 | void Controller_NPad::ConnectNPad(u32 npad_id) { | 582 | void Controller_NPad::ConnectNPad(u32 npad_id) { |
| @@ -613,97 +587,11 @@ void Controller_NPad::DisconnectNPad(u32 npad_id) { | |||
| 613 | connected_controllers[NPadIdToIndex(npad_id)].is_connected = false; | 587 | connected_controllers[NPadIdToIndex(npad_id)].is_connected = false; |
| 614 | } | 588 | } |
| 615 | 589 | ||
| 616 | Controller_NPad::NPadControllerType Controller_NPad::DecideBestController( | ||
| 617 | NPadControllerType priority) { | ||
| 618 | if (IsControllerSupported(priority)) { | ||
| 619 | return priority; | ||
| 620 | } | ||
| 621 | const auto is_docked = Settings::values.use_docked_mode; | ||
| 622 | if (is_docked && priority == NPadControllerType::Handheld) { | ||
| 623 | priority = NPadControllerType::JoyDual; | ||
| 624 | if (IsControllerSupported(priority)) { | ||
| 625 | return priority; | ||
| 626 | } | ||
| 627 | } | ||
| 628 | std::vector<NPadControllerType> priority_list{}; | ||
| 629 | switch (priority) { | ||
| 630 | case NPadControllerType::ProController: | ||
| 631 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 632 | if (!is_docked) { | ||
| 633 | priority_list.push_back(NPadControllerType::Handheld); | ||
| 634 | } | ||
| 635 | priority_list.push_back(NPadControllerType::JoyLeft); | ||
| 636 | priority_list.push_back(NPadControllerType::JoyRight); | ||
| 637 | priority_list.push_back(NPadControllerType::Pokeball); | ||
| 638 | break; | ||
| 639 | case NPadControllerType::Handheld: | ||
| 640 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 641 | priority_list.push_back(NPadControllerType::ProController); | ||
| 642 | priority_list.push_back(NPadControllerType::JoyLeft); | ||
| 643 | priority_list.push_back(NPadControllerType::JoyRight); | ||
| 644 | priority_list.push_back(NPadControllerType::Pokeball); | ||
| 645 | break; | ||
| 646 | case NPadControllerType::JoyDual: | ||
| 647 | if (!is_docked) { | ||
| 648 | priority_list.push_back(NPadControllerType::Handheld); | ||
| 649 | } | ||
| 650 | priority_list.push_back(NPadControllerType::ProController); | ||
| 651 | priority_list.push_back(NPadControllerType::JoyLeft); | ||
| 652 | priority_list.push_back(NPadControllerType::JoyRight); | ||
| 653 | priority_list.push_back(NPadControllerType::Pokeball); | ||
| 654 | break; | ||
| 655 | case NPadControllerType::JoyLeft: | ||
| 656 | priority_list.push_back(NPadControllerType::JoyRight); | ||
| 657 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 658 | if (!is_docked) { | ||
| 659 | priority_list.push_back(NPadControllerType::Handheld); | ||
| 660 | } | ||
| 661 | priority_list.push_back(NPadControllerType::ProController); | ||
| 662 | priority_list.push_back(NPadControllerType::Pokeball); | ||
| 663 | break; | ||
| 664 | case NPadControllerType::JoyRight: | ||
| 665 | priority_list.push_back(NPadControllerType::JoyLeft); | ||
| 666 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 667 | if (!is_docked) { | ||
| 668 | priority_list.push_back(NPadControllerType::Handheld); | ||
| 669 | } | ||
| 670 | priority_list.push_back(NPadControllerType::ProController); | ||
| 671 | priority_list.push_back(NPadControllerType::Pokeball); | ||
| 672 | break; | ||
| 673 | case NPadControllerType::Pokeball: | ||
| 674 | priority_list.push_back(NPadControllerType::JoyLeft); | ||
| 675 | priority_list.push_back(NPadControllerType::JoyRight); | ||
| 676 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 677 | if (!is_docked) { | ||
| 678 | priority_list.push_back(NPadControllerType::Handheld); | ||
| 679 | } | ||
| 680 | priority_list.push_back(NPadControllerType::ProController); | ||
| 681 | break; | ||
| 682 | default: | ||
| 683 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 684 | if (!is_docked) { | ||
| 685 | priority_list.push_back(NPadControllerType::Handheld); | ||
| 686 | } | ||
| 687 | priority_list.push_back(NPadControllerType::ProController); | ||
| 688 | priority_list.push_back(NPadControllerType::JoyLeft); | ||
| 689 | priority_list.push_back(NPadControllerType::JoyRight); | ||
| 690 | priority_list.push_back(NPadControllerType::JoyDual); | ||
| 691 | } | ||
| 692 | |||
| 693 | for (const auto controller_type : priority_list) { | ||
| 694 | if (IsControllerSupported(controller_type)) { | ||
| 695 | return controller_type; | ||
| 696 | } | ||
| 697 | } | ||
| 698 | UNIMPLEMENTED_MSG("Could not find supported controller!"); | ||
| 699 | return priority; | ||
| 700 | } | ||
| 701 | |||
| 702 | bool Controller_NPad::IsControllerSupported(NPadControllerType controller) { | 590 | bool Controller_NPad::IsControllerSupported(NPadControllerType controller) { |
| 703 | if (controller == NPadControllerType::Handheld) { | 591 | if (controller == NPadControllerType::Handheld) { |
| 704 | // Handheld is not even a supported type, lets stop here | 592 | // Handheld is not even a supported type, lets stop here |
| 705 | if (std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), 32) == | 593 | if (std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), |
| 706 | supported_npad_id_types.end()) { | 594 | NPAD_HANDHELD) == supported_npad_id_types.end()) { |
| 707 | return false; | 595 | return false; |
| 708 | } | 596 | } |
| 709 | // Handheld should not be supported in docked mode | 597 | // Handheld should not be supported in docked mode |
| @@ -761,13 +649,12 @@ void Controller_NPad::SetVibrationEnabled(bool can_vibrate) { | |||
| 761 | } | 649 | } |
| 762 | 650 | ||
| 763 | void Controller_NPad::ClearAllConnectedControllers() { | 651 | void Controller_NPad::ClearAllConnectedControllers() { |
| 764 | std::for_each(connected_controllers.begin(), connected_controllers.end(), | 652 | for (auto& controller : connected_controllers) { |
| 765 | [](ControllerHolder& controller) { | 653 | if (controller.is_connected && controller.type != NPadControllerType::None) { |
| 766 | if (controller.is_connected && controller.type != NPadControllerType::None) { | 654 | controller.type = NPadControllerType::None; |
| 767 | controller.type = NPadControllerType::None; | 655 | controller.is_connected = false; |
| 768 | controller.is_connected = false; | 656 | } |
| 769 | } | 657 | } |
| 770 | }); | ||
| 771 | } | 658 | } |
| 772 | void Controller_NPad::DisconnectAllConnectedControllers() { | 659 | void Controller_NPad::DisconnectAllConnectedControllers() { |
| 773 | std::for_each(connected_controllers.begin(), connected_controllers.end(), | 660 | std::for_each(connected_controllers.begin(), connected_controllers.end(), |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 52f92a4f1..ea8057b80 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -5,13 +5,18 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include "common/bit_field.h" | ||
| 8 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 9 | #include "core/frontend/input.h" | 10 | #include "core/frontend/input.h" |
| 11 | #include "core/hle/kernel/event.h" | ||
| 10 | #include "core/hle/service/hid/controllers/controller_base.h" | 12 | #include "core/hle/service/hid/controllers/controller_base.h" |
| 11 | #include "core/settings.h" | 13 | #include "core/settings.h" |
| 12 | 14 | ||
| 13 | namespace Service::HID { | 15 | namespace Service::HID { |
| 14 | 16 | ||
| 17 | constexpr u32 NPAD_HANDHELD = 32; | ||
| 18 | constexpr u32 NPAD_UNKNOWN = 16; // TODO(ogniK): What is this? | ||
| 19 | |||
| 15 | class Controller_NPad final : public ControllerBase { | 20 | class Controller_NPad final : public ControllerBase { |
| 16 | public: | 21 | public: |
| 17 | Controller_NPad(); | 22 | Controller_NPad(); |
| @@ -118,6 +123,9 @@ public: | |||
| 118 | void ConnectAllDisconnectedControllers(); | 123 | void ConnectAllDisconnectedControllers(); |
| 119 | void ClearAllControllers(); | 124 | void ClearAllControllers(); |
| 120 | 125 | ||
| 126 | static std::size_t NPadIdToIndex(u32 npad_id); | ||
| 127 | static u32 IndexToNPad(std::size_t index); | ||
| 128 | |||
| 121 | private: | 129 | private: |
| 122 | struct CommonHeader { | 130 | struct CommonHeader { |
| 123 | s64_le timestamp; | 131 | s64_le timestamp; |
| @@ -304,10 +312,7 @@ private: | |||
| 304 | bool IsControllerSupported(NPadControllerType controller) const; | 312 | bool IsControllerSupported(NPadControllerType controller) const; |
| 305 | NPadControllerType DecideBestController(NPadControllerType priority) const; | 313 | NPadControllerType DecideBestController(NPadControllerType priority) const; |
| 306 | void RequestPadStateUpdate(u32 npad_id); | 314 | void RequestPadStateUpdate(u32 npad_id); |
| 307 | std::size_t NPadIdToIndex(u32 npad_id); | ||
| 308 | u32 IndexToNPad(std::size_t index); | ||
| 309 | std::array<ControllerPad, 10> npad_pad_states{}; | 315 | std::array<ControllerPad, 10> npad_pad_states{}; |
| 310 | NPadControllerType DecideBestController(NPadControllerType priority); | ||
| 311 | bool IsControllerSupported(NPadControllerType controller); | 316 | bool IsControllerSupported(NPadControllerType controller); |
| 312 | }; | 317 | }; |
| 313 | } // namespace Service::HID | 318 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 8b9763de6..f666b1bd8 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp | |||
| @@ -43,9 +43,6 @@ void Controller_Touchscreen::OnUpdate(u8* data, std::size_t size) { | |||
| 43 | auto& touch_entry = cur_entry.states[0]; | 43 | auto& touch_entry = cur_entry.states[0]; |
| 44 | touch_entry.attribute.raw = 0; | 44 | touch_entry.attribute.raw = 0; |
| 45 | if (pressed && Settings::values.touchscreen.enabled) { | 45 | if (pressed && Settings::values.touchscreen.enabled) { |
| 46 | if (cur_entry.entry_count == 0) { | ||
| 47 | touch_entry.attribute.start_touch.Assign(1); | ||
| 48 | } | ||
| 49 | touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width); | 46 | touch_entry.x = static_cast<u16>(x * Layout::ScreenUndocked::Width); |
| 50 | touch_entry.y = static_cast<u16>(y * Layout::ScreenUndocked::Height); | 47 | touch_entry.y = static_cast<u16>(y * Layout::ScreenUndocked::Height); |
| 51 | touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; | 48 | touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; |
| @@ -57,9 +54,6 @@ void Controller_Touchscreen::OnUpdate(u8* data, std::size_t size) { | |||
| 57 | touch_entry.finger = Settings::values.touchscreen.finger; | 54 | touch_entry.finger = Settings::values.touchscreen.finger; |
| 58 | cur_entry.entry_count = 1; | 55 | cur_entry.entry_count = 1; |
| 59 | } else { | 56 | } else { |
| 60 | if (cur_entry.entry_count == 1) { | ||
| 61 | touch_entry.attribute.end_touch.Assign(1); | ||
| 62 | } | ||
| 63 | cur_entry.entry_count = 0; | 57 | cur_entry.entry_count = 0; |
| 64 | } | 58 | } |
| 65 | 59 | ||
diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 0da159559..26fcd3405 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp | |||
| @@ -10,6 +10,56 @@ | |||
| 10 | 10 | ||
| 11 | namespace Settings { | 11 | namespace Settings { |
| 12 | 12 | ||
| 13 | namespace NativeButton { | ||
| 14 | const std::array<const char*, NumButtons> mapping = {{ | ||
| 15 | "button_a", | ||
| 16 | "button_b", | ||
| 17 | "button_x", | ||
| 18 | "button_y", | ||
| 19 | "button_lstick", | ||
| 20 | "button_rstick", | ||
| 21 | "button_l", | ||
| 22 | "button_r", | ||
| 23 | "button_zl", | ||
| 24 | "button_zr", | ||
| 25 | "button_plus", | ||
| 26 | "button_minus", | ||
| 27 | "button_dleft", | ||
| 28 | "button_dup", | ||
| 29 | "button_dright", | ||
| 30 | "button_ddown", | ||
| 31 | "button_lstick_left", | ||
| 32 | "button_lstick_up", | ||
| 33 | "button_lstick_right", | ||
| 34 | "button_lstick_down", | ||
| 35 | "button_rstick_left", | ||
| 36 | "button_rstick_up", | ||
| 37 | "button_rstick_right", | ||
| 38 | "button_rstick_down", | ||
| 39 | "button_sl", | ||
| 40 | "button_sr", | ||
| 41 | "button_home", | ||
| 42 | "button_screenshot", | ||
| 43 | }}; | ||
| 44 | } | ||
| 45 | |||
| 46 | namespace NativeAnalog { | ||
| 47 | const std::array<const char*, NumAnalogs> mapping = {{ | ||
| 48 | "lstick", | ||
| 49 | "rstick", | ||
| 50 | }}; | ||
| 51 | } | ||
| 52 | |||
| 53 | namespace NativeMouseButton { | ||
| 54 | const std::array<const char*, NumMouseButtons> mapping = {{ | ||
| 55 | "left", | ||
| 56 | "right", | ||
| 57 | "middle", | ||
| 58 | "forward", | ||
| 59 | "back", | ||
| 60 | }}; | ||
| 61 | } | ||
| 62 | |||
| 13 | Values values = {}; | 63 | Values values = {}; |
| 14 | 64 | ||
| 15 | void Apply() { | 65 | void Apply() { |
diff --git a/src/core/settings.h b/src/core/settings.h index 9cc3c1dc8..e63134f80 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -60,36 +60,7 @@ constexpr int BUTTON_NS_END = NumButtons; | |||
| 60 | constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN; | 60 | constexpr int NUM_BUTTONS_HID = BUTTON_HID_END - BUTTON_HID_BEGIN; |
| 61 | constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN; | 61 | constexpr int NUM_BUTTONS_NS = BUTTON_NS_END - BUTTON_NS_BEGIN; |
| 62 | 62 | ||
| 63 | static const std::array<const char*, NumButtons> mapping = {{ | 63 | extern const std::array<const char*, NumButtons> mapping; |
| 64 | "button_a", | ||
| 65 | "button_b", | ||
| 66 | "button_x", | ||
| 67 | "button_y", | ||
| 68 | "button_lstick", | ||
| 69 | "button_rstick", | ||
| 70 | "button_l", | ||
| 71 | "button_r", | ||
| 72 | "button_zl", | ||
| 73 | "button_zr", | ||
| 74 | "button_plus", | ||
| 75 | "button_minus", | ||
| 76 | "button_dleft", | ||
| 77 | "button_dup", | ||
| 78 | "button_dright", | ||
| 79 | "button_ddown", | ||
| 80 | "button_lstick_left", | ||
| 81 | "button_lstick_up", | ||
| 82 | "button_lstick_right", | ||
| 83 | "button_lstick_down", | ||
| 84 | "button_rstick_left", | ||
| 85 | "button_rstick_up", | ||
| 86 | "button_rstick_right", | ||
| 87 | "button_rstick_down", | ||
| 88 | "button_sl", | ||
| 89 | "button_sr", | ||
| 90 | "button_home", | ||
| 91 | "button_screenshot", | ||
| 92 | }}; | ||
| 93 | 64 | ||
| 94 | } // namespace NativeButton | 65 | } // namespace NativeButton |
| 95 | 66 | ||
| @@ -105,10 +76,7 @@ constexpr int STICK_HID_BEGIN = LStick; | |||
| 105 | constexpr int STICK_HID_END = NumAnalogs; | 76 | constexpr int STICK_HID_END = NumAnalogs; |
| 106 | constexpr int NUM_STICKS_HID = NumAnalogs; | 77 | constexpr int NUM_STICKS_HID = NumAnalogs; |
| 107 | 78 | ||
| 108 | static const std::array<const char*, NumAnalogs> mapping = {{ | 79 | extern const std::array<const char*, NumAnalogs> mapping; |
| 109 | "lstick", | ||
| 110 | "rstick", | ||
| 111 | }}; | ||
| 112 | } // namespace NativeAnalog | 80 | } // namespace NativeAnalog |
| 113 | 81 | ||
| 114 | namespace NativeMouseButton { | 82 | namespace NativeMouseButton { |
| @@ -126,13 +94,7 @@ constexpr int MOUSE_HID_BEGIN = Left; | |||
| 126 | constexpr int MOUSE_HID_END = NumMouseButtons; | 94 | constexpr int MOUSE_HID_END = NumMouseButtons; |
| 127 | constexpr int NUM_MOUSE_HID = NumMouseButtons; | 95 | constexpr int NUM_MOUSE_HID = NumMouseButtons; |
| 128 | 96 | ||
| 129 | static const std::array<const char*, NumMouseButtons> mapping = {{ | 97 | extern const std::array<const char*, NumMouseButtons> mapping; |
| 130 | "left", | ||
| 131 | "right", | ||
| 132 | "middle", | ||
| 133 | "forward", | ||
| 134 | "back", | ||
| 135 | }}; | ||
| 136 | } // namespace NativeMouseButton | 98 | } // namespace NativeMouseButton |
| 137 | 99 | ||
| 138 | namespace NativeKeyboard { | 100 | namespace NativeKeyboard { |
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index c931c7cd6..652f6a0b7 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -203,9 +203,8 @@ const std::array<int, Settings::NativeKeyboard::NumKeyboardMods> Config::default | |||
| 203 | Qt::Key_Control, Qt::Key_Shift, Qt::Key_AltGr, Qt::Key_ApplicationRight, | 203 | Qt::Key_Control, Qt::Key_Shift, Qt::Key_AltGr, Qt::Key_ApplicationRight, |
| 204 | }; | 204 | }; |
| 205 | 205 | ||
| 206 | void Config::ReadValues() { | 206 | void Config::ReadPlayerValues() { |
| 207 | qt_config->beginGroup("Controls"); | 207 | for (std::size_t p = 0; p < Settings::values.players.size(); ++p) { |
| 208 | for (std::size_t p = 0; p < 10; ++p) { | ||
| 209 | Settings::values.players[p].connected = | 208 | Settings::values.players[p].connected = |
| 210 | qt_config->value(QString("player_%1_connected").arg(p), false).toBool(); | 209 | qt_config->value(QString("player_%1_connected").arg(p), false).toBool(); |
| 211 | 210 | ||
| @@ -265,28 +264,9 @@ void Config::ReadValues() { | |||
| 265 | 264 | ||
| 266 | std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(), | 265 | std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(), |
| 267 | [](const auto& player) { return player.connected; }); | 266 | [](const auto& player) { return player.connected; }); |
| 267 | } | ||
| 268 | 268 | ||
| 269 | Settings::values.motion_device = | 269 | void Config::ReadDebugValues() { |
| 270 | qt_config->value("motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01") | ||
| 271 | .toString() | ||
| 272 | .toStdString(); | ||
| 273 | |||
| 274 | Settings::values.mouse_enabled = qt_config->value("mouse_enabled", false).toBool(); | ||
| 275 | |||
| 276 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 277 | std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 278 | Settings::values.mouse_buttons[i] = | ||
| 279 | qt_config | ||
| 280 | ->value(QString("mouse_") + Settings::NativeMouseButton::mapping[i], | ||
| 281 | QString::fromStdString(default_param)) | ||
| 282 | .toString() | ||
| 283 | .toStdString(); | ||
| 284 | if (Settings::values.mouse_buttons[i].empty()) | ||
| 285 | Settings::values.mouse_buttons[i] = default_param; | ||
| 286 | } | ||
| 287 | |||
| 288 | Settings::values.keyboard_enabled = qt_config->value("keyboard_enabled", false).toBool(); | ||
| 289 | |||
| 290 | Settings::values.debug_pad_enabled = qt_config->value("debug_pad_enabled", false).toBool(); | 270 | Settings::values.debug_pad_enabled = qt_config->value("debug_pad_enabled", false).toBool(); |
| 291 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 271 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 292 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); | 272 | std::string default_param = InputCommon::GenerateKeyboardParam(default_buttons[i]); |
| @@ -313,7 +293,38 @@ void Config::ReadValues() { | |||
| 313 | if (Settings::values.debug_pad_analogs[i].empty()) | 293 | if (Settings::values.debug_pad_analogs[i].empty()) |
| 314 | Settings::values.debug_pad_analogs[i] = default_param; | 294 | Settings::values.debug_pad_analogs[i] = default_param; |
| 315 | } | 295 | } |
| 296 | } | ||
| 297 | |||
| 298 | void Config::ReadKeyboardValues() { | ||
| 299 | Settings::values.keyboard_enabled = qt_config->value("keyboard_enabled", false).toBool(); | ||
| 316 | 300 | ||
| 301 | std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(), | ||
| 302 | Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); | ||
| 303 | std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(), | ||
| 304 | Settings::values.keyboard_keys.begin() + | ||
| 305 | Settings::NativeKeyboard::LeftControlKey, | ||
| 306 | InputCommon::GenerateKeyboardParam); | ||
| 307 | std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(), | ||
| 308 | Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam); | ||
| 309 | } | ||
| 310 | |||
| 311 | void Config::ReadMouseValues() { | ||
| 312 | Settings::values.mouse_enabled = qt_config->value("mouse_enabled", false).toBool(); | ||
| 313 | |||
| 314 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 315 | std::string default_param = InputCommon::GenerateKeyboardParam(default_mouse_buttons[i]); | ||
| 316 | Settings::values.mouse_buttons[i] = | ||
| 317 | qt_config | ||
| 318 | ->value(QString("mouse_") + Settings::NativeMouseButton::mapping[i], | ||
| 319 | QString::fromStdString(default_param)) | ||
| 320 | .toString() | ||
| 321 | .toStdString(); | ||
| 322 | if (Settings::values.mouse_buttons[i].empty()) | ||
| 323 | Settings::values.mouse_buttons[i] = default_param; | ||
| 324 | } | ||
| 325 | } | ||
| 326 | |||
| 327 | void Config::ReadTouchscreenValues() { | ||
| 317 | Settings::values.touchscreen.enabled = qt_config->value("touchscreen_enabled", true).toBool(); | 328 | Settings::values.touchscreen.enabled = qt_config->value("touchscreen_enabled", true).toBool(); |
| 318 | Settings::values.touchscreen.device = | 329 | Settings::values.touchscreen.device = |
| 319 | qt_config->value("touchscreen_device", "engine:emu_window").toString().toStdString(); | 330 | qt_config->value("touchscreen_device", "engine:emu_window").toString().toStdString(); |
| @@ -325,6 +336,21 @@ void Config::ReadValues() { | |||
| 325 | Settings::values.touchscreen.diameter_y = | 336 | Settings::values.touchscreen.diameter_y = |
| 326 | qt_config->value("touchscreen_diameter_y", 15).toUInt(); | 337 | qt_config->value("touchscreen_diameter_y", 15).toUInt(); |
| 327 | qt_config->endGroup(); | 338 | qt_config->endGroup(); |
| 339 | } | ||
| 340 | |||
| 341 | void Config::ReadValues() { | ||
| 342 | qt_config->beginGroup("Controls"); | ||
| 343 | |||
| 344 | ReadPlayerValues(); | ||
| 345 | ReadDebugValues(); | ||
| 346 | ReadKeyboardValues(); | ||
| 347 | ReadMouseValues(); | ||
| 348 | ReadTouchscreenValues(); | ||
| 349 | |||
| 350 | Settings::values.motion_device = | ||
| 351 | qt_config->value("motion_device", "engine:motion_emu,update_period:100,sensitivity:0.01") | ||
| 352 | .toString() | ||
| 353 | .toStdString(); | ||
| 328 | 354 | ||
| 329 | qt_config->beginGroup("Core"); | 355 | qt_config->beginGroup("Core"); |
| 330 | Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); | 356 | Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); |
| @@ -370,15 +396,6 @@ void Config::ReadValues() { | |||
| 370 | .toStdString()); | 396 | .toStdString()); |
| 371 | qt_config->endGroup(); | 397 | qt_config->endGroup(); |
| 372 | 398 | ||
| 373 | std::transform(default_keyboard_keys.begin(), default_keyboard_keys.end(), | ||
| 374 | Settings::values.keyboard_keys.begin(), InputCommon::GenerateKeyboardParam); | ||
| 375 | std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(), | ||
| 376 | Settings::values.keyboard_keys.begin() + | ||
| 377 | Settings::NativeKeyboard::LeftControlKey, | ||
| 378 | InputCommon::GenerateKeyboardParam); | ||
| 379 | std::transform(default_keyboard_mods.begin(), default_keyboard_mods.end(), | ||
| 380 | Settings::values.keyboard_mods.begin(), InputCommon::GenerateKeyboardParam); | ||
| 381 | |||
| 382 | qt_config->beginGroup("Core"); | 399 | qt_config->beginGroup("Core"); |
| 383 | Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); | 400 | Settings::values.use_cpu_jit = qt_config->value("use_cpu_jit", true).toBool(); |
| 384 | Settings::values.use_multi_core = qt_config->value("use_multi_core", false).toBool(); | 401 | Settings::values.use_multi_core = qt_config->value("use_multi_core", false).toBool(); |
| @@ -488,9 +505,8 @@ void Config::ReadValues() { | |||
| 488 | qt_config->endGroup(); | 505 | qt_config->endGroup(); |
| 489 | } | 506 | } |
| 490 | 507 | ||
| 491 | void Config::SaveValues() { | 508 | void Config::SavePlayerValues() { |
| 492 | qt_config->beginGroup("Controls"); | 509 | for (int p = 0; p < Settings::values.players.size(); ++p) { |
| 493 | for (int p = 0; p < 10; ++p) { | ||
| 494 | qt_config->setValue(QString("player_%1_connected").arg(p), | 510 | qt_config->setValue(QString("player_%1_connected").arg(p), |
| 495 | Settings::values.players[p].connected); | 511 | Settings::values.players[p].connected); |
| 496 | qt_config->setValue(QString("player_%1_type").arg(p), | 512 | qt_config->setValue(QString("player_%1_type").arg(p), |
| @@ -516,19 +532,9 @@ void Config::SaveValues() { | |||
| 516 | QString::fromStdString(Settings::values.players[p].analogs[i])); | 532 | QString::fromStdString(Settings::values.players[p].analogs[i])); |
| 517 | } | 533 | } |
| 518 | } | 534 | } |
| 535 | } | ||
| 519 | 536 | ||
| 520 | qt_config->setValue("motion_device", QString::fromStdString(Settings::values.motion_device)); | 537 | void Config::SaveDebugValues() { |
| 521 | |||
| 522 | qt_config->setValue("mouse_enabled", Settings::values.mouse_enabled); | ||
| 523 | |||
| 524 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 525 | qt_config->setValue(QString("mouse_") + | ||
| 526 | QString::fromStdString(Settings::NativeMouseButton::mapping[i]), | ||
| 527 | QString::fromStdString(Settings::values.mouse_buttons[i])); | ||
| 528 | } | ||
| 529 | |||
| 530 | qt_config->setValue("keyboard_enabled", Settings::values.keyboard_enabled); | ||
| 531 | |||
| 532 | qt_config->setValue("debug_pad_enabled", Settings::values.debug_pad_enabled); | 538 | qt_config->setValue("debug_pad_enabled", Settings::values.debug_pad_enabled); |
| 533 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { | 539 | for (int i = 0; i < Settings::NativeButton::NumButtons; ++i) { |
| 534 | qt_config->setValue(QString("debug_pad_") + | 540 | qt_config->setValue(QString("debug_pad_") + |
| @@ -540,7 +546,19 @@ void Config::SaveValues() { | |||
| 540 | QString::fromStdString(Settings::NativeAnalog::mapping[i]), | 546 | QString::fromStdString(Settings::NativeAnalog::mapping[i]), |
| 541 | QString::fromStdString(Settings::values.debug_pad_analogs[i])); | 547 | QString::fromStdString(Settings::values.debug_pad_analogs[i])); |
| 542 | } | 548 | } |
| 549 | } | ||
| 550 | |||
| 551 | void Config::SaveMouseValues() { | ||
| 552 | qt_config->setValue("mouse_enabled", Settings::values.mouse_enabled); | ||
| 553 | |||
| 554 | for (int i = 0; i < Settings::NativeMouseButton::NumMouseButtons; ++i) { | ||
| 555 | qt_config->setValue(QString("mouse_") + | ||
| 556 | QString::fromStdString(Settings::NativeMouseButton::mapping[i]), | ||
| 557 | QString::fromStdString(Settings::values.mouse_buttons[i])); | ||
| 558 | } | ||
| 559 | } | ||
| 543 | 560 | ||
| 561 | void Config::SaveTouchscreenValues() { | ||
| 544 | qt_config->setValue("touchscreen_enabled", Settings::values.touchscreen.enabled); | 562 | qt_config->setValue("touchscreen_enabled", Settings::values.touchscreen.enabled); |
| 545 | qt_config->setValue("touchscreen_device", | 563 | qt_config->setValue("touchscreen_device", |
| 546 | QString::fromStdString(Settings::values.touchscreen.device)); | 564 | QString::fromStdString(Settings::values.touchscreen.device)); |
| @@ -549,6 +567,19 @@ void Config::SaveValues() { | |||
| 549 | qt_config->setValue("touchscreen_angle", Settings::values.touchscreen.rotation_angle); | 567 | qt_config->setValue("touchscreen_angle", Settings::values.touchscreen.rotation_angle); |
| 550 | qt_config->setValue("touchscreen_diameter_x", Settings::values.touchscreen.diameter_x); | 568 | qt_config->setValue("touchscreen_diameter_x", Settings::values.touchscreen.diameter_x); |
| 551 | qt_config->setValue("touchscreen_diameter_y", Settings::values.touchscreen.diameter_y); | 569 | qt_config->setValue("touchscreen_diameter_y", Settings::values.touchscreen.diameter_y); |
| 570 | } | ||
| 571 | |||
| 572 | void Config::SaveValues() { | ||
| 573 | qt_config->beginGroup("Controls"); | ||
| 574 | |||
| 575 | SavePlayerValues(); | ||
| 576 | SaveDebugValues(); | ||
| 577 | SaveMouseValues(); | ||
| 578 | SaveTouchscreenValues(); | ||
| 579 | |||
| 580 | qt_config->setValue("motion_device", QString::fromStdString(Settings::values.motion_device)); | ||
| 581 | qt_config->setValue("keyboard_enabled", Settings::values.keyboard_enabled); | ||
| 582 | |||
| 552 | qt_config->endGroup(); | 583 | qt_config->endGroup(); |
| 553 | 584 | ||
| 554 | qt_config->beginGroup("Core"); | 585 | qt_config->beginGroup("Core"); |
diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index 1facd6b55..a1c27bbf9 100644 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h | |||
| @@ -29,7 +29,17 @@ public: | |||
| 29 | 29 | ||
| 30 | private: | 30 | private: |
| 31 | void ReadValues(); | 31 | void ReadValues(); |
| 32 | void ReadPlayerValues(); | ||
| 33 | void ReadDebugValues(); | ||
| 34 | void ReadKeyboardValues(); | ||
| 35 | void ReadMouseValues(); | ||
| 36 | void ReadTouchscreenValues(); | ||
| 37 | |||
| 32 | void SaveValues(); | 38 | void SaveValues(); |
| 39 | void SavePlayerValues(); | ||
| 40 | void SaveDebugValues(); | ||
| 41 | void SaveMouseValues(); | ||
| 42 | void SaveTouchscreenValues(); | ||
| 33 | 43 | ||
| 34 | std::unique_ptr<QSettings> qt_config; | 44 | std::unique_ptr<QSettings> qt_config; |
| 35 | std::string qt_config_loc; | 45 | std::string qt_config_loc; |
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 9ae9827fe..a52abdd8f 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "common/param_package.h" | 11 | #include "common/param_package.h" |
| 12 | #include "configuration/configure_touchscreen_advanced.h" | 12 | #include "configuration/configure_touchscreen_advanced.h" |
| 13 | #include "core/core.h" | 13 | #include "core/core.h" |
| 14 | #include "core/hle/service/hid/controllers/npad.h" | ||
| 14 | #include "input_common/main.h" | 15 | #include "input_common/main.h" |
| 15 | #include "ui_configure_input.h" | 16 | #include "ui_configure_input.h" |
| 16 | #include "ui_configure_input_player.h" | 17 | #include "ui_configure_input_player.h" |
| @@ -83,9 +84,9 @@ ConfigureInput::ConfigureInput(QWidget* parent) | |||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 85 | template <typename Dialog, typename... Args> | 86 | template <typename Dialog, typename... Args> |
| 86 | void ConfigureInput::CallConfigureDialog(Args... args) { | 87 | void ConfigureInput::CallConfigureDialog(Args&&... args) { |
| 87 | this->applyConfiguration(); | 88 | this->applyConfiguration(); |
| 88 | Dialog dialog(this, args...); | 89 | Dialog dialog(this, std::forward<Args>(args)...); |
| 89 | 90 | ||
| 90 | const auto res = dialog.exec(); | 91 | const auto res = dialog.exec(); |
| 91 | if (res == QDialog::Accepted) { | 92 | if (res == QDialog::Accepted) { |
| @@ -94,14 +95,16 @@ void ConfigureInput::CallConfigureDialog(Args... args) { | |||
| 94 | } | 95 | } |
| 95 | 96 | ||
| 96 | void ConfigureInput::applyConfiguration() { | 97 | void ConfigureInput::applyConfiguration() { |
| 97 | for (std::size_t i = 0; i < 8; ++i) { | 98 | for (std::size_t i = 0; i < players_enabled.size(); ++i) { |
| 98 | Settings::values.players[i].connected = players_enabled[i]->isChecked(); | 99 | Settings::values.players[i].connected = players_enabled[i]->isChecked(); |
| 99 | Settings::values.players[i].type = | 100 | Settings::values.players[i].type = |
| 100 | static_cast<Settings::ControllerType>(player_controller[i]->currentIndex()); | 101 | static_cast<Settings::ControllerType>(player_controller[i]->currentIndex()); |
| 101 | } | 102 | } |
| 102 | 103 | ||
| 103 | Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); | 104 | Settings::values.use_docked_mode = ui->use_docked_mode->isChecked(); |
| 104 | Settings::values.players[8].connected = ui->handheld_connected->isChecked(); | 105 | Settings::values |
| 106 | .players[Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD)] | ||
| 107 | .connected = ui->handheld_connected->isChecked(); | ||
| 105 | Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); | 108 | Settings::values.debug_pad_enabled = ui->debug_enabled->isChecked(); |
| 106 | Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); | 109 | Settings::values.mouse_enabled = ui->mouse_enabled->isChecked(); |
| 107 | Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); | 110 | Settings::values.keyboard_enabled = ui->keyboard_enabled->isChecked(); |
| @@ -109,7 +112,7 @@ void ConfigureInput::applyConfiguration() { | |||
| 109 | } | 112 | } |
| 110 | 113 | ||
| 111 | void ConfigureInput::updateUIEnabled() { | 114 | void ConfigureInput::updateUIEnabled() { |
| 112 | for (std::size_t i = 0; i < 8; ++i) { | 115 | for (std::size_t i = 0; i < players_enabled.size(); ++i) { |
| 113 | const auto enabled = players_enabled[i]->checkState() == Qt::Checked; | 116 | const auto enabled = players_enabled[i]->checkState() == Qt::Checked; |
| 114 | 117 | ||
| 115 | player_controller[i]->setEnabled(enabled); | 118 | player_controller[i]->setEnabled(enabled); |
| @@ -118,10 +121,7 @@ void ConfigureInput::updateUIEnabled() { | |||
| 118 | 121 | ||
| 119 | bool hit_disabled = false; | 122 | bool hit_disabled = false; |
| 120 | for (auto* player : players_enabled) { | 123 | for (auto* player : players_enabled) { |
| 121 | if (hit_disabled) | 124 | player->setDisabled(hit_disabled); |
| 122 | player->setDisabled(true); | ||
| 123 | else | ||
| 124 | player->setEnabled(true); | ||
| 125 | if (!player->isChecked()) | 125 | if (!player->isChecked()) |
| 126 | hit_disabled = true; | 126 | hit_disabled = true; |
| 127 | } | 127 | } |
| @@ -138,13 +138,16 @@ void ConfigureInput::loadConfiguration() { | |||
| 138 | std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(), | 138 | std::stable_partition(Settings::values.players.begin(), Settings::values.players.end(), |
| 139 | [](const auto& player) { return player.connected; }); | 139 | [](const auto& player) { return player.connected; }); |
| 140 | 140 | ||
| 141 | for (std::size_t i = 0; i < 8; ++i) { | 141 | for (std::size_t i = 0; i < players_enabled.size(); ++i) { |
| 142 | players_enabled[i]->setChecked(Settings::values.players[i].connected); | 142 | players_enabled[i]->setChecked(Settings::values.players[i].connected); |
| 143 | player_controller[i]->setCurrentIndex(static_cast<u8>(Settings::values.players[i].type)); | 143 | player_controller[i]->setCurrentIndex(static_cast<u8>(Settings::values.players[i].type)); |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); | 146 | ui->use_docked_mode->setChecked(Settings::values.use_docked_mode); |
| 147 | ui->handheld_connected->setChecked(Settings::values.players[8].connected); | 147 | ui->handheld_connected->setChecked( |
| 148 | Settings::values | ||
| 149 | .players[Service::HID::Controller_NPad::NPadIdToIndex(Service::HID::NPAD_HANDHELD)] | ||
| 150 | .connected); | ||
| 148 | ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled); | 151 | ui->debug_enabled->setChecked(Settings::values.debug_pad_enabled); |
| 149 | ui->mouse_enabled->setChecked(Settings::values.mouse_enabled); | 152 | ui->mouse_enabled->setChecked(Settings::values.mouse_enabled); |
| 150 | ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled); | 153 | ui->keyboard_enabled->setChecked(Settings::values.keyboard_enabled); |
| @@ -157,7 +160,7 @@ void ConfigureInput::restoreDefaults() { | |||
| 157 | players_enabled[0]->setCheckState(Qt::Checked); | 160 | players_enabled[0]->setCheckState(Qt::Checked); |
| 158 | player_controller[0]->setCurrentIndex(1); | 161 | player_controller[0]->setCurrentIndex(1); |
| 159 | 162 | ||
| 160 | for (std::size_t i = 1; i < 8; ++i) { | 163 | for (std::size_t i = 1; i < players_enabled.size(); ++i) { |
| 161 | players_enabled[i]->setCheckState(Qt::Unchecked); | 164 | players_enabled[i]->setCheckState(Qt::Unchecked); |
| 162 | player_controller[i]->setCurrentIndex(0); | 165 | player_controller[i]->setCurrentIndex(0); |
| 163 | } | 166 | } |
diff --git a/src/yuzu/configuration/configure_input.h b/src/yuzu/configuration/configure_input.h index 0ba77c5ef..51b8e609c 100644 --- a/src/yuzu/configuration/configure_input.h +++ b/src/yuzu/configuration/configure_input.h | |||
| @@ -41,7 +41,7 @@ private: | |||
| 41 | void updateUIEnabled(); | 41 | void updateUIEnabled(); |
| 42 | 42 | ||
| 43 | template <typename Dialog, typename... Args> | 43 | template <typename Dialog, typename... Args> |
| 44 | void CallConfigureDialog(Args... args); | 44 | void CallConfigureDialog(Args&&... args); |
| 45 | 45 | ||
| 46 | /// Load configuration settings. | 46 | /// Load configuration settings. |
| 47 | void loadConfiguration(); | 47 | void loadConfiguration(); |
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 5de7dd962..995725b0f 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp | |||
| @@ -41,7 +41,7 @@ static void LayerGridElements(QGridLayout* grid, QWidget* item, QWidget* onTopOf | |||
| 41 | grid->addWidget(item, row, column, rowSpan, columnSpan); | 41 | grid->addWidget(item, row, column, rowSpan, columnSpan); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | static QString getKeyName(int key_code) { | 44 | static QString GetKeyName(int key_code) { |
| 45 | switch (key_code) { | 45 | switch (key_code) { |
| 46 | case Qt::Key_Shift: | 46 | case Qt::Key_Shift: |
| 47 | return QObject::tr("Shift"); | 47 | return QObject::tr("Shift"); |
| @@ -71,7 +71,7 @@ static QString ButtonToText(const Common::ParamPackage& param) { | |||
| 71 | if (!param.Has("engine")) { | 71 | if (!param.Has("engine")) { |
| 72 | return QObject::tr("[not set]"); | 72 | return QObject::tr("[not set]"); |
| 73 | } else if (param.Get("engine", "") == "keyboard") { | 73 | } else if (param.Get("engine", "") == "keyboard") { |
| 74 | return getKeyName(param.Get("code", 0)); | 74 | return GetKeyName(param.Get("code", 0)); |
| 75 | } else if (param.Get("engine", "") == "sdl") { | 75 | } else if (param.Get("engine", "") == "sdl") { |
| 76 | if (param.Has("hat")) { | 76 | if (param.Has("hat")) { |
| 77 | return QString(QObject::tr("Hat %1 %2")) | 77 | return QString(QObject::tr("Hat %1 %2")) |
| @@ -486,7 +486,7 @@ void ConfigureInputPlayer::setPollingResult(const Common::ParamPackage& params, | |||
| 486 | } | 486 | } |
| 487 | 487 | ||
| 488 | updateButtonLabels(); | 488 | updateButtonLabels(); |
| 489 | input_setter = boost::none; | 489 | input_setter = std::nullopt; |
| 490 | } | 490 | } |
| 491 | 491 | ||
| 492 | void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { | 492 | void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { |
diff --git a/src/yuzu/configuration/configure_input_player.h b/src/yuzu/configuration/configure_input_player.h index 67cc6a8ca..8248cd7de 100644 --- a/src/yuzu/configuration/configure_input_player.h +++ b/src/yuzu/configuration/configure_input_player.h | |||
| @@ -7,11 +7,11 @@ | |||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <functional> | 8 | #include <functional> |
| 9 | #include <memory> | 9 | #include <memory> |
| 10 | #include <optional> | ||
| 10 | #include <string> | 11 | #include <string> |
| 11 | #include <unordered_map> | 12 | #include <unordered_map> |
| 12 | #include <QDialog> | 13 | #include <QDialog> |
| 13 | #include <QKeyEvent> | 14 | #include <QKeyEvent> |
| 14 | #include <boost/optional.hpp> | ||
| 15 | #include "common/param_package.h" | 15 | #include "common/param_package.h" |
| 16 | #include "core/settings.h" | 16 | #include "core/settings.h" |
| 17 | #include "input_common/main.h" | 17 | #include "input_common/main.h" |
| @@ -44,7 +44,7 @@ private: | |||
| 44 | std::unique_ptr<QTimer> poll_timer; | 44 | std::unique_ptr<QTimer> poll_timer; |
| 45 | 45 | ||
| 46 | /// This will be the the setting function when an input is awaiting configuration. | 46 | /// This will be the the setting function when an input is awaiting configuration. |
| 47 | boost::optional<std::function<void(const Common::ParamPackage&)>> input_setter; | 47 | std::optional<std::function<void(const Common::ParamPackage&)>> input_setter; |
| 48 | 48 | ||
| 49 | std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param; | 49 | std::array<Common::ParamPackage, Settings::NativeButton::NumButtons> buttons_param; |
| 50 | std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param; | 50 | std::array<Common::ParamPackage, Settings::NativeAnalog::NumAnalogs> analogs_param; |
diff --git a/src/yuzu/configuration/configure_mouse_advanced.cpp b/src/yuzu/configuration/configure_mouse_advanced.cpp index 8cfcd1679..ac9c84096 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.cpp +++ b/src/yuzu/configuration/configure_mouse_advanced.cpp | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include "yuzu/configuration/config.h" | 16 | #include "yuzu/configuration/config.h" |
| 17 | #include "yuzu/configuration/configure_mouse_advanced.h" | 17 | #include "yuzu/configuration/configure_mouse_advanced.h" |
| 18 | 18 | ||
| 19 | static QString getKeyName(int key_code) { | 19 | static QString GetKeyName(int key_code) { |
| 20 | switch (key_code) { | 20 | switch (key_code) { |
| 21 | case Qt::Key_Shift: | 21 | case Qt::Key_Shift: |
| 22 | return QObject::tr("Shift"); | 22 | return QObject::tr("Shift"); |
| @@ -35,7 +35,7 @@ static QString ButtonToText(const Common::ParamPackage& param) { | |||
| 35 | if (!param.Has("engine")) { | 35 | if (!param.Has("engine")) { |
| 36 | return QObject::tr("[not set]"); | 36 | return QObject::tr("[not set]"); |
| 37 | } else if (param.Get("engine", "") == "keyboard") { | 37 | } else if (param.Get("engine", "") == "keyboard") { |
| 38 | return getKeyName(param.Get("code", 0)); | 38 | return GetKeyName(param.Get("code", 0)); |
| 39 | } else if (param.Get("engine", "") == "sdl") { | 39 | } else if (param.Get("engine", "") == "sdl") { |
| 40 | if (param.Has("hat")) { | 40 | if (param.Has("hat")) { |
| 41 | return QString(QObject::tr("Hat %1 %2")) | 41 | return QString(QObject::tr("Hat %1 %2")) |
| @@ -191,7 +191,7 @@ void ConfigureMouseAdvanced::setPollingResult(const Common::ParamPackage& params | |||
| 191 | } | 191 | } |
| 192 | 192 | ||
| 193 | updateButtonLabels(); | 193 | updateButtonLabels(); |
| 194 | input_setter = boost::none; | 194 | input_setter = std::nullopt; |
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) { | 197 | void ConfigureMouseAdvanced::keyPressEvent(QKeyEvent* event) { |
diff --git a/src/yuzu/configuration/configure_mouse_advanced.h b/src/yuzu/configuration/configure_mouse_advanced.h index f897d9044..983ac4158 100644 --- a/src/yuzu/configuration/configure_mouse_advanced.h +++ b/src/yuzu/configuration/configure_mouse_advanced.h | |||
| @@ -5,9 +5,9 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <optional> | ||
| 8 | #include <QDialog> | 9 | #include <QDialog> |
| 9 | #include <QWidget> | 10 | #include <QWidget> |
| 10 | #include <boost/optional.hpp> | ||
| 11 | #include "core/settings.h" | 11 | #include "core/settings.h" |
| 12 | 12 | ||
| 13 | class QCheckBox; | 13 | class QCheckBox; |
| @@ -30,7 +30,7 @@ private: | |||
| 30 | std::unique_ptr<Ui::ConfigureMouseAdvanced> ui; | 30 | std::unique_ptr<Ui::ConfigureMouseAdvanced> ui; |
| 31 | 31 | ||
| 32 | /// This will be the the setting function when an input is awaiting configuration. | 32 | /// This will be the the setting function when an input is awaiting configuration. |
| 33 | boost::optional<std::function<void(const Common::ParamPackage&)>> input_setter; | 33 | std::optional<std::function<void(const Common::ParamPackage&)>> input_setter; |
| 34 | 34 | ||
| 35 | std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map; | 35 | std::array<QPushButton*, Settings::NativeMouseButton::NumMouseButtons> button_map; |
| 36 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param; | 36 | std::array<Common::ParamPackage, Settings::NativeMouseButton::NumMouseButtons> buttons_param; |
diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.cpp b/src/yuzu/configuration/configure_touchscreen_advanced.cpp index 6cf3dab97..9c1561e9d 100644 --- a/src/yuzu/configuration/configure_touchscreen_advanced.cpp +++ b/src/yuzu/configuration/configure_touchscreen_advanced.cpp | |||
| @@ -2,15 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 6 | #include <memory> | 5 | #include <memory> |
| 7 | #include <utility> | ||
| 8 | #include <QMenu> | ||
| 9 | #include <QMessageBox> | ||
| 10 | #include <QTimer> | ||
| 11 | #include "common/assert.h" | ||
| 12 | #include "common/param_package.h" | ||
| 13 | #include "input_common/main.h" | ||
| 14 | #include "ui_configure_touchscreen_advanced.h" | 6 | #include "ui_configure_touchscreen_advanced.h" |
| 15 | #include "yuzu/configuration/config.h" | 7 | #include "yuzu/configuration/config.h" |
| 16 | #include "yuzu/configuration/configure_touchscreen_advanced.h" | 8 | #include "yuzu/configuration/configure_touchscreen_advanced.h" |
| @@ -22,10 +14,12 @@ ConfigureTouchscreenAdvanced::ConfigureTouchscreenAdvanced(QWidget* parent) | |||
| 22 | connect(ui->restore_defaults_button, &QPushButton::pressed, this, | 14 | connect(ui->restore_defaults_button, &QPushButton::pressed, this, |
| 23 | &ConfigureTouchscreenAdvanced::restoreDefaults); | 15 | &ConfigureTouchscreenAdvanced::restoreDefaults); |
| 24 | 16 | ||
| 25 | this->loadConfiguration(); | 17 | loadConfiguration(); |
| 26 | this->resize(0, 0); | 18 | resize(0, 0); |
| 27 | } | 19 | } |
| 28 | 20 | ||
| 21 | ConfigureTouchscreenAdvanced::~ConfigureTouchscreenAdvanced() = default; | ||
| 22 | |||
| 29 | void ConfigureTouchscreenAdvanced::applyConfiguration() { | 23 | void ConfigureTouchscreenAdvanced::applyConfiguration() { |
| 30 | Settings::values.touchscreen.finger = ui->finger_box->value(); | 24 | Settings::values.touchscreen.finger = ui->finger_box->value(); |
| 31 | Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); | 25 | Settings::values.touchscreen.diameter_x = ui->diameter_x_box->value(); |
diff --git a/src/yuzu/configuration/configure_touchscreen_advanced.h b/src/yuzu/configuration/configure_touchscreen_advanced.h index 938a62ed3..41cd255fb 100644 --- a/src/yuzu/configuration/configure_touchscreen_advanced.h +++ b/src/yuzu/configuration/configure_touchscreen_advanced.h | |||
| @@ -18,6 +18,7 @@ class ConfigureTouchscreenAdvanced : public QDialog { | |||
| 18 | 18 | ||
| 19 | public: | 19 | public: |
| 20 | explicit ConfigureTouchscreenAdvanced(QWidget* parent); | 20 | explicit ConfigureTouchscreenAdvanced(QWidget* parent); |
| 21 | ~ConfigureTouchscreenAdvanced() override; | ||
| 21 | 22 | ||
| 22 | void applyConfiguration(); | 23 | void applyConfiguration(); |
| 23 | 24 | ||