Compare commits
64 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5863f16b4c | ||
|
|
6f931d49c7 | ||
|
|
4976d14009 | ||
|
|
72b90a5bbf | ||
|
|
72ff5cd445 | ||
|
|
5cd95fa949 | ||
|
|
6d41088153 | ||
|
|
a5cd639cb6 | ||
|
|
bb84f53539 | ||
|
|
f80c7c4cd5 | ||
|
|
035ca99b02 | ||
|
|
9fc03d4b91 | ||
|
|
4d72612416 | ||
|
|
bc992b9bdc | ||
|
|
d04bc95934 | ||
|
|
411e58de28 | ||
|
|
cba3b05c94 | ||
|
|
ce42465638 | ||
|
|
85c9e31791 | ||
|
|
5a6a26449c | ||
|
|
b25090d960 | ||
|
|
a44da3c14d | ||
|
|
e8a59a6931 | ||
|
|
536626fdd6 | ||
|
|
56115f7732 | ||
|
|
72bf844110 | ||
|
|
253e1e6941 | ||
|
|
2338503241 | ||
|
|
0069b5e118 | ||
|
|
4bd8adfe42 | ||
|
|
15df026d04 | ||
|
|
9bdef7428a | ||
|
|
ada667060a | ||
|
|
af9c3e9340 | ||
|
|
050c760822 | ||
|
|
1f7e2d1cad | ||
|
|
f2fbf6d910 | ||
|
|
301702e548 | ||
|
|
8eb2c73381 | ||
|
|
d8b160c883 | ||
|
|
b1d61cd025 | ||
|
|
aae208d07f | ||
|
|
01bb5d5c4d | ||
|
|
30515b3b27 | ||
|
|
167d948ce1 | ||
|
|
b210efefb0 | ||
|
|
12dc05032b | ||
|
|
50cda3bd7b | ||
|
|
e2123b27e8 | ||
|
|
795ccc058d | ||
|
|
9dc8d02acc | ||
|
|
0f2fc6335e | ||
|
|
ee5b244cdf | ||
|
|
80b462e553 | ||
|
|
cd5bbf0f04 | ||
|
|
63673dcf98 | ||
|
|
1d364adf3e | ||
|
|
7e0afc641c | ||
|
|
8c933beb48 | ||
|
|
f580946b0d | ||
|
|
cbe5b8a13e | ||
|
|
6523854dd6 | ||
|
|
d657ea69c9 | ||
|
|
30e8876ea4 |
@@ -8,8 +8,10 @@ cp LICENSE.txt "$DIR_NAME"
|
||||
cp README.md "$DIR_NAME"
|
||||
|
||||
if [[ -z "${NO_SOURCE_PACK}" ]]; then
|
||||
tar -cJvf "${REV_NAME}-source.tar.xz" src externals CMakeLists.txt README.md LICENSE.txt
|
||||
git clone --depth 1 file://$(readlink -e .) ${REV_NAME}-source
|
||||
tar -cJvf "${REV_NAME}-source.tar.xz" ${REV_NAME}-source
|
||||
cp -v "${REV_NAME}-source.tar.xz" "$DIR_NAME"
|
||||
cp -v "${REV_NAME}-source.tar.xz" "${ARTIFACTS_DIR}/"
|
||||
fi
|
||||
|
||||
tar $COMPRESSION_FLAGS "$ARCHIVE_NAME" "$DIR_NAME"
|
||||
|
||||
@@ -42,14 +42,10 @@ mkdir $RELEASE_DIST
|
||||
mkdir $MSVC_SOURCE
|
||||
mkdir "artifacts"
|
||||
|
||||
$CURRENT_DIR = Convert-Path .
|
||||
|
||||
# Build a tar.xz for the source of the release
|
||||
Copy-Item .\LICENSE.txt -Destination $MSVC_SOURCE
|
||||
Copy-Item .\README.md -Destination $MSVC_SOURCE
|
||||
Copy-Item .\CMakeLists.txt -Destination $MSVC_SOURCE
|
||||
Copy-Item .\src -Recurse -Destination $MSVC_SOURCE
|
||||
Copy-Item .\externals -Recurse -Destination $MSVC_SOURCE
|
||||
Copy-Item .\dist -Recurse -Destination $MSVC_SOURCE
|
||||
Copy-Item .\CMakeModules -Recurse -Destination $MSVC_SOURCE
|
||||
git clone --depth 1 file://$CURRENT_DIR $MSVC_SOURCE
|
||||
7z a -r -ttar $MSVC_SOURCE_TAR $MSVC_SOURCE
|
||||
7z a -r -txz $MSVC_SOURCE_TARXZ $MSVC_SOURCE_TAR
|
||||
|
||||
|
||||
2
.gitignore
vendored
@@ -7,7 +7,7 @@ doc-build/
|
||||
|
||||
# Generated source files
|
||||
src/common/scm_rev.cpp
|
||||
.travis.descriptor.json
|
||||
dist/english_plurals/generated_en.ts
|
||||
|
||||
# Project/editor files
|
||||
*.swp
|
||||
|
||||
58
.reuse/dep5
@@ -2,7 +2,8 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Comment: It is best to use this file to record copyright information about
|
||||
generated, binary and third party files
|
||||
|
||||
Files: dist/icons/controller/*.png
|
||||
Files: dist/english_plurals/*
|
||||
dist/icons/controller/*.png
|
||||
dist/icons/overlay/*.png
|
||||
dist/languages/*
|
||||
dist/qt_themes/*/icons/index.theme
|
||||
@@ -30,30 +31,57 @@ Copyright: 2013 Colin Duquesnoy
|
||||
2019 Daniel Cosmo Pizetta
|
||||
License: CC-BY-4.0
|
||||
|
||||
Files: dist/qt_themes/default/icons/256x256/plus_folder.png
|
||||
dist/qt_themes/default/icons/48x48/bad_folder.png
|
||||
dist/qt_themes/default/icons/48x48/chip.png
|
||||
dist/qt_themes/default/icons/48x48/folder.png
|
||||
dist/qt_themes/default/icons/48x48/star.png
|
||||
dist/qt_themes/qdarkstyle/icons/256x256/plus_folder.png
|
||||
dist/qt_themes/qdarkstyle/icons/48x48/bad_folder.png
|
||||
dist/qt_themes/qdarkstyle/icons/48x48/chip.png
|
||||
dist/qt_themes/qdarkstyle/icons/48x48/folder.png
|
||||
dist/qt_themes/qdarkstyle/icons/48x48/star.png
|
||||
Copyright: Refactoring UI Inc.
|
||||
License: MIT
|
||||
Comment: https://github.com/tailwindlabs/heroicons
|
||||
|
||||
Files: dist/qt_themes/colorful/icons/16x16/lock.png
|
||||
dist/qt_themes/colorful/icons/256x256/plus_folder.png
|
||||
dist/qt_themes/colorful/icons/48x48/bad_folder.png
|
||||
dist/qt_themes/colorful/icons/48x48/chip.png
|
||||
dist/qt_themes/colorful/icons/48x48/folder.png
|
||||
dist/qt_themes/colorful_dark/icons/16x16/lock.png
|
||||
Copyright: Icons8
|
||||
License: MIT
|
||||
Comment: https://github.com/icons8/flat-color-icons
|
||||
|
||||
Files: dist/qt_themes/*/icons/16x16/connected.png
|
||||
dist/qt_themes/*/icons/16x16/connected_notification.png
|
||||
dist/qt_themes/*/icons/16x16/disconnected.png
|
||||
dist/qt_themes/*/icons/16x16/lock.png
|
||||
dist/qt_themes/*/icons/48x48/bad_folder.png
|
||||
dist/qt_themes/*/icons/48x48/chip.png
|
||||
dist/qt_themes/*/icons/48x48/folder.png
|
||||
dist/qt_themes/*/icons/48x48/no_avatar.png
|
||||
dist/qt_themes/*/icons/48x48/sd_card.png
|
||||
dist/qt_themes/*/icons/48x48/star.png
|
||||
dist/qt_themes/*/icons/256x256/plus_folder.png
|
||||
dist/qt_themes/colorful/icons/48x48/list-add.png
|
||||
Copyright: GNOME Project
|
||||
License: CC-BY-SA-3.0
|
||||
Comment: connected_notification and disconnected are modified
|
||||
|
||||
Files: dist/qt_themes/*/icons/48x48/no_avatar.png
|
||||
Copyright: Ionic (http://ionic.io/)
|
||||
License: MIT
|
||||
|
||||
|
||||
Files: dist/qt_themes/*/icons/48x48/sd_card.png
|
||||
dist/qt_themes/colorful/icons/48x48/star.png
|
||||
dist/qt_themes/default/icons/16x16/checked.png
|
||||
dist/qt_themes/default/icons/16x16/failed.png
|
||||
Copyright: https://icons8.com
|
||||
License: CC-BY-ND-3.0
|
||||
Copyright: SVG Repo
|
||||
License: CC0-1.0
|
||||
|
||||
Files: dist/qt_themes/*/icons/16x16/view-refresh.png
|
||||
dist/qt_themes/default/icons/16x16/lock.png
|
||||
dist/qt_themes/qdarkstyle/icons/16x16/lock.png
|
||||
Copyright: Google, Inc.
|
||||
License: Apache-2.0
|
||||
|
||||
Files: dist/qt_themes/default/icons/48x48/list-add.png
|
||||
dist/qt_themes/qdarkstyle/icons/48x48/list-add.png
|
||||
Copyright: BreadFish64
|
||||
Files: dist/qt_themes/*/icons/48x48/list-add.png
|
||||
Copyright: Docteh
|
||||
License: CC0-1.0
|
||||
|
||||
Files: externals/getopt/getopt.c
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
Creative Commons Attribution-NoDerivs 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
|
||||
|
||||
b. "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.
|
||||
|
||||
c. "Distribute" means to make available to the public the original and copies of the Work through sale or other transfer of ownership.
|
||||
|
||||
d. "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
|
||||
|
||||
e. "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
|
||||
|
||||
f. "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
|
||||
|
||||
g. "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
|
||||
|
||||
h. "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
|
||||
|
||||
i. "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; and,
|
||||
|
||||
b. to Distribute and Publicly Perform the Work including as incorporated in Collections.
|
||||
|
||||
c. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
|
||||
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
|
||||
|
||||
iii. Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested.
|
||||
|
||||
b. If You Distribute, or Publicly Perform the Work or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(b) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
|
||||
|
||||
c. Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
|
||||
|
||||
b. Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
|
||||
|
||||
b. If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
|
||||
|
||||
c. No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
|
||||
|
||||
d. This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
|
||||
|
||||
e. The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of this License.
|
||||
|
||||
Creative Commons may be contacted at http://creativecommons.org/.
|
||||
359
LICENSES/CC-BY-SA-3.0.txt
Normal file
@@ -0,0 +1,359 @@
|
||||
Creative Commons Legal Code
|
||||
|
||||
Attribution-ShareAlike 3.0 Unported
|
||||
|
||||
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
|
||||
LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN
|
||||
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
|
||||
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
|
||||
REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR
|
||||
DAMAGES RESULTING FROM ITS USE.
|
||||
|
||||
License
|
||||
|
||||
THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE
|
||||
COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY
|
||||
COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS
|
||||
AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
|
||||
|
||||
BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE
|
||||
TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY
|
||||
BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS
|
||||
CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND
|
||||
CONDITIONS.
|
||||
|
||||
1. Definitions
|
||||
|
||||
a. "Adaptation" means a work based upon the Work, or upon the Work and
|
||||
other pre-existing works, such as a translation, adaptation,
|
||||
derivative work, arrangement of music or other alterations of a
|
||||
literary or artistic work, or phonogram or performance and includes
|
||||
cinematographic adaptations or any other form in which the Work may be
|
||||
recast, transformed, or adapted including in any form recognizably
|
||||
derived from the original, except that a work that constitutes a
|
||||
Collection will not be considered an Adaptation for the purpose of
|
||||
this License. For the avoidance of doubt, where the Work is a musical
|
||||
work, performance or phonogram, the synchronization of the Work in
|
||||
timed-relation with a moving image ("synching") will be considered an
|
||||
Adaptation for the purpose of this License.
|
||||
b. "Collection" means a collection of literary or artistic works, such as
|
||||
encyclopedias and anthologies, or performances, phonograms or
|
||||
broadcasts, or other works or subject matter other than works listed
|
||||
in Section 1(f) below, which, by reason of the selection and
|
||||
arrangement of their contents, constitute intellectual creations, in
|
||||
which the Work is included in its entirety in unmodified form along
|
||||
with one or more other contributions, each constituting separate and
|
||||
independent works in themselves, which together are assembled into a
|
||||
collective whole. A work that constitutes a Collection will not be
|
||||
considered an Adaptation (as defined below) for the purposes of this
|
||||
License.
|
||||
c. "Creative Commons Compatible License" means a license that is listed
|
||||
at https://creativecommons.org/compatiblelicenses that has been
|
||||
approved by Creative Commons as being essentially equivalent to this
|
||||
License, including, at a minimum, because that license: (i) contains
|
||||
terms that have the same purpose, meaning and effect as the License
|
||||
Elements of this License; and, (ii) explicitly permits the relicensing
|
||||
of adaptations of works made available under that license under this
|
||||
License or a Creative Commons jurisdiction license with the same
|
||||
License Elements as this License.
|
||||
d. "Distribute" means to make available to the public the original and
|
||||
copies of the Work or Adaptation, as appropriate, through sale or
|
||||
other transfer of ownership.
|
||||
e. "License Elements" means the following high-level license attributes
|
||||
as selected by Licensor and indicated in the title of this License:
|
||||
Attribution, ShareAlike.
|
||||
f. "Licensor" means the individual, individuals, entity or entities that
|
||||
offer(s) the Work under the terms of this License.
|
||||
g. "Original Author" means, in the case of a literary or artistic work,
|
||||
the individual, individuals, entity or entities who created the Work
|
||||
or if no individual or entity can be identified, the publisher; and in
|
||||
addition (i) in the case of a performance the actors, singers,
|
||||
musicians, dancers, and other persons who act, sing, deliver, declaim,
|
||||
play in, interpret or otherwise perform literary or artistic works or
|
||||
expressions of folklore; (ii) in the case of a phonogram the producer
|
||||
being the person or legal entity who first fixes the sounds of a
|
||||
performance or other sounds; and, (iii) in the case of broadcasts, the
|
||||
organization that transmits the broadcast.
|
||||
h. "Work" means the literary and/or artistic work offered under the terms
|
||||
of this License including without limitation any production in the
|
||||
literary, scientific and artistic domain, whatever may be the mode or
|
||||
form of its expression including digital form, such as a book,
|
||||
pamphlet and other writing; a lecture, address, sermon or other work
|
||||
of the same nature; a dramatic or dramatico-musical work; a
|
||||
choreographic work or entertainment in dumb show; a musical
|
||||
composition with or without words; a cinematographic work to which are
|
||||
assimilated works expressed by a process analogous to cinematography;
|
||||
a work of drawing, painting, architecture, sculpture, engraving or
|
||||
lithography; a photographic work to which are assimilated works
|
||||
expressed by a process analogous to photography; a work of applied
|
||||
art; an illustration, map, plan, sketch or three-dimensional work
|
||||
relative to geography, topography, architecture or science; a
|
||||
performance; a broadcast; a phonogram; a compilation of data to the
|
||||
extent it is protected as a copyrightable work; or a work performed by
|
||||
a variety or circus performer to the extent it is not otherwise
|
||||
considered a literary or artistic work.
|
||||
i. "You" means an individual or entity exercising rights under this
|
||||
License who has not previously violated the terms of this License with
|
||||
respect to the Work, or who has received express permission from the
|
||||
Licensor to exercise rights under this License despite a previous
|
||||
violation.
|
||||
j. "Publicly Perform" means to perform public recitations of the Work and
|
||||
to communicate to the public those public recitations, by any means or
|
||||
process, including by wire or wireless means or public digital
|
||||
performances; to make available to the public Works in such a way that
|
||||
members of the public may access these Works from a place and at a
|
||||
place individually chosen by them; to perform the Work to the public
|
||||
by any means or process and the communication to the public of the
|
||||
performances of the Work, including by public digital performance; to
|
||||
broadcast and rebroadcast the Work by any means including signs,
|
||||
sounds or images.
|
||||
k. "Reproduce" means to make copies of the Work by any means including
|
||||
without limitation by sound or visual recordings and the right of
|
||||
fixation and reproducing fixations of the Work, including storage of a
|
||||
protected performance or phonogram in digital form or other electronic
|
||||
medium.
|
||||
|
||||
2. Fair Dealing Rights. Nothing in this License is intended to reduce,
|
||||
limit, or restrict any uses free from copyright or rights arising from
|
||||
limitations or exceptions that are provided for in connection with the
|
||||
copyright protection under copyright law or other applicable laws.
|
||||
|
||||
3. License Grant. Subject to the terms and conditions of this License,
|
||||
Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
||||
perpetual (for the duration of the applicable copyright) license to
|
||||
exercise the rights in the Work as stated below:
|
||||
|
||||
a. to Reproduce the Work, to incorporate the Work into one or more
|
||||
Collections, and to Reproduce the Work as incorporated in the
|
||||
Collections;
|
||||
b. to create and Reproduce Adaptations provided that any such Adaptation,
|
||||
including any translation in any medium, takes reasonable steps to
|
||||
clearly label, demarcate or otherwise identify that changes were made
|
||||
to the original Work. For example, a translation could be marked "The
|
||||
original work was translated from English to Spanish," or a
|
||||
modification could indicate "The original work has been modified.";
|
||||
c. to Distribute and Publicly Perform the Work including as incorporated
|
||||
in Collections; and,
|
||||
d. to Distribute and Publicly Perform Adaptations.
|
||||
e. For the avoidance of doubt:
|
||||
|
||||
i. Non-waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme cannot be waived, the Licensor
|
||||
reserves the exclusive right to collect such royalties for any
|
||||
exercise by You of the rights granted under this License;
|
||||
ii. Waivable Compulsory License Schemes. In those jurisdictions in
|
||||
which the right to collect royalties through any statutory or
|
||||
compulsory licensing scheme can be waived, the Licensor waives the
|
||||
exclusive right to collect such royalties for any exercise by You
|
||||
of the rights granted under this License; and,
|
||||
iii. Voluntary License Schemes. The Licensor waives the right to
|
||||
collect royalties, whether individually or, in the event that the
|
||||
Licensor is a member of a collecting society that administers
|
||||
voluntary licensing schemes, via that society, from any exercise
|
||||
by You of the rights granted under this License.
|
||||
|
||||
The above rights may be exercised in all media and formats whether now
|
||||
known or hereafter devised. The above rights include the right to make
|
||||
such modifications as are technically necessary to exercise the rights in
|
||||
other media and formats. Subject to Section 8(f), all rights not expressly
|
||||
granted by Licensor are hereby reserved.
|
||||
|
||||
4. Restrictions. The license granted in Section 3 above is expressly made
|
||||
subject to and limited by the following restrictions:
|
||||
|
||||
a. You may Distribute or Publicly Perform the Work only under the terms
|
||||
of this License. You must include a copy of, or the Uniform Resource
|
||||
Identifier (URI) for, this License with every copy of the Work You
|
||||
Distribute or Publicly Perform. You may not offer or impose any terms
|
||||
on the Work that restrict the terms of this License or the ability of
|
||||
the recipient of the Work to exercise the rights granted to that
|
||||
recipient under the terms of the License. You may not sublicense the
|
||||
Work. You must keep intact all notices that refer to this License and
|
||||
to the disclaimer of warranties with every copy of the Work You
|
||||
Distribute or Publicly Perform. When You Distribute or Publicly
|
||||
Perform the Work, You may not impose any effective technological
|
||||
measures on the Work that restrict the ability of a recipient of the
|
||||
Work from You to exercise the rights granted to that recipient under
|
||||
the terms of the License. This Section 4(a) applies to the Work as
|
||||
incorporated in a Collection, but this does not require the Collection
|
||||
apart from the Work itself to be made subject to the terms of this
|
||||
License. If You create a Collection, upon notice from any Licensor You
|
||||
must, to the extent practicable, remove from the Collection any credit
|
||||
as required by Section 4(c), as requested. If You create an
|
||||
Adaptation, upon notice from any Licensor You must, to the extent
|
||||
practicable, remove from the Adaptation any credit as required by
|
||||
Section 4(c), as requested.
|
||||
b. You may Distribute or Publicly Perform an Adaptation only under the
|
||||
terms of: (i) this License; (ii) a later version of this License with
|
||||
the same License Elements as this License; (iii) a Creative Commons
|
||||
jurisdiction license (either this or a later license version) that
|
||||
contains the same License Elements as this License (e.g.,
|
||||
Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible
|
||||
License. If you license the Adaptation under one of the licenses
|
||||
mentioned in (iv), you must comply with the terms of that license. If
|
||||
you license the Adaptation under the terms of any of the licenses
|
||||
mentioned in (i), (ii) or (iii) (the "Applicable License"), you must
|
||||
comply with the terms of the Applicable License generally and the
|
||||
following provisions: (I) You must include a copy of, or the URI for,
|
||||
the Applicable License with every copy of each Adaptation You
|
||||
Distribute or Publicly Perform; (II) You may not offer or impose any
|
||||
terms on the Adaptation that restrict the terms of the Applicable
|
||||
License or the ability of the recipient of the Adaptation to exercise
|
||||
the rights granted to that recipient under the terms of the Applicable
|
||||
License; (III) You must keep intact all notices that refer to the
|
||||
Applicable License and to the disclaimer of warranties with every copy
|
||||
of the Work as included in the Adaptation You Distribute or Publicly
|
||||
Perform; (IV) when You Distribute or Publicly Perform the Adaptation,
|
||||
You may not impose any effective technological measures on the
|
||||
Adaptation that restrict the ability of a recipient of the Adaptation
|
||||
from You to exercise the rights granted to that recipient under the
|
||||
terms of the Applicable License. This Section 4(b) applies to the
|
||||
Adaptation as incorporated in a Collection, but this does not require
|
||||
the Collection apart from the Adaptation itself to be made subject to
|
||||
the terms of the Applicable License.
|
||||
c. If You Distribute, or Publicly Perform the Work or any Adaptations or
|
||||
Collections, You must, unless a request has been made pursuant to
|
||||
Section 4(a), keep intact all copyright notices for the Work and
|
||||
provide, reasonable to the medium or means You are utilizing: (i) the
|
||||
name of the Original Author (or pseudonym, if applicable) if supplied,
|
||||
and/or if the Original Author and/or Licensor designate another party
|
||||
or parties (e.g., a sponsor institute, publishing entity, journal) for
|
||||
attribution ("Attribution Parties") in Licensor's copyright notice,
|
||||
terms of service or by other reasonable means, the name of such party
|
||||
or parties; (ii) the title of the Work if supplied; (iii) to the
|
||||
extent reasonably practicable, the URI, if any, that Licensor
|
||||
specifies to be associated with the Work, unless such URI does not
|
||||
refer to the copyright notice or licensing information for the Work;
|
||||
and (iv) , consistent with Ssection 3(b), in the case of an
|
||||
Adaptation, a credit identifying the use of the Work in the Adaptation
|
||||
(e.g., "French translation of the Work by Original Author," or
|
||||
"Screenplay based on original Work by Original Author"). The credit
|
||||
required by this Section 4(c) may be implemented in any reasonable
|
||||
manner; provided, however, that in the case of a Adaptation or
|
||||
Collection, at a minimum such credit will appear, if a credit for all
|
||||
contributing authors of the Adaptation or Collection appears, then as
|
||||
part of these credits and in a manner at least as prominent as the
|
||||
credits for the other contributing authors. For the avoidance of
|
||||
doubt, You may only use the credit required by this Section for the
|
||||
purpose of attribution in the manner set out above and, by exercising
|
||||
Your rights under this License, You may not implicitly or explicitly
|
||||
assert or imply any connection with, sponsorship or endorsement by the
|
||||
Original Author, Licensor and/or Attribution Parties, as appropriate,
|
||||
of You or Your use of the Work, without the separate, express prior
|
||||
written permission of the Original Author, Licensor and/or Attribution
|
||||
Parties.
|
||||
d. Except as otherwise agreed in writing by the Licensor or as may be
|
||||
otherwise permitted by applicable law, if You Reproduce, Distribute or
|
||||
Publicly Perform the Work either by itself or as part of any
|
||||
Adaptations or Collections, You must not distort, mutilate, modify or
|
||||
take other derogatory action in relation to the Work which would be
|
||||
prejudicial to the Original Author's honor or reputation. Licensor
|
||||
agrees that in those jurisdictions (e.g. Japan), in which any exercise
|
||||
of the right granted in Section 3(b) of this License (the right to
|
||||
make Adaptations) would be deemed to be a distortion, mutilation,
|
||||
modification or other derogatory action prejudicial to the Original
|
||||
Author's honor and reputation, the Licensor will waive or not assert,
|
||||
as appropriate, this Section, to the fullest extent permitted by the
|
||||
applicable national law, to enable You to reasonably exercise Your
|
||||
right under Section 3(b) of this License (right to make Adaptations)
|
||||
but not otherwise.
|
||||
|
||||
5. Representations, Warranties and Disclaimer
|
||||
|
||||
UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR
|
||||
OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
|
||||
KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE,
|
||||
INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF
|
||||
LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS,
|
||||
WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION
|
||||
OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
|
||||
|
||||
6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE
|
||||
LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR
|
||||
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES
|
||||
ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS
|
||||
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
7. Termination
|
||||
|
||||
a. This License and the rights granted hereunder will terminate
|
||||
automatically upon any breach by You of the terms of this License.
|
||||
Individuals or entities who have received Adaptations or Collections
|
||||
from You under this License, however, will not have their licenses
|
||||
terminated provided such individuals or entities remain in full
|
||||
compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will
|
||||
survive any termination of this License.
|
||||
b. Subject to the above terms and conditions, the license granted here is
|
||||
perpetual (for the duration of the applicable copyright in the Work).
|
||||
Notwithstanding the above, Licensor reserves the right to release the
|
||||
Work under different license terms or to stop distributing the Work at
|
||||
any time; provided, however that any such election will not serve to
|
||||
withdraw this License (or any other license that has been, or is
|
||||
required to be, granted under the terms of this License), and this
|
||||
License will continue in full force and effect unless terminated as
|
||||
stated above.
|
||||
|
||||
8. Miscellaneous
|
||||
|
||||
a. Each time You Distribute or Publicly Perform the Work or a Collection,
|
||||
the Licensor offers to the recipient a license to the Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
b. Each time You Distribute or Publicly Perform an Adaptation, Licensor
|
||||
offers to the recipient a license to the original Work on the same
|
||||
terms and conditions as the license granted to You under this License.
|
||||
c. If any provision of this License is invalid or unenforceable under
|
||||
applicable law, it shall not affect the validity or enforceability of
|
||||
the remainder of the terms of this License, and without further action
|
||||
by the parties to this agreement, such provision shall be reformed to
|
||||
the minimum extent necessary to make such provision valid and
|
||||
enforceable.
|
||||
d. No term or provision of this License shall be deemed waived and no
|
||||
breach consented to unless such waiver or consent shall be in writing
|
||||
and signed by the party to be charged with such waiver or consent.
|
||||
e. This License constitutes the entire agreement between the parties with
|
||||
respect to the Work licensed here. There are no understandings,
|
||||
agreements or representations with respect to the Work not specified
|
||||
here. Licensor shall not be bound by any additional provisions that
|
||||
may appear in any communication from You. This License may not be
|
||||
modified without the mutual written agreement of the Licensor and You.
|
||||
f. The rights granted under, and the subject matter referenced, in this
|
||||
License were drafted utilizing the terminology of the Berne Convention
|
||||
for the Protection of Literary and Artistic Works (as amended on
|
||||
September 28, 1979), the Rome Convention of 1961, the WIPO Copyright
|
||||
Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996
|
||||
and the Universal Copyright Convention (as revised on July 24, 1971).
|
||||
These rights and subject matter take effect in the relevant
|
||||
jurisdiction in which the License terms are sought to be enforced
|
||||
according to the corresponding provisions of the implementation of
|
||||
those treaty provisions in the applicable national law. If the
|
||||
standard suite of rights granted under applicable copyright law
|
||||
includes additional rights not granted under this License, such
|
||||
additional rights are deemed to be included in the License; this
|
||||
License is not intended to restrict the license of any rights under
|
||||
applicable law.
|
||||
|
||||
|
||||
Creative Commons Notice
|
||||
|
||||
Creative Commons is not a party to this License, and makes no warranty
|
||||
whatsoever in connection with the Work. Creative Commons will not be
|
||||
liable to You or any party on any legal theory for any damages
|
||||
whatsoever, including without limitation any general, special,
|
||||
incidental or consequential damages arising in connection to this
|
||||
license. Notwithstanding the foregoing two (2) sentences, if Creative
|
||||
Commons has expressly identified itself as the Licensor hereunder, it
|
||||
shall have all rights and obligations of Licensor.
|
||||
|
||||
Except for the limited purpose of indicating to the public that the
|
||||
Work is licensed under the CCPL, Creative Commons does not authorize
|
||||
the use by either party of the trademark "Creative Commons" or any
|
||||
related trademark or logo of Creative Commons without the prior
|
||||
written consent of Creative Commons. Any permitted use will be in
|
||||
compliance with Creative Commons' then-current trademark usage
|
||||
guidelines, as may be published on its website or otherwise made
|
||||
available upon request from time to time. For the avoidance of doubt,
|
||||
this trademark restriction does not form part of the License.
|
||||
|
||||
Creative Commons may be contacted at https://creativecommons.org/.
|
||||
19
dist/english_plurals/README.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# English Plurals
|
||||
|
||||
Qt has "Translation Rules for Plurals", small example
|
||||
|
||||
// Take a source line like
|
||||
tr("Building: %n shader(s)", "", i)
|
||||
|
||||
// i = 1:
|
||||
Building: 1 shader
|
||||
// i = 2:
|
||||
Building: 2 shaders
|
||||
|
||||
For yuzu the source language used is English, for all other languages handling of plurals is handled by Qt and the translation collaboration site. Handling plurals in the source language (English) requires special consideration.
|
||||
|
||||
With CMake flag GENERATE_QT_TRANSLATION a generated_en.ts file is created from the source. It ignored by git (`.gitignore` in the project root). It is placed in this directory so that the relative refrences with the source code is correct.
|
||||
|
||||
Having the plurals look nice isn't critical, and automation to use translation collaboration sites may require specifing the project language as "Pirate English", so this has been done manually.
|
||||
|
||||
The en.ts in this directory is taken from a build, edited in Qt Linguist and then committed. As the code is in XML, using the tool is not strictly required.
|
||||
67
dist/english_plurals/en.ts
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<TS version="2.1" language="en_US" sourcelanguage="en_US">
|
||||
<context>
|
||||
<name>GMainWindow</name>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/yuzu/main.cpp" line="2322"/>
|
||||
<source>%n file(s) remaining</source>
|
||||
<translation>
|
||||
<numerusform>%n file remaining</numerusform>
|
||||
<numerusform>%n files remaining</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/yuzu/main.cpp" line="2377"/>
|
||||
<source>%n file(s) were newly installed
|
||||
</source>
|
||||
<translation>
|
||||
<numerusform>%n file was newly installed
|
||||
</numerusform>
|
||||
<numerusform>%n files were newly installed
|
||||
</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/yuzu/main.cpp" line="2380"/>
|
||||
<source>%n file(s) were overwritten
|
||||
</source>
|
||||
<translation>
|
||||
<numerusform>%n file was overwritten
|
||||
</numerusform>
|
||||
<numerusform>%n were overwritten
|
||||
</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/yuzu/main.cpp" line="2382"/>
|
||||
<source>%n file(s) failed to install
|
||||
</source>
|
||||
<translation>
|
||||
<numerusform>%n file failed to install
|
||||
</numerusform>
|
||||
<numerusform>%n files failed to install
|
||||
</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/yuzu/main.cpp" line="3264"/>
|
||||
<source>Building: %n shader(s)</source>
|
||||
<translation>
|
||||
<numerusform>Building: %n shader</numerusform>
|
||||
<numerusform>Building: %n shaders</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GameListSearchField</name>
|
||||
<message numerus="yes">
|
||||
<location filename="../../src/yuzu/game_list.cpp" line="87"/>
|
||||
<source>%1 of %n result(s)</source>
|
||||
<translation>
|
||||
<numerusform>%1 of %n result</numerusform>
|
||||
<numerusform>%1 of %n results</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
BIN
dist/qt_themes/colorful/icons/16x16/connected.png
vendored
|
Before Width: | Height: | Size: 362 B After Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 607 B After Width: | Height: | Size: 760 B |
BIN
dist/qt_themes/colorful/icons/16x16/disconnected.png
vendored
|
Before Width: | Height: | Size: 784 B After Width: | Height: | Size: 648 B |
BIN
dist/qt_themes/colorful/icons/48x48/list-add.png
vendored
|
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 204 B |
BIN
dist/qt_themes/colorful/icons/48x48/sd_card.png
vendored
|
Before Width: | Height: | Size: 680 B After Width: | Height: | Size: 981 B |
BIN
dist/qt_themes/colorful/icons/48x48/star.png
vendored
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 401 B |
|
Before Width: | Height: | Size: 362 B |
@@ -6,8 +6,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
|
||||
<RCC>
|
||||
<qresource prefix="icons/colorful_midnight_blue">
|
||||
<file alias="index.theme">icons/index.theme</file>
|
||||
<file alias="16x16/lock.png">icons/16x16/lock.png</file>
|
||||
<file alias="16x16/view-refresh.png">icons/16x16/view-refresh.png</file>
|
||||
<file alias="16x16/lock.png">../colorful_dark/icons/16x16/lock.png</file>
|
||||
<file alias="16x16/view-refresh.png">../qdarkstyle/icons/16x16/view-refresh.png</file>
|
||||
<file alias="48x48/bad_folder.png">../colorful/icons/48x48/bad_folder.png</file>
|
||||
<file alias="48x48/chip.png">../colorful/icons/48x48/chip.png</file>
|
||||
<file alias="48x48/folder.png">../colorful/icons/48x48/folder.png</file>
|
||||
|
||||
BIN
dist/qt_themes/default/icons/16x16/checked.png
vendored
|
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 414 B |
BIN
dist/qt_themes/default/icons/16x16/connected.png
vendored
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 517 B After Width: | Height: | Size: 760 B |
BIN
dist/qt_themes/default/icons/16x16/disconnected.png
vendored
|
Before Width: | Height: | Size: 306 B After Width: | Height: | Size: 648 B |
BIN
dist/qt_themes/default/icons/16x16/failed.png
vendored
|
Before Width: | Height: | Size: 524 B After Width: | Height: | Size: 431 B |
BIN
dist/qt_themes/default/icons/16x16/lock.png
vendored
|
Before Width: | Height: | Size: 279 B After Width: | Height: | Size: 318 B |
BIN
dist/qt_themes/default/icons/256x256/plus_folder.png
vendored
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.4 KiB |
BIN
dist/qt_themes/default/icons/48x48/bad_folder.png
vendored
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1007 B |
BIN
dist/qt_themes/default/icons/48x48/chip.png
vendored
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 511 B |
BIN
dist/qt_themes/default/icons/48x48/folder.png
vendored
|
Before Width: | Height: | Size: 410 B After Width: | Height: | Size: 535 B |
BIN
dist/qt_themes/default/icons/48x48/list-add.png
vendored
|
Before Width: | Height: | Size: 316 B After Width: | Height: | Size: 204 B |
BIN
dist/qt_themes/default/icons/48x48/no_avatar.png
vendored
|
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 678 B |
BIN
dist/qt_themes/default/icons/48x48/sd_card.png
vendored
|
Before Width: | Height: | Size: 614 B After Width: | Height: | Size: 561 B |
BIN
dist/qt_themes/default/icons/48x48/star.png
vendored
|
Before Width: | Height: | Size: 686 B After Width: | Height: | Size: 1.0 KiB |
BIN
dist/qt_themes/qdarkstyle/icons/16x16/connected.png
vendored
|
Before Width: | Height: | Size: 397 B After Width: | Height: | Size: 575 B |
|
Before Width: | Height: | Size: 526 B After Width: | Height: | Size: 760 B |
|
Before Width: | Height: | Size: 444 B After Width: | Height: | Size: 648 B |
BIN
dist/qt_themes/qdarkstyle/icons/16x16/lock.png
vendored
|
Before Width: | Height: | Size: 304 B After Width: | Height: | Size: 343 B |
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.8 KiB |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/bad_folder.png
vendored
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.0 KiB |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/chip.png
vendored
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 551 B |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/folder.png
vendored
|
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 594 B |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/list-add.png
vendored
|
Before Width: | Height: | Size: 339 B After Width: | Height: | Size: 204 B |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/no_avatar.png
vendored
|
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 763 B |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/sd_card.png
vendored
|
Before Width: | Height: | Size: 676 B After Width: | Height: | Size: 587 B |
BIN
dist/qt_themes/qdarkstyle/icons/48x48/star.png
vendored
|
Before Width: | Height: | Size: 725 B After Width: | Height: | Size: 1.0 KiB |
2
externals/dynarmic
vendored
2
externals/vcpkg
vendored
@@ -162,6 +162,7 @@ add_subdirectory(video_core)
|
||||
add_subdirectory(network)
|
||||
add_subdirectory(input_common)
|
||||
add_subdirectory(shader_recompiler)
|
||||
add_subdirectory(dedicated_room)
|
||||
|
||||
if (YUZU_TESTS)
|
||||
add_subdirectory(tests)
|
||||
|
||||
@@ -185,6 +185,9 @@ public:
|
||||
constexpr s32 max{std::numeric_limits<s16>::max()};
|
||||
|
||||
auto yuzu_volume{Settings::Volume()};
|
||||
if (yuzu_volume > 1.0f) {
|
||||
yuzu_volume = 0.6f + 20 * std::log10(yuzu_volume);
|
||||
}
|
||||
auto volume{system_volume * device_volume * yuzu_volume};
|
||||
|
||||
if (system_channels == 6 && device_channels == 2) {
|
||||
|
||||
@@ -124,6 +124,7 @@ add_library(common STATIC
|
||||
settings.h
|
||||
settings_input.cpp
|
||||
settings_input.h
|
||||
socket_types.h
|
||||
spin_lock.cpp
|
||||
spin_lock.h
|
||||
stream.cpp
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "common/common_types.h"
|
||||
#include "common/socket_types.h"
|
||||
#include "web_service/web_result.h"
|
||||
|
||||
namespace AnnounceMultiplayerRoom {
|
||||
|
||||
using MacAddress = std::array<u8, 6>;
|
||||
|
||||
struct GameInfo {
|
||||
std::string name{""};
|
||||
u64 id{0};
|
||||
@@ -24,7 +23,7 @@ struct Member {
|
||||
std::string nickname;
|
||||
std::string display_name;
|
||||
std::string avatar_url;
|
||||
MacAddress mac_address;
|
||||
Network::IPv4Address fake_ip;
|
||||
GameInfo game;
|
||||
};
|
||||
|
||||
@@ -75,10 +74,7 @@ public:
|
||||
const bool has_password, const GameInfo& preferred_game) = 0;
|
||||
/**
|
||||
* Adds a player information to the data that gets announced
|
||||
* @param nickname The nickname of the player
|
||||
* @param mac_address The MAC Address of the player
|
||||
* @param game_id The title id of the game the player plays
|
||||
* @param game_name The name of the game the player plays
|
||||
* @param member The player to add
|
||||
*/
|
||||
virtual void AddPlayer(const Member& member) = 0;
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ float Volume() {
|
||||
if (values.audio_muted) {
|
||||
return 0.0f;
|
||||
}
|
||||
return values.volume.GetValue() / 100.0f;
|
||||
return values.volume.GetValue() / static_cast<f32>(values.volume.GetDefault());
|
||||
}
|
||||
|
||||
void UpdateRescalingInfo() {
|
||||
|
||||
@@ -374,7 +374,7 @@ struct Values {
|
||||
Setting<std::string> audio_output_device_id{"auto", "output_device"};
|
||||
Setting<std::string> audio_input_device_id{"auto", "input_device"};
|
||||
Setting<bool> audio_muted{false, "audio_muted"};
|
||||
SwitchableSetting<u8, true> volume{100, 0, 100, "volume"};
|
||||
SwitchableSetting<u8, true> volume{100, 0, 200, "volume"};
|
||||
Setting<bool> dump_audio_commands{false, "dump_audio_commands"};
|
||||
|
||||
// Core
|
||||
|
||||
51
src/common/socket_types.h
Normal file
@@ -0,0 +1,51 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
/// Address families
|
||||
enum class Domain : u8 {
|
||||
INET, ///< Address family for IPv4
|
||||
};
|
||||
|
||||
/// Socket types
|
||||
enum class Type {
|
||||
STREAM,
|
||||
DGRAM,
|
||||
RAW,
|
||||
SEQPACKET,
|
||||
};
|
||||
|
||||
/// Protocol values for sockets
|
||||
enum class Protocol : u8 {
|
||||
ICMP,
|
||||
TCP,
|
||||
UDP,
|
||||
};
|
||||
|
||||
/// Shutdown mode
|
||||
enum class ShutdownHow {
|
||||
RD,
|
||||
WR,
|
||||
RDWR,
|
||||
};
|
||||
|
||||
/// Array of IPv4 address
|
||||
using IPv4Address = std::array<u8, 4>;
|
||||
|
||||
/// Cross-platform sockaddr structure
|
||||
struct SockAddrIn {
|
||||
Domain family;
|
||||
IPv4Address ip;
|
||||
u16 portno;
|
||||
};
|
||||
|
||||
constexpr u32 FLAG_MSG_PEEK = 0x2;
|
||||
constexpr u32 FLAG_MSG_DONTWAIT = 0x80;
|
||||
constexpr u32 FLAG_O_NONBLOCK = 0x800;
|
||||
|
||||
} // namespace Network
|
||||
@@ -6,8 +6,6 @@ add_library(core STATIC
|
||||
announce_multiplayer_session.h
|
||||
arm/arm_interface.h
|
||||
arm/arm_interface.cpp
|
||||
arm/cpu_interrupt_handler.cpp
|
||||
arm/cpu_interrupt_handler.h
|
||||
arm/dynarmic/arm_dynarmic_32.cpp
|
||||
arm/dynarmic/arm_dynarmic_32.h
|
||||
arm/dynarmic/arm_dynarmic_64.cpp
|
||||
@@ -504,9 +502,10 @@ add_library(core STATIC
|
||||
hle/service/jit/jit.h
|
||||
hle/service/lbl/lbl.cpp
|
||||
hle/service/lbl/lbl.h
|
||||
hle/service/ldn/errors.h
|
||||
hle/service/ldn/ldn_results.h
|
||||
hle/service/ldn/ldn.cpp
|
||||
hle/service/ldn/ldn.h
|
||||
hle/service/ldn/ldn_types.h
|
||||
hle/service/ldr/ldr.cpp
|
||||
hle/service/ldr/ldr.h
|
||||
hle/service/lm/lm.cpp
|
||||
@@ -725,6 +724,8 @@ add_library(core STATIC
|
||||
internal_network/network_interface.cpp
|
||||
internal_network/network_interface.h
|
||||
internal_network/sockets.h
|
||||
internal_network/socket_proxy.cpp
|
||||
internal_network/socket_proxy.h
|
||||
loader/deconstructed_rom_directory.cpp
|
||||
loader/deconstructed_rom_directory.h
|
||||
loader/kip.cpp
|
||||
|
||||
@@ -31,7 +31,7 @@ AnnounceMultiplayerSession::AnnounceMultiplayerSession(Network::RoomNetwork& roo
|
||||
}
|
||||
|
||||
WebService::WebResult AnnounceMultiplayerSession::Register() {
|
||||
std::shared_ptr<Network::Room> room = room_network.GetRoom().lock();
|
||||
auto room = room_network.GetRoom().lock();
|
||||
if (!room) {
|
||||
return WebService::WebResult{WebService::WebResult::Code::LibError,
|
||||
"Network is not initialized", ""};
|
||||
@@ -102,7 +102,7 @@ void AnnounceMultiplayerSession::UpdateBackendData(std::shared_ptr<Network::Room
|
||||
void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
|
||||
// Invokes all current bound error callbacks.
|
||||
const auto ErrorCallback = [this](WebService::WebResult result) {
|
||||
std::lock_guard<std::mutex> lock(callback_mutex);
|
||||
std::lock_guard lock(callback_mutex);
|
||||
for (auto callback : error_callbacks) {
|
||||
(*callback)(result);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ void AnnounceMultiplayerSession::AnnounceMultiplayerLoop() {
|
||||
std::future<WebService::WebResult> future;
|
||||
while (!shutdown_event.WaitUntil(update_time)) {
|
||||
update_time += announce_time_interval;
|
||||
std::shared_ptr<Network::Room> room = room_network.GetRoom().lock();
|
||||
auto room = room_network.GetRoom().lock();
|
||||
if (!room) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@ namespace Core {
|
||||
class System;
|
||||
class CPUInterruptHandler;
|
||||
|
||||
using CPUInterrupts = std::array<CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>;
|
||||
using WatchpointArray = std::array<Kernel::DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS>;
|
||||
|
||||
/// Generic ARMv8 CPU interface
|
||||
@@ -36,10 +35,8 @@ public:
|
||||
YUZU_NON_COPYABLE(ARM_Interface);
|
||||
YUZU_NON_MOVEABLE(ARM_Interface);
|
||||
|
||||
explicit ARM_Interface(System& system_, CPUInterrupts& interrupt_handlers_,
|
||||
bool uses_wall_clock_)
|
||||
: system{system_}, interrupt_handlers{interrupt_handlers_}, uses_wall_clock{
|
||||
uses_wall_clock_} {}
|
||||
explicit ARM_Interface(System& system_, bool uses_wall_clock_)
|
||||
: system{system_}, uses_wall_clock{uses_wall_clock_} {}
|
||||
virtual ~ARM_Interface() = default;
|
||||
|
||||
struct ThreadContext32 {
|
||||
@@ -181,6 +178,9 @@ public:
|
||||
/// Signal an interrupt and ask the core to halt as soon as possible.
|
||||
virtual void SignalInterrupt() = 0;
|
||||
|
||||
/// Clear a previous interrupt.
|
||||
virtual void ClearInterrupt() = 0;
|
||||
|
||||
struct BacktraceEntry {
|
||||
std::string module;
|
||||
u64 address;
|
||||
@@ -208,7 +208,6 @@ public:
|
||||
protected:
|
||||
/// System context that this ARM interface is running under.
|
||||
System& system;
|
||||
CPUInterrupts& interrupt_handlers;
|
||||
const WatchpointArray* watchpoints;
|
||||
bool uses_wall_clock;
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/thread.h"
|
||||
#include "core/arm/cpu_interrupt_handler.h"
|
||||
|
||||
namespace Core {
|
||||
|
||||
CPUInterruptHandler::CPUInterruptHandler() : interrupt_event{std::make_unique<Common::Event>()} {}
|
||||
|
||||
CPUInterruptHandler::~CPUInterruptHandler() = default;
|
||||
|
||||
void CPUInterruptHandler::SetInterrupt(bool is_interrupted_) {
|
||||
if (is_interrupted_) {
|
||||
interrupt_event->Set();
|
||||
}
|
||||
is_interrupted = is_interrupted_;
|
||||
}
|
||||
|
||||
void CPUInterruptHandler::AwaitInterrupt() {
|
||||
interrupt_event->Wait();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
@@ -1,39 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
namespace Common {
|
||||
class Event;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CPUInterruptHandler {
|
||||
public:
|
||||
CPUInterruptHandler();
|
||||
~CPUInterruptHandler();
|
||||
|
||||
CPUInterruptHandler(const CPUInterruptHandler&) = delete;
|
||||
CPUInterruptHandler& operator=(const CPUInterruptHandler&) = delete;
|
||||
|
||||
CPUInterruptHandler(CPUInterruptHandler&&) = delete;
|
||||
CPUInterruptHandler& operator=(CPUInterruptHandler&&) = delete;
|
||||
|
||||
bool IsInterrupted() const {
|
||||
return is_interrupted;
|
||||
}
|
||||
|
||||
void SetInterrupt(bool is_interrupted);
|
||||
|
||||
void AwaitInterrupt();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Common::Event> interrupt_event;
|
||||
std::atomic_bool is_interrupted{false};
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "common/page_table.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/arm/cpu_interrupt_handler.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_32.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_cp15.h"
|
||||
#include "core/arm/dynarmic/arm_exclusive_monitor.h"
|
||||
@@ -125,7 +124,9 @@ public:
|
||||
}
|
||||
|
||||
void AddTicks(u64 ticks) override {
|
||||
ASSERT_MSG(!parent.uses_wall_clock, "This should never happen - dynarmic ticking disabled");
|
||||
if (parent.uses_wall_clock) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a
|
||||
// rough approximation of the amount of executed ticks in the system, it may be thrown off
|
||||
@@ -142,7 +143,12 @@ public:
|
||||
}
|
||||
|
||||
u64 GetTicksRemaining() override {
|
||||
ASSERT_MSG(!parent.uses_wall_clock, "This should never happen - dynarmic ticking disabled");
|
||||
if (parent.uses_wall_clock) {
|
||||
if (!IsInterrupted()) {
|
||||
return minimum_run_cycles;
|
||||
}
|
||||
return 0U;
|
||||
}
|
||||
|
||||
return std::max<s64>(parent.system.CoreTiming().GetDowncount(), 0);
|
||||
}
|
||||
@@ -168,11 +174,15 @@ public:
|
||||
parent.jit.load()->HaltExecution(hr);
|
||||
}
|
||||
|
||||
bool IsInterrupted() {
|
||||
return parent.system.Kernel().PhysicalCore(parent.core_index).IsInterrupted();
|
||||
}
|
||||
|
||||
ARM_Dynarmic_32& parent;
|
||||
Core::Memory::Memory& memory;
|
||||
std::size_t num_interpreted_instructions{};
|
||||
bool debugger_enabled{};
|
||||
static constexpr u64 minimum_run_cycles = 1000U;
|
||||
static constexpr u64 minimum_run_cycles = 10000U;
|
||||
};
|
||||
|
||||
std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable* page_table) const {
|
||||
@@ -185,14 +195,16 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable*
|
||||
if (page_table) {
|
||||
config.page_table = reinterpret_cast<std::array<std::uint8_t*, NUM_PAGE_TABLE_ENTRIES>*>(
|
||||
page_table->pointers.data());
|
||||
config.absolute_offset_page_table = true;
|
||||
config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS;
|
||||
config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128;
|
||||
config.only_detect_misalignment_via_page_table_on_page_boundary = true;
|
||||
|
||||
config.fastmem_pointer = page_table->fastmem_arena;
|
||||
|
||||
config.fastmem_exclusive_access = config.fastmem_pointer != nullptr;
|
||||
config.recompile_on_exclusive_fastmem_failure = true;
|
||||
}
|
||||
config.absolute_offset_page_table = true;
|
||||
config.page_table_pointer_mask_bits = Common::PageTable::ATTRIBUTE_BITS;
|
||||
config.detect_misaligned_access_via_page_table = 16 | 32 | 64 | 128;
|
||||
config.only_detect_misalignment_via_page_table_on_page_boundary = true;
|
||||
config.fastmem_exclusive_access = true;
|
||||
config.recompile_on_exclusive_fastmem_failure = true;
|
||||
|
||||
// Multi-process state
|
||||
config.processor_id = core_index;
|
||||
@@ -200,7 +212,7 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable*
|
||||
|
||||
// Timing
|
||||
config.wall_clock_cntpct = uses_wall_clock;
|
||||
config.enable_cycle_counting = !uses_wall_clock;
|
||||
config.enable_cycle_counting = true;
|
||||
|
||||
// Code cache size
|
||||
config.code_cache_size = 512_MiB;
|
||||
@@ -244,6 +256,7 @@ std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable*
|
||||
}
|
||||
if (!Settings::values.cpuopt_fastmem) {
|
||||
config.fastmem_pointer = nullptr;
|
||||
config.fastmem_exclusive_access = false;
|
||||
}
|
||||
if (!Settings::values.cpuopt_fastmem_exclusives) {
|
||||
config.fastmem_exclusive_access = false;
|
||||
@@ -311,11 +324,9 @@ void ARM_Dynarmic_32::RewindBreakpointInstruction() {
|
||||
LoadContext(breakpoint_context);
|
||||
}
|
||||
|
||||
ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_,
|
||||
bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_,
|
||||
std::size_t core_index_)
|
||||
: ARM_Interface{system_, interrupt_handlers_, uses_wall_clock_},
|
||||
cb(std::make_unique<DynarmicCallbacks32>(*this)),
|
||||
ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, bool uses_wall_clock_,
|
||||
ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_)
|
||||
: ARM_Interface{system_, uses_wall_clock_}, cb(std::make_unique<DynarmicCallbacks32>(*this)),
|
||||
cp15(std::make_shared<DynarmicCP15>(*this)), core_index{core_index_},
|
||||
exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor_)},
|
||||
null_jit{MakeJit(nullptr)}, jit{null_jit.get()} {}
|
||||
@@ -394,6 +405,10 @@ void ARM_Dynarmic_32::SignalInterrupt() {
|
||||
jit.load()->HaltExecution(break_loop);
|
||||
}
|
||||
|
||||
void ARM_Dynarmic_32::ClearInterrupt() {
|
||||
jit.load()->ClearHalt(break_loop);
|
||||
}
|
||||
|
||||
void ARM_Dynarmic_32::ClearInstructionCache() {
|
||||
jit.load()->ClearCache();
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ class System;
|
||||
|
||||
class ARM_Dynarmic_32 final : public ARM_Interface {
|
||||
public:
|
||||
ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_, bool uses_wall_clock_,
|
||||
ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_);
|
||||
ARM_Dynarmic_32(System& system_, bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_,
|
||||
std::size_t core_index_);
|
||||
~ARM_Dynarmic_32() override;
|
||||
|
||||
void SetPC(u64 pc) override;
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
void LoadContext(const ThreadContext64& ctx) override {}
|
||||
|
||||
void SignalInterrupt() override;
|
||||
void ClearInterrupt() override;
|
||||
void ClearExclusiveState() override;
|
||||
|
||||
void ClearInstructionCache() override;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include "common/logging/log.h"
|
||||
#include "common/page_table.h"
|
||||
#include "common/settings.h"
|
||||
#include "core/arm/cpu_interrupt_handler.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_64.h"
|
||||
#include "core/arm/dynarmic/arm_exclusive_monitor.h"
|
||||
#include "core/core.h"
|
||||
@@ -166,7 +165,9 @@ public:
|
||||
}
|
||||
|
||||
void AddTicks(u64 ticks) override {
|
||||
ASSERT_MSG(!parent.uses_wall_clock, "This should never happen - dynarmic ticking disabled");
|
||||
if (parent.uses_wall_clock) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a
|
||||
// rough approximation of the amount of executed ticks in the system, it may be thrown off
|
||||
@@ -181,7 +182,12 @@ public:
|
||||
}
|
||||
|
||||
u64 GetTicksRemaining() override {
|
||||
ASSERT_MSG(!parent.uses_wall_clock, "This should never happen - dynarmic ticking disabled");
|
||||
if (parent.uses_wall_clock) {
|
||||
if (!IsInterrupted()) {
|
||||
return minimum_run_cycles;
|
||||
}
|
||||
return 0U;
|
||||
}
|
||||
|
||||
return std::max<s64>(parent.system.CoreTiming().GetDowncount(), 0);
|
||||
}
|
||||
@@ -211,12 +217,16 @@ public:
|
||||
parent.jit.load()->HaltExecution(hr);
|
||||
}
|
||||
|
||||
bool IsInterrupted() {
|
||||
return parent.system.Kernel().PhysicalCore(parent.core_index).IsInterrupted();
|
||||
}
|
||||
|
||||
ARM_Dynarmic_64& parent;
|
||||
Core::Memory::Memory& memory;
|
||||
u64 tpidrro_el0 = 0;
|
||||
u64 tpidr_el0 = 0;
|
||||
bool debugger_enabled{};
|
||||
static constexpr u64 minimum_run_cycles = 1000U;
|
||||
static constexpr u64 minimum_run_cycles = 10000U;
|
||||
};
|
||||
|
||||
std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable* page_table,
|
||||
@@ -240,7 +250,7 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable*
|
||||
config.fastmem_address_space_bits = address_space_bits;
|
||||
config.silently_mirror_fastmem = false;
|
||||
|
||||
config.fastmem_exclusive_access = true;
|
||||
config.fastmem_exclusive_access = config.fastmem_pointer != nullptr;
|
||||
config.recompile_on_exclusive_fastmem_failure = true;
|
||||
}
|
||||
|
||||
@@ -260,7 +270,7 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable*
|
||||
|
||||
// Timing
|
||||
config.wall_clock_cntpct = uses_wall_clock;
|
||||
config.enable_cycle_counting = !uses_wall_clock;
|
||||
config.enable_cycle_counting = true;
|
||||
|
||||
// Code cache size
|
||||
config.code_cache_size = 512_MiB;
|
||||
@@ -304,6 +314,7 @@ std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable*
|
||||
}
|
||||
if (!Settings::values.cpuopt_fastmem) {
|
||||
config.fastmem_pointer = nullptr;
|
||||
config.fastmem_exclusive_access = false;
|
||||
}
|
||||
if (!Settings::values.cpuopt_fastmem_exclusives) {
|
||||
config.fastmem_exclusive_access = false;
|
||||
@@ -371,10 +382,9 @@ void ARM_Dynarmic_64::RewindBreakpointInstruction() {
|
||||
LoadContext(breakpoint_context);
|
||||
}
|
||||
|
||||
ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_,
|
||||
bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_,
|
||||
std::size_t core_index_)
|
||||
: ARM_Interface{system_, interrupt_handlers_, uses_wall_clock_},
|
||||
ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, bool uses_wall_clock_,
|
||||
ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_)
|
||||
: ARM_Interface{system_, uses_wall_clock_},
|
||||
cb(std::make_unique<DynarmicCallbacks64>(*this)), core_index{core_index_},
|
||||
exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor_)},
|
||||
null_jit{MakeJit(nullptr, 48)}, jit{null_jit.get()} {}
|
||||
@@ -461,6 +471,10 @@ void ARM_Dynarmic_64::SignalInterrupt() {
|
||||
jit.load()->HaltExecution(break_loop);
|
||||
}
|
||||
|
||||
void ARM_Dynarmic_64::ClearInterrupt() {
|
||||
jit.load()->ClearHalt(break_loop);
|
||||
}
|
||||
|
||||
void ARM_Dynarmic_64::ClearInstructionCache() {
|
||||
jit.load()->ClearCache();
|
||||
}
|
||||
|
||||
@@ -20,14 +20,13 @@ class Memory;
|
||||
namespace Core {
|
||||
|
||||
class DynarmicCallbacks64;
|
||||
class CPUInterruptHandler;
|
||||
class DynarmicExclusiveMonitor;
|
||||
class System;
|
||||
|
||||
class ARM_Dynarmic_64 final : public ARM_Interface {
|
||||
public:
|
||||
ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_, bool uses_wall_clock_,
|
||||
ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_);
|
||||
ARM_Dynarmic_64(System& system_, bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_,
|
||||
std::size_t core_index_);
|
||||
~ARM_Dynarmic_64() override;
|
||||
|
||||
void SetPC(u64 pc) override;
|
||||
@@ -50,6 +49,7 @@ public:
|
||||
void LoadContext(const ThreadContext64& ctx) override;
|
||||
|
||||
void SignalInterrupt() override;
|
||||
void ClearInterrupt() override;
|
||||
void ClearExclusiveState() override;
|
||||
|
||||
void ClearInstructionCache() override;
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
||||
using Callback = Dynarmic::A32::Coprocessor::Callback;
|
||||
using CallbackOrAccessOneWord = Dynarmic::A32::Coprocessor::CallbackOrAccessOneWord;
|
||||
using CallbackOrAccessTwoWords = Dynarmic::A32::Coprocessor::CallbackOrAccessTwoWords;
|
||||
@@ -47,12 +51,31 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1
|
||||
switch (opc2) {
|
||||
case 4:
|
||||
// CP15_DATA_SYNC_BARRIER
|
||||
// This is a dummy write, we ignore the value written here.
|
||||
return &dummy_value;
|
||||
return Callback{
|
||||
[](Dynarmic::A32::Jit*, void*, std::uint32_t, std::uint32_t) -> std::uint64_t {
|
||||
#ifdef _MSC_VER
|
||||
_mm_mfence();
|
||||
_mm_lfence();
|
||||
#else
|
||||
asm volatile("mfence\n\tlfence\n\t" : : : "memory");
|
||||
#endif
|
||||
return 0;
|
||||
},
|
||||
std::nullopt,
|
||||
};
|
||||
case 5:
|
||||
// CP15_DATA_MEMORY_BARRIER
|
||||
// This is a dummy write, we ignore the value written here.
|
||||
return &dummy_value;
|
||||
return Callback{
|
||||
[](Dynarmic::A32::Jit*, void*, std::uint32_t, std::uint32_t) -> std::uint64_t {
|
||||
#ifdef _MSC_VER
|
||||
_mm_mfence();
|
||||
#else
|
||||
asm volatile("mfence\n\t" : : : "memory");
|
||||
#endif
|
||||
return 0;
|
||||
},
|
||||
std::nullopt,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
ARM_Dynarmic_32& parent;
|
||||
u32 uprw = 0;
|
||||
u32 uro = 0;
|
||||
|
||||
friend class ARM_Dynarmic_32;
|
||||
};
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "core/debugger/debugger_interface.h"
|
||||
#include "core/debugger/gdbstub.h"
|
||||
#include "core/hle/kernel/global_scheduler_context.h"
|
||||
#include "core/hle/kernel/k_scheduler.h"
|
||||
|
||||
template <typename Readable, typename Buffer, typename Callback>
|
||||
static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) {
|
||||
@@ -230,13 +231,12 @@ private:
|
||||
}
|
||||
|
||||
void PauseEmulation() {
|
||||
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
||||
|
||||
// Put all threads to sleep on next scheduler round.
|
||||
for (auto* thread : ThreadList()) {
|
||||
thread->RequestSuspend(Kernel::SuspendType::Debug);
|
||||
}
|
||||
|
||||
// Signal an interrupt so that scheduler will fire.
|
||||
system.Kernel().InterruptAllPhysicalCores();
|
||||
}
|
||||
|
||||
void ResumeEmulation(Kernel::KThread* except = nullptr) {
|
||||
@@ -253,7 +253,8 @@ private:
|
||||
|
||||
template <typename Callback>
|
||||
void MarkResumed(Callback&& cb) {
|
||||
std::scoped_lock lk{connection_lock};
|
||||
Kernel::KScopedSchedulerLock sl{system.Kernel()};
|
||||
std::scoped_lock cl{connection_lock};
|
||||
stopped = false;
|
||||
cb();
|
||||
}
|
||||
|
||||
@@ -287,7 +287,8 @@ void IPSwitchCompiler::Parse() {
|
||||
std::copy(value.begin(), value.end(), std::back_inserter(replace));
|
||||
} else {
|
||||
// hex replacement
|
||||
const auto value = patch_line.substr(9);
|
||||
const auto value =
|
||||
patch_line.substr(9, patch_line.find_first_of(" /\r\n", 9) - 9);
|
||||
replace = Common::HexStringToVector(value, is_little_endian);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/thread.h"
|
||||
#include "core/hid/emulated_controller.h"
|
||||
#include "core/hid/input_converter.h"
|
||||
|
||||
@@ -84,18 +85,19 @@ void EmulatedController::ReloadFromSettings() {
|
||||
motion_params[index] = Common::ParamPackage(player.motions[index]);
|
||||
}
|
||||
|
||||
controller.colors_state.fullkey = {
|
||||
.body = GetNpadColor(player.body_color_left),
|
||||
.button = GetNpadColor(player.button_color_left),
|
||||
};
|
||||
controller.colors_state.left = {
|
||||
.body = player.body_color_left,
|
||||
.button = player.button_color_left,
|
||||
.body = GetNpadColor(player.body_color_left),
|
||||
.button = GetNpadColor(player.button_color_left),
|
||||
};
|
||||
|
||||
controller.colors_state.right = {
|
||||
.body = player.body_color_right,
|
||||
.button = player.button_color_right,
|
||||
controller.colors_state.left = {
|
||||
.body = GetNpadColor(player.body_color_right),
|
||||
.button = GetNpadColor(player.button_color_right),
|
||||
};
|
||||
|
||||
controller.colors_state.fullkey = controller.colors_state.left;
|
||||
|
||||
// Other or debug controller should always be a pro controller
|
||||
if (npad_id_type != NpadIdType::Other) {
|
||||
SetNpadStyleIndex(MapSettingsTypeToNPad(player.controller_type));
|
||||
@@ -949,6 +951,9 @@ bool EmulatedController::TestVibration(std::size_t device_index) {
|
||||
// Send a slight vibration to test for rumble support
|
||||
output_devices[device_index]->SetVibration(test_vibration);
|
||||
|
||||
// Wait for about 15ms to ensure the controller is ready for the stop command
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(15));
|
||||
|
||||
// Stop any vibration and return the result
|
||||
return output_devices[device_index]->SetVibration(zero_vibration) ==
|
||||
Common::Input::VibrationError::None;
|
||||
@@ -1310,6 +1315,15 @@ const CameraState& EmulatedController::GetCamera() const {
|
||||
return controller.camera_state;
|
||||
}
|
||||
|
||||
NpadColor EmulatedController::GetNpadColor(u32 color) {
|
||||
return {
|
||||
.r = static_cast<u8>((color >> 16) & 0xFF),
|
||||
.g = static_cast<u8>((color >> 8) & 0xFF),
|
||||
.b = static_cast<u8>(color & 0xFF),
|
||||
.a = 0xff,
|
||||
};
|
||||
}
|
||||
|
||||
void EmulatedController::TriggerOnChange(ControllerTriggerType type, bool is_npad_service_update) {
|
||||
std::scoped_lock lock{callback_mutex};
|
||||
for (const auto& poller_pair : callback_list) {
|
||||
|
||||
@@ -424,6 +424,13 @@ private:
|
||||
*/
|
||||
void SetCamera(const Common::Input::CallbackStatus& callback);
|
||||
|
||||
/**
|
||||
* Converts a color format from bgra to rgba
|
||||
* @param color in bgra format
|
||||
* @return NpadColor in rgba format
|
||||
*/
|
||||
NpadColor GetNpadColor(u32 color);
|
||||
|
||||
/**
|
||||
* Triggers a callback that something has changed on the controller status
|
||||
* @param type Input type of the event to trigger
|
||||
|
||||
@@ -327,10 +327,18 @@ struct TouchState {
|
||||
};
|
||||
static_assert(sizeof(TouchState) == 0x28, "Touchstate is an invalid size");
|
||||
|
||||
struct NpadColor {
|
||||
u8 r{};
|
||||
u8 g{};
|
||||
u8 b{};
|
||||
u8 a{};
|
||||
};
|
||||
static_assert(sizeof(NpadColor) == 4, "NpadColor is an invalid size");
|
||||
|
||||
// This is nn::hid::NpadControllerColor
|
||||
struct NpadControllerColor {
|
||||
u32 body{};
|
||||
u32 button{};
|
||||
NpadColor body{};
|
||||
NpadColor button{};
|
||||
};
|
||||
static_assert(sizeof(NpadControllerColor) == 8, "NpadControllerColor is an invalid size");
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "common/thread.h"
|
||||
#include "common/thread_worker.h"
|
||||
#include "core/arm/arm_interface.h"
|
||||
#include "core/arm/cpu_interrupt_handler.h"
|
||||
#include "core/arm/exclusive_monitor.h"
|
||||
#include "core/core.h"
|
||||
#include "core/core_timing.h"
|
||||
@@ -82,7 +81,7 @@ struct KernelCore::Impl {
|
||||
|
||||
void InitializeCores() {
|
||||
for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
|
||||
cores[core_id].Initialize((*current_process).Is64BitProcess());
|
||||
cores[core_id]->Initialize((*current_process).Is64BitProcess());
|
||||
system.Memory().SetCurrentPageTable(*current_process, core_id);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +99,9 @@ struct KernelCore::Impl {
|
||||
next_user_process_id = KProcess::ProcessIDMin;
|
||||
next_thread_id = 1;
|
||||
|
||||
cores.clear();
|
||||
for (auto& core : cores) {
|
||||
core = nullptr;
|
||||
}
|
||||
|
||||
global_handle_table->Finalize();
|
||||
global_handle_table.reset();
|
||||
@@ -199,7 +200,7 @@ struct KernelCore::Impl {
|
||||
const s32 core{static_cast<s32>(i)};
|
||||
|
||||
schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel());
|
||||
cores.emplace_back(i, system, *schedulers[i], interrupts);
|
||||
cores[i] = std::make_unique<Kernel::PhysicalCore>(i, system, *schedulers[i]);
|
||||
|
||||
auto* main_thread{Kernel::KThread::Create(system.Kernel())};
|
||||
main_thread->SetName(fmt::format("MainThread:{}", core));
|
||||
@@ -761,7 +762,7 @@ struct KernelCore::Impl {
|
||||
std::unordered_set<KAutoObject*> registered_in_use_objects;
|
||||
|
||||
std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor;
|
||||
std::vector<Kernel::PhysicalCore> cores;
|
||||
std::array<std::unique_ptr<Kernel::PhysicalCore>, Core::Hardware::NUM_CPU_CORES> cores;
|
||||
|
||||
// Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others
|
||||
std::atomic<u32> next_host_thread_id{Core::Hardware::NUM_CPU_CORES};
|
||||
@@ -785,7 +786,6 @@ struct KernelCore::Impl {
|
||||
Common::ThreadWorker service_threads_manager;
|
||||
|
||||
std::array<KThread*, Core::Hardware::NUM_CPU_CORES> shutdown_threads;
|
||||
std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{};
|
||||
std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{};
|
||||
|
||||
bool is_multicore{};
|
||||
@@ -874,11 +874,11 @@ const Kernel::KScheduler& KernelCore::Scheduler(std::size_t id) const {
|
||||
}
|
||||
|
||||
Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) {
|
||||
return impl->cores[id];
|
||||
return *impl->cores[id];
|
||||
}
|
||||
|
||||
const Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) const {
|
||||
return impl->cores[id];
|
||||
return *impl->cores[id];
|
||||
}
|
||||
|
||||
size_t KernelCore::CurrentPhysicalCoreIndex() const {
|
||||
@@ -890,11 +890,11 @@ size_t KernelCore::CurrentPhysicalCoreIndex() const {
|
||||
}
|
||||
|
||||
Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() {
|
||||
return impl->cores[CurrentPhysicalCoreIndex()];
|
||||
return *impl->cores[CurrentPhysicalCoreIndex()];
|
||||
}
|
||||
|
||||
const Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() const {
|
||||
return impl->cores[CurrentPhysicalCoreIndex()];
|
||||
return *impl->cores[CurrentPhysicalCoreIndex()];
|
||||
}
|
||||
|
||||
Kernel::KScheduler* KernelCore::CurrentScheduler() {
|
||||
@@ -906,15 +906,6 @@ Kernel::KScheduler* KernelCore::CurrentScheduler() {
|
||||
return impl->schedulers[core_id].get();
|
||||
}
|
||||
|
||||
std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>& KernelCore::Interrupts() {
|
||||
return impl->interrupts;
|
||||
}
|
||||
|
||||
const std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>& KernelCore::Interrupts()
|
||||
const {
|
||||
return impl->interrupts;
|
||||
}
|
||||
|
||||
Kernel::TimeManager& KernelCore::TimeManager() {
|
||||
return impl->time_manager;
|
||||
}
|
||||
@@ -939,24 +930,18 @@ const KAutoObjectWithListContainer& KernelCore::ObjectListContainer() const {
|
||||
return *impl->global_object_list_container;
|
||||
}
|
||||
|
||||
void KernelCore::InterruptAllPhysicalCores() {
|
||||
for (auto& physical_core : impl->cores) {
|
||||
physical_core.Interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void KernelCore::InvalidateAllInstructionCaches() {
|
||||
for (auto& physical_core : impl->cores) {
|
||||
physical_core.ArmInterface().ClearInstructionCache();
|
||||
physical_core->ArmInterface().ClearInstructionCache();
|
||||
}
|
||||
}
|
||||
|
||||
void KernelCore::InvalidateCpuInstructionCacheRange(VAddr addr, std::size_t size) {
|
||||
for (auto& physical_core : impl->cores) {
|
||||
if (!physical_core.IsInitialized()) {
|
||||
if (!physical_core->IsInitialized()) {
|
||||
continue;
|
||||
}
|
||||
physical_core.ArmInterface().InvalidateCacheRange(addr, size);
|
||||
physical_core->ArmInterface().InvalidateCacheRange(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,14 +9,12 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include "core/arm/cpu_interrupt_handler.h"
|
||||
#include "core/hardware_properties.h"
|
||||
#include "core/hle/kernel/k_auto_object.h"
|
||||
#include "core/hle/kernel/k_slab_heap.h"
|
||||
#include "core/hle/kernel/svc_common.h"
|
||||
|
||||
namespace Core {
|
||||
class CPUInterruptHandler;
|
||||
class ExclusiveMonitor;
|
||||
class System;
|
||||
} // namespace Core
|
||||
@@ -183,12 +181,6 @@ public:
|
||||
|
||||
const KAutoObjectWithListContainer& ObjectListContainer() const;
|
||||
|
||||
std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>& Interrupts();
|
||||
|
||||
const std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES>& Interrupts() const;
|
||||
|
||||
void InterruptAllPhysicalCores();
|
||||
|
||||
void InvalidateAllInstructionCaches();
|
||||
|
||||
void InvalidateCpuInstructionCacheRange(VAddr addr, std::size_t size);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "core/arm/cpu_interrupt_handler.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_32.h"
|
||||
#include "core/arm/dynarmic/arm_dynarmic_64.h"
|
||||
#include "core/core.h"
|
||||
@@ -11,16 +10,14 @@
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_,
|
||||
Core::CPUInterrupts& interrupts_)
|
||||
: core_index{core_index_}, system{system_}, scheduler{scheduler_},
|
||||
interrupts{interrupts_}, guard{std::make_unique<std::mutex>()} {
|
||||
PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_)
|
||||
: core_index{core_index_}, system{system_}, scheduler{scheduler_} {
|
||||
#ifdef ARCHITECTURE_x86_64
|
||||
// TODO(bunnei): Initialization relies on a core being available. We may later replace this with
|
||||
// a 32-bit instance of Dynarmic. This should be abstracted out to a CPU manager.
|
||||
auto& kernel = system.Kernel();
|
||||
arm_interface = std::make_unique<Core::ARM_Dynarmic_64>(
|
||||
system, interrupts, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
|
||||
system, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
|
||||
#else
|
||||
#error Platform not supported yet.
|
||||
#endif
|
||||
@@ -34,7 +31,7 @@ void PhysicalCore::Initialize([[maybe_unused]] bool is_64_bit) {
|
||||
if (!is_64_bit) {
|
||||
// We already initialized a 64-bit core, replace with a 32-bit one.
|
||||
arm_interface = std::make_unique<Core::ARM_Dynarmic_32>(
|
||||
system, interrupts, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
|
||||
system, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
|
||||
}
|
||||
#else
|
||||
#error Platform not supported yet.
|
||||
@@ -47,24 +44,26 @@ void PhysicalCore::Run() {
|
||||
}
|
||||
|
||||
void PhysicalCore::Idle() {
|
||||
interrupts[core_index].AwaitInterrupt();
|
||||
std::unique_lock lk{guard};
|
||||
on_interrupt.wait(lk, [this] { return is_interrupted; });
|
||||
}
|
||||
|
||||
bool PhysicalCore::IsInterrupted() const {
|
||||
return interrupts[core_index].IsInterrupted();
|
||||
return is_interrupted;
|
||||
}
|
||||
|
||||
void PhysicalCore::Interrupt() {
|
||||
guard->lock();
|
||||
interrupts[core_index].SetInterrupt(true);
|
||||
std::unique_lock lk{guard};
|
||||
is_interrupted = true;
|
||||
arm_interface->SignalInterrupt();
|
||||
guard->unlock();
|
||||
on_interrupt.notify_all();
|
||||
}
|
||||
|
||||
void PhysicalCore::ClearInterrupt() {
|
||||
guard->lock();
|
||||
interrupts[core_index].SetInterrupt(false);
|
||||
guard->unlock();
|
||||
std::unique_lock lk{guard};
|
||||
is_interrupted = false;
|
||||
arm_interface->ClearInterrupt();
|
||||
on_interrupt.notify_all();
|
||||
}
|
||||
|
||||
} // namespace Kernel
|
||||
|
||||
@@ -14,7 +14,6 @@ class KScheduler;
|
||||
} // namespace Kernel
|
||||
|
||||
namespace Core {
|
||||
class CPUInterruptHandler;
|
||||
class ExclusiveMonitor;
|
||||
class System;
|
||||
} // namespace Core
|
||||
@@ -23,15 +22,11 @@ namespace Kernel {
|
||||
|
||||
class PhysicalCore {
|
||||
public:
|
||||
PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_,
|
||||
Core::CPUInterrupts& interrupts_);
|
||||
PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_);
|
||||
~PhysicalCore();
|
||||
|
||||
PhysicalCore(const PhysicalCore&) = delete;
|
||||
PhysicalCore& operator=(const PhysicalCore&) = delete;
|
||||
|
||||
PhysicalCore(PhysicalCore&&) = default;
|
||||
PhysicalCore& operator=(PhysicalCore&&) = delete;
|
||||
YUZU_NON_COPYABLE(PhysicalCore);
|
||||
YUZU_NON_MOVEABLE(PhysicalCore);
|
||||
|
||||
/// Initialize the core for the specified parameters.
|
||||
void Initialize(bool is_64_bit);
|
||||
@@ -86,9 +81,11 @@ private:
|
||||
const std::size_t core_index;
|
||||
Core::System& system;
|
||||
Kernel::KScheduler& scheduler;
|
||||
Core::CPUInterrupts& interrupts;
|
||||
std::unique_ptr<std::mutex> guard;
|
||||
|
||||
std::mutex guard;
|
||||
std::condition_variable on_interrupt;
|
||||
std::unique_ptr<Core::ARM_Interface> arm_interface;
|
||||
bool is_interrupted;
|
||||
};
|
||||
|
||||
} // namespace Kernel
|
||||
|
||||
@@ -163,28 +163,51 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
}
|
||||
LOG_DEBUG(Service_HID, "Npad connected {}", npad_id);
|
||||
const auto controller_type = controller.device->GetNpadStyleIndex();
|
||||
const auto& body_colors = controller.device->GetColors();
|
||||
const auto& battery_level = controller.device->GetBattery();
|
||||
auto* shared_memory = controller.shared_memory;
|
||||
if (controller_type == Core::HID::NpadStyleIndex::None) {
|
||||
controller.styleset_changed_event->GetWritableEvent().Signal();
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset memory values
|
||||
shared_memory->style_tag.raw = Core::HID::NpadStyleSet::None;
|
||||
shared_memory->device_type.raw = 0;
|
||||
shared_memory->system_properties.raw = 0;
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::NoController;
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::NoController;
|
||||
shared_memory->fullkey_color = {};
|
||||
shared_memory->joycon_color.left = {};
|
||||
shared_memory->joycon_color.right = {};
|
||||
shared_memory->battery_level_dual = {};
|
||||
shared_memory->battery_level_left = {};
|
||||
shared_memory->battery_level_right = {};
|
||||
|
||||
switch (controller_type) {
|
||||
case Core::HID::NpadStyleIndex::None:
|
||||
ASSERT(false);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::ProController:
|
||||
shared_memory->fullkey_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->fullkey_color.fullkey = body_colors.fullkey;
|
||||
shared_memory->battery_level_dual = battery_level.dual.battery_level;
|
||||
shared_memory->style_tag.fullkey.Assign(1);
|
||||
shared_memory->device_type.fullkey.Assign(1);
|
||||
shared_memory->system_properties.is_vertical.Assign(1);
|
||||
shared_memory->system_properties.use_plus.Assign(1);
|
||||
shared_memory->system_properties.use_minus.Assign(1);
|
||||
shared_memory->system_properties.is_charging_joy_dual.Assign(
|
||||
battery_level.dual.is_charging);
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type = AppletFooterUiType::SwitchProController;
|
||||
shared_memory->sixaxis_fullkey_properties.is_newly_assigned.Assign(1);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::Handheld:
|
||||
shared_memory->fullkey_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->fullkey_color.fullkey = body_colors.fullkey;
|
||||
shared_memory->joycon_color.left = body_colors.left;
|
||||
shared_memory->joycon_color.right = body_colors.right;
|
||||
shared_memory->style_tag.handheld.Assign(1);
|
||||
shared_memory->device_type.handheld_left.Assign(1);
|
||||
shared_memory->device_type.handheld_right.Assign(1);
|
||||
@@ -192,47 +215,86 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
shared_memory->system_properties.use_plus.Assign(1);
|
||||
shared_memory->system_properties.use_minus.Assign(1);
|
||||
shared_memory->system_properties.use_directional_buttons.Assign(1);
|
||||
shared_memory->system_properties.is_charging_joy_dual.Assign(
|
||||
battery_level.left.is_charging);
|
||||
shared_memory->system_properties.is_charging_joy_left.Assign(
|
||||
battery_level.left.is_charging);
|
||||
shared_memory->system_properties.is_charging_joy_right.Assign(
|
||||
battery_level.right.is_charging);
|
||||
shared_memory->assignment_mode = NpadJoyAssignmentMode::Dual;
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type =
|
||||
AppletFooterUiType::HandheldJoyConLeftJoyConRight;
|
||||
shared_memory->sixaxis_handheld_properties.is_newly_assigned.Assign(1);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconDual:
|
||||
shared_memory->fullkey_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->style_tag.joycon_dual.Assign(1);
|
||||
if (controller.is_dual_left_connected) {
|
||||
shared_memory->joycon_color.left = body_colors.left;
|
||||
shared_memory->battery_level_left = battery_level.left.battery_level;
|
||||
shared_memory->device_type.joycon_left.Assign(1);
|
||||
shared_memory->system_properties.use_minus.Assign(1);
|
||||
shared_memory->system_properties.is_charging_joy_left.Assign(
|
||||
battery_level.left.is_charging);
|
||||
shared_memory->sixaxis_dual_left_properties.is_newly_assigned.Assign(1);
|
||||
}
|
||||
if (controller.is_dual_right_connected) {
|
||||
shared_memory->joycon_color.right = body_colors.right;
|
||||
shared_memory->battery_level_right = battery_level.right.battery_level;
|
||||
shared_memory->device_type.joycon_right.Assign(1);
|
||||
shared_memory->system_properties.use_plus.Assign(1);
|
||||
shared_memory->system_properties.is_charging_joy_right.Assign(
|
||||
battery_level.right.is_charging);
|
||||
shared_memory->sixaxis_dual_right_properties.is_newly_assigned.Assign(1);
|
||||
}
|
||||
shared_memory->system_properties.use_directional_buttons.Assign(1);
|
||||
shared_memory->system_properties.is_vertical.Assign(1);
|
||||
shared_memory->assignment_mode = NpadJoyAssignmentMode::Dual;
|
||||
|
||||
if (controller.is_dual_left_connected && controller.is_dual_right_connected) {
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type = AppletFooterUiType::JoyDual;
|
||||
shared_memory->fullkey_color.fullkey = body_colors.left;
|
||||
shared_memory->battery_level_dual = battery_level.left.battery_level;
|
||||
shared_memory->system_properties.is_charging_joy_dual.Assign(
|
||||
battery_level.left.is_charging);
|
||||
} else if (controller.is_dual_left_connected) {
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type = AppletFooterUiType::JoyDualLeftOnly;
|
||||
shared_memory->fullkey_color.fullkey = body_colors.left;
|
||||
shared_memory->battery_level_dual = battery_level.left.battery_level;
|
||||
shared_memory->system_properties.is_charging_joy_dual.Assign(
|
||||
battery_level.left.is_charging);
|
||||
} else {
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type = AppletFooterUiType::JoyDualRightOnly;
|
||||
shared_memory->fullkey_color.fullkey = body_colors.right;
|
||||
shared_memory->battery_level_dual = battery_level.right.battery_level;
|
||||
shared_memory->system_properties.is_charging_joy_dual.Assign(
|
||||
battery_level.right.is_charging);
|
||||
}
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconLeft:
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->joycon_color.left = body_colors.left;
|
||||
shared_memory->battery_level_dual = battery_level.left.battery_level;
|
||||
shared_memory->style_tag.joycon_left.Assign(1);
|
||||
shared_memory->device_type.joycon_left.Assign(1);
|
||||
shared_memory->system_properties.is_horizontal.Assign(1);
|
||||
shared_memory->system_properties.use_minus.Assign(1);
|
||||
shared_memory->system_properties.is_charging_joy_left.Assign(
|
||||
battery_level.left.is_charging);
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal;
|
||||
shared_memory->sixaxis_left_properties.is_newly_assigned.Assign(1);
|
||||
break;
|
||||
case Core::HID::NpadStyleIndex::JoyconRight:
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->joycon_color.right = body_colors.right;
|
||||
shared_memory->battery_level_right = battery_level.right.battery_level;
|
||||
shared_memory->style_tag.joycon_right.Assign(1);
|
||||
shared_memory->device_type.joycon_right.Assign(1);
|
||||
shared_memory->system_properties.is_horizontal.Assign(1);
|
||||
shared_memory->system_properties.use_plus.Assign(1);
|
||||
shared_memory->system_properties.is_charging_joy_right.Assign(
|
||||
battery_level.right.is_charging);
|
||||
shared_memory->applet_nfc_xcd.applet_footer.type = AppletFooterUiType::JoyRightHorizontal;
|
||||
shared_memory->sixaxis_right_properties.is_newly_assigned.Assign(1);
|
||||
break;
|
||||
@@ -269,21 +331,6 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) {
|
||||
break;
|
||||
}
|
||||
|
||||
const auto& body_colors = controller.device->GetColors();
|
||||
|
||||
shared_memory->fullkey_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->fullkey_color.fullkey = body_colors.fullkey;
|
||||
|
||||
shared_memory->joycon_color.attribute = ColorAttribute::Ok;
|
||||
shared_memory->joycon_color.left = body_colors.left;
|
||||
shared_memory->joycon_color.right = body_colors.right;
|
||||
|
||||
// TODO: Investigate when we should report all batery types
|
||||
const auto& battery_level = controller.device->GetBattery();
|
||||
shared_memory->battery_level_dual = battery_level.dual.battery_level;
|
||||
shared_memory->battery_level_left = battery_level.left.battery_level;
|
||||
shared_memory->battery_level_right = battery_level.right.battery_level;
|
||||
|
||||
controller.is_connected = true;
|
||||
controller.device->Connect();
|
||||
SignalStyleSetChangedEvent(npad_id);
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace Service::LDN {
|
||||
|
||||
constexpr Result ERROR_DISABLED{ErrorModule::LDN, 22};
|
||||
|
||||
} // namespace Service::LDN
|
||||
@@ -3,11 +3,15 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/ldn/errors.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/ldn/ldn.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
#include "core/hle/service/ldn/ldn_results.h"
|
||||
#include "core/hle/service/ldn/ldn_types.h"
|
||||
#include "core/internal_network/network.h"
|
||||
#include "core/internal_network/network_interface.h"
|
||||
|
||||
// This is defined by synchapi.h and conflicts with ServiceContext::CreateEvent
|
||||
#undef CreateEvent
|
||||
|
||||
namespace Service::LDN {
|
||||
|
||||
@@ -100,74 +104,418 @@ class IUserLocalCommunicationService final
|
||||
: public ServiceFramework<IUserLocalCommunicationService> {
|
||||
public:
|
||||
explicit IUserLocalCommunicationService(Core::System& system_)
|
||||
: ServiceFramework{system_, "IUserLocalCommunicationService"} {
|
||||
: ServiceFramework{system_, "IUserLocalCommunicationService", ServiceThreadType::CreateNew},
|
||||
service_context{system, "IUserLocalCommunicationService"}, room_network{
|
||||
system_.GetRoomNetwork()} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IUserLocalCommunicationService::GetState, "GetState"},
|
||||
{1, nullptr, "GetNetworkInfo"},
|
||||
{1, &IUserLocalCommunicationService::GetNetworkInfo, "GetNetworkInfo"},
|
||||
{2, nullptr, "GetIpv4Address"},
|
||||
{3, nullptr, "GetDisconnectReason"},
|
||||
{4, nullptr, "GetSecurityParameter"},
|
||||
{5, nullptr, "GetNetworkConfig"},
|
||||
{100, nullptr, "AttachStateChangeEvent"},
|
||||
{101, nullptr, "GetNetworkInfoLatestUpdate"},
|
||||
{102, nullptr, "Scan"},
|
||||
{103, nullptr, "ScanPrivate"},
|
||||
{3, &IUserLocalCommunicationService::GetDisconnectReason, "GetDisconnectReason"},
|
||||
{4, &IUserLocalCommunicationService::GetSecurityParameter, "GetSecurityParameter"},
|
||||
{5, &IUserLocalCommunicationService::GetNetworkConfig, "GetNetworkConfig"},
|
||||
{100, &IUserLocalCommunicationService::AttachStateChangeEvent, "AttachStateChangeEvent"},
|
||||
{101, &IUserLocalCommunicationService::GetNetworkInfoLatestUpdate, "GetNetworkInfoLatestUpdate"},
|
||||
{102, &IUserLocalCommunicationService::Scan, "Scan"},
|
||||
{103, &IUserLocalCommunicationService::ScanPrivate, "ScanPrivate"},
|
||||
{104, nullptr, "SetWirelessControllerRestriction"},
|
||||
{200, nullptr, "OpenAccessPoint"},
|
||||
{201, nullptr, "CloseAccessPoint"},
|
||||
{202, nullptr, "CreateNetwork"},
|
||||
{203, nullptr, "CreateNetworkPrivate"},
|
||||
{204, nullptr, "DestroyNetwork"},
|
||||
{200, &IUserLocalCommunicationService::OpenAccessPoint, "OpenAccessPoint"},
|
||||
{201, &IUserLocalCommunicationService::CloseAccessPoint, "CloseAccessPoint"},
|
||||
{202, &IUserLocalCommunicationService::CreateNetwork, "CreateNetwork"},
|
||||
{203, &IUserLocalCommunicationService::CreateNetworkPrivate, "CreateNetworkPrivate"},
|
||||
{204, &IUserLocalCommunicationService::DestroyNetwork, "DestroyNetwork"},
|
||||
{205, nullptr, "Reject"},
|
||||
{206, nullptr, "SetAdvertiseData"},
|
||||
{207, nullptr, "SetStationAcceptPolicy"},
|
||||
{208, nullptr, "AddAcceptFilterEntry"},
|
||||
{206, &IUserLocalCommunicationService::SetAdvertiseData, "SetAdvertiseData"},
|
||||
{207, &IUserLocalCommunicationService::SetStationAcceptPolicy, "SetStationAcceptPolicy"},
|
||||
{208, &IUserLocalCommunicationService::AddAcceptFilterEntry, "AddAcceptFilterEntry"},
|
||||
{209, nullptr, "ClearAcceptFilter"},
|
||||
{300, nullptr, "OpenStation"},
|
||||
{301, nullptr, "CloseStation"},
|
||||
{302, nullptr, "Connect"},
|
||||
{300, &IUserLocalCommunicationService::OpenStation, "OpenStation"},
|
||||
{301, &IUserLocalCommunicationService::CloseStation, "CloseStation"},
|
||||
{302, &IUserLocalCommunicationService::Connect, "Connect"},
|
||||
{303, nullptr, "ConnectPrivate"},
|
||||
{304, nullptr, "Disconnect"},
|
||||
{400, nullptr, "Initialize"},
|
||||
{401, nullptr, "Finalize"},
|
||||
{402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, // 7.0.0+
|
||||
{304, &IUserLocalCommunicationService::Disconnect, "Disconnect"},
|
||||
{400, &IUserLocalCommunicationService::Initialize, "Initialize"},
|
||||
{401, &IUserLocalCommunicationService::Finalize, "Finalize"},
|
||||
{402, &IUserLocalCommunicationService::Initialize2, "Initialize2"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
state_change_event =
|
||||
service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent");
|
||||
}
|
||||
|
||||
~IUserLocalCommunicationService() {
|
||||
service_context.CloseEvent(state_change_event);
|
||||
}
|
||||
|
||||
void OnEventFired() {
|
||||
state_change_event->GetWritableEvent().Signal();
|
||||
}
|
||||
|
||||
void GetState(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
State state = State::Error;
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, state = {}", state);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(state);
|
||||
}
|
||||
|
||||
// Indicate a network error, as we do not actually emulate LDN
|
||||
rb.Push(static_cast<u32>(State::Error));
|
||||
void GetNetworkInfo(Kernel::HLERequestContext& ctx) {
|
||||
const auto write_buffer_size = ctx.GetWriteBufferSize();
|
||||
|
||||
if (write_buffer_size != sizeof(NetworkInfo)) {
|
||||
LOG_ERROR(Service_LDN, "Invalid buffer size {}", write_buffer_size);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultBadInput);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkInfo network_info{};
|
||||
const auto rc = ResultSuccess;
|
||||
if (rc.IsError()) {
|
||||
LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}",
|
||||
network_info.common.ssid.GetStringValue(), network_info.ldn.node_count);
|
||||
|
||||
ctx.WriteBuffer<NetworkInfo>(network_info);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
}
|
||||
|
||||
void GetDisconnectReason(Kernel::HLERequestContext& ctx) {
|
||||
const auto disconnect_reason = DisconnectReason::None;
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, disconnect_reason={}", disconnect_reason);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushEnum(disconnect_reason);
|
||||
}
|
||||
|
||||
void GetSecurityParameter(Kernel::HLERequestContext& ctx) {
|
||||
SecurityParameter security_parameter{};
|
||||
NetworkInfo info{};
|
||||
const Result rc = ResultSuccess;
|
||||
|
||||
if (rc.IsError()) {
|
||||
LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
security_parameter.session_id = info.network_id.session_id;
|
||||
std::memcpy(security_parameter.data.data(), info.ldn.security_parameter.data(),
|
||||
sizeof(SecurityParameter::data));
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(rc);
|
||||
rb.PushRaw<SecurityParameter>(security_parameter);
|
||||
}
|
||||
|
||||
void GetNetworkConfig(Kernel::HLERequestContext& ctx) {
|
||||
NetworkConfig config{};
|
||||
NetworkInfo info{};
|
||||
const Result rc = ResultSuccess;
|
||||
|
||||
if (rc.IsError()) {
|
||||
LOG_ERROR(Service_LDN, "NetworkConfig is not valid {}", rc.raw);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
config.intent_id = info.network_id.intent_id;
|
||||
config.channel = info.common.channel;
|
||||
config.node_count_max = info.ldn.node_count_max;
|
||||
config.local_communication_version = info.ldn.nodes[0].local_communication_version;
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, intent_id={}/{}, channel={}, node_count_max={}, "
|
||||
"local_communication_version={}",
|
||||
config.intent_id.local_communication_id, config.intent_id.scene_id,
|
||||
config.channel, config.node_count_max, config.local_communication_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 10};
|
||||
rb.Push(rc);
|
||||
rb.PushRaw<NetworkConfig>(config);
|
||||
}
|
||||
|
||||
void AttachStateChangeEvent(Kernel::HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_LDN, "called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushCopyObjects(state_change_event->GetReadableEvent());
|
||||
}
|
||||
|
||||
void GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx) {
|
||||
const std::size_t network_buffer_size = ctx.GetWriteBufferSize(0);
|
||||
const std::size_t node_buffer_count = ctx.GetWriteBufferSize(1) / sizeof(NodeLatestUpdate);
|
||||
|
||||
if (node_buffer_count == 0 || network_buffer_size != sizeof(NetworkInfo)) {
|
||||
LOG_ERROR(Service_LDN, "Invalid buffer size {}, {}", network_buffer_size,
|
||||
node_buffer_count);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultBadInput);
|
||||
return;
|
||||
}
|
||||
|
||||
NetworkInfo info;
|
||||
std::vector<NodeLatestUpdate> latest_update(node_buffer_count);
|
||||
|
||||
const auto rc = ResultSuccess;
|
||||
if (rc.IsError()) {
|
||||
LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
return;
|
||||
}
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}",
|
||||
info.common.ssid.GetStringValue(), info.ldn.node_count);
|
||||
|
||||
ctx.WriteBuffer(info, 0);
|
||||
ctx.WriteBuffer(latest_update, 1);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void Scan(Kernel::HLERequestContext& ctx) {
|
||||
ScanImpl(ctx);
|
||||
}
|
||||
|
||||
void ScanPrivate(Kernel::HLERequestContext& ctx) {
|
||||
ScanImpl(ctx, true);
|
||||
}
|
||||
|
||||
void ScanImpl(Kernel::HLERequestContext& ctx, bool is_private = false) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
const auto channel{rp.PopEnum<WifiChannel>()};
|
||||
const auto scan_filter{rp.PopRaw<ScanFilter>()};
|
||||
|
||||
const std::size_t network_info_size = ctx.GetWriteBufferSize() / sizeof(NetworkInfo);
|
||||
|
||||
if (network_info_size == 0) {
|
||||
LOG_ERROR(Service_LDN, "Invalid buffer size {}", network_info_size);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultBadInput);
|
||||
return;
|
||||
}
|
||||
|
||||
u16 count = 0;
|
||||
std::vector<NetworkInfo> network_infos(network_info_size);
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}",
|
||||
channel, scan_filter.flag, scan_filter.network_type);
|
||||
|
||||
ctx.WriteBuffer(network_infos);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u32>(count);
|
||||
}
|
||||
|
||||
void OpenAccessPoint(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void CloseAccessPoint(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void CreateNetwork(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
SecurityConfig security_config;
|
||||
UserConfig user_config;
|
||||
INSERT_PADDING_WORDS_NOINIT(1);
|
||||
NetworkConfig network_config;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x98, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, passphrase_size={}, security_mode={}, "
|
||||
"local_communication_version={}",
|
||||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode,
|
||||
parameters.network_config.local_communication_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void CreateNetworkPrivate(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
SecurityConfig security_config;
|
||||
SecurityParameter security_parameter;
|
||||
UserConfig user_config;
|
||||
NetworkConfig network_config;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0xB8, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, passphrase_size={}, security_mode={}, "
|
||||
"local_communication_version={}",
|
||||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode,
|
||||
parameters.network_config.local_communication_version);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void DestroyNetwork(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void SetAdvertiseData(Kernel::HLERequestContext& ctx) {
|
||||
std::vector<u8> read_buffer = ctx.ReadBuffer();
|
||||
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called, size {}", read_buffer.size());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void OpenStation(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void CloseStation(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void Connect(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
struct Parameters {
|
||||
SecurityConfig security_config;
|
||||
UserConfig user_config;
|
||||
u32 local_communication_version;
|
||||
u32 option;
|
||||
};
|
||||
static_assert(sizeof(Parameters) == 0x7C, "Parameters has incorrect size.");
|
||||
|
||||
const auto parameters{rp.PopRaw<Parameters>()};
|
||||
|
||||
LOG_WARNING(Service_LDN,
|
||||
"(STUBBED) called, passphrase_size={}, security_mode={}, "
|
||||
"local_communication_version={}",
|
||||
parameters.security_config.passphrase_size,
|
||||
parameters.security_config.security_mode,
|
||||
parameters.local_communication_version);
|
||||
|
||||
const std::vector<u8> read_buffer = ctx.ReadBuffer();
|
||||
NetworkInfo network_info{};
|
||||
|
||||
if (read_buffer.size() != sizeof(NetworkInfo)) {
|
||||
LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!");
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultBadInput);
|
||||
return;
|
||||
}
|
||||
|
||||
std::memcpy(&network_info, read_buffer.data(), read_buffer.size());
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void Disconnect(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
void Initialize(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
const auto rc = InitializeImpl(ctx);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(rc);
|
||||
}
|
||||
|
||||
void Finalize(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
is_initialized = false;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void Initialize2(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_LDN, "called");
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
is_initialized = true;
|
||||
const auto rc = InitializeImpl(ctx);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERROR_DISABLED);
|
||||
rb.Push(rc);
|
||||
}
|
||||
|
||||
private:
|
||||
enum class State {
|
||||
None,
|
||||
Initialized,
|
||||
AccessPointOpened,
|
||||
AccessPointCreated,
|
||||
StationOpened,
|
||||
StationConnected,
|
||||
Error,
|
||||
};
|
||||
Result InitializeImpl(Kernel::HLERequestContext& ctx) {
|
||||
const auto network_interface = Network::GetSelectedNetworkInterface();
|
||||
if (!network_interface) {
|
||||
LOG_ERROR(Service_LDN, "No network interface is set");
|
||||
return ResultAirplaneModeEnabled;
|
||||
}
|
||||
|
||||
is_initialized = true;
|
||||
// TODO (flTobi): Change this to ResultSuccess when LDN is fully implemented
|
||||
return ResultAirplaneModeEnabled;
|
||||
}
|
||||
|
||||
KernelHelpers::ServiceContext service_context;
|
||||
Kernel::KEvent* state_change_event;
|
||||
Network::RoomNetwork& room_network;
|
||||
|
||||
bool is_initialized{};
|
||||
};
|
||||
@@ -273,7 +621,7 @@ public:
|
||||
LOG_WARNING(Service_LDN, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ERROR_DISABLED);
|
||||
rb.Push(ResultDisabled);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
27
src/core/hle/service/ldn/ldn_results.h
Normal file
@@ -0,0 +1,27 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace Service::LDN {
|
||||
|
||||
constexpr Result ResultAdvertiseDataTooLarge{ErrorModule::LDN, 10};
|
||||
constexpr Result ResultAuthenticationFailed{ErrorModule::LDN, 20};
|
||||
constexpr Result ResultDisabled{ErrorModule::LDN, 22};
|
||||
constexpr Result ResultAirplaneModeEnabled{ErrorModule::LDN, 23};
|
||||
constexpr Result ResultInvalidNodeCount{ErrorModule::LDN, 30};
|
||||
constexpr Result ResultConnectionFailed{ErrorModule::LDN, 31};
|
||||
constexpr Result ResultBadState{ErrorModule::LDN, 32};
|
||||
constexpr Result ResultNoIpAddress{ErrorModule::LDN, 33};
|
||||
constexpr Result ResultInvalidBufferCount{ErrorModule::LDN, 50};
|
||||
constexpr Result ResultAccessPointConnectionFailed{ErrorModule::LDN, 65};
|
||||
constexpr Result ResultAuthenticationTimeout{ErrorModule::LDN, 66};
|
||||
constexpr Result ResultMaximumNodeCount{ErrorModule::LDN, 67};
|
||||
constexpr Result ResultBadInput{ErrorModule::LDN, 96};
|
||||
constexpr Result ResultLocalCommunicationIdNotFound{ErrorModule::LDN, 97};
|
||||
constexpr Result ResultLocalCommunicationVersionTooLow{ErrorModule::LDN, 113};
|
||||
constexpr Result ResultLocalCommunicationVersionTooHigh{ErrorModule::LDN, 114};
|
||||
|
||||
} // namespace Service::LDN
|
||||
284
src/core/hle/service/ldn/ldn_types.h
Normal file
@@ -0,0 +1,284 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "network/network.h"
|
||||
|
||||
namespace Service::LDN {
|
||||
|
||||
constexpr size_t SsidLengthMax = 32;
|
||||
constexpr size_t AdvertiseDataSizeMax = 384;
|
||||
constexpr size_t UserNameBytesMax = 32;
|
||||
constexpr int NodeCountMax = 8;
|
||||
constexpr int StationCountMax = NodeCountMax - 1;
|
||||
constexpr size_t PassphraseLengthMax = 64;
|
||||
|
||||
enum class SecurityMode : u16 {
|
||||
All,
|
||||
Retail,
|
||||
Debug,
|
||||
};
|
||||
|
||||
enum class NodeStateChange : u8 {
|
||||
None,
|
||||
Connect,
|
||||
Disconnect,
|
||||
DisconnectAndConnect,
|
||||
};
|
||||
|
||||
enum class ScanFilterFlag : u32 {
|
||||
None = 0,
|
||||
LocalCommunicationId = 1 << 0,
|
||||
SessionId = 1 << 1,
|
||||
NetworkType = 1 << 2,
|
||||
Ssid = 1 << 4,
|
||||
SceneId = 1 << 5,
|
||||
IntentId = LocalCommunicationId | SceneId,
|
||||
NetworkId = IntentId | SessionId,
|
||||
};
|
||||
|
||||
enum class NetworkType : u32 {
|
||||
None,
|
||||
General,
|
||||
Ldn,
|
||||
All,
|
||||
};
|
||||
|
||||
enum class PackedNetworkType : u8 {
|
||||
None,
|
||||
General,
|
||||
Ldn,
|
||||
All,
|
||||
};
|
||||
|
||||
enum class State : u32 {
|
||||
None,
|
||||
Initialized,
|
||||
AccessPointOpened,
|
||||
AccessPointCreated,
|
||||
StationOpened,
|
||||
StationConnected,
|
||||
Error,
|
||||
};
|
||||
|
||||
enum class DisconnectReason : s16 {
|
||||
Unknown = -1,
|
||||
None,
|
||||
DisconnectedByUser,
|
||||
DisconnectedBySystem,
|
||||
DestroyedByUser,
|
||||
DestroyedBySystem,
|
||||
Rejected,
|
||||
SignalLost,
|
||||
};
|
||||
|
||||
enum class NetworkError {
|
||||
Unknown = -1,
|
||||
None = 0,
|
||||
PortUnreachable,
|
||||
TooManyPlayers,
|
||||
VersionTooLow,
|
||||
VersionTooHigh,
|
||||
ConnectFailure,
|
||||
ConnectNotFound,
|
||||
ConnectTimeout,
|
||||
ConnectRejected,
|
||||
RejectFailed,
|
||||
};
|
||||
|
||||
enum class AcceptPolicy : u8 {
|
||||
AcceptAll,
|
||||
RejectAll,
|
||||
BlackList,
|
||||
WhiteList,
|
||||
};
|
||||
|
||||
enum class WifiChannel : s16 {
|
||||
Default = 0,
|
||||
wifi24_1 = 1,
|
||||
wifi24_6 = 6,
|
||||
wifi24_11 = 11,
|
||||
wifi50_36 = 36,
|
||||
wifi50_40 = 40,
|
||||
wifi50_44 = 44,
|
||||
wifi50_48 = 48,
|
||||
};
|
||||
|
||||
enum class LinkLevel : s8 {
|
||||
Bad,
|
||||
Low,
|
||||
Good,
|
||||
Excelent,
|
||||
};
|
||||
|
||||
struct NodeLatestUpdate {
|
||||
NodeStateChange state_change;
|
||||
INSERT_PADDING_BYTES(0x7); // Unknown
|
||||
};
|
||||
static_assert(sizeof(NodeLatestUpdate) == 0x8, "NodeLatestUpdate is an invalid size");
|
||||
|
||||
struct SessionId {
|
||||
u64 high;
|
||||
u64 low;
|
||||
|
||||
bool operator==(const SessionId&) const = default;
|
||||
};
|
||||
static_assert(sizeof(SessionId) == 0x10, "SessionId is an invalid size");
|
||||
|
||||
struct IntentId {
|
||||
u64 local_communication_id;
|
||||
INSERT_PADDING_BYTES(0x2); // Reserved
|
||||
u16 scene_id;
|
||||
INSERT_PADDING_BYTES(0x4); // Reserved
|
||||
};
|
||||
static_assert(sizeof(IntentId) == 0x10, "IntentId is an invalid size");
|
||||
|
||||
struct NetworkId {
|
||||
IntentId intent_id;
|
||||
SessionId session_id;
|
||||
};
|
||||
static_assert(sizeof(NetworkId) == 0x20, "NetworkId is an invalid size");
|
||||
|
||||
struct Ssid {
|
||||
u8 length;
|
||||
std::array<char, SsidLengthMax + 1> raw;
|
||||
|
||||
std::string GetStringValue() const {
|
||||
return std::string(raw.data(), length);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(Ssid) == 0x22, "Ssid is an invalid size");
|
||||
|
||||
struct Ipv4Address {
|
||||
union {
|
||||
u32 raw{};
|
||||
std::array<u8, 4> bytes;
|
||||
};
|
||||
|
||||
std::string GetStringValue() const {
|
||||
return fmt::format("{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]);
|
||||
}
|
||||
};
|
||||
static_assert(sizeof(Ipv4Address) == 0x4, "Ipv4Address is an invalid size");
|
||||
|
||||
struct MacAddress {
|
||||
std::array<u8, 6> raw{};
|
||||
|
||||
friend bool operator==(const MacAddress& lhs, const MacAddress& rhs) = default;
|
||||
};
|
||||
static_assert(sizeof(MacAddress) == 0x6, "MacAddress is an invalid size");
|
||||
|
||||
struct ScanFilter {
|
||||
NetworkId network_id;
|
||||
NetworkType network_type;
|
||||
MacAddress mac_address;
|
||||
Ssid ssid;
|
||||
INSERT_PADDING_BYTES(0x10);
|
||||
ScanFilterFlag flag;
|
||||
};
|
||||
static_assert(sizeof(ScanFilter) == 0x60, "ScanFilter is an invalid size");
|
||||
|
||||
struct CommonNetworkInfo {
|
||||
MacAddress bssid;
|
||||
Ssid ssid;
|
||||
WifiChannel channel;
|
||||
LinkLevel link_level;
|
||||
PackedNetworkType network_type;
|
||||
INSERT_PADDING_BYTES(0x4);
|
||||
};
|
||||
static_assert(sizeof(CommonNetworkInfo) == 0x30, "CommonNetworkInfo is an invalid size");
|
||||
|
||||
struct NodeInfo {
|
||||
Ipv4Address ipv4_address;
|
||||
MacAddress mac_address;
|
||||
s8 node_id;
|
||||
u8 is_connected;
|
||||
std::array<u8, UserNameBytesMax + 1> user_name;
|
||||
INSERT_PADDING_BYTES(0x1); // Reserved
|
||||
s16 local_communication_version;
|
||||
INSERT_PADDING_BYTES(0x10); // Reserved
|
||||
};
|
||||
static_assert(sizeof(NodeInfo) == 0x40, "NodeInfo is an invalid size");
|
||||
|
||||
struct LdnNetworkInfo {
|
||||
std::array<u8, 0x10> security_parameter;
|
||||
SecurityMode security_mode;
|
||||
AcceptPolicy station_accept_policy;
|
||||
u8 has_action_frame;
|
||||
INSERT_PADDING_BYTES(0x2); // Padding
|
||||
u8 node_count_max;
|
||||
u8 node_count;
|
||||
std::array<NodeInfo, NodeCountMax> nodes;
|
||||
INSERT_PADDING_BYTES(0x2); // Reserved
|
||||
u16 advertise_data_size;
|
||||
std::array<u8, AdvertiseDataSizeMax> advertise_data;
|
||||
INSERT_PADDING_BYTES(0x8C); // Reserved
|
||||
u64 random_authentication_id;
|
||||
};
|
||||
static_assert(sizeof(LdnNetworkInfo) == 0x430, "LdnNetworkInfo is an invalid size");
|
||||
|
||||
struct NetworkInfo {
|
||||
NetworkId network_id;
|
||||
CommonNetworkInfo common;
|
||||
LdnNetworkInfo ldn;
|
||||
};
|
||||
static_assert(sizeof(NetworkInfo) == 0x480, "NetworkInfo is an invalid size");
|
||||
|
||||
struct SecurityConfig {
|
||||
SecurityMode security_mode;
|
||||
u16 passphrase_size;
|
||||
std::array<u8, PassphraseLengthMax> passphrase;
|
||||
};
|
||||
static_assert(sizeof(SecurityConfig) == 0x44, "SecurityConfig is an invalid size");
|
||||
|
||||
struct UserConfig {
|
||||
std::array<u8, UserNameBytesMax + 1> user_name;
|
||||
INSERT_PADDING_BYTES(0xF); // Reserved
|
||||
};
|
||||
static_assert(sizeof(UserConfig) == 0x30, "UserConfig is an invalid size");
|
||||
|
||||
#pragma pack(push, 4)
|
||||
struct ConnectRequest {
|
||||
SecurityConfig security_config;
|
||||
UserConfig user_config;
|
||||
u32 local_communication_version;
|
||||
u32 option_unknown;
|
||||
NetworkInfo network_info;
|
||||
};
|
||||
static_assert(sizeof(ConnectRequest) == 0x4FC, "ConnectRequest is an invalid size");
|
||||
#pragma pack(pop)
|
||||
|
||||
struct SecurityParameter {
|
||||
std::array<u8, 0x10> data; // Data, used with the same key derivation as SecurityConfig
|
||||
SessionId session_id;
|
||||
};
|
||||
static_assert(sizeof(SecurityParameter) == 0x20, "SecurityParameter is an invalid size");
|
||||
|
||||
struct NetworkConfig {
|
||||
IntentId intent_id;
|
||||
WifiChannel channel;
|
||||
u8 node_count_max;
|
||||
INSERT_PADDING_BYTES(0x1); // Reserved
|
||||
u16 local_communication_version;
|
||||
INSERT_PADDING_BYTES(0xA); // Reserved
|
||||
};
|
||||
static_assert(sizeof(NetworkConfig) == 0x20, "NetworkConfig is an invalid size");
|
||||
|
||||
struct AddressEntry {
|
||||
Ipv4Address ipv4_address;
|
||||
MacAddress mac_address;
|
||||
INSERT_PADDING_BYTES(0x2); // Reserved
|
||||
};
|
||||
static_assert(sizeof(AddressEntry) == 0xC, "AddressEntry is an invalid size");
|
||||
|
||||
struct AddressList {
|
||||
std::array<AddressEntry, 0x8> addresses;
|
||||
};
|
||||
static_assert(sizeof(AddressList) == 0x60, "AddressList is an invalid size");
|
||||
|
||||
} // namespace Service::LDN
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "core/hle/kernel/k_event.h"
|
||||
#include "core/hle/service/kernel_helpers.h"
|
||||
#include "core/hle/service/nifm/nifm.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -271,142 +270,45 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class IGeneralService final : public ServiceFramework<IGeneralService> {
|
||||
public:
|
||||
explicit IGeneralService(Core::System& system_);
|
||||
void IGeneralService::GetClientId(Kernel::HLERequestContext& ctx) {
|
||||
static constexpr u32 client_id = 1;
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
private:
|
||||
void GetClientId(Kernel::HLERequestContext& ctx) {
|
||||
static constexpr u32 client_id = 1;
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u64>(client_id); // Client ID needs to be non zero otherwise it's considered invalid
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u64>(client_id); // Client ID needs to be non zero otherwise it's considered invalid
|
||||
}
|
||||
void IGeneralService::CreateScanRequest(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
|
||||
void CreateScanRequest(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IScanRequest>(system);
|
||||
}
|
||||
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IScanRequest>(system);
|
||||
}
|
||||
void IGeneralService::CreateRequest(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
|
||||
void CreateRequest(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IRequest>(system);
|
||||
}
|
||||
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<IRequest>(system);
|
||||
}
|
||||
void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
const auto net_iface = Network::GetSelectedNetworkInterface();
|
||||
|
||||
const auto net_iface = Network::GetSelectedNetworkInterface();
|
||||
|
||||
const SfNetworkProfileData network_profile_data = [&net_iface] {
|
||||
if (!net_iface) {
|
||||
return SfNetworkProfileData{};
|
||||
}
|
||||
|
||||
return SfNetworkProfileData{
|
||||
.ip_setting_data{
|
||||
.ip_address_setting{
|
||||
.is_automatic{true},
|
||||
.current_address{Network::TranslateIPv4(net_iface->ip_address)},
|
||||
.subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
|
||||
.gateway{Network::TranslateIPv4(net_iface->gateway)},
|
||||
},
|
||||
.dns_setting{
|
||||
.is_automatic{true},
|
||||
.primary_dns{1, 1, 1, 1},
|
||||
.secondary_dns{1, 0, 0, 1},
|
||||
},
|
||||
.proxy_setting{
|
||||
.enabled{false},
|
||||
.port{},
|
||||
.proxy_server{},
|
||||
.automatic_auth_enabled{},
|
||||
.user{},
|
||||
.password{},
|
||||
},
|
||||
.mtu{1500},
|
||||
},
|
||||
.uuid{0xdeadbeef, 0xdeadbeef},
|
||||
.network_name{"yuzu Network"},
|
||||
.wireless_setting_data{
|
||||
.ssid_length{12},
|
||||
.ssid{"yuzu Network"},
|
||||
.passphrase{"yuzupassword"},
|
||||
},
|
||||
};
|
||||
}();
|
||||
|
||||
ctx.WriteBuffer(network_profile_data);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void GetCurrentIpAddress(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
auto ipv4 = Network::GetHostIPv4Address();
|
||||
if (!ipv4) {
|
||||
LOG_ERROR(Service_NIFM, "Couldn't get host IPv4 address, defaulting to 0.0.0.0");
|
||||
ipv4.emplace(Network::IPv4Address{0, 0, 0, 0});
|
||||
SfNetworkProfileData network_profile_data = [&net_iface] {
|
||||
if (!net_iface) {
|
||||
return SfNetworkProfileData{};
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(*ipv4);
|
||||
}
|
||||
|
||||
void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
|
||||
ASSERT_MSG(ctx.GetReadBufferSize() == 0x17c,
|
||||
"SfNetworkProfileData is not the correct size");
|
||||
u128 uuid{};
|
||||
auto buffer = ctx.ReadBuffer();
|
||||
std::memcpy(&uuid, buffer.data() + 8, sizeof(u128));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6, 0, 1};
|
||||
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<INetworkProfile>(system);
|
||||
rb.PushRaw<u128>(uuid);
|
||||
}
|
||||
|
||||
void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
struct IpConfigInfo {
|
||||
IpAddressSetting ip_address_setting{};
|
||||
DnsSetting dns_setting{};
|
||||
};
|
||||
static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting),
|
||||
"IpConfigInfo has incorrect size.");
|
||||
|
||||
const auto net_iface = Network::GetSelectedNetworkInterface();
|
||||
|
||||
const IpConfigInfo ip_config_info = [&net_iface] {
|
||||
if (!net_iface) {
|
||||
return IpConfigInfo{};
|
||||
}
|
||||
|
||||
return IpConfigInfo{
|
||||
return SfNetworkProfileData{
|
||||
.ip_setting_data{
|
||||
.ip_address_setting{
|
||||
.is_automatic{true},
|
||||
.current_address{Network::TranslateIPv4(net_iface->ip_address)},
|
||||
@@ -418,66 +320,178 @@ private:
|
||||
.primary_dns{1, 1, 1, 1},
|
||||
.secondary_dns{1, 0, 0, 1},
|
||||
},
|
||||
};
|
||||
}();
|
||||
.proxy_setting{
|
||||
.enabled{false},
|
||||
.port{},
|
||||
.proxy_server{},
|
||||
.automatic_auth_enabled{},
|
||||
.user{},
|
||||
.password{},
|
||||
},
|
||||
.mtu{1500},
|
||||
},
|
||||
.uuid{0xdeadbeef, 0xdeadbeef},
|
||||
.network_name{"yuzu Network"},
|
||||
.wireless_setting_data{
|
||||
.ssid_length{12},
|
||||
.ssid{"yuzu Network"},
|
||||
.passphrase{"yuzupassword"},
|
||||
},
|
||||
};
|
||||
}();
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw<IpConfigInfo>(ip_config_info);
|
||||
// When we're connected to a room, spoof the hosts IP address
|
||||
if (auto room_member = network.GetRoomMember().lock()) {
|
||||
if (room_member->IsConnected()) {
|
||||
network_profile_data.ip_setting_data.ip_address_setting.current_address =
|
||||
room_member->GetFakeIpAddress();
|
||||
}
|
||||
}
|
||||
|
||||
void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
ctx.WriteBuffer(network_profile_data);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IGeneralService::RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
|
||||
void IGeneralService::GetCurrentIpAddress(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
auto ipv4 = Network::GetHostIPv4Address();
|
||||
if (!ipv4) {
|
||||
LOG_ERROR(Service_NIFM, "Couldn't get host IPv4 address, defaulting to 0.0.0.0");
|
||||
ipv4.emplace(Network::IPv4Address{0, 0, 0, 0});
|
||||
}
|
||||
|
||||
// When we're connected to a room, spoof the hosts IP address
|
||||
if (auto room_member = network.GetRoomMember().lock()) {
|
||||
if (room_member->IsConnected()) {
|
||||
ipv4 = room_member->GetFakeIpAddress();
|
||||
}
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(*ipv4);
|
||||
}
|
||||
|
||||
void IGeneralService::CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_NIFM, "called");
|
||||
|
||||
ASSERT_MSG(ctx.GetReadBufferSize() == 0x17c, "SfNetworkProfileData is not the correct size");
|
||||
u128 uuid{};
|
||||
auto buffer = ctx.ReadBuffer();
|
||||
std::memcpy(&uuid, buffer.data() + 8, sizeof(u128));
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6, 0, 1};
|
||||
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushIpcInterface<INetworkProfile>(system);
|
||||
rb.PushRaw<u128>(uuid);
|
||||
}
|
||||
|
||||
void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
struct IpConfigInfo {
|
||||
IpAddressSetting ip_address_setting{};
|
||||
DnsSetting dns_setting{};
|
||||
};
|
||||
static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting),
|
||||
"IpConfigInfo has incorrect size.");
|
||||
|
||||
const auto net_iface = Network::GetSelectedNetworkInterface();
|
||||
|
||||
IpConfigInfo ip_config_info = [&net_iface] {
|
||||
if (!net_iface) {
|
||||
return IpConfigInfo{};
|
||||
}
|
||||
|
||||
return IpConfigInfo{
|
||||
.ip_address_setting{
|
||||
.is_automatic{true},
|
||||
.current_address{Network::TranslateIPv4(net_iface->ip_address)},
|
||||
.subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
|
||||
.gateway{Network::TranslateIPv4(net_iface->gateway)},
|
||||
},
|
||||
.dns_setting{
|
||||
.is_automatic{true},
|
||||
.primary_dns{1, 1, 1, 1},
|
||||
.secondary_dns{1, 0, 0, 1},
|
||||
},
|
||||
};
|
||||
}();
|
||||
|
||||
// When we're connected to a room, spoof the hosts IP address
|
||||
if (auto room_member = network.GetRoomMember().lock()) {
|
||||
if (room_member->IsConnected()) {
|
||||
ip_config_info.ip_address_setting.current_address = room_member->GetFakeIpAddress();
|
||||
}
|
||||
}
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2 + (sizeof(IpConfigInfo) + 3) / sizeof(u32)};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw<IpConfigInfo>(ip_config_info);
|
||||
}
|
||||
|
||||
void IGeneralService::IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push<u8>(1);
|
||||
}
|
||||
|
||||
void IGeneralService::GetInternetConnectionStatus(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
struct Output {
|
||||
InternetConnectionType type{InternetConnectionType::WiFi};
|
||||
u8 wifi_strength{3};
|
||||
InternetConnectionStatus state{InternetConnectionStatus::Connected};
|
||||
};
|
||||
static_assert(sizeof(Output) == 0x3, "Output has incorrect size.");
|
||||
|
||||
constexpr Output out{};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(out);
|
||||
}
|
||||
|
||||
void IGeneralService::IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
if (Network::GetHostIPv4Address().has_value()) {
|
||||
rb.Push<u8>(1);
|
||||
} else {
|
||||
rb.Push<u8>(0);
|
||||
}
|
||||
}
|
||||
|
||||
void GetInternetConnectionStatus(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
void IGeneralService::IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx) {
|
||||
LOG_ERROR(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
struct Output {
|
||||
InternetConnectionType type{InternetConnectionType::WiFi};
|
||||
u8 wifi_strength{3};
|
||||
InternetConnectionStatus state{InternetConnectionStatus::Connected};
|
||||
};
|
||||
static_assert(sizeof(Output) == 0x3, "Output has incorrect size.");
|
||||
|
||||
constexpr Output out{};
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.PushRaw(out);
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
if (Network::GetHostIPv4Address().has_value()) {
|
||||
rb.Push<u8>(1);
|
||||
} else {
|
||||
rb.Push<u8>(0);
|
||||
}
|
||||
|
||||
void IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
if (Network::GetHostIPv4Address().has_value()) {
|
||||
rb.Push<u8>(1);
|
||||
} else {
|
||||
rb.Push<u8>(0);
|
||||
}
|
||||
}
|
||||
|
||||
void IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx) {
|
||||
LOG_WARNING(Service_NIFM, "(STUBBED) called");
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
if (Network::GetHostIPv4Address().has_value()) {
|
||||
rb.Push<u8>(1);
|
||||
} else {
|
||||
rb.Push<u8>(0);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
IGeneralService::IGeneralService(Core::System& system_)
|
||||
: ServiceFramework{system_, "IGeneralService"} {
|
||||
: ServiceFramework{system_, "IGeneralService"}, network{system_.GetRoomNetwork()} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &IGeneralService::GetClientId, "GetClientId"},
|
||||
@@ -528,6 +542,8 @@ IGeneralService::IGeneralService(Core::System& system_)
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
IGeneralService::~IGeneralService() = default;
|
||||
|
||||
class NetworkInterface final : public ServiceFramework<NetworkInterface> {
|
||||
public:
|
||||
explicit NetworkInterface(const char* name, Core::System& system_)
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/hle/service/service.h"
|
||||
#include "network/network.h"
|
||||
#include "network/room.h"
|
||||
#include "network/room_member.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
@@ -16,4 +21,26 @@ namespace Service::NIFM {
|
||||
/// Registers all NIFM services with the specified service manager.
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
||||
|
||||
class IGeneralService final : public ServiceFramework<IGeneralService> {
|
||||
public:
|
||||
explicit IGeneralService(Core::System& system_);
|
||||
~IGeneralService() override;
|
||||
|
||||
private:
|
||||
void GetClientId(Kernel::HLERequestContext& ctx);
|
||||
void CreateScanRequest(Kernel::HLERequestContext& ctx);
|
||||
void CreateRequest(Kernel::HLERequestContext& ctx);
|
||||
void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx);
|
||||
void RemoveNetworkProfile(Kernel::HLERequestContext& ctx);
|
||||
void GetCurrentIpAddress(Kernel::HLERequestContext& ctx);
|
||||
void CreateTemporaryNetworkProfile(Kernel::HLERequestContext& ctx);
|
||||
void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx);
|
||||
void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx);
|
||||
void GetInternetConnectionStatus(Kernel::HLERequestContext& ctx);
|
||||
void IsEthernetCommunicationEnabled(Kernel::HLERequestContext& ctx);
|
||||
void IsAnyInternetRequestAccepted(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Network::RoomNetwork& network;
|
||||
};
|
||||
|
||||
} // namespace Service::NIFM
|
||||
|
||||
@@ -9,12 +9,16 @@
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "common/microprofile.h"
|
||||
#include "common/socket_types.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/k_thread.h"
|
||||
#include "core/hle/service/sockets/bsd.h"
|
||||
#include "core/hle/service/sockets/sockets_translate.h"
|
||||
#include "core/internal_network/network.h"
|
||||
#include "core/internal_network/socket_proxy.h"
|
||||
#include "core/internal_network/sockets.h"
|
||||
#include "network/network.h"
|
||||
|
||||
namespace Service::Sockets {
|
||||
|
||||
@@ -472,7 +476,13 @@ std::pair<s32, Errno> BSD::SocketImpl(Domain domain, Type type, Protocol protoco
|
||||
|
||||
LOG_INFO(Service, "New socket fd={}", fd);
|
||||
|
||||
descriptor.socket = std::make_unique<Network::Socket>();
|
||||
auto room_member = room_network.GetRoomMember().lock();
|
||||
if (room_member && room_member->IsConnected()) {
|
||||
descriptor.socket = std::make_unique<Network::ProxySocket>(room_network);
|
||||
} else {
|
||||
descriptor.socket = std::make_unique<Network::Socket>();
|
||||
}
|
||||
|
||||
descriptor.socket->Initialize(Translate(domain), Translate(type), Translate(type, protocol));
|
||||
descriptor.is_connection_based = IsConnectionBased(type);
|
||||
|
||||
@@ -648,7 +658,7 @@ std::pair<s32, Errno> BSD::FcntlImpl(s32 fd, FcntlCmd cmd, s32 arg) {
|
||||
ASSERT(arg == 0);
|
||||
return {descriptor.flags, Errno::SUCCESS};
|
||||
case FcntlCmd::SETFL: {
|
||||
const bool enable = (arg & FLAG_O_NONBLOCK) != 0;
|
||||
const bool enable = (arg & Network::FLAG_O_NONBLOCK) != 0;
|
||||
const Errno bsd_errno = Translate(descriptor.socket->SetNonBlock(enable));
|
||||
if (bsd_errno != Errno::SUCCESS) {
|
||||
return {-1, bsd_errno};
|
||||
@@ -669,7 +679,7 @@ Errno BSD::SetSockOptImpl(s32 fd, u32 level, OptName optname, size_t optlen, con
|
||||
return Errno::BADF;
|
||||
}
|
||||
|
||||
Network::Socket* const socket = file_descriptors[fd]->socket.get();
|
||||
Network::SocketBase* const socket = file_descriptors[fd]->socket.get();
|
||||
|
||||
if (optname == OptName::LINGER) {
|
||||
ASSERT(optlen == sizeof(Linger));
|
||||
@@ -724,6 +734,8 @@ std::pair<s32, Errno> BSD::RecvImpl(s32 fd, u32 flags, std::vector<u8>& message)
|
||||
FileDescriptor& descriptor = *file_descriptors[fd];
|
||||
|
||||
// Apply flags
|
||||
using Network::FLAG_MSG_DONTWAIT;
|
||||
using Network::FLAG_O_NONBLOCK;
|
||||
if ((flags & FLAG_MSG_DONTWAIT) != 0) {
|
||||
flags &= ~FLAG_MSG_DONTWAIT;
|
||||
if ((descriptor.flags & FLAG_O_NONBLOCK) == 0) {
|
||||
@@ -759,6 +771,8 @@ std::pair<s32, Errno> BSD::RecvFromImpl(s32 fd, u32 flags, std::vector<u8>& mess
|
||||
}
|
||||
|
||||
// Apply flags
|
||||
using Network::FLAG_MSG_DONTWAIT;
|
||||
using Network::FLAG_O_NONBLOCK;
|
||||
if ((flags & FLAG_MSG_DONTWAIT) != 0) {
|
||||
flags &= ~FLAG_MSG_DONTWAIT;
|
||||
if ((descriptor.flags & FLAG_O_NONBLOCK) == 0) {
|
||||
@@ -857,8 +871,19 @@ void BSD::BuildErrnoResponse(Kernel::HLERequestContext& ctx, Errno bsd_errno) co
|
||||
rb.PushEnum(bsd_errno);
|
||||
}
|
||||
|
||||
void BSD::OnProxyPacketReceived(const Network::ProxyPacket& packet) {
|
||||
for (auto& optional_descriptor : file_descriptors) {
|
||||
if (!optional_descriptor.has_value()) {
|
||||
continue;
|
||||
}
|
||||
FileDescriptor& descriptor = *optional_descriptor;
|
||||
descriptor.socket.get()->HandleProxyPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
BSD::BSD(Core::System& system_, const char* name)
|
||||
: ServiceFramework{system_, name, ServiceThreadType::CreateNew} {
|
||||
: ServiceFramework{system_, name, ServiceThreadType::CreateNew}, room_network{
|
||||
system_.GetRoomNetwork()} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &BSD::RegisterClient, "RegisterClient"},
|
||||
@@ -899,6 +924,13 @@ BSD::BSD(Core::System& system_, const char* name)
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
if (auto room_member = room_network.GetRoomMember().lock()) {
|
||||
proxy_packet_received = room_member->BindOnProxyPacketReceived(
|
||||
[this](const Network::ProxyPacket& packet) { OnProxyPacketReceived(packet); });
|
||||
} else {
|
||||
LOG_ERROR(Service, "Network isn't initalized");
|
||||
}
|
||||
}
|
||||
|
||||
BSD::~BSD() = default;
|
||||
|
||||
@@ -7,14 +7,17 @@
|
||||
#include <vector>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "common/socket_types.h"
|
||||
#include "core/hle/service/service.h"
|
||||
#include "core/hle/service/sockets/sockets.h"
|
||||
#include "network/network.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Network {
|
||||
class SocketBase;
|
||||
class Socket;
|
||||
} // namespace Network
|
||||
|
||||
@@ -30,7 +33,7 @@ private:
|
||||
static constexpr size_t MAX_FD = 128;
|
||||
|
||||
struct FileDescriptor {
|
||||
std::unique_ptr<Network::Socket> socket;
|
||||
std::unique_ptr<Network::SocketBase> socket;
|
||||
s32 flags = 0;
|
||||
bool is_connection_based = false;
|
||||
};
|
||||
@@ -165,6 +168,14 @@ private:
|
||||
void BuildErrnoResponse(Kernel::HLERequestContext& ctx, Errno bsd_errno) const noexcept;
|
||||
|
||||
std::array<std::optional<FileDescriptor>, MAX_FD> file_descriptors;
|
||||
|
||||
Network::RoomNetwork& room_network;
|
||||
|
||||
/// Callback to parse and handle a received wifi packet.
|
||||
void OnProxyPacketReceived(const Network::ProxyPacket& packet);
|
||||
|
||||
// Callback identifier for the OnProxyPacketReceived event.
|
||||
Network::RoomMember::CallbackHandle<Network::ProxyPacket> proxy_packet_received;
|
||||
};
|
||||
|
||||
class BSDCFG final : public ServiceFramework<BSDCFG> {
|
||||
|
||||
@@ -22,7 +22,9 @@ enum class Errno : u32 {
|
||||
AGAIN = 11,
|
||||
INVAL = 22,
|
||||
MFILE = 24,
|
||||
MSGSIZE = 90,
|
||||
NOTCONN = 107,
|
||||
TIMEDOUT = 110,
|
||||
};
|
||||
|
||||
enum class Domain : u32 {
|
||||
@@ -96,10 +98,6 @@ struct Linger {
|
||||
u32 linger;
|
||||
};
|
||||
|
||||
constexpr u32 FLAG_MSG_DONTWAIT = 0x80;
|
||||
|
||||
constexpr u32 FLAG_O_NONBLOCK = 0x800;
|
||||
|
||||
/// Registers all Sockets services with the specified service manager.
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ Errno Translate(Network::Errno value) {
|
||||
return Errno::MFILE;
|
||||
case Network::Errno::NOTCONN:
|
||||
return Errno::NOTCONN;
|
||||
case Network::Errno::TIMEDOUT:
|
||||
return Errno::TIMEDOUT;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented errno={}", value);
|
||||
return Errno::SUCCESS;
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "core/internal_network/network.h"
|
||||
#include "core/internal_network/network_interface.h"
|
||||
#include "core/internal_network/sockets.h"
|
||||
#include "network/network.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
@@ -114,7 +115,10 @@ Errno TranslateNativeError(int e) {
|
||||
return Errno::NETDOWN;
|
||||
case WSAENETUNREACH:
|
||||
return Errno::NETUNREACH;
|
||||
case WSAEMSGSIZE:
|
||||
return Errno::MSGSIZE;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented errno={}", e);
|
||||
return Errno::OTHER;
|
||||
}
|
||||
}
|
||||
@@ -125,7 +129,6 @@ using SOCKET = int;
|
||||
using WSAPOLLFD = pollfd;
|
||||
using ULONG = u64;
|
||||
|
||||
constexpr SOCKET INVALID_SOCKET = -1;
|
||||
constexpr SOCKET SOCKET_ERROR = -1;
|
||||
|
||||
constexpr int SD_RECEIVE = SHUT_RD;
|
||||
@@ -206,7 +209,10 @@ Errno TranslateNativeError(int e) {
|
||||
return Errno::NETDOWN;
|
||||
case ENETUNREACH:
|
||||
return Errno::NETUNREACH;
|
||||
case EMSGSIZE:
|
||||
return Errno::MSGSIZE;
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unimplemented errno={}", e);
|
||||
return Errno::OTHER;
|
||||
}
|
||||
}
|
||||
@@ -329,16 +335,6 @@ PollEvents TranslatePollRevents(short revents) {
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Errno SetSockOpt(SOCKET fd, int option, T value) {
|
||||
const int result =
|
||||
setsockopt(fd, SOL_SOCKET, option, reinterpret_cast<const char*>(&value), sizeof(value));
|
||||
if (result != SOCKET_ERROR) {
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
return GetAndLogLastError();
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
NetworkInstance::NetworkInstance() {
|
||||
@@ -350,26 +346,16 @@ NetworkInstance::~NetworkInstance() {
|
||||
}
|
||||
|
||||
std::optional<IPv4Address> GetHostIPv4Address() {
|
||||
const std::string& selected_network_interface = Settings::values.network_interface.GetValue();
|
||||
const auto network_interfaces = Network::GetAvailableNetworkInterfaces();
|
||||
if (network_interfaces.size() == 0) {
|
||||
LOG_ERROR(Network, "GetAvailableNetworkInterfaces returned no interfaces");
|
||||
const auto network_interface = Network::GetSelectedNetworkInterface();
|
||||
if (!network_interface.has_value()) {
|
||||
LOG_ERROR(Network, "GetSelectedNetworkInterface returned no interface");
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto res =
|
||||
std::ranges::find_if(network_interfaces, [&selected_network_interface](const auto& iface) {
|
||||
return iface.name == selected_network_interface;
|
||||
});
|
||||
|
||||
if (res != network_interfaces.end()) {
|
||||
char ip_addr[16] = {};
|
||||
ASSERT(inet_ntop(AF_INET, &res->ip_address, ip_addr, sizeof(ip_addr)) != nullptr);
|
||||
return TranslateIPv4(res->ip_address);
|
||||
} else {
|
||||
LOG_ERROR(Network, "Couldn't find selected interface \"{}\"", selected_network_interface);
|
||||
return {};
|
||||
}
|
||||
std::array<char, 16> ip_addr = {};
|
||||
ASSERT(inet_ntop(AF_INET, &network_interface->ip_address, ip_addr.data(), sizeof(ip_addr)) !=
|
||||
nullptr);
|
||||
return TranslateIPv4(network_interface->ip_address);
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> Poll(std::vector<PollFD>& pollfds, s32 timeout) {
|
||||
@@ -412,7 +398,19 @@ Socket::~Socket() {
|
||||
fd = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
Socket::Socket(Socket&& rhs) noexcept : fd{std::exchange(rhs.fd, INVALID_SOCKET)} {}
|
||||
Socket::Socket(Socket&& rhs) noexcept {
|
||||
fd = std::exchange(rhs.fd, INVALID_SOCKET);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Errno Socket::SetSockOpt(SOCKET fd_, int option, T value) {
|
||||
const int result =
|
||||
setsockopt(fd_, SOL_SOCKET, option, reinterpret_cast<const char*>(&value), sizeof(value));
|
||||
if (result != SOCKET_ERROR) {
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
return GetAndLogLastError();
|
||||
}
|
||||
|
||||
Errno Socket::Initialize(Domain domain, Type type, Protocol protocol) {
|
||||
fd = socket(TranslateDomain(domain), TranslateType(type), TranslateProtocol(protocol));
|
||||
@@ -423,7 +421,7 @@ Errno Socket::Initialize(Domain domain, Type type, Protocol protocol) {
|
||||
return GetAndLogLastError();
|
||||
}
|
||||
|
||||
std::pair<Socket::AcceptResult, Errno> Socket::Accept() {
|
||||
std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
|
||||
sockaddr addr;
|
||||
socklen_t addrlen = sizeof(addr);
|
||||
const SOCKET new_socket = accept(fd, &addr, &addrlen);
|
||||
@@ -634,4 +632,8 @@ bool Socket::IsOpened() const {
|
||||
return fd != INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void Socket::HandleProxyPacket(const ProxyPacket& packet) {
|
||||
LOG_WARNING(Network, "ProxyPacket received, but not in Proxy mode!");
|
||||
}
|
||||
|
||||
} // namespace Network
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/socket_types.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <winsock2.h>
|
||||
@@ -17,6 +18,7 @@
|
||||
|
||||
namespace Network {
|
||||
|
||||
class SocketBase;
|
||||
class Socket;
|
||||
|
||||
/// Error code for network functions
|
||||
@@ -31,46 +33,11 @@ enum class Errno {
|
||||
HOSTUNREACH,
|
||||
NETDOWN,
|
||||
NETUNREACH,
|
||||
TIMEDOUT,
|
||||
MSGSIZE,
|
||||
OTHER,
|
||||
};
|
||||
|
||||
/// Address families
|
||||
enum class Domain {
|
||||
INET, ///< Address family for IPv4
|
||||
};
|
||||
|
||||
/// Socket types
|
||||
enum class Type {
|
||||
STREAM,
|
||||
DGRAM,
|
||||
RAW,
|
||||
SEQPACKET,
|
||||
};
|
||||
|
||||
/// Protocol values for sockets
|
||||
enum class Protocol {
|
||||
ICMP,
|
||||
TCP,
|
||||
UDP,
|
||||
};
|
||||
|
||||
/// Shutdown mode
|
||||
enum class ShutdownHow {
|
||||
RD,
|
||||
WR,
|
||||
RDWR,
|
||||
};
|
||||
|
||||
/// Array of IPv4 address
|
||||
using IPv4Address = std::array<u8, 4>;
|
||||
|
||||
/// Cross-platform sockaddr structure
|
||||
struct SockAddrIn {
|
||||
Domain family;
|
||||
IPv4Address ip;
|
||||
u16 portno;
|
||||
};
|
||||
|
||||
/// Cross-platform poll fd structure
|
||||
|
||||
enum class PollEvents : u16 {
|
||||
@@ -86,7 +53,7 @@ enum class PollEvents : u16 {
|
||||
DECLARE_ENUM_FLAG_OPERATORS(PollEvents);
|
||||
|
||||
struct PollFD {
|
||||
Socket* socket;
|
||||
SocketBase* socket;
|
||||
PollEvents events;
|
||||
PollEvents revents;
|
||||
};
|
||||
|
||||
284
src/core/internal_network/socket_proxy.cpp
Normal file
@@ -0,0 +1,284 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/internal_network/network.h"
|
||||
#include "core/internal_network/network_interface.h"
|
||||
#include "core/internal_network/socket_proxy.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
ProxySocket::ProxySocket(RoomNetwork& room_network_) noexcept : room_network{room_network_} {}
|
||||
|
||||
ProxySocket::~ProxySocket() {
|
||||
if (fd == INVALID_SOCKET) {
|
||||
return;
|
||||
}
|
||||
fd = INVALID_SOCKET;
|
||||
}
|
||||
|
||||
void ProxySocket::HandleProxyPacket(const ProxyPacket& packet) {
|
||||
if (protocol != packet.protocol || local_endpoint.portno != packet.remote_endpoint.portno ||
|
||||
closed) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard guard(packets_mutex);
|
||||
received_packets.push(packet);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Errno ProxySocket::SetSockOpt(SOCKET fd_, int option, T value) {
|
||||
LOG_DEBUG(Network, "(STUBBED) called");
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
Errno ProxySocket::Initialize(Domain domain, Type type, Protocol socket_protocol) {
|
||||
protocol = socket_protocol;
|
||||
SetSockOpt(fd, SO_TYPE, type);
|
||||
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
std::pair<ProxySocket::AcceptResult, Errno> ProxySocket::Accept() {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
return {AcceptResult{}, Errno::SUCCESS};
|
||||
}
|
||||
|
||||
Errno ProxySocket::Connect(SockAddrIn addr_in) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
std::pair<SockAddrIn, Errno> ProxySocket::GetPeerName() {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
return {SockAddrIn{}, Errno::SUCCESS};
|
||||
}
|
||||
|
||||
std::pair<SockAddrIn, Errno> ProxySocket::GetSockName() {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
return {SockAddrIn{}, Errno::SUCCESS};
|
||||
}
|
||||
|
||||
Errno ProxySocket::Bind(SockAddrIn addr) {
|
||||
if (is_bound) {
|
||||
LOG_WARNING(Network, "Rebinding Socket is unimplemented!");
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
local_endpoint = addr;
|
||||
is_bound = true;
|
||||
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
Errno ProxySocket::Listen(s32 backlog) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
Errno ProxySocket::Shutdown(ShutdownHow how) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::Recv(int flags, std::vector<u8>& message) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
|
||||
return {static_cast<s32>(0), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr) {
|
||||
ASSERT(flags == 0);
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
|
||||
// TODO (flTobi): Verify the timeout behavior and break when connection is lost
|
||||
const auto timestamp = std::chrono::steady_clock::now();
|
||||
// When receive_timeout is set to zero, the socket is supposed to wait indefinitely until a
|
||||
// packet arrives. In order to prevent lost packets from hanging the emulation thread, we set
|
||||
// the timeout to 5s instead
|
||||
const auto timeout = receive_timeout == 0 ? 5000 : receive_timeout;
|
||||
while (true) {
|
||||
{
|
||||
std::lock_guard guard(packets_mutex);
|
||||
if (received_packets.size() > 0) {
|
||||
return ReceivePacket(flags, message, addr, message.size());
|
||||
}
|
||||
}
|
||||
|
||||
if (!blocking) {
|
||||
return {-1, Errno::AGAIN};
|
||||
}
|
||||
|
||||
std::this_thread::yield();
|
||||
|
||||
const auto time_diff = std::chrono::steady_clock::now() - timestamp;
|
||||
const auto time_diff_ms =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(time_diff).count();
|
||||
|
||||
if (time_diff_ms > timeout) {
|
||||
return {-1, Errno::TIMEDOUT};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::ReceivePacket(int flags, std::vector<u8>& message,
|
||||
SockAddrIn* addr, std::size_t max_length) {
|
||||
ProxyPacket& packet = received_packets.front();
|
||||
if (addr) {
|
||||
addr->family = Domain::INET;
|
||||
addr->ip = packet.local_endpoint.ip; // The senders ip address
|
||||
addr->portno = packet.local_endpoint.portno; // The senders port number
|
||||
}
|
||||
|
||||
bool peek = (flags & FLAG_MSG_PEEK) != 0;
|
||||
std::size_t read_bytes;
|
||||
if (packet.data.size() > max_length) {
|
||||
read_bytes = max_length;
|
||||
message.clear();
|
||||
std::copy(packet.data.begin(), packet.data.begin() + read_bytes,
|
||||
std::back_inserter(message));
|
||||
message.resize(max_length);
|
||||
|
||||
if (protocol == Protocol::UDP) {
|
||||
if (!peek) {
|
||||
received_packets.pop();
|
||||
}
|
||||
return {-1, Errno::MSGSIZE};
|
||||
} else if (protocol == Protocol::TCP) {
|
||||
std::vector<u8> numArray(packet.data.size() - max_length);
|
||||
std::copy(packet.data.begin() + max_length, packet.data.end(),
|
||||
std::back_inserter(numArray));
|
||||
packet.data = numArray;
|
||||
}
|
||||
} else {
|
||||
read_bytes = packet.data.size();
|
||||
message.clear();
|
||||
std::copy(packet.data.begin(), packet.data.end(), std::back_inserter(message));
|
||||
message.resize(max_length);
|
||||
if (!peek) {
|
||||
received_packets.pop();
|
||||
}
|
||||
}
|
||||
|
||||
return {static_cast<u32>(read_bytes), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::Send(const std::vector<u8>& message, int flags) {
|
||||
LOG_WARNING(Network, "(STUBBED) called");
|
||||
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
|
||||
ASSERT(flags == 0);
|
||||
|
||||
return {static_cast<s32>(0), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
void ProxySocket::SendPacket(ProxyPacket& packet) {
|
||||
if (auto room_member = room_network.GetRoomMember().lock()) {
|
||||
if (room_member->IsConnected()) {
|
||||
room_member->SendProxyPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<s32, Errno> ProxySocket::SendTo(u32 flags, const std::vector<u8>& message,
|
||||
const SockAddrIn* addr) {
|
||||
ASSERT(flags == 0);
|
||||
|
||||
if (!is_bound) {
|
||||
LOG_ERROR(Network, "ProxySocket is not bound!");
|
||||
return {static_cast<s32>(message.size()), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
if (auto room_member = room_network.GetRoomMember().lock()) {
|
||||
if (!room_member->IsConnected()) {
|
||||
return {static_cast<s32>(message.size()), Errno::SUCCESS};
|
||||
}
|
||||
}
|
||||
|
||||
ProxyPacket packet;
|
||||
packet.local_endpoint = local_endpoint;
|
||||
packet.remote_endpoint = *addr;
|
||||
packet.protocol = protocol;
|
||||
packet.broadcast = broadcast;
|
||||
|
||||
auto& ip = local_endpoint.ip;
|
||||
auto ipv4 = Network::GetHostIPv4Address();
|
||||
// If the ip is all zeroes (INADDR_ANY) or if it matches the hosts ip address,
|
||||
// replace it with a "fake" routing address
|
||||
if (std::all_of(ip.begin(), ip.end(), [](u8 i) { return i == 0; }) || (ipv4 && ipv4 == ip)) {
|
||||
if (auto room_member = room_network.GetRoomMember().lock()) {
|
||||
packet.local_endpoint.ip = room_member->GetFakeIpAddress();
|
||||
}
|
||||
}
|
||||
|
||||
packet.data.clear();
|
||||
std::copy(message.begin(), message.end(), std::back_inserter(packet.data));
|
||||
|
||||
SendPacket(packet);
|
||||
|
||||
return {static_cast<s32>(message.size()), Errno::SUCCESS};
|
||||
}
|
||||
|
||||
Errno ProxySocket::Close() {
|
||||
fd = INVALID_SOCKET;
|
||||
closed = true;
|
||||
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetLinger(bool enable, u32 linger) {
|
||||
struct Linger {
|
||||
u16 linger_enable;
|
||||
u16 linger_time;
|
||||
} values;
|
||||
values.linger_enable = enable ? 1 : 0;
|
||||
values.linger_time = static_cast<u16>(linger);
|
||||
|
||||
return SetSockOpt(fd, SO_LINGER, values);
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetReuseAddr(bool enable) {
|
||||
return SetSockOpt<u32>(fd, SO_REUSEADDR, enable ? 1 : 0);
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetBroadcast(bool enable) {
|
||||
broadcast = enable;
|
||||
return SetSockOpt<u32>(fd, SO_BROADCAST, enable ? 1 : 0);
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetSndBuf(u32 value) {
|
||||
return SetSockOpt(fd, SO_SNDBUF, value);
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetKeepAlive(bool enable) {
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetRcvBuf(u32 value) {
|
||||
return SetSockOpt(fd, SO_RCVBUF, value);
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetSndTimeo(u32 value) {
|
||||
send_timeout = value;
|
||||
return SetSockOpt(fd, SO_SNDTIMEO, static_cast<int>(value));
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetRcvTimeo(u32 value) {
|
||||
receive_timeout = value;
|
||||
return SetSockOpt(fd, SO_RCVTIMEO, static_cast<int>(value));
|
||||
}
|
||||
|
||||
Errno ProxySocket::SetNonBlock(bool enable) {
|
||||
blocking = !enable;
|
||||
return Errno::SUCCESS;
|
||||
}
|
||||
|
||||
bool ProxySocket::IsOpened() const {
|
||||
return fd != INVALID_SOCKET;
|
||||
}
|
||||
|
||||
} // namespace Network
|
||||
97
src/core/internal_network/socket_proxy.h
Normal file
@@ -0,0 +1,97 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "core/internal_network/sockets.h"
|
||||
#include "network/network.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
class ProxySocket : public SocketBase {
|
||||
public:
|
||||
YUZU_NON_COPYABLE(ProxySocket);
|
||||
YUZU_NON_MOVEABLE(ProxySocket);
|
||||
|
||||
explicit ProxySocket(RoomNetwork& room_network_) noexcept;
|
||||
~ProxySocket() override;
|
||||
|
||||
void HandleProxyPacket(const ProxyPacket& packet) override;
|
||||
|
||||
Errno Initialize(Domain domain, Type type, Protocol socket_protocol) override;
|
||||
|
||||
Errno Close() override;
|
||||
|
||||
std::pair<AcceptResult, Errno> Accept() override;
|
||||
|
||||
Errno Connect(SockAddrIn addr_in) override;
|
||||
|
||||
std::pair<SockAddrIn, Errno> GetPeerName() override;
|
||||
|
||||
std::pair<SockAddrIn, Errno> GetSockName() override;
|
||||
|
||||
Errno Bind(SockAddrIn addr) override;
|
||||
|
||||
Errno Listen(s32 backlog) override;
|
||||
|
||||
Errno Shutdown(ShutdownHow how) override;
|
||||
|
||||
std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message) override;
|
||||
|
||||
std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr) override;
|
||||
|
||||
std::pair<s32, Errno> ReceivePacket(int flags, std::vector<u8>& message, SockAddrIn* addr,
|
||||
std::size_t max_length);
|
||||
|
||||
std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags) override;
|
||||
|
||||
void SendPacket(ProxyPacket& packet);
|
||||
|
||||
std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message,
|
||||
const SockAddrIn* addr) override;
|
||||
|
||||
Errno SetLinger(bool enable, u32 linger) override;
|
||||
|
||||
Errno SetReuseAddr(bool enable) override;
|
||||
|
||||
Errno SetBroadcast(bool enable) override;
|
||||
|
||||
Errno SetKeepAlive(bool enable) override;
|
||||
|
||||
Errno SetSndBuf(u32 value) override;
|
||||
|
||||
Errno SetRcvBuf(u32 value) override;
|
||||
|
||||
Errno SetSndTimeo(u32 value) override;
|
||||
|
||||
Errno SetRcvTimeo(u32 value) override;
|
||||
|
||||
Errno SetNonBlock(bool enable) override;
|
||||
|
||||
template <typename T>
|
||||
Errno SetSockOpt(SOCKET fd, int option, T value);
|
||||
|
||||
bool IsOpened() const override;
|
||||
|
||||
private:
|
||||
bool broadcast = false;
|
||||
bool closed = false;
|
||||
u32 send_timeout = 0;
|
||||
u32 receive_timeout = 0;
|
||||
bool is_bound = false;
|
||||
SockAddrIn local_endpoint{};
|
||||
bool blocking = true;
|
||||
std::queue<ProxyPacket> received_packets;
|
||||
Protocol protocol;
|
||||
|
||||
std::mutex packets_mutex;
|
||||
|
||||
RoomNetwork& room_network;
|
||||
};
|
||||
|
||||
} // namespace Network
|
||||
@@ -14,20 +14,88 @@
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "core/internal_network/network.h"
|
||||
#include "network/network.h"
|
||||
|
||||
// TODO: C++20 Replace std::vector usages with std::span
|
||||
|
||||
namespace Network {
|
||||
|
||||
class Socket {
|
||||
class SocketBase {
|
||||
public:
|
||||
#ifdef YUZU_UNIX
|
||||
using SOCKET = int;
|
||||
static constexpr SOCKET INVALID_SOCKET = -1;
|
||||
static constexpr SOCKET SOCKET_ERROR = -1;
|
||||
#endif
|
||||
|
||||
struct AcceptResult {
|
||||
std::unique_ptr<Socket> socket;
|
||||
std::unique_ptr<SocketBase> socket;
|
||||
SockAddrIn sockaddr_in;
|
||||
};
|
||||
virtual ~SocketBase() = default;
|
||||
|
||||
explicit Socket() = default;
|
||||
~Socket();
|
||||
virtual SocketBase& operator=(const SocketBase&) = delete;
|
||||
|
||||
// Avoid closing sockets implicitly
|
||||
virtual SocketBase& operator=(SocketBase&&) noexcept = delete;
|
||||
|
||||
virtual Errno Initialize(Domain domain, Type type, Protocol protocol) = 0;
|
||||
|
||||
virtual Errno Close() = 0;
|
||||
|
||||
virtual std::pair<AcceptResult, Errno> Accept() = 0;
|
||||
|
||||
virtual Errno Connect(SockAddrIn addr_in) = 0;
|
||||
|
||||
virtual std::pair<SockAddrIn, Errno> GetPeerName() = 0;
|
||||
|
||||
virtual std::pair<SockAddrIn, Errno> GetSockName() = 0;
|
||||
|
||||
virtual Errno Bind(SockAddrIn addr) = 0;
|
||||
|
||||
virtual Errno Listen(s32 backlog) = 0;
|
||||
|
||||
virtual Errno Shutdown(ShutdownHow how) = 0;
|
||||
|
||||
virtual std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message) = 0;
|
||||
|
||||
virtual std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message,
|
||||
SockAddrIn* addr) = 0;
|
||||
|
||||
virtual std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags) = 0;
|
||||
|
||||
virtual std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message,
|
||||
const SockAddrIn* addr) = 0;
|
||||
|
||||
virtual Errno SetLinger(bool enable, u32 linger) = 0;
|
||||
|
||||
virtual Errno SetReuseAddr(bool enable) = 0;
|
||||
|
||||
virtual Errno SetKeepAlive(bool enable) = 0;
|
||||
|
||||
virtual Errno SetBroadcast(bool enable) = 0;
|
||||
|
||||
virtual Errno SetSndBuf(u32 value) = 0;
|
||||
|
||||
virtual Errno SetRcvBuf(u32 value) = 0;
|
||||
|
||||
virtual Errno SetSndTimeo(u32 value) = 0;
|
||||
|
||||
virtual Errno SetRcvTimeo(u32 value) = 0;
|
||||
|
||||
virtual Errno SetNonBlock(bool enable) = 0;
|
||||
|
||||
virtual bool IsOpened() const = 0;
|
||||
|
||||
virtual void HandleProxyPacket(const ProxyPacket& packet) = 0;
|
||||
|
||||
SOCKET fd = INVALID_SOCKET;
|
||||
};
|
||||
|
||||
class Socket : public SocketBase {
|
||||
public:
|
||||
Socket() = default;
|
||||
~Socket() override;
|
||||
|
||||
Socket(const Socket&) = delete;
|
||||
Socket& operator=(const Socket&) = delete;
|
||||
@@ -37,57 +105,57 @@ public:
|
||||
// Avoid closing sockets implicitly
|
||||
Socket& operator=(Socket&&) noexcept = delete;
|
||||
|
||||
Errno Initialize(Domain domain, Type type, Protocol protocol);
|
||||
Errno Initialize(Domain domain, Type type, Protocol protocol) override;
|
||||
|
||||
Errno Close();
|
||||
Errno Close() override;
|
||||
|
||||
std::pair<AcceptResult, Errno> Accept();
|
||||
std::pair<AcceptResult, Errno> Accept() override;
|
||||
|
||||
Errno Connect(SockAddrIn addr_in);
|
||||
Errno Connect(SockAddrIn addr_in) override;
|
||||
|
||||
std::pair<SockAddrIn, Errno> GetPeerName();
|
||||
std::pair<SockAddrIn, Errno> GetPeerName() override;
|
||||
|
||||
std::pair<SockAddrIn, Errno> GetSockName();
|
||||
std::pair<SockAddrIn, Errno> GetSockName() override;
|
||||
|
||||
Errno Bind(SockAddrIn addr);
|
||||
Errno Bind(SockAddrIn addr) override;
|
||||
|
||||
Errno Listen(s32 backlog);
|
||||
Errno Listen(s32 backlog) override;
|
||||
|
||||
Errno Shutdown(ShutdownHow how);
|
||||
Errno Shutdown(ShutdownHow how) override;
|
||||
|
||||
std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message);
|
||||
std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message) override;
|
||||
|
||||
std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr);
|
||||
std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr) override;
|
||||
|
||||
std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags);
|
||||
std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags) override;
|
||||
|
||||
std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message, const SockAddrIn* addr);
|
||||
std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message,
|
||||
const SockAddrIn* addr) override;
|
||||
|
||||
Errno SetLinger(bool enable, u32 linger);
|
||||
Errno SetLinger(bool enable, u32 linger) override;
|
||||
|
||||
Errno SetReuseAddr(bool enable);
|
||||
Errno SetReuseAddr(bool enable) override;
|
||||
|
||||
Errno SetKeepAlive(bool enable);
|
||||
Errno SetKeepAlive(bool enable) override;
|
||||
|
||||
Errno SetBroadcast(bool enable);
|
||||
Errno SetBroadcast(bool enable) override;
|
||||
|
||||
Errno SetSndBuf(u32 value);
|
||||
Errno SetSndBuf(u32 value) override;
|
||||
|
||||
Errno SetRcvBuf(u32 value);
|
||||
Errno SetRcvBuf(u32 value) override;
|
||||
|
||||
Errno SetSndTimeo(u32 value);
|
||||
Errno SetSndTimeo(u32 value) override;
|
||||
|
||||
Errno SetRcvTimeo(u32 value);
|
||||
Errno SetRcvTimeo(u32 value) override;
|
||||
|
||||
Errno SetNonBlock(bool enable);
|
||||
Errno SetNonBlock(bool enable) override;
|
||||
|
||||
bool IsOpened() const;
|
||||
template <typename T>
|
||||
Errno SetSockOpt(SOCKET fd, int option, T value);
|
||||
|
||||
#if defined(_WIN32)
|
||||
SOCKET fd = INVALID_SOCKET;
|
||||
#elif YUZU_UNIX
|
||||
int fd = -1;
|
||||
#endif
|
||||
bool IsOpened() const override;
|
||||
|
||||
void HandleProxyPacket(const ProxyPacket& packet) override;
|
||||
};
|
||||
|
||||
std::pair<s32, Errno> Poll(std::vector<PollFD>& poll_fds, s32 timeout);
|
||||
|
||||
27
src/dedicated_room/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
# SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
|
||||
|
||||
add_executable(yuzu-room
|
||||
yuzu_room.cpp
|
||||
yuzu_room.rc
|
||||
)
|
||||
|
||||
create_target_directory_groups(yuzu-room)
|
||||
|
||||
target_link_libraries(yuzu-room PRIVATE common core network)
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_compile_definitions(yuzu-room PRIVATE -DENABLE_WEB_SERVICE)
|
||||
target_link_libraries(yuzu-room PRIVATE web_service)
|
||||
endif()
|
||||
|
||||
target_link_libraries(yuzu-room PRIVATE mbedtls)
|
||||
if (MSVC)
|
||||
target_link_libraries(yuzu-room PRIVATE getopt)
|
||||
endif()
|
||||
target_link_libraries(yuzu-room PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
|
||||
|
||||
if(UNIX AND NOT APPLE)
|
||||
install(TARGETS yuzu-room RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
|
||||
endif()
|
||||
375
src/dedicated_room/yuzu_room.cpp
Normal file
@@ -0,0 +1,375 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2017 Citra Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#ifdef _WIN32
|
||||
// windows.h needs to be included before shellapi.h
|
||||
#include <windows.h>
|
||||
|
||||
#include <shellapi.h>
|
||||
#endif
|
||||
|
||||
#include <mbedtls/base64.h>
|
||||
#include "common/common_types.h"
|
||||
#include "common/detached_tasks.h"
|
||||
#include "common/fs/file.h"
|
||||
#include "common/fs/fs.h"
|
||||
#include "common/fs/path_util.h"
|
||||
#include "common/logging/backend.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "common/scm_rev.h"
|
||||
#include "common/settings.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/announce_multiplayer_session.h"
|
||||
#include "core/core.h"
|
||||
#include "network/network.h"
|
||||
#include "network/room.h"
|
||||
#include "network/verify_user.h"
|
||||
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
#include "web_service/verify_user_jwt.h"
|
||||
#endif
|
||||
|
||||
#undef _UNICODE
|
||||
#include <getopt.h>
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static void PrintHelp(const char* argv0) {
|
||||
LOG_INFO(Network,
|
||||
"Usage: {}"
|
||||
" [options] <filename>\n"
|
||||
"--room-name The name of the room\n"
|
||||
"--room-description The room description\n"
|
||||
"--port The port used for the room\n"
|
||||
"--max_members The maximum number of players for this room\n"
|
||||
"--password The password for the room\n"
|
||||
"--preferred-game The preferred game for this room\n"
|
||||
"--preferred-game-id The preferred game-id for this room\n"
|
||||
"--username The username used for announce\n"
|
||||
"--token The token used for announce\n"
|
||||
"--web-api-url yuzu Web API url\n"
|
||||
"--ban-list-file The file for storing the room ban list\n"
|
||||
"--log-file The file for storing the room log\n"
|
||||
"--enable-yuzu-mods Allow yuzu Community Moderators to moderate on your room\n"
|
||||
"-h, --help Display this help and exit\n"
|
||||
"-v, --version Output version information and exit\n",
|
||||
argv0);
|
||||
}
|
||||
|
||||
static void PrintVersion() {
|
||||
LOG_INFO(Network, "yuzu dedicated room {} {} Libnetwork: {}", Common::g_scm_branch,
|
||||
Common::g_scm_desc, Network::network_version);
|
||||
}
|
||||
|
||||
/// The magic text at the beginning of a yuzu-room ban list file.
|
||||
static constexpr char BanListMagic[] = "YuzuRoom-BanList-1";
|
||||
|
||||
static constexpr char token_delimiter{':'};
|
||||
|
||||
static std::string UsernameFromDisplayToken(const std::string& display_token) {
|
||||
std::size_t outlen;
|
||||
|
||||
std::array<unsigned char, 512> output{};
|
||||
mbedtls_base64_decode(output.data(), output.size(), &outlen,
|
||||
reinterpret_cast<const unsigned char*>(display_token.c_str()),
|
||||
display_token.length());
|
||||
std::string decoded_display_token(reinterpret_cast<char*>(&output), outlen);
|
||||
return decoded_display_token.substr(0, decoded_display_token.find(token_delimiter));
|
||||
}
|
||||
|
||||
static std::string TokenFromDisplayToken(const std::string& display_token) {
|
||||
std::size_t outlen;
|
||||
|
||||
std::array<unsigned char, 512> output{};
|
||||
mbedtls_base64_decode(output.data(), output.size(), &outlen,
|
||||
reinterpret_cast<const unsigned char*>(display_token.c_str()),
|
||||
display_token.length());
|
||||
std::string decoded_display_token(reinterpret_cast<char*>(&output), outlen);
|
||||
return decoded_display_token.substr(decoded_display_token.find(token_delimiter) + 1);
|
||||
}
|
||||
|
||||
static Network::Room::BanList LoadBanList(const std::string& path) {
|
||||
std::ifstream file;
|
||||
Common::FS::OpenFileStream(file, path, std::ios_base::in);
|
||||
if (!file || file.eof()) {
|
||||
LOG_ERROR(Network, "Could not open ban list!");
|
||||
return {};
|
||||
}
|
||||
std::string magic;
|
||||
std::getline(file, magic);
|
||||
if (magic != BanListMagic) {
|
||||
LOG_ERROR(Network, "Ban list is not valid!");
|
||||
return {};
|
||||
}
|
||||
|
||||
// false = username ban list, true = ip ban list
|
||||
bool ban_list_type = false;
|
||||
Network::Room::UsernameBanList username_ban_list;
|
||||
Network::Room::IPBanList ip_ban_list;
|
||||
while (!file.eof()) {
|
||||
std::string line;
|
||||
std::getline(file, line);
|
||||
line.erase(std::remove(line.begin(), line.end(), '\0'), line.end());
|
||||
line = Common::StripSpaces(line);
|
||||
if (line.empty()) {
|
||||
// An empty line marks start of the IP ban list
|
||||
ban_list_type = true;
|
||||
continue;
|
||||
}
|
||||
if (ban_list_type) {
|
||||
ip_ban_list.emplace_back(line);
|
||||
} else {
|
||||
username_ban_list.emplace_back(line);
|
||||
}
|
||||
}
|
||||
|
||||
return {username_ban_list, ip_ban_list};
|
||||
}
|
||||
|
||||
static void SaveBanList(const Network::Room::BanList& ban_list, const std::string& path) {
|
||||
std::ofstream file;
|
||||
Common::FS::OpenFileStream(file, path, std::ios_base::out);
|
||||
if (!file) {
|
||||
LOG_ERROR(Network, "Could not save ban list!");
|
||||
return;
|
||||
}
|
||||
|
||||
file << BanListMagic << "\n";
|
||||
|
||||
// Username ban list
|
||||
for (const auto& username : ban_list.first) {
|
||||
file << username << "\n";
|
||||
}
|
||||
file << "\n";
|
||||
|
||||
// IP ban list
|
||||
for (const auto& ip : ban_list.second) {
|
||||
file << ip << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
static void InitializeLogging(const std::string& log_file) {
|
||||
Common::Log::Initialize();
|
||||
Common::Log::SetColorConsoleBackendEnabled(true);
|
||||
Common::Log::Start();
|
||||
}
|
||||
|
||||
/// Application entry point
|
||||
int main(int argc, char** argv) {
|
||||
Common::DetachedTasks detached_tasks;
|
||||
int option_index = 0;
|
||||
char* endarg;
|
||||
|
||||
std::string room_name;
|
||||
std::string room_description;
|
||||
std::string password;
|
||||
std::string preferred_game;
|
||||
std::string username;
|
||||
std::string token;
|
||||
std::string web_api_url;
|
||||
std::string ban_list_file;
|
||||
std::string log_file = "yuzu-room.log";
|
||||
u64 preferred_game_id = 0;
|
||||
u32 port = Network::DefaultRoomPort;
|
||||
u32 max_members = 16;
|
||||
bool enable_yuzu_mods = false;
|
||||
|
||||
static struct option long_options[] = {
|
||||
{"room-name", required_argument, 0, 'n'},
|
||||
{"room-description", required_argument, 0, 'd'},
|
||||
{"port", required_argument, 0, 'p'},
|
||||
{"max_members", required_argument, 0, 'm'},
|
||||
{"password", required_argument, 0, 'w'},
|
||||
{"preferred-game", required_argument, 0, 'g'},
|
||||
{"preferred-game-id", required_argument, 0, 'i'},
|
||||
{"username", optional_argument, 0, 'u'},
|
||||
{"token", required_argument, 0, 't'},
|
||||
{"web-api-url", required_argument, 0, 'a'},
|
||||
{"ban-list-file", required_argument, 0, 'b'},
|
||||
{"log-file", required_argument, 0, 'l'},
|
||||
{"enable-yuzu-mods", no_argument, 0, 'e'},
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"version", no_argument, 0, 'v'},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
InitializeLogging(log_file);
|
||||
|
||||
while (optind < argc) {
|
||||
int arg = getopt_long(argc, argv, "n:d:p:m:w:g:u:t:a:i:l:hv", long_options, &option_index);
|
||||
if (arg != -1) {
|
||||
switch (static_cast<char>(arg)) {
|
||||
case 'n':
|
||||
room_name.assign(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
room_description.assign(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
port = strtoul(optarg, &endarg, 0);
|
||||
break;
|
||||
case 'm':
|
||||
max_members = strtoul(optarg, &endarg, 0);
|
||||
break;
|
||||
case 'w':
|
||||
password.assign(optarg);
|
||||
break;
|
||||
case 'g':
|
||||
preferred_game.assign(optarg);
|
||||
break;
|
||||
case 'i':
|
||||
preferred_game_id = strtoull(optarg, &endarg, 16);
|
||||
break;
|
||||
case 'u':
|
||||
username.assign(optarg);
|
||||
break;
|
||||
case 't':
|
||||
token.assign(optarg);
|
||||
break;
|
||||
case 'a':
|
||||
web_api_url.assign(optarg);
|
||||
break;
|
||||
case 'b':
|
||||
ban_list_file.assign(optarg);
|
||||
break;
|
||||
case 'l':
|
||||
log_file.assign(optarg);
|
||||
break;
|
||||
case 'e':
|
||||
enable_yuzu_mods = true;
|
||||
break;
|
||||
case 'h':
|
||||
PrintHelp(argv[0]);
|
||||
return 0;
|
||||
case 'v':
|
||||
PrintVersion();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (room_name.empty()) {
|
||||
LOG_ERROR(Network, "Room name is empty!");
|
||||
PrintHelp(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
if (preferred_game.empty()) {
|
||||
LOG_ERROR(Network, "Preferred game is empty!");
|
||||
PrintHelp(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
if (preferred_game_id == 0) {
|
||||
LOG_ERROR(Network,
|
||||
"preferred-game-id not set!\nThis should get set to allow users to find your "
|
||||
"room.\nSet with --preferred-game-id id");
|
||||
}
|
||||
if (max_members > Network::MaxConcurrentConnections || max_members < 2) {
|
||||
LOG_ERROR(Network, "max_members needs to be in the range 2 - {}!",
|
||||
Network::MaxConcurrentConnections);
|
||||
PrintHelp(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
if (port > UINT16_MAX) {
|
||||
LOG_ERROR(Network, "Port needs to be in the range 0 - 65535!");
|
||||
PrintHelp(argv[0]);
|
||||
return -1;
|
||||
}
|
||||
if (ban_list_file.empty()) {
|
||||
LOG_ERROR(Network, "Ban list file not set!\nThis should get set to load and save room ban "
|
||||
"list.\nSet with --ban-list-file <file>");
|
||||
}
|
||||
bool announce = true;
|
||||
if (token.empty() && announce) {
|
||||
announce = false;
|
||||
LOG_INFO(Network, "Token is empty: Hosting a private room");
|
||||
}
|
||||
if (web_api_url.empty() && announce) {
|
||||
announce = false;
|
||||
LOG_INFO(Network, "Endpoint url is empty: Hosting a private room");
|
||||
}
|
||||
if (announce) {
|
||||
if (username.empty()) {
|
||||
LOG_INFO(Network, "Hosting a public room");
|
||||
Settings::values.web_api_url = web_api_url;
|
||||
Settings::values.yuzu_username = UsernameFromDisplayToken(token);
|
||||
username = Settings::values.yuzu_username.GetValue();
|
||||
Settings::values.yuzu_token = TokenFromDisplayToken(token);
|
||||
} else {
|
||||
LOG_INFO(Network, "Hosting a public room");
|
||||
Settings::values.web_api_url = web_api_url;
|
||||
Settings::values.yuzu_username = username;
|
||||
Settings::values.yuzu_token = token;
|
||||
}
|
||||
}
|
||||
if (!announce && enable_yuzu_mods) {
|
||||
enable_yuzu_mods = false;
|
||||
LOG_INFO(Network, "Can not enable yuzu Moderators for private rooms");
|
||||
}
|
||||
|
||||
// Load the ban list
|
||||
Network::Room::BanList ban_list;
|
||||
if (!ban_list_file.empty()) {
|
||||
ban_list = LoadBanList(ban_list_file);
|
||||
}
|
||||
|
||||
std::unique_ptr<Network::VerifyUser::Backend> verify_backend;
|
||||
if (announce) {
|
||||
#ifdef ENABLE_WEB_SERVICE
|
||||
verify_backend =
|
||||
std::make_unique<WebService::VerifyUserJWT>(Settings::values.web_api_url.GetValue());
|
||||
#else
|
||||
LOG_INFO(Network,
|
||||
"yuzu Web Services is not available with this build: validation is disabled.");
|
||||
verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
|
||||
#endif
|
||||
} else {
|
||||
verify_backend = std::make_unique<Network::VerifyUser::NullBackend>();
|
||||
}
|
||||
|
||||
Network::RoomNetwork network{};
|
||||
network.Init();
|
||||
if (auto room = network.GetRoom().lock()) {
|
||||
AnnounceMultiplayerRoom::GameInfo preferred_game_info{.name = preferred_game,
|
||||
.id = preferred_game_id};
|
||||
if (!room->Create(room_name, room_description, "", port, password, max_members, username,
|
||||
preferred_game_info, std::move(verify_backend), ban_list,
|
||||
enable_yuzu_mods)) {
|
||||
LOG_INFO(Network, "Failed to create room: ");
|
||||
return -1;
|
||||
}
|
||||
LOG_INFO(Network, "Room is open. Close with Q+Enter...");
|
||||
auto announce_session = std::make_unique<Core::AnnounceMultiplayerSession>(network);
|
||||
if (announce) {
|
||||
announce_session->Start();
|
||||
}
|
||||
while (room->GetState() == Network::Room::State::Open) {
|
||||
std::string in;
|
||||
std::cin >> in;
|
||||
if (in.size() > 0) {
|
||||
break;
|
||||
}
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
}
|
||||
if (announce) {
|
||||
announce_session->Stop();
|
||||
}
|
||||
announce_session.reset();
|
||||
// Save the ban list
|
||||
if (!ban_list_file.empty()) {
|
||||
SaveBanList(room->GetBanList(), ban_list_file);
|
||||
}
|
||||
room->Destroy();
|
||||
}
|
||||
network.Shutdown();
|
||||
detached_tasks.WaitForAllTasks();
|
||||
return 0;
|
||||
}
|
||||
20
src/dedicated_room/yuzu_room.rc
Normal file
@@ -0,0 +1,20 @@
|
||||
// SPDX-FileCopyrightText: 2017 Citra Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "winresrc.h"
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
YUZU_ICON ICON "../../dist/yuzu.ico"
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// RT_MANIFEST
|
||||
//
|
||||
|
||||
0 RT_MANIFEST "../../dist/yuzu.manifest"
|
||||
@@ -20,9 +20,7 @@ namespace Network {
|
||||
|
||||
class Room::RoomImpl {
|
||||
public:
|
||||
// This MAC address is used to generate a 'Nintendo' like Mac address.
|
||||
const MacAddress NintendoOUI;
|
||||
std::mt19937 random_gen; ///< Random number generator. Used for GenerateMacAddress
|
||||
std::mt19937 random_gen; ///< Random number generator. Used for GenerateFakeIPAddress
|
||||
|
||||
ENetHost* server = nullptr; ///< Network interface.
|
||||
|
||||
@@ -35,10 +33,9 @@ public:
|
||||
std::string password; ///< The password required to connect to this room.
|
||||
|
||||
struct Member {
|
||||
std::string nickname; ///< The nickname of the member.
|
||||
std::string console_id_hash; ///< A hash of the console ID of the member.
|
||||
GameInfo game_info; ///< The current game of the member
|
||||
MacAddress mac_address; ///< The assigned mac address of the member.
|
||||
std::string nickname; ///< The nickname of the member.
|
||||
GameInfo game_info; ///< The current game of the member
|
||||
IPv4Address fake_ip; ///< The assigned fake ip address of the member.
|
||||
/// Data of the user, often including authenticated forum username.
|
||||
VerifyUser::UserData user_data;
|
||||
ENetPeer* peer; ///< The remote peer.
|
||||
@@ -51,8 +48,7 @@ public:
|
||||
IPBanList ip_ban_list; ///< List of banned IP addresses
|
||||
mutable std::mutex ban_list_mutex; ///< Mutex for the ban lists
|
||||
|
||||
RoomImpl()
|
||||
: NintendoOUI{0x00, 0x1F, 0x32, 0x00, 0x00, 0x00}, random_gen(std::random_device()()) {}
|
||||
RoomImpl() : random_gen(std::random_device()()) {}
|
||||
|
||||
/// Thread that receives and dispatches network packets
|
||||
std::unique_ptr<std::thread> room_thread;
|
||||
@@ -101,16 +97,10 @@ public:
|
||||
bool IsValidNickname(const std::string& nickname) const;
|
||||
|
||||
/**
|
||||
* Returns whether the MAC address is valid, ie. isn't already taken by someone else in the
|
||||
* Returns whether the fake ip address is valid, ie. isn't already taken by someone else in the
|
||||
* room.
|
||||
*/
|
||||
bool IsValidMacAddress(const MacAddress& address) const;
|
||||
|
||||
/**
|
||||
* Returns whether the console ID (hash) is valid, ie. isn't already taken by someone else in
|
||||
* the room.
|
||||
*/
|
||||
bool IsValidConsoleId(const std::string& console_id_hash) const;
|
||||
bool IsValidFakeIPAddress(const IPv4Address& address) const;
|
||||
|
||||
/**
|
||||
* Returns whether a user has mod permissions.
|
||||
@@ -128,15 +118,9 @@ public:
|
||||
void SendNameCollision(ENetPeer* client);
|
||||
|
||||
/**
|
||||
* Sends a ID_ROOM_MAC_COLLISION message telling the client that the MAC is invalid.
|
||||
* Sends a ID_ROOM_IP_COLLISION message telling the client that the IP is invalid.
|
||||
*/
|
||||
void SendMacCollision(ENetPeer* client);
|
||||
|
||||
/**
|
||||
* Sends a IdConsoleIdCollison message telling the client that another member with the same
|
||||
* console ID exists.
|
||||
*/
|
||||
void SendConsoleIdCollision(ENetPeer* client);
|
||||
void SendIPCollision(ENetPeer* client);
|
||||
|
||||
/**
|
||||
* Sends a ID_ROOM_VERSION_MISMATCH message telling the client that the version is invalid.
|
||||
@@ -152,13 +136,13 @@ public:
|
||||
* Notifies the member that its connection attempt was successful,
|
||||
* and it is now part of the room.
|
||||
*/
|
||||
void SendJoinSuccess(ENetPeer* client, MacAddress mac_address);
|
||||
void SendJoinSuccess(ENetPeer* client, IPv4Address fake_ip);
|
||||
|
||||
/**
|
||||
* Notifies the member that its connection attempt was successful,
|
||||
* and it is now part of the room, and it has been granted mod permissions.
|
||||
*/
|
||||
void SendJoinSuccessAsMod(ENetPeer* client, MacAddress mac_address);
|
||||
void SendJoinSuccessAsMod(ENetPeer* client, IPv4Address fake_ip);
|
||||
|
||||
/**
|
||||
* Sends a IdHostKicked message telling the client that they have been kicked.
|
||||
@@ -210,7 +194,7 @@ public:
|
||||
* <u32> num_members: the number of currently joined clients
|
||||
* This is followed by the following three values for each member:
|
||||
* <String> nickname of that member
|
||||
* <MacAddress> mac_address of that member
|
||||
* <IPv4Address> fake_ip of that member
|
||||
* <String> game_name of that member
|
||||
*/
|
||||
void BroadcastRoomInformation();
|
||||
@@ -219,13 +203,13 @@ public:
|
||||
* Generates a free MAC address to assign to a new client.
|
||||
* The first 3 bytes are the NintendoOUI 0x00, 0x1F, 0x32
|
||||
*/
|
||||
MacAddress GenerateMacAddress();
|
||||
IPv4Address GenerateFakeIPAddress();
|
||||
|
||||
/**
|
||||
* Broadcasts this packet to all members except the sender.
|
||||
* @param event The ENet event containing the data
|
||||
*/
|
||||
void HandleWifiPacket(const ENetEvent* event);
|
||||
void HandleProxyPacket(const ENetEvent* event);
|
||||
|
||||
/**
|
||||
* Extracts a chat entry from a received ENet packet and adds it to the chat queue.
|
||||
@@ -250,7 +234,7 @@ public:
|
||||
void Room::RoomImpl::ServerLoop() {
|
||||
while (state != State::Closed) {
|
||||
ENetEvent event;
|
||||
if (enet_host_service(server, &event, 16) > 0) {
|
||||
if (enet_host_service(server, &event, 50) > 0) {
|
||||
switch (event.type) {
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
switch (event.packet->data[0]) {
|
||||
@@ -260,8 +244,8 @@ void Room::RoomImpl::ServerLoop() {
|
||||
case IdSetGameInfo:
|
||||
HandleGameNamePacket(&event);
|
||||
break;
|
||||
case IdWifiPacket:
|
||||
HandleWifiPacket(&event);
|
||||
case IdProxyPacket:
|
||||
HandleProxyPacket(&event);
|
||||
break;
|
||||
case IdChatMessage:
|
||||
HandleChatPacket(&event);
|
||||
@@ -313,11 +297,8 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
||||
std::string nickname;
|
||||
packet.Read(nickname);
|
||||
|
||||
std::string console_id_hash;
|
||||
packet.Read(console_id_hash);
|
||||
|
||||
MacAddress preferred_mac;
|
||||
packet.Read(preferred_mac);
|
||||
IPv4Address preferred_fake_ip;
|
||||
packet.Read(preferred_fake_ip);
|
||||
|
||||
u32 client_version;
|
||||
packet.Read(client_version);
|
||||
@@ -338,20 +319,15 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (preferred_mac != NoPreferredMac) {
|
||||
// Verify if the preferred mac is available
|
||||
if (!IsValidMacAddress(preferred_mac)) {
|
||||
SendMacCollision(event->peer);
|
||||
if (preferred_fake_ip != NoPreferredIP) {
|
||||
// Verify if the preferred fake ip is available
|
||||
if (!IsValidFakeIPAddress(preferred_fake_ip)) {
|
||||
SendIPCollision(event->peer);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// Assign a MAC address of this client automatically
|
||||
preferred_mac = GenerateMacAddress();
|
||||
}
|
||||
|
||||
if (!IsValidConsoleId(console_id_hash)) {
|
||||
SendConsoleIdCollision(event->peer);
|
||||
return;
|
||||
// Assign a fake ip address of this client automatically
|
||||
preferred_fake_ip = GenerateFakeIPAddress();
|
||||
}
|
||||
|
||||
if (client_version != network_version) {
|
||||
@@ -361,8 +337,7 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
||||
|
||||
// At this point the client is ready to be added to the room.
|
||||
Member member{};
|
||||
member.mac_address = preferred_mac;
|
||||
member.console_id_hash = console_id_hash;
|
||||
member.fake_ip = preferred_fake_ip;
|
||||
member.nickname = nickname;
|
||||
member.peer = event->peer;
|
||||
|
||||
@@ -408,9 +383,9 @@ void Room::RoomImpl::HandleJoinRequest(const ENetEvent* event) {
|
||||
// Notify everyone that the room information has changed.
|
||||
BroadcastRoomInformation();
|
||||
if (HasModPermission(event->peer)) {
|
||||
SendJoinSuccessAsMod(event->peer, preferred_mac);
|
||||
SendJoinSuccessAsMod(event->peer, preferred_fake_ip);
|
||||
} else {
|
||||
SendJoinSuccess(event->peer, preferred_mac);
|
||||
SendJoinSuccess(event->peer, preferred_fake_ip);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -575,19 +550,11 @@ bool Room::RoomImpl::IsValidNickname(const std::string& nickname) const {
|
||||
[&nickname](const auto& member) { return member.nickname != nickname; });
|
||||
}
|
||||
|
||||
bool Room::RoomImpl::IsValidMacAddress(const MacAddress& address) const {
|
||||
// A MAC address is valid if it is not already taken by anybody else in the room.
|
||||
bool Room::RoomImpl::IsValidFakeIPAddress(const IPv4Address& address) const {
|
||||
// An IP address is valid if it is not already taken by anybody else in the room.
|
||||
std::lock_guard lock(member_mutex);
|
||||
return std::all_of(members.begin(), members.end(),
|
||||
[&address](const auto& member) { return member.mac_address != address; });
|
||||
}
|
||||
|
||||
bool Room::RoomImpl::IsValidConsoleId(const std::string& console_id_hash) const {
|
||||
// A Console ID is valid if it is not already taken by anybody else in the room.
|
||||
std::lock_guard lock(member_mutex);
|
||||
return std::all_of(members.begin(), members.end(), [&console_id_hash](const auto& member) {
|
||||
return member.console_id_hash != console_id_hash;
|
||||
});
|
||||
[&address](const auto& member) { return member.fake_ip != address; });
|
||||
}
|
||||
|
||||
bool Room::RoomImpl::HasModPermission(const ENetPeer* client) const {
|
||||
@@ -621,19 +588,9 @@ void Room::RoomImpl::SendNameCollision(ENetPeer* client) {
|
||||
enet_host_flush(server);
|
||||
}
|
||||
|
||||
void Room::RoomImpl::SendMacCollision(ENetPeer* client) {
|
||||
void Room::RoomImpl::SendIPCollision(ENetPeer* client) {
|
||||
Packet packet;
|
||||
packet.Write(static_cast<u8>(IdMacCollision));
|
||||
|
||||
ENetPacket* enet_packet =
|
||||
enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(client, 0, enet_packet);
|
||||
enet_host_flush(server);
|
||||
}
|
||||
|
||||
void Room::RoomImpl::SendConsoleIdCollision(ENetPeer* client) {
|
||||
Packet packet;
|
||||
packet.Write(static_cast<u8>(IdConsoleIdCollision));
|
||||
packet.Write(static_cast<u8>(IdIpCollision));
|
||||
|
||||
ENetPacket* enet_packet =
|
||||
enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
||||
@@ -672,20 +629,20 @@ void Room::RoomImpl::SendVersionMismatch(ENetPeer* client) {
|
||||
enet_host_flush(server);
|
||||
}
|
||||
|
||||
void Room::RoomImpl::SendJoinSuccess(ENetPeer* client, MacAddress mac_address) {
|
||||
void Room::RoomImpl::SendJoinSuccess(ENetPeer* client, IPv4Address fake_ip) {
|
||||
Packet packet;
|
||||
packet.Write(static_cast<u8>(IdJoinSuccess));
|
||||
packet.Write(mac_address);
|
||||
packet.Write(fake_ip);
|
||||
ENetPacket* enet_packet =
|
||||
enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(client, 0, enet_packet);
|
||||
enet_host_flush(server);
|
||||
}
|
||||
|
||||
void Room::RoomImpl::SendJoinSuccessAsMod(ENetPeer* client, MacAddress mac_address) {
|
||||
void Room::RoomImpl::SendJoinSuccessAsMod(ENetPeer* client, IPv4Address fake_ip) {
|
||||
Packet packet;
|
||||
packet.Write(static_cast<u8>(IdJoinSuccessAsMod));
|
||||
packet.Write(mac_address);
|
||||
packet.Write(fake_ip);
|
||||
ENetPacket* enet_packet =
|
||||
enet_packet_create(packet.GetData(), packet.GetDataSize(), ENET_PACKET_FLAG_RELIABLE);
|
||||
enet_peer_send(client, 0, enet_packet);
|
||||
@@ -818,7 +775,7 @@ void Room::RoomImpl::BroadcastRoomInformation() {
|
||||
std::lock_guard lock(member_mutex);
|
||||
for (const auto& member : members) {
|
||||
packet.Write(member.nickname);
|
||||
packet.Write(member.mac_address);
|
||||
packet.Write(member.fake_ip);
|
||||
packet.Write(member.game_info.name);
|
||||
packet.Write(member.game_info.id);
|
||||
packet.Write(member.user_data.username);
|
||||
@@ -833,34 +790,43 @@ void Room::RoomImpl::BroadcastRoomInformation() {
|
||||
enet_host_flush(server);
|
||||
}
|
||||
|
||||
MacAddress Room::RoomImpl::GenerateMacAddress() {
|
||||
MacAddress result_mac =
|
||||
NintendoOUI; // The first three bytes of each MAC address will be the NintendoOUI
|
||||
std::uniform_int_distribution<> dis(0x00, 0xFF); // Random byte between 0 and 0xFF
|
||||
IPv4Address Room::RoomImpl::GenerateFakeIPAddress() {
|
||||
IPv4Address result_ip{192, 168, 0, 0};
|
||||
std::uniform_int_distribution<> dis(0x01, 0xFE); // Random byte between 1 and 0xFE
|
||||
do {
|
||||
for (std::size_t i = 3; i < result_mac.size(); ++i) {
|
||||
result_mac[i] = dis(random_gen);
|
||||
for (std::size_t i = 2; i < result_ip.size(); ++i) {
|
||||
result_ip[i] = dis(random_gen);
|
||||
}
|
||||
} while (!IsValidMacAddress(result_mac));
|
||||
return result_mac;
|
||||
} while (!IsValidFakeIPAddress(result_ip));
|
||||
|
||||
return result_ip;
|
||||
}
|
||||
|
||||
void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) {
|
||||
void Room::RoomImpl::HandleProxyPacket(const ENetEvent* event) {
|
||||
Packet in_packet;
|
||||
in_packet.Append(event->packet->data, event->packet->dataLength);
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // Message type
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // WifiPacket Type
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // WifiPacket Channel
|
||||
in_packet.IgnoreBytes(sizeof(MacAddress)); // WifiPacket Transmitter Address
|
||||
MacAddress destination_address;
|
||||
in_packet.Read(destination_address);
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // Message type
|
||||
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // Domain
|
||||
in_packet.IgnoreBytes(sizeof(IPv4Address)); // IP
|
||||
in_packet.IgnoreBytes(sizeof(u16)); // Port
|
||||
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // Domain
|
||||
IPv4Address remote_ip;
|
||||
in_packet.Read(remote_ip); // IP
|
||||
in_packet.IgnoreBytes(sizeof(u16)); // Port
|
||||
|
||||
in_packet.IgnoreBytes(sizeof(u8)); // Protocol
|
||||
bool broadcast;
|
||||
in_packet.Read(broadcast); // Broadcast
|
||||
|
||||
Packet out_packet;
|
||||
out_packet.Append(event->packet->data, event->packet->dataLength);
|
||||
ENetPacket* enet_packet = enet_packet_create(out_packet.GetData(), out_packet.GetDataSize(),
|
||||
ENET_PACKET_FLAG_RELIABLE);
|
||||
|
||||
if (destination_address == BroadcastMac) { // Send the data to everyone except the sender
|
||||
const auto& destination_address = remote_ip;
|
||||
if (broadcast) { // Send the data to everyone except the sender
|
||||
std::lock_guard lock(member_mutex);
|
||||
bool sent_packet = false;
|
||||
for (const auto& member : members) {
|
||||
@@ -877,16 +843,16 @@ void Room::RoomImpl::HandleWifiPacket(const ENetEvent* event) {
|
||||
std::lock_guard lock(member_mutex);
|
||||
auto member = std::find_if(members.begin(), members.end(),
|
||||
[destination_address](const Member& member_entry) -> bool {
|
||||
return member_entry.mac_address == destination_address;
|
||||
return member_entry.fake_ip == destination_address;
|
||||
});
|
||||
if (member != members.end()) {
|
||||
enet_peer_send(member->peer, 0, enet_packet);
|
||||
} else {
|
||||
LOG_ERROR(Network,
|
||||
"Attempting to send to unknown MAC address: "
|
||||
"{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}",
|
||||
"Attempting to send to unknown IP address: "
|
||||
"{}.{}.{}.{}",
|
||||
destination_address[0], destination_address[1], destination_address[2],
|
||||
destination_address[3], destination_address[4], destination_address[5]);
|
||||
destination_address[3]);
|
||||
enet_packet_destroy(enet_packet);
|
||||
}
|
||||
}
|
||||
@@ -1073,7 +1039,7 @@ std::vector<Member> Room::GetRoomMemberList() const {
|
||||
member.username = member_impl.user_data.username;
|
||||
member.display_name = member_impl.user_data.display_name;
|
||||
member.avatar_url = member_impl.user_data.avatar_url;
|
||||
member.mac_address = member_impl.mac_address;
|
||||
member.fake_ip = member_impl.fake_ip;
|
||||
member.game = member_impl.game_info;
|
||||
member_list.push_back(member);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include <vector>
|
||||
#include "common/announce_multiplayer_room.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/socket_types.h"
|
||||
#include "network/verify_user.h"
|
||||
|
||||
namespace Network {
|
||||
|
||||
using AnnounceMultiplayerRoom::GameInfo;
|
||||
using AnnounceMultiplayerRoom::MacAddress;
|
||||
using AnnounceMultiplayerRoom::Member;
|
||||
using AnnounceMultiplayerRoom::RoomInformation;
|
||||
|
||||
@@ -29,12 +29,9 @@ static constexpr u32 MaxConcurrentConnections = 254;
|
||||
|
||||
constexpr std::size_t NumChannels = 1; // Number of channels used for the connection
|
||||
|
||||
/// A special MAC address that tells the room we're joining to assign us a MAC address
|
||||
/// A special IP address that tells the room we're joining to assign us a IP address
|
||||
/// automatically.
|
||||
constexpr MacAddress NoPreferredMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
// 802.11 broadcast MAC address
|
||||
constexpr MacAddress BroadcastMac = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
constexpr IPv4Address NoPreferredIP = {0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
// The different types of messages that can be sent. The first byte of each packet defines the type
|
||||
enum RoomMessageTypes : u8 {
|
||||
@@ -42,15 +39,14 @@ enum RoomMessageTypes : u8 {
|
||||
IdJoinSuccess,
|
||||
IdRoomInformation,
|
||||
IdSetGameInfo,
|
||||
IdWifiPacket,
|
||||
IdProxyPacket,
|
||||
IdChatMessage,
|
||||
IdNameCollision,
|
||||
IdMacCollision,
|
||||
IdIpCollision,
|
||||
IdVersionMismatch,
|
||||
IdWrongPassword,
|
||||
IdCloseRoom,
|
||||
IdRoomIsFull,
|
||||
IdConsoleIdCollision,
|
||||
IdStatusMessage,
|
||||
IdHostKicked,
|
||||
IdHostBanned,
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <set>
|
||||
#include <thread>
|
||||
#include "common/assert.h"
|
||||
#include "common/socket_types.h"
|
||||
#include "enet/enet.h"
|
||||
#include "network/packet.h"
|
||||
#include "network/room_member.h"
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
std::string username; ///< The username of this member.
|
||||
mutable std::mutex username_mutex; ///< Mutex for locking username.
|
||||
|
||||
MacAddress mac_address; ///< The mac_address of this member.
|
||||
IPv4Address fake_ip; ///< The fake ip of this member.
|
||||
|
||||
std::mutex network_mutex; ///< Mutex that controls access to the `client` variable.
|
||||
/// Thread that receives and dispatches network packets
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
CallbackSet<T>& Get();
|
||||
|
||||
private:
|
||||
CallbackSet<WifiPacket> callback_set_wifi_packet;
|
||||
CallbackSet<ProxyPacket> callback_set_proxy_packet;
|
||||
CallbackSet<ChatEntry> callback_set_chat_messages;
|
||||
CallbackSet<StatusMessageEntry> callback_set_status_messages;
|
||||
CallbackSet<RoomInformation> callback_set_room_information;
|
||||
@@ -78,15 +79,15 @@ public:
|
||||
|
||||
/**
|
||||
* Sends a request to the server, asking for permission to join a room with the specified
|
||||
* nickname and preferred mac.
|
||||
* nickname and preferred fake ip.
|
||||
* @params nickname The desired nickname.
|
||||
* @params console_id_hash A hash of the Console ID.
|
||||
* @params preferred_mac The preferred MAC address to use in the room, the NoPreferredMac tells
|
||||
* @params preferred_fake_ip The preferred IP address to use in the room, the NoPreferredIP
|
||||
* tells
|
||||
* @params password The password for the room
|
||||
* the server to assign one for us.
|
||||
*/
|
||||
void SendJoinRequest(const std::string& nickname_, const std::string& console_id_hash,
|
||||
const MacAddress& preferred_mac = NoPreferredMac,
|
||||
void SendJoinRequest(const std::string& nickname_,
|
||||
const IPv4Address& preferred_fake_ip = NoPreferredIP,
|
||||
const std::string& password = "", const std::string& token = "");
|
||||
|
||||
/**
|
||||
@@ -101,10 +102,10 @@ public:
|
||||
void HandleRoomInformationPacket(const ENetEvent* event);
|
||||
|
||||
/**
|
||||
* Extracts a WifiPacket from a received ENet packet.
|
||||
* Extracts a ProxyPacket from a received ENet packet.
|
||||
* @param event The ENet event that was received.
|
||||
*/
|
||||
void HandleWifiPackets(const ENetEvent* event);
|
||||
void HandleProxyPackets(const ENetEvent* event);
|
||||
|
||||
/**
|
||||
* Extracts a chat entry from a received ENet packet and adds it to the chat queue.
|
||||
@@ -158,12 +159,12 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
|
||||
while (IsConnected()) {
|
||||
std::lock_guard lock(network_mutex);
|
||||
ENetEvent event;
|
||||
if (enet_host_service(client, &event, 16) > 0) {
|
||||
if (enet_host_service(client, &event, 100) > 0) {
|
||||
switch (event.type) {
|
||||
case ENET_EVENT_TYPE_RECEIVE:
|
||||
switch (event.packet->data[0]) {
|
||||
case IdWifiPacket:
|
||||
HandleWifiPackets(&event);
|
||||
case IdProxyPacket:
|
||||
HandleProxyPackets(&event);
|
||||
break;
|
||||
case IdChatMessage:
|
||||
HandleChatPacket(&event);
|
||||
@@ -198,13 +199,9 @@ void RoomMember::RoomMemberImpl::MemberLoop() {
|
||||
SetState(State::Idle);
|
||||
SetError(Error::NameCollision);
|
||||
break;
|
||||
case IdMacCollision:
|
||||
case IdIpCollision:
|
||||
SetState(State::Idle);
|
||||
SetError(Error::MacCollision);
|
||||
break;
|
||||
case IdConsoleIdCollision:
|
||||
SetState(State::Idle);
|
||||
SetError(Error::ConsoleIdCollision);
|
||||
SetError(Error::IpCollision);
|
||||
break;
|
||||
case IdVersionMismatch:
|
||||
SetState(State::Idle);
|
||||
@@ -275,15 +272,13 @@ void RoomMember::RoomMemberImpl::Send(Packet&& packet) {
|
||||
}
|
||||
|
||||
void RoomMember::RoomMemberImpl::SendJoinRequest(const std::string& nickname_,
|
||||
const std::string& console_id_hash,
|
||||
const MacAddress& preferred_mac,
|
||||
const IPv4Address& preferred_fake_ip,
|
||||
const std::string& password,
|
||||
const std::string& token) {
|
||||
Packet packet;
|
||||
packet.Write(static_cast<u8>(IdJoinRequest));
|
||||
packet.Write(nickname_);
|
||||
packet.Write(console_id_hash);
|
||||
packet.Write(preferred_mac);
|
||||
packet.Write(preferred_fake_ip);
|
||||
packet.Write(network_version);
|
||||
packet.Write(password);
|
||||
packet.Write(token);
|
||||
@@ -317,7 +312,7 @@ void RoomMember::RoomMemberImpl::HandleRoomInformationPacket(const ENetEvent* ev
|
||||
|
||||
for (auto& member : member_information) {
|
||||
packet.Read(member.nickname);
|
||||
packet.Read(member.mac_address);
|
||||
packet.Read(member.fake_ip);
|
||||
packet.Read(member.game_info.name);
|
||||
packet.Read(member.game_info.id);
|
||||
packet.Read(member.username);
|
||||
@@ -342,29 +337,38 @@ void RoomMember::RoomMemberImpl::HandleJoinPacket(const ENetEvent* event) {
|
||||
packet.IgnoreBytes(sizeof(u8)); // Ignore the message type
|
||||
|
||||
// Parse the MAC Address from the packet
|
||||
packet.Read(mac_address);
|
||||
packet.Read(fake_ip);
|
||||
}
|
||||
|
||||
void RoomMember::RoomMemberImpl::HandleWifiPackets(const ENetEvent* event) {
|
||||
WifiPacket wifi_packet{};
|
||||
void RoomMember::RoomMemberImpl::HandleProxyPackets(const ENetEvent* event) {
|
||||
ProxyPacket proxy_packet{};
|
||||
Packet packet;
|
||||
packet.Append(event->packet->data, event->packet->dataLength);
|
||||
|
||||
// Ignore the first byte, which is the message id.
|
||||
packet.IgnoreBytes(sizeof(u8)); // Ignore the message type
|
||||
|
||||
// Parse the WifiPacket from the packet
|
||||
u8 frame_type;
|
||||
packet.Read(frame_type);
|
||||
WifiPacket::PacketType type = static_cast<WifiPacket::PacketType>(frame_type);
|
||||
// Parse the ProxyPacket from the packet
|
||||
u8 local_family;
|
||||
packet.Read(local_family);
|
||||
proxy_packet.local_endpoint.family = static_cast<Domain>(local_family);
|
||||
packet.Read(proxy_packet.local_endpoint.ip);
|
||||
packet.Read(proxy_packet.local_endpoint.portno);
|
||||
|
||||
wifi_packet.type = type;
|
||||
packet.Read(wifi_packet.channel);
|
||||
packet.Read(wifi_packet.transmitter_address);
|
||||
packet.Read(wifi_packet.destination_address);
|
||||
packet.Read(wifi_packet.data);
|
||||
u8 remote_family;
|
||||
packet.Read(remote_family);
|
||||
proxy_packet.remote_endpoint.family = static_cast<Domain>(remote_family);
|
||||
packet.Read(proxy_packet.remote_endpoint.ip);
|
||||
packet.Read(proxy_packet.remote_endpoint.portno);
|
||||
|
||||
Invoke<WifiPacket>(wifi_packet);
|
||||
u8 protocol_type;
|
||||
packet.Read(protocol_type);
|
||||
proxy_packet.protocol = static_cast<Protocol>(protocol_type);
|
||||
|
||||
packet.Read(proxy_packet.broadcast);
|
||||
packet.Read(proxy_packet.data);
|
||||
|
||||
Invoke<ProxyPacket>(proxy_packet);
|
||||
}
|
||||
|
||||
void RoomMember::RoomMemberImpl::HandleChatPacket(const ENetEvent* event) {
|
||||
@@ -440,8 +444,8 @@ void RoomMember::RoomMemberImpl::Disconnect() {
|
||||
}
|
||||
|
||||
template <>
|
||||
RoomMember::RoomMemberImpl::CallbackSet<WifiPacket>& RoomMember::RoomMemberImpl::Callbacks::Get() {
|
||||
return callback_set_wifi_packet;
|
||||
RoomMember::RoomMemberImpl::CallbackSet<ProxyPacket>& RoomMember::RoomMemberImpl::Callbacks::Get() {
|
||||
return callback_set_proxy_packet;
|
||||
}
|
||||
|
||||
template <>
|
||||
@@ -525,19 +529,18 @@ const std::string& RoomMember::GetUsername() const {
|
||||
return room_member_impl->username;
|
||||
}
|
||||
|
||||
const MacAddress& RoomMember::GetMacAddress() const {
|
||||
ASSERT_MSG(IsConnected(), "Tried to get MAC address while not connected");
|
||||
return room_member_impl->mac_address;
|
||||
const IPv4Address& RoomMember::GetFakeIpAddress() const {
|
||||
ASSERT_MSG(IsConnected(), "Tried to get fake ip address while not connected");
|
||||
return room_member_impl->fake_ip;
|
||||
}
|
||||
|
||||
RoomInformation RoomMember::GetRoomInformation() const {
|
||||
return room_member_impl->room_information;
|
||||
}
|
||||
|
||||
void RoomMember::Join(const std::string& nick, const std::string& console_id_hash,
|
||||
const char* server_addr, u16 server_port, u16 client_port,
|
||||
const MacAddress& preferred_mac, const std::string& password,
|
||||
const std::string& token) {
|
||||
void RoomMember::Join(const std::string& nick, const char* server_addr, u16 server_port,
|
||||
u16 client_port, const IPv4Address& preferred_fake_ip,
|
||||
const std::string& password, const std::string& token) {
|
||||
// If the member is connected, kill the connection first
|
||||
if (room_member_impl->loop_thread && room_member_impl->loop_thread->joinable()) {
|
||||
Leave();
|
||||
@@ -571,7 +574,7 @@ void RoomMember::Join(const std::string& nick, const std::string& console_id_has
|
||||
if (net > 0 && event.type == ENET_EVENT_TYPE_CONNECT) {
|
||||
room_member_impl->nickname = nick;
|
||||
room_member_impl->StartLoop();
|
||||
room_member_impl->SendJoinRequest(nick, console_id_hash, preferred_mac, password, token);
|
||||
room_member_impl->SendJoinRequest(nick, preferred_fake_ip, password, token);
|
||||
SendGameInfo(room_member_impl->current_game_info);
|
||||
} else {
|
||||
enet_peer_disconnect(room_member_impl->server, 0);
|
||||
@@ -584,14 +587,22 @@ bool RoomMember::IsConnected() const {
|
||||
return room_member_impl->IsConnected();
|
||||
}
|
||||
|
||||
void RoomMember::SendWifiPacket(const WifiPacket& wifi_packet) {
|
||||
void RoomMember::SendProxyPacket(const ProxyPacket& proxy_packet) {
|
||||
Packet packet;
|
||||
packet.Write(static_cast<u8>(IdWifiPacket));
|
||||
packet.Write(static_cast<u8>(wifi_packet.type));
|
||||
packet.Write(wifi_packet.channel);
|
||||
packet.Write(wifi_packet.transmitter_address);
|
||||
packet.Write(wifi_packet.destination_address);
|
||||
packet.Write(wifi_packet.data);
|
||||
packet.Write(static_cast<u8>(IdProxyPacket));
|
||||
|
||||
packet.Write(static_cast<u8>(proxy_packet.local_endpoint.family));
|
||||
packet.Write(proxy_packet.local_endpoint.ip);
|
||||
packet.Write(proxy_packet.local_endpoint.portno);
|
||||
|
||||
packet.Write(static_cast<u8>(proxy_packet.remote_endpoint.family));
|
||||
packet.Write(proxy_packet.remote_endpoint.ip);
|
||||
packet.Write(proxy_packet.remote_endpoint.portno);
|
||||
|
||||
packet.Write(static_cast<u8>(proxy_packet.protocol));
|
||||
packet.Write(proxy_packet.broadcast);
|
||||
packet.Write(proxy_packet.data);
|
||||
|
||||
room_member_impl->Send(std::move(packet));
|
||||
}
|
||||
|
||||
@@ -645,8 +656,8 @@ RoomMember::CallbackHandle<RoomMember::Error> RoomMember::BindOnError(
|
||||
return room_member_impl->Bind(callback);
|
||||
}
|
||||
|
||||
RoomMember::CallbackHandle<WifiPacket> RoomMember::BindOnWifiPacketReceived(
|
||||
std::function<void(const WifiPacket&)> callback) {
|
||||
RoomMember::CallbackHandle<ProxyPacket> RoomMember::BindOnProxyPacketReceived(
|
||||
std::function<void(const ProxyPacket&)> callback) {
|
||||
return room_member_impl->Bind(callback);
|
||||
}
|
||||
|
||||
@@ -685,7 +696,7 @@ void RoomMember::Leave() {
|
||||
room_member_impl->client = nullptr;
|
||||
}
|
||||
|
||||
template void RoomMember::Unbind(CallbackHandle<WifiPacket>);
|
||||
template void RoomMember::Unbind(CallbackHandle<ProxyPacket>);
|
||||
template void RoomMember::Unbind(CallbackHandle<RoomMember::State>);
|
||||
template void RoomMember::Unbind(CallbackHandle<RoomMember::Error>);
|
||||
template void RoomMember::Unbind(CallbackHandle<RoomInformation>);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
#include "common/announce_multiplayer_room.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/socket_types.h"
|
||||
#include "network/room.h"
|
||||
|
||||
namespace Network {
|
||||
@@ -17,22 +18,12 @@ using AnnounceMultiplayerRoom::GameInfo;
|
||||
using AnnounceMultiplayerRoom::RoomInformation;
|
||||
|
||||
/// Information about the received WiFi packets.
|
||||
/// Acts as our own 802.11 header.
|
||||
struct WifiPacket {
|
||||
enum class PacketType : u8 {
|
||||
Beacon,
|
||||
Data,
|
||||
Authentication,
|
||||
AssociationResponse,
|
||||
Deauthentication,
|
||||
NodeMap
|
||||
};
|
||||
PacketType type; ///< The type of 802.11 frame.
|
||||
std::vector<u8> data; ///< Raw 802.11 frame data, starting at the management frame header
|
||||
/// for management frames.
|
||||
MacAddress transmitter_address; ///< Mac address of the transmitter.
|
||||
MacAddress destination_address; ///< Mac address of the receiver.
|
||||
u8 channel; ///< WiFi channel where this frame was transmitted.
|
||||
struct ProxyPacket {
|
||||
SockAddrIn local_endpoint;
|
||||
SockAddrIn remote_endpoint;
|
||||
Protocol protocol;
|
||||
bool broadcast;
|
||||
std::vector<u8> data;
|
||||
};
|
||||
|
||||
/// Represents a chat message.
|
||||
@@ -72,15 +63,14 @@ public:
|
||||
HostKicked, ///< Kicked by the host
|
||||
|
||||
// Reasons why connection was rejected
|
||||
UnknownError, ///< Some error [permissions to network device missing or something]
|
||||
NameCollision, ///< Somebody is already using this name
|
||||
MacCollision, ///< Somebody is already using that mac-address
|
||||
ConsoleIdCollision, ///< Somebody in the room has the same Console ID
|
||||
WrongVersion, ///< The room version is not the same as for this RoomMember
|
||||
WrongPassword, ///< The password doesn't match the one from the Room
|
||||
CouldNotConnect, ///< The room is not responding to a connection attempt
|
||||
RoomIsFull, ///< Room is already at the maximum number of players
|
||||
HostBanned, ///< The user is banned by the host
|
||||
UnknownError, ///< Some error [permissions to network device missing or something]
|
||||
NameCollision, ///< Somebody is already using this name
|
||||
IpCollision, ///< Somebody is already using that fake-ip-address
|
||||
WrongVersion, ///< The room version is not the same as for this RoomMember
|
||||
WrongPassword, ///< The password doesn't match the one from the Room
|
||||
CouldNotConnect, ///< The room is not responding to a connection attempt
|
||||
RoomIsFull, ///< Room is already at the maximum number of players
|
||||
HostBanned, ///< The user is banned by the host
|
||||
|
||||
// Reasons why moderation request failed
|
||||
PermissionDenied, ///< The user does not have mod permissions
|
||||
@@ -92,9 +82,9 @@ public:
|
||||
std::string username; ///< The web services username of the member. Can be empty.
|
||||
std::string display_name; ///< The web services display name of the member. Can be empty.
|
||||
std::string avatar_url; ///< Url to the member's avatar. Can be empty.
|
||||
GameInfo game_info; ///< Name of the game they're currently playing, or empty if they're
|
||||
/// not playing anything.
|
||||
MacAddress mac_address; ///< MAC address associated with this member.
|
||||
GameInfo game_info; ///< Name of the game they're currently playing, or empty if they're
|
||||
/// not playing anything.
|
||||
IPv4Address fake_ip; ///< Fake Ip address associated with this member.
|
||||
};
|
||||
using MemberList = std::vector<MemberInformation>;
|
||||
|
||||
@@ -135,7 +125,7 @@ public:
|
||||
/**
|
||||
* Returns the MAC address of the RoomMember.
|
||||
*/
|
||||
const MacAddress& GetMacAddress() const;
|
||||
const IPv4Address& GetFakeIpAddress() const;
|
||||
|
||||
/**
|
||||
* Returns information about the room we're currently connected to.
|
||||
@@ -149,19 +139,17 @@ public:
|
||||
|
||||
/**
|
||||
* Attempts to join a room at the specified address and port, using the specified nickname.
|
||||
* A console ID hash is passed in to check console ID conflicts.
|
||||
* This may fail if the username or console ID is already taken.
|
||||
*/
|
||||
void Join(const std::string& nickname, const std::string& console_id_hash,
|
||||
const char* server_addr = "127.0.0.1", u16 server_port = DefaultRoomPort,
|
||||
u16 client_port = 0, const MacAddress& preferred_mac = NoPreferredMac,
|
||||
void Join(const std::string& nickname, const char* server_addr = "127.0.0.1",
|
||||
u16 server_port = DefaultRoomPort, u16 client_port = 0,
|
||||
const IPv4Address& preferred_fake_ip = NoPreferredIP,
|
||||
const std::string& password = "", const std::string& token = "");
|
||||
|
||||
/**
|
||||
* Sends a WiFi packet to the room.
|
||||
* @param packet The WiFi packet to send.
|
||||
*/
|
||||
void SendWifiPacket(const WifiPacket& packet);
|
||||
void SendProxyPacket(const ProxyPacket& packet);
|
||||
|
||||
/**
|
||||
* Sends a chat message to the room.
|
||||
@@ -207,14 +195,14 @@ public:
|
||||
CallbackHandle<Error> BindOnError(std::function<void(const Error&)> callback);
|
||||
|
||||
/**
|
||||
* Binds a function to an event that will be triggered every time a WifiPacket is received.
|
||||
* Binds a function to an event that will be triggered every time a ProxyPacket is received.
|
||||
* The function wil be called everytime the event is triggered.
|
||||
* The callback function must not bind or unbind a function. Doing so will cause a deadlock
|
||||
* @param callback The function to call
|
||||
* @return A handle used for removing the function from the registered list
|
||||
*/
|
||||
CallbackHandle<WifiPacket> BindOnWifiPacketReceived(
|
||||
std::function<void(const WifiPacket&)> callback);
|
||||
CallbackHandle<ProxyPacket> BindOnProxyPacketReceived(
|
||||
std::function<void(const ProxyPacket&)> callback);
|
||||
|
||||
/**
|
||||
* Binds a function to an event that will be triggered every time the RoomInformation changes.
|
||||
@@ -292,10 +280,8 @@ inline const char* GetErrorStr(const RoomMember::Error& e) {
|
||||
return "UnknownError";
|
||||
case RoomMember::Error::NameCollision:
|
||||
return "NameCollision";
|
||||
case RoomMember::Error::MacCollision:
|
||||
return "MaxCollision";
|
||||
case RoomMember::Error::ConsoleIdCollision:
|
||||
return "ConsoleIdCollision";
|
||||
case RoomMember::Error::IpCollision:
|
||||
return "IpCollision";
|
||||
case RoomMember::Error::WrongVersion:
|
||||
return "WrongVersion";
|
||||
case RoomMember::Error::WrongPassword:
|
||||
|
||||
@@ -1306,7 +1306,7 @@ void EmitContext::DefineInputs(const IR::Program& program) {
|
||||
subgroup_mask_gt = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupGtMaskKHR);
|
||||
subgroup_mask_ge = DefineInput(*this, U32[4], false, spv::BuiltIn::SubgroupGeMaskKHR);
|
||||
}
|
||||
if (info.uses_subgroup_invocation_id || info.uses_subgroup_shuffles ||
|
||||
if (info.uses_fswzadd || info.uses_subgroup_invocation_id || info.uses_subgroup_shuffles ||
|
||||
(profile.warp_size_potentially_larger_than_guest &&
|
||||
(info.uses_subgroup_vote || info.uses_subgroup_mask))) {
|
||||
subgroup_local_invocation_id =
|
||||
@@ -1411,7 +1411,8 @@ void EmitContext::DefineInputs(const IR::Program& program) {
|
||||
void EmitContext::DefineOutputs(const IR::Program& program) {
|
||||
const Info& info{program.info};
|
||||
const std::optional<u32> invocations{program.invocations};
|
||||
if (info.stores.AnyComponent(IR::Attribute::PositionX) || stage == Stage::VertexB) {
|
||||
if (runtime_info.convert_depth_mode || info.stores.AnyComponent(IR::Attribute::PositionX) ||
|
||||
stage == Stage::VertexB) {
|
||||
output_position = DefineOutput(*this, F32[4], invocations, spv::BuiltIn::Position);
|
||||
}
|
||||
if (info.stores[IR::Attribute::PointSize] || runtime_info.fixed_state_point_size) {
|
||||
|
||||
@@ -87,12 +87,8 @@ u32 GetBytesPerPixel(const Tegra::FramebufferConfig& framebuffer) {
|
||||
}
|
||||
|
||||
std::size_t GetSizeInBytes(const Tegra::FramebufferConfig& framebuffer) {
|
||||
// TODO(Rodrigo): Read this from HLE
|
||||
constexpr u32 block_height_log2 = 4;
|
||||
const u32 bytes_per_pixel = GetBytesPerPixel(framebuffer);
|
||||
const u64 size_bytes{Tegra::Texture::CalculateSize(
|
||||
true, bytes_per_pixel, framebuffer.stride, framebuffer.height, 1, block_height_log2, 0)};
|
||||
return size_bytes;
|
||||
return static_cast<std::size_t>(framebuffer.stride) *
|
||||
static_cast<std::size_t>(framebuffer.height) * GetBytesPerPixel(framebuffer);
|
||||
}
|
||||
|
||||
VkFormat GetFormat(const Tegra::FramebufferConfig& framebuffer) {
|
||||
@@ -173,10 +169,12 @@ VkSemaphore BlitScreen::Draw(const Tegra::FramebufferConfig& framebuffer,
|
||||
// TODO(Rodrigo): Read this from HLE
|
||||
constexpr u32 block_height_log2 = 4;
|
||||
const u32 bytes_per_pixel = GetBytesPerPixel(framebuffer);
|
||||
const u64 size_bytes{GetSizeInBytes(framebuffer)};
|
||||
|
||||
const u64 linear_size{GetSizeInBytes(framebuffer)};
|
||||
const u64 tiled_size{Tegra::Texture::CalculateSize(true, bytes_per_pixel,
|
||||
framebuffer.stride, framebuffer.height,
|
||||
1, block_height_log2, 0)};
|
||||
Tegra::Texture::UnswizzleTexture(
|
||||
mapped_span.subspan(image_offset, size_bytes), std::span(host_ptr, size_bytes),
|
||||
mapped_span.subspan(image_offset, linear_size), std::span(host_ptr, tiled_size),
|
||||
bytes_per_pixel, framebuffer.width, framebuffer.height, 1, block_height_log2, 0);
|
||||
|
||||
const VkBufferImageCopy copy{
|
||||
|
||||
@@ -33,9 +33,10 @@ VkSurfaceFormatKHR ChooseSwapSurfaceFormat(vk::Span<VkSurfaceFormatKHR> formats)
|
||||
}
|
||||
|
||||
VkPresentModeKHR ChooseSwapPresentMode(vk::Span<VkPresentModeKHR> modes) {
|
||||
// Mailbox doesn't lock the application like fifo (vsync), prefer it
|
||||
// Mailbox (triple buffering) doesn't lock the application like fifo (vsync),
|
||||
// prefer it if vsync option is not selected
|
||||
const auto found_mailbox = std::find(modes.begin(), modes.end(), VK_PRESENT_MODE_MAILBOX_KHR);
|
||||
if (found_mailbox != modes.end()) {
|
||||
if (found_mailbox != modes.end() && !Settings::values.use_vsync.GetValue()) {
|
||||
return VK_PRESENT_MODE_MAILBOX_KHR;
|
||||
}
|
||||
if (!Settings::values.use_speed_limit.GetValue()) {
|
||||
|
||||
@@ -1618,6 +1618,9 @@ ImageView::ImageView(TextureCacheRuntime&, const VideoCommon::NullImageViewParam
|
||||
ImageView::~ImageView() = default;
|
||||
|
||||
VkImageView ImageView::DepthView() {
|
||||
if (!image_handle) {
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
if (depth_view) {
|
||||
return *depth_view;
|
||||
}
|
||||
@@ -1627,6 +1630,9 @@ VkImageView ImageView::DepthView() {
|
||||
}
|
||||
|
||||
VkImageView ImageView::StencilView() {
|
||||
if (!image_handle) {
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
if (stencil_view) {
|
||||
return *stencil_view;
|
||||
}
|
||||
@@ -1636,6 +1642,9 @@ VkImageView ImageView::StencilView() {
|
||||
}
|
||||
|
||||
VkImageView ImageView::ColorView() {
|
||||
if (!image_handle) {
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
if (color_view) {
|
||||
return *color_view;
|
||||
}
|
||||
@@ -1645,6 +1654,9 @@ VkImageView ImageView::ColorView() {
|
||||
|
||||
VkImageView ImageView::StorageView(Shader::TextureType texture_type,
|
||||
Shader::ImageFormat image_format) {
|
||||
if (!image_handle) {
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
if (image_format == Shader::ImageFormat::Typeless) {
|
||||
return Handle(texture_type);
|
||||
}
|
||||
|
||||