diff options
Diffstat (limited to 'src/input_common')
| -rw-r--r-- | src/input_common/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | src/input_common/drivers/gc_adapter.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.cpp | 1 | ||||
| -rw-r--r-- | src/input_common/drivers/mouse.h | 2 | ||||
| -rw-r--r-- | src/input_common/drivers/tas_input.cpp | 1 | ||||
| -rw-r--r-- | src/input_common/drivers/virtual_amiibo.cpp | 38 | ||||
| -rw-r--r-- | src/input_common/drivers/virtual_amiibo.h | 7 | ||||
| -rw-r--r-- | src/input_common/precompiled_headers.h | 6 |
8 files changed, 45 insertions, 27 deletions
diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 193127d0a..7932aaab0 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt | |||
| @@ -34,6 +34,7 @@ add_library(input_common STATIC | |||
| 34 | input_poller.h | 34 | input_poller.h |
| 35 | main.cpp | 35 | main.cpp |
| 36 | main.h | 36 | main.h |
| 37 | precompiled_headers.h | ||
| 37 | ) | 38 | ) |
| 38 | 39 | ||
| 39 | if (MSVC) | 40 | if (MSVC) |
| @@ -55,15 +56,13 @@ if (ENABLE_SDL2) | |||
| 55 | drivers/sdl_driver.cpp | 56 | drivers/sdl_driver.cpp |
| 56 | drivers/sdl_driver.h | 57 | drivers/sdl_driver.h |
| 57 | ) | 58 | ) |
| 58 | if (YUZU_USE_EXTERNAL_SDL2) | 59 | target_link_libraries(input_common PRIVATE SDL2::SDL2) |
| 59 | target_link_libraries(input_common PRIVATE SDL2-static) | ||
| 60 | else() | ||
| 61 | target_link_libraries(input_common PRIVATE SDL2) | ||
| 62 | endif() | ||
| 63 | target_compile_definitions(input_common PRIVATE HAVE_SDL2) | 60 | target_compile_definitions(input_common PRIVATE HAVE_SDL2) |
| 64 | endif() | 61 | endif() |
| 65 | 62 | ||
| 66 | target_link_libraries(input_common PRIVATE usb) | ||
| 67 | |||
| 68 | create_target_directory_groups(input_common) | 63 | create_target_directory_groups(input_common) |
| 69 | target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost) | 64 | target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost libusb::usb) |
| 65 | |||
| 66 | if (YUZU_USE_PRECOMPILED_HEADERS) | ||
| 67 | target_precompile_headers(input_common PRIVATE precompiled_headers.h) | ||
| 68 | endif() | ||
diff --git a/src/input_common/drivers/gc_adapter.h b/src/input_common/drivers/gc_adapter.h index 7f81767f7..b5270fd0b 100644 --- a/src/input_common/drivers/gc_adapter.h +++ b/src/input_common/drivers/gc_adapter.h | |||
| @@ -5,10 +5,10 @@ | |||
| 5 | 5 | ||
| 6 | #include <array> | 6 | #include <array> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <stop_token> | ||
| 9 | #include <string> | 8 | #include <string> |
| 10 | #include <thread> | 9 | #include <thread> |
| 11 | 10 | ||
| 11 | #include "common/polyfill_thread.h" | ||
| 12 | #include "input_common/input_engine.h" | 12 | #include "input_common/input_engine.h" |
| 13 | 13 | ||
| 14 | struct libusb_context; | 14 | struct libusb_context; |
diff --git a/src/input_common/drivers/mouse.cpp b/src/input_common/drivers/mouse.cpp index 98c3157a8..faf9cbdc3 100644 --- a/src/input_common/drivers/mouse.cpp +++ b/src/input_common/drivers/mouse.cpp | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <stop_token> | ||
| 5 | #include <thread> | 4 | #include <thread> |
| 6 | #include <fmt/format.h> | 5 | #include <fmt/format.h> |
| 7 | 6 | ||
diff --git a/src/input_common/drivers/mouse.h b/src/input_common/drivers/mouse.h index 286ce1cf6..72073cc23 100644 --- a/src/input_common/drivers/mouse.h +++ b/src/input_common/drivers/mouse.h | |||
| @@ -3,9 +3,9 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <stop_token> | ||
| 7 | #include <thread> | 6 | #include <thread> |
| 8 | 7 | ||
| 8 | #include "common/polyfill_thread.h" | ||
| 9 | #include "common/vector_math.h" | 9 | #include "common/vector_math.h" |
| 10 | #include "input_common/input_engine.h" | 10 | #include "input_common/input_engine.h" |
| 11 | 11 | ||
diff --git a/src/input_common/drivers/tas_input.cpp b/src/input_common/drivers/tas_input.cpp index 21c6ed405..f3ade90da 100644 --- a/src/input_common/drivers/tas_input.cpp +++ b/src/input_common/drivers/tas_input.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <cstring> | 4 | #include <cstring> |
| 5 | #include <sstream> | ||
| 5 | #include <fmt/format.h> | 6 | #include <fmt/format.h> |
| 6 | 7 | ||
| 7 | #include "common/fs/file.h" | 8 | #include "common/fs/file.h" |
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp index 564a188e5..63ffaca67 100644 --- a/src/input_common/drivers/virtual_amiibo.cpp +++ b/src/input_common/drivers/virtual_amiibo.cpp | |||
| @@ -47,20 +47,20 @@ Common::Input::NfcState VirtualAmiibo::SupportsNfc( | |||
| 47 | 47 | ||
| 48 | Common::Input::NfcState VirtualAmiibo::WriteNfcData( | 48 | Common::Input::NfcState VirtualAmiibo::WriteNfcData( |
| 49 | [[maybe_unused]] const PadIdentifier& identifier_, const std::vector<u8>& data) { | 49 | [[maybe_unused]] const PadIdentifier& identifier_, const std::vector<u8>& data) { |
| 50 | const Common::FS::IOFile amiibo_file{file_path, Common::FS::FileAccessMode::ReadWrite, | 50 | const Common::FS::IOFile nfc_file{file_path, Common::FS::FileAccessMode::ReadWrite, |
| 51 | Common::FS::FileType::BinaryFile}; | 51 | Common::FS::FileType::BinaryFile}; |
| 52 | 52 | ||
| 53 | if (!amiibo_file.IsOpen()) { | 53 | if (!nfc_file.IsOpen()) { |
| 54 | LOG_ERROR(Core, "Amiibo is already on use"); | 54 | LOG_ERROR(Core, "Amiibo is already on use"); |
| 55 | return Common::Input::NfcState::WriteFailed; | 55 | return Common::Input::NfcState::WriteFailed; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | if (!amiibo_file.Write(data)) { | 58 | if (!nfc_file.Write(data)) { |
| 59 | LOG_ERROR(Service_NFP, "Error writting to file"); | 59 | LOG_ERROR(Service_NFP, "Error writting to file"); |
| 60 | return Common::Input::NfcState::WriteFailed; | 60 | return Common::Input::NfcState::WriteFailed; |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | amiibo_data = data; | 63 | nfc_data = data; |
| 64 | 64 | ||
| 65 | return Common::Input::NfcState::Success; | 65 | return Common::Input::NfcState::Success; |
| 66 | } | 66 | } |
| @@ -70,32 +70,44 @@ VirtualAmiibo::State VirtualAmiibo::GetCurrentState() const { | |||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) { | 72 | VirtualAmiibo::Info VirtualAmiibo::LoadAmiibo(const std::string& filename) { |
| 73 | const Common::FS::IOFile amiibo_file{filename, Common::FS::FileAccessMode::Read, | 73 | const Common::FS::IOFile nfc_file{filename, Common::FS::FileAccessMode::Read, |
| 74 | Common::FS::FileType::BinaryFile}; | 74 | Common::FS::FileType::BinaryFile}; |
| 75 | 75 | ||
| 76 | if (state != State::WaitingForAmiibo) { | 76 | if (state != State::WaitingForAmiibo) { |
| 77 | return Info::WrongDeviceState; | 77 | return Info::WrongDeviceState; |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | if (!amiibo_file.IsOpen()) { | 80 | if (!nfc_file.IsOpen()) { |
| 81 | return Info::UnableToLoad; | 81 | return Info::UnableToLoad; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | amiibo_data.resize(amiibo_size); | 84 | switch (nfc_file.GetSize()) { |
| 85 | 85 | case AmiiboSize: | |
| 86 | if (amiibo_file.Read(amiibo_data) < amiibo_size_without_password) { | 86 | case AmiiboSizeWithoutPassword: |
| 87 | nfc_data.resize(AmiiboSize); | ||
| 88 | if (nfc_file.Read(nfc_data) < AmiiboSizeWithoutPassword) { | ||
| 89 | return Info::NotAnAmiibo; | ||
| 90 | } | ||
| 91 | break; | ||
| 92 | case MifareSize: | ||
| 93 | nfc_data.resize(MifareSize); | ||
| 94 | if (nfc_file.Read(nfc_data) < MifareSize) { | ||
| 95 | return Info::NotAnAmiibo; | ||
| 96 | } | ||
| 97 | break; | ||
| 98 | default: | ||
| 87 | return Info::NotAnAmiibo; | 99 | return Info::NotAnAmiibo; |
| 88 | } | 100 | } |
| 89 | 101 | ||
| 90 | file_path = filename; | 102 | file_path = filename; |
| 91 | state = State::AmiiboIsOpen; | 103 | state = State::AmiiboIsOpen; |
| 92 | SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, amiibo_data}); | 104 | SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, nfc_data}); |
| 93 | return Info::Success; | 105 | return Info::Success; |
| 94 | } | 106 | } |
| 95 | 107 | ||
| 96 | VirtualAmiibo::Info VirtualAmiibo::ReloadAmiibo() { | 108 | VirtualAmiibo::Info VirtualAmiibo::ReloadAmiibo() { |
| 97 | if (state == State::AmiiboIsOpen) { | 109 | if (state == State::AmiiboIsOpen) { |
| 98 | SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, amiibo_data}); | 110 | SetNfc(identifier, {Common::Input::NfcState::NewAmiibo, nfc_data}); |
| 99 | return Info::Success; | 111 | return Info::Success; |
| 100 | } | 112 | } |
| 101 | 113 | ||
diff --git a/src/input_common/drivers/virtual_amiibo.h b/src/input_common/drivers/virtual_amiibo.h index 9baeb3997..0f9dad333 100644 --- a/src/input_common/drivers/virtual_amiibo.h +++ b/src/input_common/drivers/virtual_amiibo.h | |||
| @@ -53,12 +53,13 @@ public: | |||
| 53 | std::string GetLastFilePath() const; | 53 | std::string GetLastFilePath() const; |
| 54 | 54 | ||
| 55 | private: | 55 | private: |
| 56 | static constexpr std::size_t amiibo_size = 0x21C; | 56 | static constexpr std::size_t AmiiboSize = 0x21C; |
| 57 | static constexpr std::size_t amiibo_size_without_password = amiibo_size - 0x8; | 57 | static constexpr std::size_t AmiiboSizeWithoutPassword = AmiiboSize - 0x8; |
| 58 | static constexpr std::size_t MifareSize = 0x400; | ||
| 58 | 59 | ||
| 59 | std::string file_path{}; | 60 | std::string file_path{}; |
| 60 | State state{State::Initialized}; | 61 | State state{State::Initialized}; |
| 61 | std::vector<u8> amiibo_data; | 62 | std::vector<u8> nfc_data; |
| 62 | Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Pasive}; | 63 | Common::Input::PollingMode polling_mode{Common::Input::PollingMode::Pasive}; |
| 63 | }; | 64 | }; |
| 64 | } // namespace InputCommon | 65 | } // namespace InputCommon |
diff --git a/src/input_common/precompiled_headers.h b/src/input_common/precompiled_headers.h new file mode 100644 index 000000000..aabae730b --- /dev/null +++ b/src/input_common/precompiled_headers.h | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | // SPDX-FileCopyrightText: 2022 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_precompiled_headers.h" | ||