diff options
| -rw-r--r-- | src/core/hle/service/am/applets/applet_software_keyboard.cpp | 474 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_software_keyboard.h | 35 | ||||
| -rw-r--r-- | src/core/hle/service/am/applets/applet_software_keyboard_types.h | 72 | ||||
| -rw-r--r-- | src/core/memory.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/texture_cache/image_base.h | 3 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 41 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 11 |
9 files changed, 419 insertions, 231 deletions
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp index f38f53f69..ee669686c 100644 --- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp +++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp | |||
| @@ -226,7 +226,7 @@ void SoftwareKeyboard::InitializeForeground() { | |||
| 226 | ASSERT(work_buffer_storage != nullptr); | 226 | ASSERT(work_buffer_storage != nullptr); |
| 227 | 227 | ||
| 228 | if (swkbd_config_common.initial_string_length == 0) { | 228 | if (swkbd_config_common.initial_string_length == 0) { |
| 229 | InitializeFrontendKeyboard(); | 229 | InitializeFrontendNormalKeyboard(); |
| 230 | return; | 230 | return; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| @@ -243,7 +243,7 @@ void SoftwareKeyboard::InitializeForeground() { | |||
| 243 | 243 | ||
| 244 | LOG_DEBUG(Service_AM, "\nInitial Text: {}", Common::UTF16ToUTF8(initial_text)); | 244 | LOG_DEBUG(Service_AM, "\nInitial Text: {}", Common::UTF16ToUTF8(initial_text)); |
| 245 | 245 | ||
| 246 | InitializeFrontendKeyboard(); | 246 | InitializeFrontendNormalKeyboard(); |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | void SoftwareKeyboard::InitializeBackground(LibraryAppletMode library_applet_mode) { | 249 | void SoftwareKeyboard::InitializeBackground(LibraryAppletMode library_applet_mode) { |
| @@ -480,129 +480,173 @@ void SoftwareKeyboard::ChangeState(SwkbdState state) { | |||
| 480 | ReplyDefault(); | 480 | ReplyDefault(); |
| 481 | } | 481 | } |
| 482 | 482 | ||
| 483 | void SoftwareKeyboard::InitializeFrontendKeyboard() { | 483 | void SoftwareKeyboard::InitializeFrontendNormalKeyboard() { |
| 484 | if (is_background) { | 484 | std::u16string ok_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( |
| 485 | const auto& appear_arg = swkbd_calc_arg.appear_arg; | 485 | swkbd_config_common.ok_text.data(), swkbd_config_common.ok_text.size()); |
| 486 | 486 | ||
| 487 | std::u16string ok_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | 487 | std::u16string header_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( |
| 488 | appear_arg.ok_text.data(), appear_arg.ok_text.size()); | 488 | swkbd_config_common.header_text.data(), swkbd_config_common.header_text.size()); |
| 489 | 489 | ||
| 490 | const u32 max_text_length = | 490 | std::u16string sub_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( |
| 491 | appear_arg.max_text_length > 0 && appear_arg.max_text_length <= DEFAULT_MAX_TEXT_LENGTH | 491 | swkbd_config_common.sub_text.data(), swkbd_config_common.sub_text.size()); |
| 492 | ? appear_arg.max_text_length | 492 | |
| 493 | : DEFAULT_MAX_TEXT_LENGTH; | 493 | std::u16string guide_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( |
| 494 | 494 | swkbd_config_common.guide_text.data(), swkbd_config_common.guide_text.size()); | |
| 495 | const u32 min_text_length = | 495 | |
| 496 | appear_arg.min_text_length <= max_text_length ? appear_arg.min_text_length : 0; | 496 | const u32 max_text_length = |
| 497 | 497 | swkbd_config_common.max_text_length > 0 && | |
| 498 | const s32 initial_cursor_position = | 498 | swkbd_config_common.max_text_length <= DEFAULT_MAX_TEXT_LENGTH |
| 499 | current_cursor_position > 0 ? current_cursor_position : 0; | 499 | ? swkbd_config_common.max_text_length |
| 500 | 500 | : DEFAULT_MAX_TEXT_LENGTH; | |
| 501 | const auto text_draw_type = | 501 | |
| 502 | max_text_length <= 32 ? SwkbdTextDrawType::Line : SwkbdTextDrawType::Box; | 502 | const u32 min_text_length = swkbd_config_common.min_text_length <= max_text_length |
| 503 | 503 | ? swkbd_config_common.min_text_length | |
| 504 | Core::Frontend::KeyboardInitializeParameters initialize_parameters{ | 504 | : 0; |
| 505 | .ok_text{std::move(ok_text)}, | 505 | |
| 506 | .header_text{}, | 506 | const s32 initial_cursor_position = [this] { |
| 507 | .sub_text{}, | 507 | switch (swkbd_config_common.initial_cursor_position) { |
| 508 | .guide_text{}, | 508 | case SwkbdInitialCursorPosition::Start: |
| 509 | .initial_text{current_text}, | 509 | default: |
| 510 | .max_text_length{max_text_length}, | 510 | return 0; |
| 511 | .min_text_length{min_text_length}, | 511 | case SwkbdInitialCursorPosition::End: |
| 512 | .initial_cursor_position{initial_cursor_position}, | 512 | return static_cast<s32>(initial_text.size()); |
| 513 | .type{appear_arg.type}, | 513 | } |
| 514 | .password_mode{SwkbdPasswordMode::Disabled}, | 514 | }(); |
| 515 | .text_draw_type{text_draw_type}, | 515 | |
| 516 | .key_disable_flags{appear_arg.key_disable_flags}, | 516 | const auto text_draw_type = [this, max_text_length] { |
| 517 | .use_blur_background{false}, | 517 | switch (swkbd_config_common.text_draw_type) { |
| 518 | .enable_backspace_button{swkbd_calc_arg.enable_backspace_button}, | 518 | case SwkbdTextDrawType::Line: |
| 519 | .enable_return_button{appear_arg.enable_return_button}, | 519 | default: |
| 520 | .disable_cancel_button{appear_arg.disable_cancel_button}, | 520 | return max_text_length <= 32 ? SwkbdTextDrawType::Line : SwkbdTextDrawType::Box; |
| 521 | }; | 521 | case SwkbdTextDrawType::Box: |
| 522 | 522 | case SwkbdTextDrawType::DownloadCode: | |
| 523 | frontend.InitializeKeyboard( | 523 | return swkbd_config_common.text_draw_type; |
| 524 | true, std::move(initialize_parameters), {}, | 524 | } |
| 525 | [this](SwkbdReplyType reply_type, std::u16string submitted_text, s32 cursor_position) { | 525 | }(); |
| 526 | SubmitTextInline(reply_type, submitted_text, cursor_position); | 526 | |
| 527 | }); | 527 | const auto enable_return_button = |
| 528 | } else { | 528 | text_draw_type == SwkbdTextDrawType::Box ? swkbd_config_common.enable_return_button : false; |
| 529 | std::u16string ok_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | 529 | |
| 530 | swkbd_config_common.ok_text.data(), swkbd_config_common.ok_text.size()); | 530 | const auto disable_cancel_button = swkbd_applet_version >= SwkbdAppletVersion::Version393227 |
| 531 | 531 | ? swkbd_config_new.disable_cancel_button | |
| 532 | std::u16string header_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | 532 | : false; |
| 533 | swkbd_config_common.header_text.data(), swkbd_config_common.header_text.size()); | 533 | |
| 534 | 534 | Core::Frontend::KeyboardInitializeParameters initialize_parameters{ | |
| 535 | std::u16string sub_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | 535 | .ok_text{std::move(ok_text)}, |
| 536 | swkbd_config_common.sub_text.data(), swkbd_config_common.sub_text.size()); | 536 | .header_text{std::move(header_text)}, |
| 537 | 537 | .sub_text{std::move(sub_text)}, | |
| 538 | std::u16string guide_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | 538 | .guide_text{std::move(guide_text)}, |
| 539 | swkbd_config_common.guide_text.data(), swkbd_config_common.guide_text.size()); | 539 | .initial_text{initial_text}, |
| 540 | 540 | .max_text_length{max_text_length}, | |
| 541 | const u32 max_text_length = | 541 | .min_text_length{min_text_length}, |
| 542 | swkbd_config_common.max_text_length > 0 && | 542 | .initial_cursor_position{initial_cursor_position}, |
| 543 | swkbd_config_common.max_text_length <= DEFAULT_MAX_TEXT_LENGTH | 543 | .type{swkbd_config_common.type}, |
| 544 | ? swkbd_config_common.max_text_length | 544 | .password_mode{swkbd_config_common.password_mode}, |
| 545 | : DEFAULT_MAX_TEXT_LENGTH; | 545 | .text_draw_type{text_draw_type}, |
| 546 | 546 | .key_disable_flags{swkbd_config_common.key_disable_flags}, | |
| 547 | const u32 min_text_length = swkbd_config_common.min_text_length <= max_text_length | 547 | .use_blur_background{swkbd_config_common.use_blur_background}, |
| 548 | ? swkbd_config_common.min_text_length | 548 | .enable_backspace_button{true}, |
| 549 | : 0; | 549 | .enable_return_button{enable_return_button}, |
| 550 | 550 | .disable_cancel_button{disable_cancel_button}, | |
| 551 | const s32 initial_cursor_position = [this] { | 551 | }; |
| 552 | switch (swkbd_config_common.initial_cursor_position) { | 552 | |
| 553 | case SwkbdInitialCursorPosition::Start: | 553 | frontend.InitializeKeyboard( |
| 554 | default: | 554 | false, std::move(initialize_parameters), |
| 555 | return 0; | 555 | [this](SwkbdResult result, std::u16string submitted_text, bool confirmed) { |
| 556 | case SwkbdInitialCursorPosition::End: | 556 | SubmitTextNormal(result, submitted_text, confirmed); |
| 557 | return static_cast<s32>(initial_text.size()); | 557 | }, |
| 558 | } | 558 | {}); |
| 559 | }(); | 559 | } |
| 560 | 560 | ||
| 561 | const auto text_draw_type = [this, max_text_length] { | 561 | void SoftwareKeyboard::InitializeFrontendInlineKeyboard( |
| 562 | switch (swkbd_config_common.text_draw_type) { | 562 | Core::Frontend::KeyboardInitializeParameters initialize_parameters) { |
| 563 | case SwkbdTextDrawType::Line: | 563 | frontend.InitializeKeyboard( |
| 564 | default: | 564 | true, std::move(initialize_parameters), {}, |
| 565 | return max_text_length <= 32 ? SwkbdTextDrawType::Line : SwkbdTextDrawType::Box; | 565 | [this](SwkbdReplyType reply_type, std::u16string submitted_text, s32 cursor_position) { |
| 566 | case SwkbdTextDrawType::Box: | 566 | SubmitTextInline(reply_type, submitted_text, cursor_position); |
| 567 | case SwkbdTextDrawType::DownloadCode: | 567 | }); |
| 568 | return swkbd_config_common.text_draw_type; | 568 | } |
| 569 | } | 569 | |
| 570 | }(); | 570 | void SoftwareKeyboard::InitializeFrontendInlineKeyboardOld() { |
| 571 | 571 | const auto& appear_arg = swkbd_calc_arg_old.appear_arg; | |
| 572 | const auto enable_return_button = text_draw_type == SwkbdTextDrawType::Box | 572 | |
| 573 | ? swkbd_config_common.enable_return_button | 573 | std::u16string ok_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( |
| 574 | : false; | 574 | appear_arg.ok_text.data(), appear_arg.ok_text.size()); |
| 575 | 575 | ||
| 576 | const auto disable_cancel_button = swkbd_applet_version >= SwkbdAppletVersion::Version393227 | 576 | const u32 max_text_length = |
| 577 | ? swkbd_config_new.disable_cancel_button | 577 | appear_arg.max_text_length > 0 && appear_arg.max_text_length <= DEFAULT_MAX_TEXT_LENGTH |
| 578 | : false; | 578 | ? appear_arg.max_text_length |
| 579 | 579 | : DEFAULT_MAX_TEXT_LENGTH; | |
| 580 | Core::Frontend::KeyboardInitializeParameters initialize_parameters{ | 580 | |
| 581 | .ok_text{std::move(ok_text)}, | 581 | const u32 min_text_length = |
| 582 | .header_text{std::move(header_text)}, | 582 | appear_arg.min_text_length <= max_text_length ? appear_arg.min_text_length : 0; |
| 583 | .sub_text{std::move(sub_text)}, | 583 | |
| 584 | .guide_text{std::move(guide_text)}, | 584 | const s32 initial_cursor_position = current_cursor_position > 0 ? current_cursor_position : 0; |
| 585 | .initial_text{initial_text}, | 585 | |
| 586 | .max_text_length{max_text_length}, | 586 | const auto text_draw_type = |
| 587 | .min_text_length{min_text_length}, | 587 | max_text_length <= 32 ? SwkbdTextDrawType::Line : SwkbdTextDrawType::Box; |
| 588 | .initial_cursor_position{initial_cursor_position}, | 588 | |
| 589 | .type{swkbd_config_common.type}, | 589 | Core::Frontend::KeyboardInitializeParameters initialize_parameters{ |
| 590 | .password_mode{swkbd_config_common.password_mode}, | 590 | .ok_text{std::move(ok_text)}, |
| 591 | .text_draw_type{text_draw_type}, | 591 | .header_text{}, |
| 592 | .key_disable_flags{swkbd_config_common.key_disable_flags}, | 592 | .sub_text{}, |
| 593 | .use_blur_background{swkbd_config_common.use_blur_background}, | 593 | .guide_text{}, |
| 594 | .enable_backspace_button{true}, | 594 | .initial_text{current_text}, |
| 595 | .enable_return_button{enable_return_button}, | 595 | .max_text_length{max_text_length}, |
| 596 | .disable_cancel_button{disable_cancel_button}, | 596 | .min_text_length{min_text_length}, |
| 597 | }; | 597 | .initial_cursor_position{initial_cursor_position}, |
| 598 | 598 | .type{appear_arg.type}, | |
| 599 | frontend.InitializeKeyboard( | 599 | .password_mode{SwkbdPasswordMode::Disabled}, |
| 600 | false, std::move(initialize_parameters), | 600 | .text_draw_type{text_draw_type}, |
| 601 | [this](SwkbdResult result, std::u16string submitted_text, bool confirmed) { | 601 | .key_disable_flags{appear_arg.key_disable_flags}, |
| 602 | SubmitTextNormal(result, submitted_text, confirmed); | 602 | .use_blur_background{false}, |
| 603 | }, | 603 | .enable_backspace_button{swkbd_calc_arg_old.enable_backspace_button}, |
| 604 | {}); | 604 | .enable_return_button{appear_arg.enable_return_button}, |
| 605 | } | 605 | .disable_cancel_button{appear_arg.disable_cancel_button}, |
| 606 | }; | ||
| 607 | |||
| 608 | InitializeFrontendInlineKeyboard(std::move(initialize_parameters)); | ||
| 609 | } | ||
| 610 | |||
| 611 | void SoftwareKeyboard::InitializeFrontendInlineKeyboardNew() { | ||
| 612 | const auto& appear_arg = swkbd_calc_arg_new.appear_arg; | ||
| 613 | |||
| 614 | std::u16string ok_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | ||
| 615 | appear_arg.ok_text.data(), appear_arg.ok_text.size()); | ||
| 616 | |||
| 617 | const u32 max_text_length = | ||
| 618 | appear_arg.max_text_length > 0 && appear_arg.max_text_length <= DEFAULT_MAX_TEXT_LENGTH | ||
| 619 | ? appear_arg.max_text_length | ||
| 620 | : DEFAULT_MAX_TEXT_LENGTH; | ||
| 621 | |||
| 622 | const u32 min_text_length = | ||
| 623 | appear_arg.min_text_length <= max_text_length ? appear_arg.min_text_length : 0; | ||
| 624 | |||
| 625 | const s32 initial_cursor_position = current_cursor_position > 0 ? current_cursor_position : 0; | ||
| 626 | |||
| 627 | const auto text_draw_type = | ||
| 628 | max_text_length <= 32 ? SwkbdTextDrawType::Line : SwkbdTextDrawType::Box; | ||
| 629 | |||
| 630 | Core::Frontend::KeyboardInitializeParameters initialize_parameters{ | ||
| 631 | .ok_text{std::move(ok_text)}, | ||
| 632 | .header_text{}, | ||
| 633 | .sub_text{}, | ||
| 634 | .guide_text{}, | ||
| 635 | .initial_text{current_text}, | ||
| 636 | .max_text_length{max_text_length}, | ||
| 637 | .min_text_length{min_text_length}, | ||
| 638 | .initial_cursor_position{initial_cursor_position}, | ||
| 639 | .type{appear_arg.type}, | ||
| 640 | .password_mode{SwkbdPasswordMode::Disabled}, | ||
| 641 | .text_draw_type{text_draw_type}, | ||
| 642 | .key_disable_flags{appear_arg.key_disable_flags}, | ||
| 643 | .use_blur_background{false}, | ||
| 644 | .enable_backspace_button{swkbd_calc_arg_new.enable_backspace_button}, | ||
| 645 | .enable_return_button{appear_arg.enable_return_button}, | ||
| 646 | .disable_cancel_button{appear_arg.disable_cancel_button}, | ||
| 647 | }; | ||
| 648 | |||
| 649 | InitializeFrontendInlineKeyboard(std::move(initialize_parameters)); | ||
| 606 | } | 650 | } |
| 607 | 651 | ||
| 608 | void SoftwareKeyboard::ShowNormalKeyboard() { | 652 | void SoftwareKeyboard::ShowNormalKeyboard() { |
| @@ -614,14 +658,21 @@ void SoftwareKeyboard::ShowTextCheckDialog(SwkbdTextCheckResult text_check_resul | |||
| 614 | frontend.ShowTextCheckDialog(text_check_result, std::move(text_check_message)); | 658 | frontend.ShowTextCheckDialog(text_check_result, std::move(text_check_message)); |
| 615 | } | 659 | } |
| 616 | 660 | ||
| 617 | void SoftwareKeyboard::ShowInlineKeyboard() { | 661 | void SoftwareKeyboard::ShowInlineKeyboard( |
| 662 | Core::Frontend::InlineAppearParameters appear_parameters) { | ||
| 663 | frontend.ShowInlineKeyboard(std::move(appear_parameters)); | ||
| 664 | |||
| 665 | ChangeState(SwkbdState::InitializedIsShown); | ||
| 666 | } | ||
| 667 | |||
| 668 | void SoftwareKeyboard::ShowInlineKeyboardOld() { | ||
| 618 | if (swkbd_state != SwkbdState::InitializedIsHidden) { | 669 | if (swkbd_state != SwkbdState::InitializedIsHidden) { |
| 619 | return; | 670 | return; |
| 620 | } | 671 | } |
| 621 | 672 | ||
| 622 | ChangeState(SwkbdState::InitializedIsAppearing); | 673 | ChangeState(SwkbdState::InitializedIsAppearing); |
| 623 | 674 | ||
| 624 | const auto& appear_arg = swkbd_calc_arg.appear_arg; | 675 | const auto& appear_arg = swkbd_calc_arg_old.appear_arg; |
| 625 | 676 | ||
| 626 | const u32 max_text_length = | 677 | const u32 max_text_length = |
| 627 | appear_arg.max_text_length > 0 && appear_arg.max_text_length <= DEFAULT_MAX_TEXT_LENGTH | 678 | appear_arg.max_text_length > 0 && appear_arg.max_text_length <= DEFAULT_MAX_TEXT_LENGTH |
| @@ -634,21 +685,54 @@ void SoftwareKeyboard::ShowInlineKeyboard() { | |||
| 634 | Core::Frontend::InlineAppearParameters appear_parameters{ | 685 | Core::Frontend::InlineAppearParameters appear_parameters{ |
| 635 | .max_text_length{max_text_length}, | 686 | .max_text_length{max_text_length}, |
| 636 | .min_text_length{min_text_length}, | 687 | .min_text_length{min_text_length}, |
| 637 | .key_top_scale_x{swkbd_calc_arg.key_top_scale_x}, | 688 | .key_top_scale_x{swkbd_calc_arg_old.key_top_scale_x}, |
| 638 | .key_top_scale_y{swkbd_calc_arg.key_top_scale_y}, | 689 | .key_top_scale_y{swkbd_calc_arg_old.key_top_scale_y}, |
| 639 | .key_top_translate_x{swkbd_calc_arg.key_top_translate_x}, | 690 | .key_top_translate_x{swkbd_calc_arg_old.key_top_translate_x}, |
| 640 | .key_top_translate_y{swkbd_calc_arg.key_top_translate_y}, | 691 | .key_top_translate_y{swkbd_calc_arg_old.key_top_translate_y}, |
| 641 | .type{appear_arg.type}, | 692 | .type{appear_arg.type}, |
| 642 | .key_disable_flags{appear_arg.key_disable_flags}, | 693 | .key_disable_flags{appear_arg.key_disable_flags}, |
| 643 | .key_top_as_floating{swkbd_calc_arg.key_top_as_floating}, | 694 | .key_top_as_floating{swkbd_calc_arg_old.key_top_as_floating}, |
| 644 | .enable_backspace_button{swkbd_calc_arg.enable_backspace_button}, | 695 | .enable_backspace_button{swkbd_calc_arg_old.enable_backspace_button}, |
| 645 | .enable_return_button{appear_arg.enable_return_button}, | 696 | .enable_return_button{appear_arg.enable_return_button}, |
| 646 | .disable_cancel_button{appear_arg.disable_cancel_button}, | 697 | .disable_cancel_button{appear_arg.disable_cancel_button}, |
| 647 | }; | 698 | }; |
| 648 | 699 | ||
| 649 | frontend.ShowInlineKeyboard(std::move(appear_parameters)); | 700 | ShowInlineKeyboard(std::move(appear_parameters)); |
| 701 | } | ||
| 650 | 702 | ||
| 651 | ChangeState(SwkbdState::InitializedIsShown); | 703 | void SoftwareKeyboard::ShowInlineKeyboardNew() { |
| 704 | if (swkbd_state != SwkbdState::InitializedIsHidden) { | ||
| 705 | return; | ||
| 706 | } | ||
| 707 | |||
| 708 | ChangeState(SwkbdState::InitializedIsAppearing); | ||
| 709 | |||
| 710 | const auto& appear_arg = swkbd_calc_arg_new.appear_arg; | ||
| 711 | |||
| 712 | const u32 max_text_length = | ||
| 713 | appear_arg.max_text_length > 0 && appear_arg.max_text_length <= DEFAULT_MAX_TEXT_LENGTH | ||
| 714 | ? appear_arg.max_text_length | ||
| 715 | : DEFAULT_MAX_TEXT_LENGTH; | ||
| 716 | |||
| 717 | const u32 min_text_length = | ||
| 718 | appear_arg.min_text_length <= max_text_length ? appear_arg.min_text_length : 0; | ||
| 719 | |||
| 720 | Core::Frontend::InlineAppearParameters appear_parameters{ | ||
| 721 | .max_text_length{max_text_length}, | ||
| 722 | .min_text_length{min_text_length}, | ||
| 723 | .key_top_scale_x{swkbd_calc_arg_new.key_top_scale_x}, | ||
| 724 | .key_top_scale_y{swkbd_calc_arg_new.key_top_scale_y}, | ||
| 725 | .key_top_translate_x{swkbd_calc_arg_new.key_top_translate_x}, | ||
| 726 | .key_top_translate_y{swkbd_calc_arg_new.key_top_translate_y}, | ||
| 727 | .type{appear_arg.type}, | ||
| 728 | .key_disable_flags{appear_arg.key_disable_flags}, | ||
| 729 | .key_top_as_floating{swkbd_calc_arg_new.key_top_as_floating}, | ||
| 730 | .enable_backspace_button{swkbd_calc_arg_new.enable_backspace_button}, | ||
| 731 | .enable_return_button{appear_arg.enable_return_button}, | ||
| 732 | .disable_cancel_button{appear_arg.disable_cancel_button}, | ||
| 733 | }; | ||
| 734 | |||
| 735 | ShowInlineKeyboard(std::move(appear_parameters)); | ||
| 652 | } | 736 | } |
| 653 | 737 | ||
| 654 | void SoftwareKeyboard::HideInlineKeyboard() { | 738 | void SoftwareKeyboard::HideInlineKeyboard() { |
| @@ -693,6 +777,8 @@ void SoftwareKeyboard::RequestFinalize(const std::vector<u8>& request_data) { | |||
| 693 | 777 | ||
| 694 | void SoftwareKeyboard::RequestSetUserWordInfo(const std::vector<u8>& request_data) { | 778 | void SoftwareKeyboard::RequestSetUserWordInfo(const std::vector<u8>& request_data) { |
| 695 | LOG_WARNING(Service_AM, "SetUserWordInfo is not implemented."); | 779 | LOG_WARNING(Service_AM, "SetUserWordInfo is not implemented."); |
| 780 | |||
| 781 | ReplyReleasedUserWordInfo(); | ||
| 696 | } | 782 | } |
| 697 | 783 | ||
| 698 | void SoftwareKeyboard::RequestSetCustomizeDic(const std::vector<u8>& request_data) { | 784 | void SoftwareKeyboard::RequestSetCustomizeDic(const std::vector<u8>& request_data) { |
| @@ -702,53 +788,135 @@ void SoftwareKeyboard::RequestSetCustomizeDic(const std::vector<u8>& request_dat | |||
| 702 | void SoftwareKeyboard::RequestCalc(const std::vector<u8>& request_data) { | 788 | void SoftwareKeyboard::RequestCalc(const std::vector<u8>& request_data) { |
| 703 | LOG_DEBUG(Service_AM, "Processing Request: Calc"); | 789 | LOG_DEBUG(Service_AM, "Processing Request: Calc"); |
| 704 | 790 | ||
| 705 | ASSERT(request_data.size() == sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArg)); | 791 | ASSERT(request_data.size() >= sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon)); |
| 706 | 792 | ||
| 707 | std::memcpy(&swkbd_calc_arg, request_data.data() + sizeof(SwkbdRequestCommand), | 793 | std::memcpy(&swkbd_calc_arg_common, request_data.data() + sizeof(SwkbdRequestCommand), |
| 708 | sizeof(SwkbdCalcArg)); | 794 | sizeof(SwkbdCalcArgCommon)); |
| 795 | |||
| 796 | switch (swkbd_calc_arg_common.calc_arg_size) { | ||
| 797 | case sizeof(SwkbdCalcArgCommon) + sizeof(SwkbdCalcArgOld): | ||
| 798 | ASSERT(request_data.size() == | ||
| 799 | sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon) + sizeof(SwkbdCalcArgOld)); | ||
| 800 | std::memcpy(&swkbd_calc_arg_old, | ||
| 801 | request_data.data() + sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon), | ||
| 802 | sizeof(SwkbdCalcArgOld)); | ||
| 803 | RequestCalcOld(); | ||
| 804 | break; | ||
| 805 | case sizeof(SwkbdCalcArgCommon) + sizeof(SwkbdCalcArgNew): | ||
| 806 | ASSERT(request_data.size() == | ||
| 807 | sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon) + sizeof(SwkbdCalcArgNew)); | ||
| 808 | std::memcpy(&swkbd_calc_arg_new, | ||
| 809 | request_data.data() + sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon), | ||
| 810 | sizeof(SwkbdCalcArgNew)); | ||
| 811 | RequestCalcNew(); | ||
| 812 | break; | ||
| 813 | default: | ||
| 814 | UNIMPLEMENTED_MSG("Unknown SwkbdCalcArg size={}", swkbd_calc_arg_common.calc_arg_size); | ||
| 815 | ASSERT(request_data.size() >= | ||
| 816 | sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon) + sizeof(SwkbdCalcArgNew)); | ||
| 817 | std::memcpy(&swkbd_calc_arg_new, | ||
| 818 | request_data.data() + sizeof(SwkbdRequestCommand) + sizeof(SwkbdCalcArgCommon), | ||
| 819 | sizeof(SwkbdCalcArgNew)); | ||
| 820 | RequestCalcNew(); | ||
| 821 | break; | ||
| 822 | } | ||
| 823 | } | ||
| 824 | |||
| 825 | void SoftwareKeyboard::RequestCalcOld() { | ||
| 826 | if (swkbd_calc_arg_common.flags.set_input_text) { | ||
| 827 | current_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | ||
| 828 | swkbd_calc_arg_old.input_text.data(), swkbd_calc_arg_old.input_text.size()); | ||
| 829 | } | ||
| 830 | |||
| 831 | if (swkbd_calc_arg_common.flags.set_cursor_position) { | ||
| 832 | current_cursor_position = swkbd_calc_arg_old.cursor_position; | ||
| 833 | } | ||
| 834 | |||
| 835 | if (swkbd_calc_arg_common.flags.set_utf8_mode) { | ||
| 836 | inline_use_utf8 = swkbd_calc_arg_old.utf8_mode; | ||
| 837 | } | ||
| 838 | |||
| 839 | if (swkbd_state <= SwkbdState::InitializedIsHidden && | ||
| 840 | swkbd_calc_arg_common.flags.unset_customize_dic) { | ||
| 841 | ReplyUnsetCustomizeDic(); | ||
| 842 | } | ||
| 843 | |||
| 844 | if (swkbd_state <= SwkbdState::InitializedIsHidden && | ||
| 845 | swkbd_calc_arg_common.flags.unset_user_word_info) { | ||
| 846 | ReplyReleasedUserWordInfo(); | ||
| 847 | } | ||
| 848 | |||
| 849 | if (swkbd_state == SwkbdState::NotInitialized && | ||
| 850 | swkbd_calc_arg_common.flags.set_initialize_arg) { | ||
| 851 | InitializeFrontendInlineKeyboardOld(); | ||
| 852 | |||
| 853 | ChangeState(SwkbdState::InitializedIsHidden); | ||
| 854 | |||
| 855 | ReplyFinishedInitialize(); | ||
| 856 | } | ||
| 857 | |||
| 858 | if (!swkbd_calc_arg_common.flags.set_initialize_arg && | ||
| 859 | (swkbd_calc_arg_common.flags.set_input_text || | ||
| 860 | swkbd_calc_arg_common.flags.set_cursor_position)) { | ||
| 861 | InlineTextChanged(); | ||
| 862 | } | ||
| 863 | |||
| 864 | if (swkbd_state == SwkbdState::InitializedIsHidden && swkbd_calc_arg_common.flags.appear) { | ||
| 865 | ShowInlineKeyboardOld(); | ||
| 866 | return; | ||
| 867 | } | ||
| 868 | |||
| 869 | if (swkbd_state == SwkbdState::InitializedIsShown && swkbd_calc_arg_common.flags.disappear) { | ||
| 870 | HideInlineKeyboard(); | ||
| 871 | return; | ||
| 872 | } | ||
| 873 | } | ||
| 709 | 874 | ||
| 710 | if (swkbd_calc_arg.flags.set_input_text) { | 875 | void SoftwareKeyboard::RequestCalcNew() { |
| 876 | if (swkbd_calc_arg_common.flags.set_input_text) { | ||
| 711 | current_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( | 877 | current_text = Common::UTF16StringFromFixedZeroTerminatedBuffer( |
| 712 | swkbd_calc_arg.input_text.data(), swkbd_calc_arg.input_text.size()); | 878 | swkbd_calc_arg_new.input_text.data(), swkbd_calc_arg_new.input_text.size()); |
| 713 | } | 879 | } |
| 714 | 880 | ||
| 715 | if (swkbd_calc_arg.flags.set_cursor_position) { | 881 | if (swkbd_calc_arg_common.flags.set_cursor_position) { |
| 716 | current_cursor_position = swkbd_calc_arg.cursor_position; | 882 | current_cursor_position = swkbd_calc_arg_new.cursor_position; |
| 717 | } | 883 | } |
| 718 | 884 | ||
| 719 | if (swkbd_calc_arg.flags.set_utf8_mode) { | 885 | if (swkbd_calc_arg_common.flags.set_utf8_mode) { |
| 720 | inline_use_utf8 = swkbd_calc_arg.utf8_mode; | 886 | inline_use_utf8 = swkbd_calc_arg_new.utf8_mode; |
| 721 | } | 887 | } |
| 722 | 888 | ||
| 723 | if (swkbd_state <= SwkbdState::InitializedIsHidden && | 889 | if (swkbd_state <= SwkbdState::InitializedIsHidden && |
| 724 | swkbd_calc_arg.flags.unset_customize_dic) { | 890 | swkbd_calc_arg_common.flags.unset_customize_dic) { |
| 725 | ReplyUnsetCustomizeDic(); | 891 | ReplyUnsetCustomizeDic(); |
| 726 | } | 892 | } |
| 727 | 893 | ||
| 728 | if (swkbd_state <= SwkbdState::InitializedIsHidden && | 894 | if (swkbd_state <= SwkbdState::InitializedIsHidden && |
| 729 | swkbd_calc_arg.flags.unset_user_word_info) { | 895 | swkbd_calc_arg_common.flags.unset_user_word_info) { |
| 730 | ReplyReleasedUserWordInfo(); | 896 | ReplyReleasedUserWordInfo(); |
| 731 | } | 897 | } |
| 732 | 898 | ||
| 733 | if (swkbd_state == SwkbdState::NotInitialized && swkbd_calc_arg.flags.set_initialize_arg) { | 899 | if (swkbd_state == SwkbdState::NotInitialized && |
| 734 | InitializeFrontendKeyboard(); | 900 | swkbd_calc_arg_common.flags.set_initialize_arg) { |
| 901 | InitializeFrontendInlineKeyboardNew(); | ||
| 735 | 902 | ||
| 736 | ChangeState(SwkbdState::InitializedIsHidden); | 903 | ChangeState(SwkbdState::InitializedIsHidden); |
| 737 | 904 | ||
| 738 | ReplyFinishedInitialize(); | 905 | ReplyFinishedInitialize(); |
| 739 | } | 906 | } |
| 740 | 907 | ||
| 741 | if (!swkbd_calc_arg.flags.set_initialize_arg && | 908 | if (!swkbd_calc_arg_common.flags.set_initialize_arg && |
| 742 | (swkbd_calc_arg.flags.set_input_text || swkbd_calc_arg.flags.set_cursor_position)) { | 909 | (swkbd_calc_arg_common.flags.set_input_text || |
| 910 | swkbd_calc_arg_common.flags.set_cursor_position)) { | ||
| 743 | InlineTextChanged(); | 911 | InlineTextChanged(); |
| 744 | } | 912 | } |
| 745 | 913 | ||
| 746 | if (swkbd_state == SwkbdState::InitializedIsHidden && swkbd_calc_arg.flags.appear) { | 914 | if (swkbd_state == SwkbdState::InitializedIsHidden && swkbd_calc_arg_common.flags.appear) { |
| 747 | ShowInlineKeyboard(); | 915 | ShowInlineKeyboardNew(); |
| 748 | return; | 916 | return; |
| 749 | } | 917 | } |
| 750 | 918 | ||
| 751 | if (swkbd_state == SwkbdState::InitializedIsShown && swkbd_calc_arg.flags.disappear) { | 919 | if (swkbd_state == SwkbdState::InitializedIsShown && swkbd_calc_arg_common.flags.disappear) { |
| 752 | HideInlineKeyboard(); | 920 | HideInlineKeyboard(); |
| 753 | return; | 921 | return; |
| 754 | } | 922 | } |
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.h b/src/core/hle/service/am/applets/applet_software_keyboard.h index a0fddd965..7ee4c5eea 100644 --- a/src/core/hle/service/am/applets/applet_software_keyboard.h +++ b/src/core/hle/service/am/applets/applet_software_keyboard.h | |||
| @@ -13,6 +13,11 @@ namespace Core { | |||
| 13 | class System; | 13 | class System; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | namespace Core::Frontend { | ||
| 17 | struct KeyboardInitializeParameters; | ||
| 18 | struct InlineAppearParameters; | ||
| 19 | } // namespace Core::Frontend | ||
| 20 | |||
| 16 | namespace Service::AM::Applets { | 21 | namespace Service::AM::Applets { |
| 17 | 22 | ||
| 18 | class SoftwareKeyboard final : public Applet { | 23 | class SoftwareKeyboard final : public Applet { |
| @@ -78,13 +83,22 @@ private: | |||
| 78 | void ChangeState(SwkbdState state); | 83 | void ChangeState(SwkbdState state); |
| 79 | 84 | ||
| 80 | /** | 85 | /** |
| 81 | * Signals the frontend to initialize the software keyboard with common parameters. | 86 | * Signals the frontend to initialize the normal software keyboard with common parameters. |
| 82 | * This initializes either the normal software keyboard or the inline software keyboard | ||
| 83 | * depending on the state of is_background. | ||
| 84 | * Note that this does not cause the keyboard to appear. | 87 | * Note that this does not cause the keyboard to appear. |
| 85 | * Use the respective Show*Keyboard() functions to cause the respective keyboards to appear. | 88 | * Use the ShowNormalKeyboard() functions to cause the keyboard to appear. |
| 86 | */ | 89 | */ |
| 87 | void InitializeFrontendKeyboard(); | 90 | void InitializeFrontendNormalKeyboard(); |
| 91 | |||
| 92 | /** | ||
| 93 | * Signals the frontend to initialize the inline software keyboard with common parameters. | ||
| 94 | * Note that this does not cause the keyboard to appear. | ||
| 95 | * Use the ShowInlineKeyboard() to cause the keyboard to appear. | ||
| 96 | */ | ||
| 97 | void InitializeFrontendInlineKeyboard( | ||
| 98 | Core::Frontend::KeyboardInitializeParameters initialize_parameters); | ||
| 99 | |||
| 100 | void InitializeFrontendInlineKeyboardOld(); | ||
| 101 | void InitializeFrontendInlineKeyboardNew(); | ||
| 88 | 102 | ||
| 89 | /// Signals the frontend to show the normal software keyboard. | 103 | /// Signals the frontend to show the normal software keyboard. |
| 90 | void ShowNormalKeyboard(); | 104 | void ShowNormalKeyboard(); |
| @@ -94,7 +108,10 @@ private: | |||
| 94 | std::u16string text_check_message); | 108 | std::u16string text_check_message); |
| 95 | 109 | ||
| 96 | /// Signals the frontend to show the inline software keyboard. | 110 | /// Signals the frontend to show the inline software keyboard. |
| 97 | void ShowInlineKeyboard(); | 111 | void ShowInlineKeyboard(Core::Frontend::InlineAppearParameters appear_parameters); |
| 112 | |||
| 113 | void ShowInlineKeyboardOld(); | ||
| 114 | void ShowInlineKeyboardNew(); | ||
| 98 | 115 | ||
| 99 | /// Signals the frontend to hide the inline software keyboard. | 116 | /// Signals the frontend to hide the inline software keyboard. |
| 100 | void HideInlineKeyboard(); | 117 | void HideInlineKeyboard(); |
| @@ -111,6 +128,8 @@ private: | |||
| 111 | void RequestSetUserWordInfo(const std::vector<u8>& request_data); | 128 | void RequestSetUserWordInfo(const std::vector<u8>& request_data); |
| 112 | void RequestSetCustomizeDic(const std::vector<u8>& request_data); | 129 | void RequestSetCustomizeDic(const std::vector<u8>& request_data); |
| 113 | void RequestCalc(const std::vector<u8>& request_data); | 130 | void RequestCalc(const std::vector<u8>& request_data); |
| 131 | void RequestCalcOld(); | ||
| 132 | void RequestCalcNew(); | ||
| 114 | void RequestSetCustomizedDictionaries(const std::vector<u8>& request_data); | 133 | void RequestSetCustomizedDictionaries(const std::vector<u8>& request_data); |
| 115 | void RequestUnsetCustomizedDictionaries(const std::vector<u8>& request_data); | 134 | void RequestUnsetCustomizedDictionaries(const std::vector<u8>& request_data); |
| 116 | void RequestSetChangedStringV2Flag(const std::vector<u8>& request_data); | 135 | void RequestSetChangedStringV2Flag(const std::vector<u8>& request_data); |
| @@ -149,7 +168,9 @@ private: | |||
| 149 | 168 | ||
| 150 | SwkbdState swkbd_state{SwkbdState::NotInitialized}; | 169 | SwkbdState swkbd_state{SwkbdState::NotInitialized}; |
| 151 | SwkbdInitializeArg swkbd_initialize_arg; | 170 | SwkbdInitializeArg swkbd_initialize_arg; |
| 152 | SwkbdCalcArg swkbd_calc_arg; | 171 | SwkbdCalcArgCommon swkbd_calc_arg_common; |
| 172 | SwkbdCalcArgOld swkbd_calc_arg_old; | ||
| 173 | SwkbdCalcArgNew swkbd_calc_arg_new; | ||
| 153 | bool use_changed_string_v2{false}; | 174 | bool use_changed_string_v2{false}; |
| 154 | bool use_moved_cursor_v2{false}; | 175 | bool use_moved_cursor_v2{false}; |
| 155 | bool inline_use_utf8{false}; | 176 | bool inline_use_utf8{false}; |
diff --git a/src/core/hle/service/am/applets/applet_software_keyboard_types.h b/src/core/hle/service/am/applets/applet_software_keyboard_types.h index 21aa8e800..de1ca7aa5 100644 --- a/src/core/hle/service/am/applets/applet_software_keyboard_types.h +++ b/src/core/hle/service/am/applets/applet_software_keyboard_types.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "common/common_funcs.h" | 10 | #include "common/common_funcs.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/swap.h" | 12 | #include "common/swap.h" |
| 13 | #include "common/uuid.h" | ||
| 13 | 14 | ||
| 14 | namespace Service::AM::Applets { | 15 | namespace Service::AM::Applets { |
| 15 | 16 | ||
| @@ -216,7 +217,7 @@ struct SwkbdInitializeArg { | |||
| 216 | }; | 217 | }; |
| 217 | static_assert(sizeof(SwkbdInitializeArg) == 0x8, "SwkbdInitializeArg has incorrect size."); | 218 | static_assert(sizeof(SwkbdInitializeArg) == 0x8, "SwkbdInitializeArg has incorrect size."); |
| 218 | 219 | ||
| 219 | struct SwkbdAppearArg { | 220 | struct SwkbdAppearArgOld { |
| 220 | SwkbdType type{}; | 221 | SwkbdType type{}; |
| 221 | std::array<char16_t, MAX_OK_TEXT_LENGTH + 1> ok_text{}; | 222 | std::array<char16_t, MAX_OK_TEXT_LENGTH + 1> ok_text{}; |
| 222 | char16_t left_optional_symbol_key{}; | 223 | char16_t left_optional_symbol_key{}; |
| @@ -229,19 +230,76 @@ struct SwkbdAppearArg { | |||
| 229 | bool enable_return_button{}; | 230 | bool enable_return_button{}; |
| 230 | INSERT_PADDING_BYTES(3); | 231 | INSERT_PADDING_BYTES(3); |
| 231 | u32 flags{}; | 232 | u32 flags{}; |
| 232 | INSERT_PADDING_WORDS(6); | 233 | bool is_use_save_data{}; |
| 234 | INSERT_PADDING_BYTES(7); | ||
| 235 | Common::UUID user_id{}; | ||
| 233 | }; | 236 | }; |
| 234 | static_assert(sizeof(SwkbdAppearArg) == 0x48, "SwkbdAppearArg has incorrect size."); | 237 | static_assert(sizeof(SwkbdAppearArgOld) == 0x48, "SwkbdAppearArg has incorrect size."); |
| 235 | 238 | ||
| 236 | struct SwkbdCalcArg { | 239 | struct SwkbdAppearArgNew { |
| 240 | SwkbdType type{}; | ||
| 241 | std::array<char16_t, MAX_OK_TEXT_LENGTH + 1> ok_text{}; | ||
| 242 | char16_t left_optional_symbol_key{}; | ||
| 243 | char16_t right_optional_symbol_key{}; | ||
| 244 | bool use_prediction{}; | ||
| 245 | bool disable_cancel_button{}; | ||
| 246 | SwkbdKeyDisableFlags key_disable_flags{}; | ||
| 247 | u32 max_text_length{}; | ||
| 248 | u32 min_text_length{}; | ||
| 249 | bool enable_return_button{}; | ||
| 250 | INSERT_PADDING_BYTES(3); | ||
| 251 | u32 flags{}; | ||
| 252 | bool is_use_save_data{}; | ||
| 253 | INSERT_PADDING_BYTES(7); | ||
| 254 | Common::UUID user_id{}; | ||
| 255 | u64 start_sampling_number{}; | ||
| 256 | INSERT_PADDING_WORDS(8); | ||
| 257 | }; | ||
| 258 | static_assert(sizeof(SwkbdAppearArgNew) == 0x70, "SwkbdAppearArg has incorrect size."); | ||
| 259 | |||
| 260 | struct SwkbdCalcArgCommon { | ||
| 237 | u32 unknown{}; | 261 | u32 unknown{}; |
| 238 | u16 calc_arg_size{}; | 262 | u16 calc_arg_size{}; |
| 239 | INSERT_PADDING_BYTES(2); | 263 | INSERT_PADDING_BYTES(2); |
| 240 | SwkbdCalcArgFlags flags{}; | 264 | SwkbdCalcArgFlags flags{}; |
| 241 | SwkbdInitializeArg initialize_arg{}; | 265 | SwkbdInitializeArg initialize_arg{}; |
| 266 | }; | ||
| 267 | static_assert(sizeof(SwkbdCalcArgCommon) == 0x18, "SwkbdCalcArgCommon has incorrect size."); | ||
| 268 | |||
| 269 | struct SwkbdCalcArgOld { | ||
| 270 | f32 volume{}; | ||
| 271 | s32 cursor_position{}; | ||
| 272 | SwkbdAppearArgOld appear_arg{}; | ||
| 273 | std::array<char16_t, 0x1FA> input_text{}; | ||
| 274 | bool utf8_mode{}; | ||
| 275 | INSERT_PADDING_BYTES(1); | ||
| 276 | bool enable_backspace_button{}; | ||
| 277 | INSERT_PADDING_BYTES(3); | ||
| 278 | bool key_top_as_floating{}; | ||
| 279 | bool footer_scalable{}; | ||
| 280 | bool alpha_enabled_in_input_mode{}; | ||
| 281 | u8 input_mode_fade_type{}; | ||
| 282 | bool disable_touch{}; | ||
| 283 | bool disable_hardware_keyboard{}; | ||
| 284 | INSERT_PADDING_BYTES(8); | ||
| 285 | f32 key_top_scale_x{}; | ||
| 286 | f32 key_top_scale_y{}; | ||
| 287 | f32 key_top_translate_x{}; | ||
| 288 | f32 key_top_translate_y{}; | ||
| 289 | f32 key_top_bg_alpha{}; | ||
| 290 | f32 footer_bg_alpha{}; | ||
| 291 | f32 balloon_scale{}; | ||
| 292 | INSERT_PADDING_WORDS(4); | ||
| 293 | u8 se_group{}; | ||
| 294 | INSERT_PADDING_BYTES(3); | ||
| 295 | }; | ||
| 296 | static_assert(sizeof(SwkbdCalcArgOld) == 0x4A0 - sizeof(SwkbdCalcArgCommon), | ||
| 297 | "SwkbdCalcArgOld has incorrect size."); | ||
| 298 | |||
| 299 | struct SwkbdCalcArgNew { | ||
| 300 | SwkbdAppearArgNew appear_arg{}; | ||
| 242 | f32 volume{}; | 301 | f32 volume{}; |
| 243 | s32 cursor_position{}; | 302 | s32 cursor_position{}; |
| 244 | SwkbdAppearArg appear_arg{}; | ||
| 245 | std::array<char16_t, 0x1FA> input_text{}; | 303 | std::array<char16_t, 0x1FA> input_text{}; |
| 246 | bool utf8_mode{}; | 304 | bool utf8_mode{}; |
| 247 | INSERT_PADDING_BYTES(1); | 305 | INSERT_PADDING_BYTES(1); |
| @@ -264,8 +322,10 @@ struct SwkbdCalcArg { | |||
| 264 | INSERT_PADDING_WORDS(4); | 322 | INSERT_PADDING_WORDS(4); |
| 265 | u8 se_group{}; | 323 | u8 se_group{}; |
| 266 | INSERT_PADDING_BYTES(3); | 324 | INSERT_PADDING_BYTES(3); |
| 325 | INSERT_PADDING_WORDS(8); | ||
| 267 | }; | 326 | }; |
| 268 | static_assert(sizeof(SwkbdCalcArg) == 0x4A0, "SwkbdCalcArg has incorrect size."); | 327 | static_assert(sizeof(SwkbdCalcArgNew) == 0x4E8 - sizeof(SwkbdCalcArgCommon), |
| 328 | "SwkbdCalcArgNew has incorrect size."); | ||
| 269 | 329 | ||
| 270 | struct SwkbdChangedStringArg { | 330 | struct SwkbdChangedStringArg { |
| 271 | u32 text_length{}; | 331 | u32 text_length{}; |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 3fed51400..28d30eee2 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -322,7 +322,7 @@ struct Memory::Impl { | |||
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | if (Settings::IsFastmemEnabled()) { | 324 | if (Settings::IsFastmemEnabled()) { |
| 325 | const bool is_read_enable = !Settings::IsGPULevelExtreme() || !cached; | 325 | const bool is_read_enable = Settings::IsGPULevelHigh() || !cached; |
| 326 | system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); | 326 | system.DeviceMemory().buffer.Protect(vaddr, size, is_read_enable, !cached); |
| 327 | } | 327 | } |
| 328 | 328 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 7e06d0069..4d632d211 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -352,7 +352,7 @@ void RasterizerOpenGL::OnCPUWrite(VAddr addr, u64 size) { | |||
| 352 | shader_cache.OnCPUWrite(addr, size); | 352 | shader_cache.OnCPUWrite(addr, size); |
| 353 | { | 353 | { |
| 354 | std::scoped_lock lock{texture_cache.mutex}; | 354 | std::scoped_lock lock{texture_cache.mutex}; |
| 355 | texture_cache.CachedWriteMemory(addr, size); | 355 | texture_cache.WriteMemory(addr, size); |
| 356 | } | 356 | } |
| 357 | { | 357 | { |
| 358 | std::scoped_lock lock{buffer_cache.mutex}; | 358 | std::scoped_lock lock{buffer_cache.mutex}; |
| @@ -364,10 +364,6 @@ void RasterizerOpenGL::SyncGuestHost() { | |||
| 364 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); | 364 | MICROPROFILE_SCOPE(OpenGL_CacheManagement); |
| 365 | shader_cache.SyncGuestHost(); | 365 | shader_cache.SyncGuestHost(); |
| 366 | { | 366 | { |
| 367 | std::scoped_lock lock{texture_cache.mutex}; | ||
| 368 | texture_cache.FlushCachedWrites(); | ||
| 369 | } | ||
| 370 | { | ||
| 371 | std::scoped_lock lock{buffer_cache.mutex}; | 367 | std::scoped_lock lock{buffer_cache.mutex}; |
| 372 | buffer_cache.FlushCachedWrites(); | 368 | buffer_cache.FlushCachedWrites(); |
| 373 | } | 369 | } |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index dd6e0027e..fa87d37f8 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -408,7 +408,7 @@ void RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) { | |||
| 408 | pipeline_cache.OnCPUWrite(addr, size); | 408 | pipeline_cache.OnCPUWrite(addr, size); |
| 409 | { | 409 | { |
| 410 | std::scoped_lock lock{texture_cache.mutex}; | 410 | std::scoped_lock lock{texture_cache.mutex}; |
| 411 | texture_cache.CachedWriteMemory(addr, size); | 411 | texture_cache.WriteMemory(addr, size); |
| 412 | } | 412 | } |
| 413 | { | 413 | { |
| 414 | std::scoped_lock lock{buffer_cache.mutex}; | 414 | std::scoped_lock lock{buffer_cache.mutex}; |
| @@ -419,10 +419,6 @@ void RasterizerVulkan::OnCPUWrite(VAddr addr, u64 size) { | |||
| 419 | void RasterizerVulkan::SyncGuestHost() { | 419 | void RasterizerVulkan::SyncGuestHost() { |
| 420 | pipeline_cache.SyncGuestHost(); | 420 | pipeline_cache.SyncGuestHost(); |
| 421 | { | 421 | { |
| 422 | std::scoped_lock lock{texture_cache.mutex}; | ||
| 423 | texture_cache.FlushCachedWrites(); | ||
| 424 | } | ||
| 425 | { | ||
| 426 | std::scoped_lock lock{buffer_cache.mutex}; | 422 | std::scoped_lock lock{buffer_cache.mutex}; |
| 427 | buffer_cache.FlushCachedWrites(); | 423 | buffer_cache.FlushCachedWrites(); |
| 428 | } | 424 | } |
diff --git a/src/video_core/texture_cache/image_base.h b/src/video_core/texture_cache/image_base.h index cc7999027..dd0106432 100644 --- a/src/video_core/texture_cache/image_base.h +++ b/src/video_core/texture_cache/image_base.h | |||
| @@ -39,9 +39,6 @@ enum class ImageFlagBits : u32 { | |||
| 39 | Rescaled = 1 << 13, | 39 | Rescaled = 1 << 13, |
| 40 | CheckingRescalable = 1 << 14, | 40 | CheckingRescalable = 1 << 14, |
| 41 | IsRescalable = 1 << 15, | 41 | IsRescalable = 1 << 15, |
| 42 | |||
| 43 | // Cached CPU | ||
| 44 | CachedCpuModified = 1 << 16, ///< Contents have been modified from the CPU | ||
| 45 | }; | 42 | }; |
| 46 | DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) | 43 | DECLARE_ENUM_FLAG_OPERATORS(ImageFlagBits) |
| 47 | 44 | ||
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 099b2ae1b..efc1c4525 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -438,23 +438,6 @@ void TextureCache<P>::WriteMemory(VAddr cpu_addr, size_t size) { | |||
| 438 | } | 438 | } |
| 439 | 439 | ||
| 440 | template <class P> | 440 | template <class P> |
| 441 | void TextureCache<P>::CachedWriteMemory(VAddr cpu_addr, size_t size) { | ||
| 442 | const VAddr new_cpu_addr = Common::AlignDown(cpu_addr, CPU_PAGE_SIZE); | ||
| 443 | const size_t new_size = Common::AlignUp(size + cpu_addr - new_cpu_addr, CPU_PAGE_SIZE); | ||
| 444 | ForEachImageInRegion(new_cpu_addr, new_size, [this](ImageId image_id, Image& image) { | ||
| 445 | if (True(image.flags & ImageFlagBits::CachedCpuModified)) { | ||
| 446 | return; | ||
| 447 | } | ||
| 448 | image.flags |= ImageFlagBits::CachedCpuModified; | ||
| 449 | cached_cpu_invalidate.insert(image_id); | ||
| 450 | |||
| 451 | if (True(image.flags & ImageFlagBits::Tracked)) { | ||
| 452 | UntrackImage(image, image_id); | ||
| 453 | } | ||
| 454 | }); | ||
| 455 | } | ||
| 456 | |||
| 457 | template <class P> | ||
| 458 | void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) { | 441 | void TextureCache<P>::DownloadMemory(VAddr cpu_addr, size_t size) { |
| 459 | std::vector<ImageId> images; | 442 | std::vector<ImageId> images; |
| 460 | ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) { | 443 | ForEachImageInRegion(cpu_addr, size, [this, &images](ImageId image_id, ImageBase& image) { |
| @@ -512,18 +495,6 @@ void TextureCache<P>::UnmapGPUMemory(GPUVAddr gpu_addr, size_t size) { | |||
| 512 | } | 495 | } |
| 513 | 496 | ||
| 514 | template <class P> | 497 | template <class P> |
| 515 | void TextureCache<P>::FlushCachedWrites() { | ||
| 516 | for (ImageId image_id : cached_cpu_invalidate) { | ||
| 517 | Image& image = slot_images[image_id]; | ||
| 518 | if (True(image.flags & ImageFlagBits::CachedCpuModified)) { | ||
| 519 | image.flags &= ~ImageFlagBits::CachedCpuModified; | ||
| 520 | image.flags |= ImageFlagBits::CpuModified; | ||
| 521 | } | ||
| 522 | } | ||
| 523 | cached_cpu_invalidate.clear(); | ||
| 524 | } | ||
| 525 | |||
| 526 | template <class P> | ||
| 527 | void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | 498 | void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, |
| 528 | const Tegra::Engines::Fermi2D::Surface& src, | 499 | const Tegra::Engines::Fermi2D::Surface& src, |
| 529 | const Tegra::Engines::Fermi2D::Config& copy) { | 500 | const Tegra::Engines::Fermi2D::Config& copy) { |
| @@ -1589,9 +1560,6 @@ void TextureCache<P>::UnregisterImage(ImageId image_id) { | |||
| 1589 | template <class P> | 1560 | template <class P> |
| 1590 | void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { | 1561 | void TextureCache<P>::TrackImage(ImageBase& image, ImageId image_id) { |
| 1591 | ASSERT(False(image.flags & ImageFlagBits::Tracked)); | 1562 | ASSERT(False(image.flags & ImageFlagBits::Tracked)); |
| 1592 | if (True(image.flags & ImageFlagBits::CachedCpuModified)) { | ||
| 1593 | return; | ||
| 1594 | } | ||
| 1595 | image.flags |= ImageFlagBits::Tracked; | 1563 | image.flags |= ImageFlagBits::Tracked; |
| 1596 | if (False(image.flags & ImageFlagBits::Sparse)) { | 1564 | if (False(image.flags & ImageFlagBits::Sparse)) { |
| 1597 | rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); | 1565 | rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); |
| @@ -1648,9 +1616,6 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) { | |||
| 1648 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); | 1616 | tentative_size = EstimatedDecompressedSize(tentative_size, image.info.format); |
| 1649 | } | 1617 | } |
| 1650 | total_used_memory -= Common::AlignUp(tentative_size, 1024); | 1618 | total_used_memory -= Common::AlignUp(tentative_size, 1024); |
| 1651 | if (True(image.flags & ImageFlagBits::CachedCpuModified)) { | ||
| 1652 | cached_cpu_invalidate.erase(image_id); | ||
| 1653 | } | ||
| 1654 | const GPUVAddr gpu_addr = image.gpu_addr; | 1619 | const GPUVAddr gpu_addr = image.gpu_addr; |
| 1655 | const auto alloc_it = image_allocs_table.find(gpu_addr); | 1620 | const auto alloc_it = image_allocs_table.find(gpu_addr); |
| 1656 | if (alloc_it == image_allocs_table.end()) { | 1621 | if (alloc_it == image_allocs_table.end()) { |
| @@ -1817,11 +1782,7 @@ template <class P> | |||
| 1817 | void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool invalidate) { | 1782 | void TextureCache<P>::PrepareImage(ImageId image_id, bool is_modification, bool invalidate) { |
| 1818 | Image& image = slot_images[image_id]; | 1783 | Image& image = slot_images[image_id]; |
| 1819 | if (invalidate) { | 1784 | if (invalidate) { |
| 1820 | if (True(image.flags & ImageFlagBits::CachedCpuModified)) { | 1785 | image.flags &= ~(ImageFlagBits::CpuModified | ImageFlagBits::GpuModified); |
| 1821 | cached_cpu_invalidate.erase(image_id); | ||
| 1822 | } | ||
| 1823 | image.flags &= ~(ImageFlagBits::CpuModified | ImageFlagBits::GpuModified | | ||
| 1824 | ImageFlagBits::CachedCpuModified); | ||
| 1825 | if (False(image.flags & ImageFlagBits::Tracked)) { | 1786 | if (False(image.flags & ImageFlagBits::Tracked)) { |
| 1826 | TrackImage(image, image_id); | 1787 | TrackImage(image, image_id); |
| 1827 | } | 1788 | } |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index ad5978a33..b1324edf3 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <span> | 8 | #include <span> |
| 9 | #include <type_traits> | 9 | #include <type_traits> |
| 10 | #include <unordered_map> | 10 | #include <unordered_map> |
| 11 | #include <unordered_set> | ||
| 12 | #include <vector> | 11 | #include <vector> |
| 13 | #include <queue> | 12 | #include <queue> |
| 14 | 13 | ||
| @@ -51,9 +50,6 @@ class TextureCache { | |||
| 51 | /// Address shift for caching images into a hash table | 50 | /// Address shift for caching images into a hash table |
| 52 | static constexpr u64 PAGE_BITS = 20; | 51 | static constexpr u64 PAGE_BITS = 20; |
| 53 | 52 | ||
| 54 | static constexpr u64 CPU_PAGE_BITS = 12; | ||
| 55 | static constexpr u64 CPU_PAGE_SIZE = 1ULL << CPU_PAGE_BITS; | ||
| 56 | |||
| 57 | /// Enables debugging features to the texture cache | 53 | /// Enables debugging features to the texture cache |
| 58 | static constexpr bool ENABLE_VALIDATION = P::ENABLE_VALIDATION; | 54 | static constexpr bool ENABLE_VALIDATION = P::ENABLE_VALIDATION; |
| 59 | /// Implement blits as copies between framebuffers | 55 | /// Implement blits as copies between framebuffers |
| @@ -140,9 +136,6 @@ public: | |||
| 140 | /// Mark images in a range as modified from the CPU | 136 | /// Mark images in a range as modified from the CPU |
| 141 | void WriteMemory(VAddr cpu_addr, size_t size); | 137 | void WriteMemory(VAddr cpu_addr, size_t size); |
| 142 | 138 | ||
| 143 | /// Mark images in a range as modified from the CPU | ||
| 144 | void CachedWriteMemory(VAddr cpu_addr, size_t size); | ||
| 145 | |||
| 146 | /// Download contents of host images to guest memory in a region | 139 | /// Download contents of host images to guest memory in a region |
| 147 | void DownloadMemory(VAddr cpu_addr, size_t size); | 140 | void DownloadMemory(VAddr cpu_addr, size_t size); |
| 148 | 141 | ||
| @@ -152,8 +145,6 @@ public: | |||
| 152 | /// Remove images in a region | 145 | /// Remove images in a region |
| 153 | void UnmapGPUMemory(GPUVAddr gpu_addr, size_t size); | 146 | void UnmapGPUMemory(GPUVAddr gpu_addr, size_t size); |
| 154 | 147 | ||
| 155 | void FlushCachedWrites(); | ||
| 156 | |||
| 157 | /// Blit an image with the given parameters | 148 | /// Blit an image with the given parameters |
| 158 | void BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | 149 | void BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, |
| 159 | const Tegra::Engines::Fermi2D::Surface& src, | 150 | const Tegra::Engines::Fermi2D::Surface& src, |
| @@ -375,8 +366,6 @@ private: | |||
| 375 | 366 | ||
| 376 | std::unordered_map<ImageId, std::vector<ImageViewId>> sparse_views; | 367 | std::unordered_map<ImageId, std::vector<ImageViewId>> sparse_views; |
| 377 | 368 | ||
| 378 | std::unordered_set<ImageId> cached_cpu_invalidate; | ||
| 379 | |||
| 380 | VAddr virtual_invalid_space{}; | 369 | VAddr virtual_invalid_space{}; |
| 381 | 370 | ||
| 382 | bool has_deleted_images = false; | 371 | bool has_deleted_images = false; |