├── .gitignore ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md └── src ├── config.cpp ├── config.h ├── forwarder_patches.cpp ├── globals.cpp ├── globals.hpp ├── logger.c ├── logger.h ├── main.cpp ├── main.h ├── mocha.cpp ├── mocha.h ├── notifications.cpp ├── notifications.h ├── sysconf_preserver.cpp └── sysconf_preserver.h /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | build/ 3 | *.elf 4 | *.wps 5 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ghcr.io/wiiu-env/devkitppc:20240704 2 | 3 | COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20240505 /artifacts $DEVKITPRO 4 | COPY --from=ghcr.io/wiiu-env/libnotifications:20240426 /artifacts $DEVKITPRO 5 | COPY --from=ghcr.io/wiiu-env/libmocha:20240603 /artifacts $DEVKITPRO 6 | 7 | WORKDIR project 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITPRO)),) 6 | $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") 7 | endif 8 | 9 | TOPDIR ?= $(CURDIR) 10 | 11 | include $(DEVKITPRO)/wups/share/wups_rules 12 | 13 | WUT_ROOT := $(DEVKITPRO)/wut 14 | WUMS_ROOT := $(DEVKITPRO)/wums 15 | 16 | #------------------------------------------------------------------------------- 17 | # TARGET is the name of the output 18 | # BUILD is the directory where object files & intermediate files will be placed 19 | # SOURCES is a list of directories containing source code 20 | # DATA is a list of directories containing data files 21 | # INCLUDES is a list of directories containing header files 22 | #------------------------------------------------------------------------------- 23 | TARGET := WiiVCLaunch 24 | BUILD := build 25 | SOURCES := src 26 | DATA := data 27 | INCLUDES := src 28 | 29 | #------------------------------------------------------------------------------- 30 | # options for code generation 31 | #------------------------------------------------------------------------------- 32 | CFLAGS := -Wall -O3 -ffunction-sections \ 33 | $(MACHDEP) 34 | 35 | CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__ 36 | 37 | CXXFLAGS := $(CFLAGS) -std=c++20 38 | 39 | ASFLAGS := $(ARCH) 40 | LDFLAGS = $(ARCH) $(RPXSPECS) -Wl,-Map,$(notdir $*.map) $(WUPSSPECS) 41 | 42 | ifeq ($(DEBUG),1) 43 | CXXFLAGS += -DDEBUG -g 44 | CFLAGS += -DDEBUG -g 45 | endif 46 | 47 | ifeq ($(DEBUG),VERBOSE) 48 | CXXFLAGS += -DDEBUG -DVERBOSE_DEBUG -g 49 | CFLAGS += -DDEBUG -DVERBOSE_DEBUG -g 50 | endif 51 | 52 | LIBS := -lmocha -lnotifications -lwups -lwut 53 | 54 | #------------------------------------------------------------------------------- 55 | # list of directories containing libraries, this must be the top level 56 | # containing include and lib 57 | #------------------------------------------------------------------------------- 58 | LIBDIRS := $(PORTLIBS) $(WUMS_ROOT) $(WUPS_ROOT) $(WUT_ROOT) $(WUT_ROOT)/usr 59 | 60 | #------------------------------------------------------------------------------- 61 | # no real need to edit anything past this point unless you need to add additional 62 | # rules for different file extensions 63 | #------------------------------------------------------------------------------- 64 | ifneq ($(BUILD),$(notdir $(CURDIR))) 65 | #------------------------------------------------------------------------------- 66 | 67 | export OUTPUT := $(CURDIR)/$(TARGET) 68 | export TOPDIR := $(CURDIR) 69 | 70 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 71 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 72 | 73 | export DEPSDIR := $(CURDIR)/$(BUILD) 74 | 75 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 76 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 77 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 78 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 79 | 80 | #------------------------------------------------------------------------------- 81 | # use CXX for linking C++ projects, CC for standard C 82 | #------------------------------------------------------------------------------- 83 | ifeq ($(strip $(CPPFILES)),) 84 | #------------------------------------------------------------------------------- 85 | export LD := $(CC) 86 | #------------------------------------------------------------------------------- 87 | else 88 | #------------------------------------------------------------------------------- 89 | export LD := $(CXX) 90 | #------------------------------------------------------------------------------- 91 | endif 92 | #------------------------------------------------------------------------------- 93 | 94 | export OFILES_BIN := $(addsuffix .o,$(BINFILES)) 95 | export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 96 | export OFILES := $(OFILES_BIN) $(OFILES_SRC) 97 | export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES))) 98 | 99 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 100 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 101 | -I$(CURDIR)/$(BUILD) 102 | 103 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) 104 | 105 | .PHONY: $(BUILD) clean all 106 | 107 | #------------------------------------------------------------------------------- 108 | all: $(BUILD) 109 | 110 | $(BUILD): 111 | @$(shell [ ! -d $(BUILD) ] && mkdir -p $(BUILD)) 112 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 113 | 114 | #------------------------------------------------------------------------------- 115 | clean: 116 | @echo clean ... 117 | @rm -fr $(BUILD) $(TARGET).wps $(TARGET).elf 118 | 119 | #------------------------------------------------------------------------------- 120 | else 121 | .PHONY: all 122 | 123 | DEPENDS := $(OFILES:.o=.d) 124 | 125 | #------------------------------------------------------------------------------- 126 | # main targets 127 | #------------------------------------------------------------------------------- 128 | all : $(OUTPUT).wps 129 | 130 | $(OUTPUT).wps : $(OUTPUT).elf 131 | $(OUTPUT).elf : $(OFILES) 132 | 133 | $(OFILES_SRC) : $(HFILES_BIN) 134 | 135 | #------------------------------------------------------------------------------- 136 | # you need a rule like this for each extension you use as binary data 137 | #------------------------------------------------------------------------------- 138 | %.bin.o %_bin.h : %.bin 139 | #------------------------------------------------------------------------------- 140 | @echo $(notdir $<) 141 | @$(bin2o) 142 | 143 | -include $(DEPENDS) 144 | 145 | #------------------------------------------------------------------------------- 146 | endif 147 | #------------------------------------------------------------------------------- 148 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Wii VC Launch 2 | Wii U plugin to enhance launching Wii VC titles and Wii Mode. 3 | 4 | ## Features 5 | ### Custom dialogs 6 | - Select a display option (TV Only, TV and GamePad, etc.) with any controller 7 | - Autolaunch into a specific display option bypassing all dialogs 8 | - Keep A pressed when launching a game to force open the Select a display option dialogs 9 | - Falls back to the GamePad screen if TV not connected 10 | 11 | ### Original built in dialogs 12 | - Enables the GamePad sensor bar for built in dialogs 13 | - Allow using a Pro Controller to Select a display option in the built in dialogs 14 | 15 | ### Video 16 | - Set the resolution to 480p, 720p, 480i, or 576i (including 4:3 variants) 17 | - Can be set separately for Wii VC and Wii Mode 18 | 19 | ## Installation 20 | For convenience, you can download Wii VC Launch directly on your console from the [Homebrew App Store](https://github.com/fortheusers/hb-appstore). 21 | 22 |

23 | 24 | Get it on the Homebrew App Store! 25 | 26 |

27 | 28 | Alternatively, download the latest release from the [Releases page](https://github.com/Lynx64/WiiVCLaunch/releases/latest) by clicking on `WiiVCLaunch.wps`.
29 | Copy the `WiiVCLaunch.wps` file into `wiiu/environments/[ENVIRONMENT]/plugins`,
30 | where [ENVIRONMENT] is the actual environment name (most likely 'aroma'). 31 | 32 | ## Usage 33 | Open the plugin config menu by pressing L, DPAD Down and Minus on the GamePad, Pro Controller or Classic Controller, or B, DPAD Down and Minus on a Wii Remote. 34 | 35 | Press B on any controller to back out of the custom dialogs. 36 | 37 | If custom dialogs are disabled: 38 | - Autolaunch cannot be used 39 | - Set resolution can still be used 40 | 41 | "Preserve SYSCONF on Wii VC title launch" and "Permanent Wii Internet Settings" (Disables Wii Internet Connection Settings overwrite) are useful in combination with [Priiloader](https://github.com/DacoTaco/priiloader) or Wii homebrew that can change the Internet Connection settings. If you don't have Priiloader installed you don't need to worry about them and can leave them both on `false`. 42 | 43 | ## Building 44 | For building you need: 45 | - [wut](https://github.com/devkitPro/wut) 46 | - [wups](https://github.com/wiiu-env/WiiUPluginSystem) 47 | - [libnotifications](https://github.com/wiiu-env/libnotifications) 48 | - [libmocha](https://github.com/wiiu-env/libmocha) 49 | 50 | then run `make` 51 | 52 | ## Building using the Dockerfile 53 | It's possible to use a docker image for building. This way you don't need anything installed on your host system other than Docker. 54 | 55 | ``` 56 | # Build docker image (only needed once) 57 | docker build . -t wiivclaunch-builder 58 | 59 | # make 60 | docker run --rm -v ${PWD}:/project wiivclaunch-builder make 61 | 62 | # make clean 63 | docker run --rm -v ${PWD}:/project wiivclaunch-builder make clean 64 | ``` 65 | -------------------------------------------------------------------------------- /src/config.cpp: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include "globals.hpp" 3 | #include "logger.h" 4 | #include "notifications.h" 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | WUPS_USE_STORAGE("WiiVCLaunch"); 12 | 13 | void boolItemCallback(ConfigItemBoolean *item, bool newValue) 14 | { 15 | if (!item || !item->identifier) { 16 | return; 17 | } 18 | if (std::string_view(USE_CUSTOM_DIALOGS_CONFIG_ID) == item->identifier) { 19 | gUseCustomDialogs = newValue; 20 | WUPSStorageAPI::Store(item->identifier, gUseCustomDialogs); 21 | } else if (std::string_view(PRESERVE_SYSCONF_CONFIG_ID) == item->identifier) { 22 | gPreserveSysconf = newValue; 23 | WUPSStorageAPI::Store(item->identifier, gPreserveSysconf); 24 | } else if (std::string_view(PERMANENT_NET_CONFIG_CONFIG_ID) == item->identifier) { 25 | gPermanentNetConfig = newValue; 26 | WUPSStorageAPI::Store(item->identifier, gPermanentNetConfig); 27 | } 28 | } 29 | 30 | void multipleValueItemCallback(ConfigItemMultipleValues *item, uint32_t newValue) 31 | { 32 | if (!item || !item->identifier) { 33 | return; 34 | } 35 | if (std::string_view(AUTOLAUNCH_DRC_SUPPORTED_CONFIG_ID) == item->identifier) { 36 | gAutolaunchDRCSupported = newValue; 37 | WUPSStorageAPI::Store(item->identifier, gAutolaunchDRCSupported); 38 | } else if (std::string_view(AUTOLAUNCH_NO_DRC_SUPPORT_CONFIG_ID) == item->identifier) { 39 | gAutolaunchNoDRCSupport = newValue; 40 | WUPSStorageAPI::Store(item->identifier, gAutolaunchNoDRCSupport); 41 | } else if (std::string_view(DISPLAY_OPTIONS_ORDER_CONFIG_ID) == item->identifier) { 42 | gDisplayOptionsOrder = newValue; 43 | WUPSStorageAPI::Store(item->identifier, gDisplayOptionsOrder); 44 | } else if (std::string_view(SET_RESOLUTION_CONFIG_ID) == item->identifier) { 45 | gSetResolution = newValue; 46 | WUPSStorageAPI::Store(item->identifier, gSetResolution); 47 | } else if (std::string_view(WII_MENU_SET_RESOLUTION_CONFIG_ID) == item->identifier) { 48 | gWiiMenuSetResolution = newValue; 49 | WUPSStorageAPI::Store(item->identifier, gWiiMenuSetResolution); 50 | } else if (std::string_view(NOTIFICATION_THEME_CONFIG_ID) == item->identifier) { 51 | gNotificationTheme = newValue; 52 | WUPSStorageAPI::Store(item->identifier, gNotificationTheme); 53 | applyNotificationThemeSetting(); 54 | } else if (std::string_view(FORWARDER_DISPLAY_OVERRIDE_CONFIG_ID) == item->identifier) { 55 | gForwarderDisplayOverride = newValue; 56 | WUPSStorageAPI::Store(item->identifier, gForwarderDisplayOverride); 57 | } 58 | } 59 | 60 | WUPSConfigAPICallbackStatus ConfigMenuOpenedCallback(WUPSConfigCategoryHandle rootHandle) 61 | { 62 | try { 63 | WUPSConfigCategory root = WUPSConfigCategory(rootHandle); 64 | 65 | // Category: Wii VC settings 66 | auto settings = WUPSConfigCategory::Create("Wii VC settings"); 67 | 68 | // Autolaunch (GamePad supported) 69 | constexpr WUPSConfigItemMultipleValues::ValuePair autolaunchDRCSupportedValues[] = { 70 | {DISPLAY_OPTION_CHOOSE, "Select each time"}, 71 | {DISPLAY_OPTION_USE_DRC, "Use \ue087 as controller"}, 72 | {DISPLAY_OPTION_TV, "TV Only"}, 73 | {DISPLAY_OPTION_BOTH, "TV and \ue087"}, 74 | {DISPLAY_OPTION_DRC, "\ue087 screen only"}}; 75 | 76 | settings.add(WUPSConfigItemMultipleValues::CreateFromValue(AUTOLAUNCH_DRC_SUPPORTED_CONFIG_ID, 77 | "Autolaunch (\ue087 supported)", 78 | DEFAULT_AUTOLAUNCH_DRC_SUPPORTED_VALUE, 79 | gAutolaunchDRCSupported, 80 | autolaunchDRCSupportedValues, 81 | &multipleValueItemCallback)); 82 | 83 | // Autolaunch (GamePad not supported) 84 | constexpr WUPSConfigItemMultipleValues::ValuePair autolaunchNoDRCSupportValues[] = { 85 | {DISPLAY_OPTION_CHOOSE, "Select each time"}, 86 | {DISPLAY_OPTION_TV, "TV Only"}, 87 | {DISPLAY_OPTION_BOTH, "TV and \ue087"}, 88 | {DISPLAY_OPTION_DRC, "\ue087 screen only"}}; 89 | 90 | settings.add(WUPSConfigItemMultipleValues::CreateFromValue(AUTOLAUNCH_NO_DRC_SUPPORT_CONFIG_ID, 91 | "Autolaunch (\ue087 not supported)", 92 | DEFAULT_AUTOLAUNCH_NO_DRC_SUPPORT_VALUE, 93 | gAutolaunchNoDRCSupport, 94 | autolaunchNoDRCSupportValues, 95 | &multipleValueItemCallback)); 96 | 97 | // Set resolution 98 | constexpr WUPSConfigItemMultipleValues::ValuePair setResolutionValues[] = { 99 | {SET_RESOLUTION_NONE, "Same as Wii U"}, 100 | {SET_RESOLUTION_480P, "480p"}, 101 | {SET_RESOLUTION_480P_43, "480p 4:3"}, 102 | {SET_RESOLUTION_720P, "720p"}, 103 | {SET_RESOLUTION_480I, "480i (non-HDMI only)"}, 104 | {SET_RESOLUTION_480I_43, "480i 4:3 (non-HDMI only)"}, 105 | {SET_RESOLUTION_576I, "576i (non-HDMI, PAL only)"}, 106 | {SET_RESOLUTION_576I_43, "576i 4:3 (non-HDMI, PAL only)"}, 107 | {SET_RESOLUTION_1080I, "1080i"}, 108 | {SET_RESOLUTION_1080P, "1080p"}}; 109 | 110 | settings.add(WUPSConfigItemMultipleValues::CreateFromValue(SET_RESOLUTION_CONFIG_ID, 111 | "Set resolution", 112 | DEFAULT_SET_RESOLUTION_VALUE, 113 | gSetResolution, 114 | setResolutionValues, 115 | &multipleValueItemCallback)); 116 | 117 | // Display options order 118 | constexpr WUPSConfigItemMultipleValues::ValuePair displayOptionsOrderValues[] = { 119 | {DISPLAY_OPTIONS_ORDER_DEFAULT, "Default"}, 120 | {DISPLAY_OPTIONS_ORDER_RECENT, "Recent"}}; 121 | 122 | settings.add(WUPSConfigItemMultipleValues::CreateFromValue(DISPLAY_OPTIONS_ORDER_CONFIG_ID, 123 | "Display options order", 124 | DEFAULT_DISPLAY_OPTIONS_ORDER_VALUE, 125 | gDisplayOptionsOrder, 126 | displayOptionsOrderValues, 127 | &multipleValueItemCallback)); 128 | 129 | // Use custom dialogs 130 | settings.add(WUPSConfigItemBoolean::Create(USE_CUSTOM_DIALOGS_CONFIG_ID, 131 | "Use custom dialogs (Wii U Menu needs to be restarted)", 132 | DEFAULT_USE_CUSTOM_DIALOGS_VALUE, 133 | gUseCustomDialogs, 134 | &boolItemCallback)); 135 | 136 | // Separator 137 | settings.add(WUPSConfigItemStub::Create(" ")); 138 | 139 | // Help text 140 | settings.add(WUPSConfigItemStub::Create("\uE06B Override Autolaunch by holding \uE000 when launching")); 141 | 142 | root.add(std::move(settings)); 143 | 144 | // Category: Wii Mode settings 145 | auto wiiMenuSettings = WUPSConfigCategory::Create("Wii Mode settings"); 146 | 147 | // Wii Mode set resolution 148 | constexpr WUPSConfigItemMultipleValues::ValuePair wiiMenuSetResolutionValues[] = { 149 | {SET_RESOLUTION_NONE, "Same as Wii U"}, 150 | {SET_RESOLUTION_480P, "480p"}, 151 | {SET_RESOLUTION_480P_43, "480p 4:3"}, 152 | {SET_RESOLUTION_720P, "720p"}, 153 | {SET_RESOLUTION_480I, "480i (non-HDMI only)"}, 154 | {SET_RESOLUTION_480I_43, "480i 4:3 (non-HDMI only)"}, 155 | {SET_RESOLUTION_576I, "576i (non-HDMI, PAL only)"}, 156 | {SET_RESOLUTION_576I_43, "576i 4:3 (non-HDMI, PAL only)"}, 157 | {SET_RESOLUTION_1080I, "1080i"}, 158 | {SET_RESOLUTION_1080P, "1080p"}}; 159 | 160 | wiiMenuSettings.add(WUPSConfigItemMultipleValues::CreateFromValue(WII_MENU_SET_RESOLUTION_CONFIG_ID, 161 | "Set resolution", 162 | DEFAULT_WII_MENU_SET_RESOLUTION_VALUE, 163 | gWiiMenuSetResolution, 164 | wiiMenuSetResolutionValues, 165 | &multipleValueItemCallback)); 166 | 167 | root.add(std::move(wiiMenuSettings)); 168 | 169 | // Category: WUHB Forwarder settings 170 | auto forwarderSettings = WUPSConfigCategory::Create("WUHB Forwarder settings"); 171 | 172 | // Override display 173 | constexpr WUPSConfigItemMultipleValues::ValuePair forwarderDisplayOverrideValues[] = { 174 | {DISPLAY_OPTION_CHOOSE, "Don't override"}, 175 | {DISPLAY_OPTION_TV, "TV Only"}, 176 | {DISPLAY_OPTION_BOTH, "TV and \uE087"}, 177 | {DISPLAY_OPTION_DRC, "\uE087 screen only"}}; 178 | 179 | forwarderSettings.add(WUPSConfigItemMultipleValues::CreateFromValue(FORWARDER_DISPLAY_OVERRIDE_CONFIG_ID, 180 | "Override display", 181 | DEFAULT_FORWARDER_DISPLAY_OVERRIDE, 182 | gForwarderDisplayOverride, 183 | forwarderDisplayOverrideValues, 184 | &multipleValueItemCallback)); 185 | 186 | root.add(std::move(forwarderSettings)); 187 | 188 | // Category: Other settings 189 | auto otherSettings = WUPSConfigCategory::Create("Other settings"); 190 | 191 | // Notification theme 192 | constexpr WUPSConfigItemMultipleValues::ValuePair notificationThemeValues[] = { 193 | {NOTIFICATION_THEME_OFF, "Off"}, 194 | {NOTIFICATION_THEME_DARK, "Dark"}, 195 | {NOTIFICATION_THEME_LIGHT, "Light"}}; 196 | 197 | otherSettings.add(WUPSConfigItemMultipleValues::CreateFromValue(NOTIFICATION_THEME_CONFIG_ID, 198 | "Notification theme", 199 | DEFAULT_NOTIFICATION_THEME_VALUE, 200 | gNotificationTheme, 201 | notificationThemeValues, 202 | &multipleValueItemCallback)); 203 | 204 | // Preserve SYSCONF 205 | otherSettings.add(WUPSConfigItemBoolean::Create(PRESERVE_SYSCONF_CONFIG_ID, 206 | "Preserve SYSCONF on Wii VC title launch", 207 | DEFAULT_PRESERVE_SYSCONF_VALUE, 208 | gPreserveSysconf, 209 | &boolItemCallback)); 210 | 211 | // Permanent Internet Settings 212 | otherSettings.add(WUPSConfigItemBoolean::Create(PERMANENT_NET_CONFIG_CONFIG_ID, 213 | "Permanent Wii Internet Settings", 214 | DEFAULT_PERMANENT_NET_CONFIG_VALUE, 215 | gPermanentNetConfig, 216 | &boolItemCallback)); 217 | 218 | root.add(std::move(otherSettings)); 219 | } catch (const std::exception &e) { 220 | DEBUG_FUNCTION_LINE_ERR("Exception: %s", e.what()); 221 | return WUPSCONFIG_API_CALLBACK_RESULT_ERROR; 222 | } 223 | return WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS; 224 | } 225 | 226 | void ConfigMenuClosedCallback() 227 | { 228 | // Save all changes 229 | WUPSStorageAPI::SaveStorage(); 230 | } 231 | 232 | void initConfig() 233 | { 234 | WUPSConfigAPIOptionsV1 configOptions = {.name = "Wii VC Launch"}; 235 | WUPSConfigAPI_Init(configOptions, ConfigMenuOpenedCallback, ConfigMenuClosedCallback); 236 | 237 | WUPSStorageAPI::GetOrStoreDefault(AUTOLAUNCH_DRC_SUPPORTED_CONFIG_ID, gAutolaunchDRCSupported, DEFAULT_AUTOLAUNCH_DRC_SUPPORTED_VALUE); 238 | 239 | WUPSStorageAPI::GetOrStoreDefault(AUTOLAUNCH_NO_DRC_SUPPORT_CONFIG_ID, gAutolaunchNoDRCSupport, DEFAULT_AUTOLAUNCH_NO_DRC_SUPPORT_VALUE); 240 | 241 | WUPSStorageAPI::GetOrStoreDefault(DISPLAY_OPTIONS_ORDER_CONFIG_ID, gDisplayOptionsOrder, DEFAULT_DISPLAY_OPTIONS_ORDER_VALUE); 242 | 243 | WUPSStorageAPI::GetOrStoreDefault(SET_RESOLUTION_CONFIG_ID, gSetResolution, DEFAULT_SET_RESOLUTION_VALUE); 244 | 245 | WUPSStorageAPI::GetOrStoreDefault(USE_CUSTOM_DIALOGS_CONFIG_ID, gUseCustomDialogs, DEFAULT_USE_CUSTOM_DIALOGS_VALUE); 246 | 247 | if (WUPSStorageAPI::Get(WII_MENU_SET_RESOLUTION_CONFIG_ID, gWiiMenuSetResolution) == WUPS_STORAGE_ERROR_NOT_FOUND) { 248 | gWiiMenuSetResolution = gSetResolution; 249 | WUPSStorageAPI::Store(WII_MENU_SET_RESOLUTION_CONFIG_ID, gWiiMenuSetResolution); 250 | WUPSStorageAPI::SaveStorage(); 251 | } 252 | 253 | WUPSStorageAPI::GetOrStoreDefault(FORWARDER_DISPLAY_OVERRIDE_CONFIG_ID, gForwarderDisplayOverride, DEFAULT_FORWARDER_DISPLAY_OVERRIDE); 254 | 255 | WUPSStorageAPI::GetOrStoreDefault(NOTIFICATION_THEME_CONFIG_ID, gNotificationTheme, DEFAULT_NOTIFICATION_THEME_VALUE); 256 | 257 | WUPSStorageAPI::GetOrStoreDefault(PRESERVE_SYSCONF_CONFIG_ID, gPreserveSysconf, DEFAULT_PRESERVE_SYSCONF_VALUE); 258 | 259 | WUPSStorageAPI::GetOrStoreDefault(PERMANENT_NET_CONFIG_CONFIG_ID, gPermanentNetConfig, DEFAULT_PERMANENT_NET_CONFIG_VALUE); 260 | } 261 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Wii VC 4 | #define DEFAULT_AUTOLAUNCH_DRC_SUPPORTED_VALUE DISPLAY_OPTION_CHOOSE 5 | #define DEFAULT_AUTOLAUNCH_NO_DRC_SUPPORT_VALUE DISPLAY_OPTION_CHOOSE 6 | #define DEFAULT_DISPLAY_OPTIONS_ORDER_VALUE DISPLAY_OPTIONS_ORDER_RECENT 7 | #define DEFAULT_SET_RESOLUTION_VALUE SET_RESOLUTION_NONE 8 | #define DEFAULT_USE_CUSTOM_DIALOGS_VALUE true 9 | 10 | // Wii Mode 11 | #define DEFAULT_WII_MENU_SET_RESOLUTION_VALUE SET_RESOLUTION_NONE 12 | 13 | // WUHB Forwarder 14 | #define DEFAULT_FORWARDER_DISPLAY_OVERRIDE DISPLAY_OPTION_CHOOSE 15 | 16 | // Other 17 | #define DEFAULT_NOTIFICATION_THEME_VALUE NOTIFICATION_THEME_LIGHT 18 | #define DEFAULT_PRESERVE_SYSCONF_VALUE true 19 | #define DEFAULT_PERMANENT_NET_CONFIG_VALUE false 20 | 21 | // Wii VC 22 | #define AUTOLAUNCH_DRC_SUPPORTED_CONFIG_ID "gAutolaunchDRCSupported" 23 | #define AUTOLAUNCH_NO_DRC_SUPPORT_CONFIG_ID "gAutolaunchNoDRCSupport" 24 | #define DISPLAY_OPTIONS_ORDER_CONFIG_ID "gDisplayOptionsOrder" 25 | #define SET_RESOLUTION_CONFIG_ID "gSetResolution" 26 | #define USE_CUSTOM_DIALOGS_CONFIG_ID "gUseCustomDialogs" 27 | 28 | // Wii Mode 29 | #define WII_MENU_SET_RESOLUTION_CONFIG_ID "wiiMenuSetResolution" 30 | 31 | // WUHB Forwarder 32 | #define FORWARDER_DISPLAY_OVERRIDE_CONFIG_ID "forwarderDisplayOverride" 33 | 34 | // Other 35 | #define NOTIFICATION_THEME_CONFIG_ID "notificationTheme" 36 | #define PRESERVE_SYSCONF_CONFIG_ID "preserveSysconf" 37 | #define PERMANENT_NET_CONFIG_CONFIG_ID "permanentNetConfig" 38 | 39 | void initConfig(); 40 | -------------------------------------------------------------------------------- /src/forwarder_patches.cpp: -------------------------------------------------------------------------------- 1 | #include "globals.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | static bool sAlreadyOverride = false; 8 | 9 | DECL_FUNCTION(int32_t, CMPTAcctSetScreenType, CmptScreenType type) 10 | { 11 | /* we need to allow falling back to DRC only, 12 | so a "DRC only" argument is only overridden if this is the first time calling CMPTAcctSetScreenType(), 13 | after that we never override a "DRC only" argument */ 14 | if (gForwarderDisplayOverride != DISPLAY_OPTION_CHOOSE && 15 | (!sAlreadyOverride || type != CMPT_SCREEN_TYPE_DRC) && 16 | OSGetTitleID() == _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HEALTH_AND_SAFETY)) { //only do for homebrew 17 | sAlreadyOverride = true; 18 | type = (CmptScreenType) gForwarderDisplayOverride; 19 | } 20 | return real_CMPTAcctSetScreenType(type); 21 | } 22 | 23 | WUPS_MUST_REPLACE_FOR_PROCESS(CMPTAcctSetScreenType, WUPS_LOADER_LIBRARY_NN_CMPT, CMPTAcctSetScreenType, WUPS_FP_TARGET_PROCESS_GAME); 24 | -------------------------------------------------------------------------------- /src/globals.cpp: -------------------------------------------------------------------------------- 1 | #include "globals.hpp" 2 | #include "config.h" 3 | 4 | // Wii VC 5 | int32_t gAutolaunchDRCSupported = DEFAULT_AUTOLAUNCH_DRC_SUPPORTED_VALUE; 6 | int32_t gAutolaunchNoDRCSupport = DEFAULT_AUTOLAUNCH_NO_DRC_SUPPORT_VALUE; 7 | int32_t gDisplayOptionsOrder = DEFAULT_DISPLAY_OPTIONS_ORDER_VALUE; 8 | int32_t gSetResolution = DEFAULT_SET_RESOLUTION_VALUE; 9 | bool gUseCustomDialogs = DEFAULT_USE_CUSTOM_DIALOGS_VALUE; 10 | 11 | // Wii Mode 12 | int32_t gWiiMenuSetResolution = DEFAULT_WII_MENU_SET_RESOLUTION_VALUE; 13 | 14 | // WUHB Forwarder 15 | int32_t gForwarderDisplayOverride = DEFAULT_FORWARDER_DISPLAY_OVERRIDE; 16 | 17 | // Other 18 | int32_t gNotificationTheme = DEFAULT_NOTIFICATION_THEME_VALUE; 19 | bool gPreserveSysconf = DEFAULT_PRESERVE_SYSCONF_VALUE; 20 | bool gPermanentNetConfig = DEFAULT_PERMANENT_NET_CONFIG_VALUE; 21 | 22 | bool gInWiiUMenu = false; 23 | -------------------------------------------------------------------------------- /src/globals.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | //values must align with corresponding values in enum CmptScreenType in in wut 6 | enum DisplayOption { 7 | DISPLAY_OPTION_USE_DRC, 8 | DISPLAY_OPTION_TV, 9 | DISPLAY_OPTION_DRC, 10 | DISPLAY_OPTION_BOTH, 11 | DISPLAY_OPTION_CHOOSE, 12 | }; 13 | 14 | enum DisplayOptionsOrder { 15 | DISPLAY_OPTIONS_ORDER_DEFAULT, 16 | DISPLAY_OPTIONS_ORDER_RECENT, 17 | }; 18 | 19 | //values must align with corresponding values in enum AVMTvResolution in in wut 20 | enum SetResolution { 21 | SET_RESOLUTION_NONE = 0, 22 | SET_RESOLUTION_576I = 1, 23 | SET_RESOLUTION_480I = 2, 24 | SET_RESOLUTION_480P = 3, 25 | SET_RESOLUTION_720P = 4, 26 | SET_RESOLUTION_1080I = 6, 27 | SET_RESOLUTION_1080P = 7, 28 | SET_RESOLUTION_576I_43 = 101, 29 | SET_RESOLUTION_480I_43 = 102, 30 | SET_RESOLUTION_480P_43 = 103, 31 | }; 32 | 33 | enum NotificationTheme { 34 | NOTIFICATION_THEME_OFF, 35 | NOTIFICATION_THEME_DARK, 36 | NOTIFICATION_THEME_LIGHT, 37 | }; 38 | 39 | #define SET_RESOLUTION_4_3_MODIFIER 100 40 | 41 | // Wii VC 42 | extern int32_t gAutolaunchDRCSupported; 43 | extern int32_t gAutolaunchNoDRCSupport; 44 | extern int32_t gDisplayOptionsOrder; 45 | extern int32_t gSetResolution; 46 | extern bool gUseCustomDialogs; 47 | 48 | // Wii Mode 49 | extern int32_t gWiiMenuSetResolution; 50 | 51 | // WUHB Forwarder 52 | extern int32_t gForwarderDisplayOverride; 53 | 54 | // Other 55 | extern int32_t gNotificationTheme; 56 | extern bool gPreserveSysconf; 57 | extern bool gPermanentNetConfig; 58 | 59 | extern bool gInWiiUMenu; 60 | -------------------------------------------------------------------------------- /src/logger.c: -------------------------------------------------------------------------------- 1 | #ifdef DEBUG 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | uint32_t moduleLogInit = false; 8 | uint32_t cafeLogInit = false; 9 | uint32_t udpLogInit = false; 10 | #endif // DEBUG 11 | 12 | void initLogging() { 13 | #ifdef DEBUG 14 | if (!(moduleLogInit = WHBLogModuleInit())) { 15 | cafeLogInit = WHBLogCafeInit(); 16 | udpLogInit = WHBLogUdpInit(); 17 | } 18 | #endif // DEBUG 19 | } 20 | 21 | void deinitLogging() { 22 | #ifdef DEBUG 23 | if (moduleLogInit) { 24 | WHBLogModuleDeinit(); 25 | moduleLogInit = false; 26 | } 27 | if (cafeLogInit) { 28 | WHBLogCafeDeinit(); 29 | cafeLogInit = false; 30 | } 31 | if (udpLogInit) { 32 | WHBLogUdpDeinit(); 33 | udpLogInit = false; 34 | } 35 | #endif // DEBUG 36 | } 37 | -------------------------------------------------------------------------------- /src/logger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define LOG_APP_TYPE "P" 12 | #define LOG_APP_NAME "WiiVCLaunch" 13 | 14 | #define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) 15 | #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__) 16 | 17 | #define LOG(LOG_FUNC, FMT, ARGS...) LOG_EX(LOG_FUNC, "", "", FMT, ##ARGS) 18 | 19 | #define LOG_EX(LOG_FUNC, LOG_LEVEL, LINE_END, FMT, ARGS...) \ 20 | do { \ 21 | LOG_FUNC("[(%s)%s][%23s]%30s@L%04d: " LOG_LEVEL "" FMT "" LINE_END, LOG_APP_TYPE, LOG_APP_NAME, __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ 22 | } while (0) 23 | 24 | 25 | #ifdef DEBUG 26 | 27 | #ifdef VERBOSE_DEBUG 28 | #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) LOG(WHBLogPrintf, FMT, ##ARGS) 29 | #else 30 | #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) 31 | #endif 32 | 33 | #define DEBUG_FUNCTION_LINE(FMT, ARGS...) LOG(WHBLogPrintf, FMT, ##ARGS) 34 | 35 | #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) LOG(WHBLogWritef, FMT, ##ARGS) 36 | 37 | #define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS) 38 | #define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX(WHBLogPrintf, "##WARN ## ", "", FMT, ##ARGS) 39 | #define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX(WHBLogPrintf, "##INFO ## ", "", FMT, ##ARGS) 40 | 41 | #else 42 | 43 | #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) 44 | 45 | #define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0) 46 | 47 | #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0) 48 | 49 | #define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX(OSReport, "##ERROR## ", "\n", FMT, ##ARGS) 50 | #define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX(OSReport, "##WARN ## ", "\n", FMT, ##ARGS) 51 | #define DEBUG_FUNCTION_LINE_INFO(FMT, ARGS...) LOG_EX(OSReport, "##INFO ## ", "\n", FMT, ##ARGS) 52 | 53 | #endif 54 | 55 | void initLogging(); 56 | void deinitLogging(); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "config.h" 3 | #include "globals.hpp" 4 | #include "logger.h" 5 | #include "mocha.h" 6 | #include "notifications.h" 7 | #include "sysconf_preserver.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | // Mandatory plugin info 21 | WUPS_PLUGIN_NAME("Wii VC Launch"); 22 | WUPS_PLUGIN_DESCRIPTION(DESCRIPTION); 23 | WUPS_PLUGIN_VERSION(VERSION); 24 | WUPS_PLUGIN_AUTHOR("Lynx64"); 25 | WUPS_PLUGIN_LICENSE("GPLv3"); 26 | 27 | WUPS_USE_WUT_DEVOPTAB(); 28 | 29 | // Gets called ONCE when the plugin was loaded 30 | INITIALIZE_PLUGIN() 31 | { 32 | initConfig(); 33 | initNotifications(); 34 | restoreSysconfIfNeeded(); 35 | } 36 | 37 | DEINITIALIZE_PLUGIN() 38 | { 39 | NotificationModule_DeInitLibrary(); 40 | } 41 | 42 | extern "C" int32_t CMPTAcctSetDrcCtrlEnabled(int32_t enable); 43 | 44 | static OSDynLoad_Module erreulaModule = nullptr; 45 | //ErrEula functions copied from in wut 46 | static void (*dyn_ErrEulaAppearError)(const nn::erreula::AppearArg &arg) = nullptr; 47 | static void (*dyn_ErrEulaCalc)(const nn::erreula::ControllerInfo &controllerInfo) = nullptr; 48 | static void (*dyn_ErrEulaDisappearError)() = nullptr; 49 | static nn::erreula::State (*dyn_ErrEulaGetStateErrorViewer)() = nullptr; 50 | static bool (*dyn_ErrEulaIsDecideSelectLeftButtonError)() = nullptr; 51 | static bool (*dyn_ErrEulaIsDecideSelectRightButtonError)() = nullptr; 52 | 53 | static bool sLaunchingWiiGame = false; 54 | static bool sInputRedirectionActive = false; 55 | static bool sUserCancelledCustomDialogs = false; 56 | 57 | //remap buttons functions copied from https://github.com/wiiu-env/WiiUPluginLoaderBackend/blob/cb527add76c95bff3fb1ddef7a016fec3db4c497/source/utils/ConfigUtils.cpp#LL35C7-L35C7 58 | static uint32_t remapWiiMoteButtons(uint32_t buttons) 59 | { 60 | uint32_t convButtons = 0; 61 | 62 | if (buttons & WPAD_BUTTON_LEFT) 63 | convButtons |= VPAD_BUTTON_LEFT; 64 | 65 | if (buttons & WPAD_BUTTON_RIGHT) 66 | convButtons |= VPAD_BUTTON_RIGHT; 67 | 68 | if (buttons & WPAD_BUTTON_DOWN) 69 | convButtons |= VPAD_BUTTON_DOWN; 70 | 71 | if (buttons & WPAD_BUTTON_UP) 72 | convButtons |= VPAD_BUTTON_UP; 73 | 74 | if (buttons & WPAD_BUTTON_PLUS) 75 | convButtons |= VPAD_BUTTON_PLUS; 76 | 77 | if (buttons & WPAD_BUTTON_B) 78 | convButtons |= VPAD_BUTTON_B; 79 | 80 | if (buttons & WPAD_BUTTON_A) 81 | convButtons |= VPAD_BUTTON_A; 82 | 83 | if (buttons & WPAD_BUTTON_MINUS) 84 | convButtons |= VPAD_BUTTON_MINUS; 85 | 86 | if (buttons & WPAD_BUTTON_HOME) 87 | convButtons |= VPAD_BUTTON_HOME; 88 | 89 | return convButtons; 90 | } 91 | 92 | static uint32_t remapClassicButtons(uint32_t buttons) 93 | { 94 | uint32_t convButtons = 0; 95 | 96 | if (buttons & WPAD_CLASSIC_BUTTON_LEFT) 97 | convButtons |= VPAD_BUTTON_LEFT; 98 | 99 | if (buttons & WPAD_CLASSIC_BUTTON_RIGHT) 100 | convButtons |= VPAD_BUTTON_RIGHT; 101 | 102 | if (buttons & WPAD_CLASSIC_BUTTON_DOWN) 103 | convButtons |= VPAD_BUTTON_DOWN; 104 | 105 | if (buttons & WPAD_CLASSIC_BUTTON_UP) 106 | convButtons |= VPAD_BUTTON_UP; 107 | 108 | if (buttons & WPAD_CLASSIC_BUTTON_PLUS) 109 | convButtons |= VPAD_BUTTON_PLUS; 110 | 111 | if (buttons & WPAD_CLASSIC_BUTTON_X) 112 | convButtons |= VPAD_BUTTON_X; 113 | 114 | if (buttons & WPAD_CLASSIC_BUTTON_Y) 115 | convButtons |= VPAD_BUTTON_Y; 116 | 117 | if (buttons & WPAD_CLASSIC_BUTTON_B) 118 | convButtons |= VPAD_BUTTON_B; 119 | 120 | if (buttons & WPAD_CLASSIC_BUTTON_A) 121 | convButtons |= VPAD_BUTTON_A; 122 | 123 | if (buttons & WPAD_CLASSIC_BUTTON_MINUS) 124 | convButtons |= VPAD_BUTTON_MINUS; 125 | 126 | if (buttons & WPAD_CLASSIC_BUTTON_HOME) 127 | convButtons |= VPAD_BUTTON_HOME; 128 | 129 | if (buttons & WPAD_CLASSIC_BUTTON_ZR) 130 | convButtons |= VPAD_BUTTON_ZR; 131 | 132 | if (buttons & WPAD_CLASSIC_BUTTON_ZL) 133 | convButtons |= VPAD_BUTTON_ZL; 134 | 135 | if (buttons & WPAD_CLASSIC_BUTTON_R) 136 | convButtons |= VPAD_BUTTON_R; 137 | 138 | if (buttons & WPAD_CLASSIC_BUTTON_L) 139 | convButtons |= VPAD_BUTTON_L; 140 | 141 | return convButtons; 142 | } //end of copied functions 143 | 144 | static const char * displayOptionToStringWithoutIcons(int32_t displayOption) 145 | { 146 | // the GamePad icon doesn't look good on the notification's small font size 147 | switch (displayOption) 148 | { 149 | case DISPLAY_OPTION_USE_DRC: 150 | return "Use GamePad as controller"; 151 | case DISPLAY_OPTION_TV: 152 | return "TV Only"; 153 | case DISPLAY_OPTION_BOTH: 154 | return "TV and GamePad"; 155 | case DISPLAY_OPTION_DRC: 156 | return "GamePad screen only"; 157 | default: 158 | return ""; 159 | } 160 | } 161 | 162 | static const char16_t * displayOptionToString16(int32_t displayOption) 163 | { 164 | switch (displayOption) 165 | { 166 | case DISPLAY_OPTION_USE_DRC: 167 | return u"Use \uE087 as controller"; 168 | case DISPLAY_OPTION_TV: 169 | return u"TV Only"; 170 | case DISPLAY_OPTION_BOTH: 171 | return u"TV and \uE087"; 172 | case DISPLAY_OPTION_DRC: 173 | return u"\uE087 screen only"; 174 | default: 175 | return u""; 176 | } 177 | } 178 | 179 | static void showAutolaunchNotification(int32_t displayOption) 180 | { 181 | char text[41]; 182 | snprintf(text, sizeof(text), "Autolaunching: %s", displayOptionToStringWithoutIcons(displayOption)); 183 | NotificationModule_AddInfoNotification(text); 184 | } 185 | 186 | static void setResolution(int32_t resolution) 187 | { 188 | if (resolution == SET_RESOLUTION_NONE) return; 189 | 190 | if (resolution == SET_RESOLUTION_576I || resolution == SET_RESOLUTION_576I_43) { 191 | AVMSetTVVideoRegion(AVM_TV_VIDEO_REGION_PAL, TVEGetCurrentPort(), AVM_TV_RESOLUTION_576I); 192 | } else { 193 | if (resolution > SET_RESOLUTION_4_3_MODIFIER) { 194 | AVMSetTVScanResolution((AVMTvResolution) (resolution - SET_RESOLUTION_4_3_MODIFIER)); 195 | } else { 196 | AVMSetTVScanResolution((AVMTvResolution) resolution); 197 | } 198 | } 199 | 200 | if (resolution > SET_RESOLUTION_4_3_MODIFIER) 201 | AVMSetTVAspectRatio(AVM_TV_ASPECT_RATIO_4_3); 202 | } 203 | 204 | static void setDisplay(int32_t displayOption) 205 | { 206 | if (displayOption == DISPLAY_OPTION_USE_DRC) { 207 | CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_BOTH); 208 | CMPTAcctSetDrcCtrlEnabled(1); 209 | } else { 210 | CMPTAcctSetDrcCtrlEnabled(0); 211 | CMPTAcctSetScreenType((CmptScreenType) displayOption); 212 | } 213 | 214 | if (CMPTCheckScreenState() < 0) 215 | CMPTAcctSetScreenType(CMPT_SCREEN_TYPE_DRC); 216 | } 217 | 218 | ON_APPLICATION_START() 219 | { 220 | #ifdef DEBUG 221 | initLogging(); 222 | #endif 223 | if (OSGetTitleID() == 0x0005001010040000 || // Wii U Menu JPN 224 | OSGetTitleID() == 0x0005001010040100 || // Wii U Menu USA 225 | OSGetTitleID() == 0x0005001010040200) { // Wii U Menu EUR 226 | gInWiiUMenu = true; 227 | sLaunchingWiiGame = false; 228 | } else { 229 | gInWiiUMenu = false; 230 | } 231 | } 232 | 233 | //patch the app type of Wii games to a Wii U game on the Wii U Menu. This avoids the built in Wii dialogs 234 | DECL_FUNCTION(int32_t, MCP_TitleList, int32_t handle, uint32_t *outTitleCount, MCPTitleListType *titleList, uint32_t size) 235 | { 236 | int32_t result = real_MCP_TitleList(handle, outTitleCount, titleList, size); 237 | 238 | if (gUseCustomDialogs && gInWiiUMenu) { 239 | if (result == 0 && outTitleCount && titleList && size != 0) { 240 | DEBUG_FUNCTION_LINE_INFO("Patching MCP_TitleList in Wii U Menu"); 241 | uint32_t titleCount = *outTitleCount; 242 | for (uint32_t i = 0; i < titleCount; i++) { 243 | if (titleList[i].appType == MCP_APP_TYPE_GAME_WII) titleList[i].appType = MCP_APP_TYPE_GAME; 244 | } 245 | } else { 246 | DEBUG_FUNCTION_LINE_WARN("Either real_MCP_TitleList did not return 0 (returned %d)", result); 247 | DEBUG_FUNCTION_LINE_WARN("or outTitleCount == nullptr or titleList == nullptr"); 248 | } 249 | } 250 | 251 | return result; 252 | } 253 | 254 | DECL_FUNCTION(int32_t, ACPGetLaunchMetaXml, ACPMetaXml *metaXml) 255 | { 256 | int32_t result = real_ACPGetLaunchMetaXml(metaXml); 257 | 258 | if (!gUseCustomDialogs || !gInWiiUMenu) { 259 | return result; 260 | } else if (result != ACP_RESULT_SUCCESS) { 261 | sLaunchingWiiGame = false; 262 | return result; 263 | } else if (sLaunchingWiiGame) { 264 | //the rest of this function has already ran once, no need to run again (ACPGetLaunchMetaXml can get called twice) 265 | return ACP_RESULT_SUCCESS; 266 | } 267 | 268 | //check if wii game launched, if not then return 269 | MCPTitleListType titleInfo; 270 | int32_t mcpHandle = MCP_Open(); 271 | MCPError mcpError = MCP_GetTitleInfo(mcpHandle, metaXml->title_id, &titleInfo); 272 | MCP_Close(mcpHandle); 273 | if (mcpError != 0 || titleInfo.appType != MCP_APP_TYPE_GAME_WII) { 274 | return ACP_RESULT_SUCCESS; 275 | } 276 | sLaunchingWiiGame = true; 277 | 278 | //read drc_use value 279 | const bool DRC_USE = metaXml->drc_use == 65537; 280 | 281 | //check if A button held, if so then skip autolaunch check 282 | VPADStatus vpadStatus{}; 283 | VPADReadError vpadError = VPAD_READ_UNINITIALIZED; 284 | KPADStatus kpadStatus[4]; 285 | KPADError kpadError[4]; 286 | uint32_t buttonsHeld = 0; 287 | bool activateCursor = true; 288 | 289 | if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) { 290 | buttonsHeld = vpadStatus.hold; 291 | } 292 | 293 | for (int32_t chan = 0; chan < 4; chan++) { 294 | if (KPADReadEx((KPADChan) chan, &kpadStatus[chan], 1, &kpadError[chan]) > 0) { 295 | if (kpadError[chan] == KPAD_ERROR_OK && kpadStatus[chan].extensionType != 0xFF) { 296 | if (kpadStatus[chan].extensionType == WPAD_EXT_CORE || kpadStatus[chan].extensionType == WPAD_EXT_NUNCHUK || 297 | kpadStatus[chan].extensionType == WPAD_EXT_MPLUS || kpadStatus[chan].extensionType == WPAD_EXT_MPLUS_NUNCHUK) { 298 | buttonsHeld |= remapWiiMoteButtons(kpadStatus[chan].hold); 299 | } else { 300 | buttonsHeld |= remapClassicButtons(kpadStatus[chan].classic.hold); 301 | } 302 | } 303 | } 304 | } 305 | 306 | if (!(buttonsHeld & VPAD_BUTTON_A)) { 307 | //check autolaunch 308 | if (DRC_USE && gAutolaunchDRCSupported != DISPLAY_OPTION_CHOOSE) { 309 | setDisplay(gAutolaunchDRCSupported); 310 | if (gNotificationTheme != NOTIFICATION_THEME_OFF) 311 | showAutolaunchNotification(gAutolaunchDRCSupported); 312 | return ACP_RESULT_SUCCESS; 313 | } else if (!DRC_USE && gAutolaunchNoDRCSupport != DISPLAY_OPTION_CHOOSE) { 314 | setDisplay(gAutolaunchNoDRCSupport); 315 | if (gNotificationTheme != NOTIFICATION_THEME_OFF) 316 | showAutolaunchNotification(gAutolaunchNoDRCSupport); 317 | return ACP_RESULT_SUCCESS; 318 | } 319 | } else { 320 | activateCursor = false; 321 | } 322 | 323 | //load erreula 324 | if (OSDynLoad_Acquire("erreula.rpl", &erreulaModule) != OS_DYNLOAD_OK) { 325 | return ACP_RESULT_SUCCESS; 326 | } 327 | if (OSDynLoad_FindExport(erreulaModule, OS_DYNLOAD_EXPORT_FUNC, "ErrEulaAppearError__3RplFRCQ3_2nn7erreula9AppearArg", (void**) &dyn_ErrEulaAppearError) != OS_DYNLOAD_OK || 328 | OSDynLoad_FindExport(erreulaModule, OS_DYNLOAD_EXPORT_FUNC, "ErrEulaCalc__3RplFRCQ3_2nn7erreula14ControllerInfo", (void**) &dyn_ErrEulaCalc) != OS_DYNLOAD_OK || 329 | OSDynLoad_FindExport(erreulaModule, OS_DYNLOAD_EXPORT_FUNC, "ErrEulaDisappearError__3RplFv", (void**) &dyn_ErrEulaDisappearError) != OS_DYNLOAD_OK || 330 | OSDynLoad_FindExport(erreulaModule, OS_DYNLOAD_EXPORT_FUNC, "ErrEulaGetStateErrorViewer__3RplFv", (void**) &dyn_ErrEulaGetStateErrorViewer) != OS_DYNLOAD_OK || 331 | OSDynLoad_FindExport(erreulaModule, OS_DYNLOAD_EXPORT_FUNC, "ErrEulaIsDecideSelectLeftButtonError__3RplFv", (void**) &dyn_ErrEulaIsDecideSelectLeftButtonError) != OS_DYNLOAD_OK || 332 | OSDynLoad_FindExport(erreulaModule, OS_DYNLOAD_EXPORT_FUNC, "ErrEulaIsDecideSelectRightButtonError__3RplFv", (void**) &dyn_ErrEulaIsDecideSelectRightButtonError) != OS_DYNLOAD_OK) { 333 | 334 | OSDynLoad_Release(erreulaModule); 335 | return ACP_RESULT_SUCCESS; 336 | } 337 | 338 | int32_t recent[4] = {DISPLAY_OPTION_USE_DRC, DISPLAY_OPTION_TV, DISPLAY_OPTION_BOTH, DISPLAY_OPTION_DRC}; 339 | //read recent order 340 | if (gDisplayOptionsOrder == DISPLAY_OPTIONS_ORDER_RECENT) { 341 | if (WUPSStorageAPI::Get("recent0", recent[0]) != WUPS_STORAGE_ERROR_SUCCESS || 342 | WUPSStorageAPI::Get("recent1", recent[1]) != WUPS_STORAGE_ERROR_SUCCESS || 343 | WUPSStorageAPI::Get("recent2", recent[2]) != WUPS_STORAGE_ERROR_SUCCESS || 344 | WUPSStorageAPI::Get("recent3", recent[3]) != WUPS_STORAGE_ERROR_SUCCESS) { 345 | 346 | //failed to read values from storage - use default values 347 | recent[0] = DISPLAY_OPTION_USE_DRC; 348 | recent[1] = DISPLAY_OPTION_TV; 349 | recent[2] = DISPLAY_OPTION_BOTH; 350 | recent[3] = DISPLAY_OPTION_DRC; 351 | } 352 | } 353 | 354 | //set the values for the error viewer that we will keep the same 355 | nn::erreula::AppearArg appearArg; 356 | appearArg.errorArg.renderTarget = nn::erreula::RenderTarget::Both; 357 | appearArg.errorArg.controllerType = nn::erreula::ControllerType::DrcGamepad; 358 | 359 | bool redraw = true; 360 | bool onFirstPage = true; 361 | int32_t selectedDisplay = recent[0]; 362 | int32_t position[2] = {recent[0], recent[1]}; 363 | 364 | while (true) { 365 | OSSleepTicks(OSMillisecondsToTicks(16)); 366 | 367 | if (ProcUIInForeground() == FALSE) { 368 | sLaunchingWiiGame = false; 369 | break; 370 | } 371 | 372 | if (dyn_ErrEulaGetStateErrorViewer() != nn::erreula::State::Visible && dyn_ErrEulaGetStateErrorViewer() != nn::erreula::State::Hidden) 373 | continue; 374 | 375 | if (redraw) { 376 | redraw = false; 377 | 378 | uint32_t positionI = 0; 379 | uint32_t skippedOptionsCount = 0; 380 | bool tvConnected = true; //default to true so tv options are always displayed if non-hdmi is used 381 | if (TVEGetCurrentPort() == TVE_PORT_HDMI) { 382 | TVEHdmiState hdmiState = TVE_HDMI_STATE_HTPG_OFF; 383 | AVMGetHDMIState(&hdmiState); 384 | if (hdmiState != TVE_HDMI_STATE_DONE && hdmiState != TVE_HDMI_STATE_3RDA) 385 | tvConnected = false; 386 | } 387 | 388 | for (uint32_t recentI = 0; recentI < 4; recentI++) { 389 | if (!DRC_USE && recent[recentI] == DISPLAY_OPTION_USE_DRC) 390 | continue; 391 | if (tvConnected && !onFirstPage && skippedOptionsCount < 2) { 392 | skippedOptionsCount++; 393 | continue; 394 | } else if (!tvConnected && (recent[recentI] == DISPLAY_OPTION_TV || recent[recentI] == DISPLAY_OPTION_BOTH)) { 395 | continue; 396 | } 397 | position[positionI] = recent[recentI]; 398 | positionI++; 399 | if (positionI > 1) 400 | break; 401 | } 402 | 403 | if (positionI == 0) { //should never happen - filter returned 0 options 404 | break; 405 | } else if (positionI == 1) { 406 | position[1] = position[0]; 407 | appearArg.errorArg.errorType = nn::erreula::ErrorType::Message1Button; 408 | } else { 409 | appearArg.errorArg.button2Label = displayOptionToString16(position[1]); 410 | appearArg.errorArg.errorType = nn::erreula::ErrorType::Message2Button; 411 | } 412 | appearArg.errorArg.button1Label = displayOptionToString16(position[0]); 413 | if (tvConnected) { 414 | appearArg.errorArg.errorMessage = u"\n\nSelect a display option.\n\n\n\uE07D More options"; 415 | } else { 416 | appearArg.errorArg.errorMessage = u"\n\nSelect a display option.\n\n\n\uE07D Detect TV"; 417 | } 418 | dyn_ErrEulaAppearError(appearArg); 419 | continue; 420 | } 421 | 422 | if (dyn_ErrEulaIsDecideSelectLeftButtonError()) { 423 | selectedDisplay = position[0]; 424 | break; 425 | } else if (dyn_ErrEulaIsDecideSelectRightButtonError()) { 426 | //note when using Message1Button, IsDecideSelectRight returns true, IsDecideSelectLeft returns false 427 | selectedDisplay = position[1]; 428 | break; 429 | } 430 | 431 | buttonsHeld = 0; 432 | 433 | if (VPADRead(VPAD_CHAN_0, &vpadStatus, 1, &vpadError) > 0 && vpadError == VPAD_READ_SUCCESS) { 434 | buttonsHeld = vpadStatus.hold; 435 | } 436 | 437 | for (int32_t chan = 0; chan < 4; chan++) { 438 | if (KPADReadEx((KPADChan) chan, &kpadStatus[chan], 1, &kpadError[chan]) > 0) { 439 | if (kpadError[chan] == KPAD_ERROR_OK && kpadStatus[chan].extensionType != 0xFF) { 440 | if (kpadStatus[chan].extensionType == WPAD_EXT_CORE || kpadStatus[chan].extensionType == WPAD_EXT_NUNCHUK || 441 | kpadStatus[chan].extensionType == WPAD_EXT_MPLUS || kpadStatus[chan].extensionType == WPAD_EXT_MPLUS_NUNCHUK) { 442 | buttonsHeld |= remapWiiMoteButtons(kpadStatus[chan].hold); 443 | } else { 444 | buttonsHeld |= remapClassicButtons(kpadStatus[chan].classic.hold); 445 | } 446 | } 447 | } 448 | } 449 | 450 | if (activateCursor) { 451 | //pass a fake input into Calc to activate the select cursor by default when the dialog appears 452 | activateCursor = false; 453 | vpadStatus.hold = VPAD_BUTTON_LEFT; 454 | kpadStatus[0].hold = WPAD_BUTTON_LEFT; 455 | kpadStatus[0].classic.hold = WPAD_CLASSIC_BUTTON_LEFT; 456 | nn::erreula::ControllerInfo controllerInfo; 457 | controllerInfo.vpad = &vpadStatus; 458 | controllerInfo.kpad[0] = &kpadStatus[0]; 459 | controllerInfo.kpad[1] = nullptr; 460 | controllerInfo.kpad[2] = nullptr; 461 | controllerInfo.kpad[3] = nullptr; 462 | dyn_ErrEulaCalc(controllerInfo); 463 | } 464 | 465 | if (buttonsHeld & VPAD_BUTTON_DOWN || buttonsHeld & VPAD_BUTTON_UP) { 466 | redraw = true; 467 | activateCursor = true; 468 | onFirstPage = !onFirstPage; 469 | dyn_ErrEulaDisappearError(); 470 | } else if (buttonsHeld & VPAD_BUTTON_B) { 471 | sUserCancelledCustomDialogs = true; 472 | sLaunchingWiiGame = false; 473 | break; 474 | } 475 | 476 | } //end while 477 | 478 | if (!sUserCancelledCustomDialogs) 479 | dyn_ErrEulaDisappearError(); 480 | OSDynLoad_Release(erreulaModule); 481 | 482 | if (sUserCancelledCustomDialogs) { 483 | return ACP_RESULT_MEDIA_NOT_READY; //return error to abort launching 484 | } else if (!sLaunchingWiiGame) { 485 | return ACP_RESULT_SUCCESS; //return early if we're exiting from ProcUI 486 | } 487 | 488 | setDisplay(selectedDisplay); 489 | 490 | //check if we need to update recent order 491 | if (gDisplayOptionsOrder == DISPLAY_OPTIONS_ORDER_RECENT && selectedDisplay != recent[0]) { 492 | //update recent order 493 | if (selectedDisplay != recent[1]) { 494 | if (selectedDisplay != recent[2]) { 495 | recent[3] = recent[2]; 496 | } 497 | recent[2] = recent[1]; 498 | } 499 | recent[1] = recent[0]; 500 | recent[0] = selectedDisplay; 501 | 502 | //save new order to storage 503 | WUPSStorageAPI::Store("recent0", recent[0]); 504 | WUPSStorageAPI::Store("recent1", recent[1]); 505 | WUPSStorageAPI::Store("recent2", recent[2]); 506 | WUPSStorageAPI::Store("recent3", recent[3]); 507 | 508 | WUPSStorageAPI::SaveStorage(); 509 | } 510 | 511 | return ACP_RESULT_SUCCESS; 512 | } 513 | 514 | DECL_FUNCTION(bool, ErrEulaIsDecideSelectButtonError__3RplFv) 515 | { 516 | if (sUserCancelledCustomDialogs) { 517 | sUserCancelledCustomDialogs = false; 518 | return true; 519 | } 520 | return real_ErrEulaIsDecideSelectButtonError__3RplFv(); 521 | } 522 | 523 | static void patchNetConfigOverwrite() 524 | { 525 | if (initMocha() != MOCHA_RESULT_SUCCESS) 526 | return; 527 | 528 | uint32_t data0 = 0; 529 | uint32_t data1 = 0; 530 | Mocha_IOSUKernelRead32(0x0503A1C4, &data0); // cmp r6,#0x3 ; bne LAB_0503a178 531 | Mocha_IOSUKernelRead32(0x0503A1FC, &data1); // adds r5,#0x18 ; add r3,sp,#0x330 532 | if (data0 != 0x2E03D1D7 || data1 != 0x3518ABCC) { 533 | Mocha_DeInitLibrary(); 534 | return; 535 | } 536 | 537 | Mocha_IOSUKernelWrite32(0x0503A1C4, 0x2E02D1D7); // cmp r6,#0x2 ; bne LAB_0503a178 538 | Mocha_IOSUKernelWrite32(0x0503A1FC, 0x3518ABC6); // adds r5,#0x18 ; add r3,sp,#0x318 539 | 540 | Mocha_DeInitLibrary(); 541 | } 542 | 543 | DECL_FUNCTION(int32_t, CMPTExPrepareLaunch, uint32_t unk1, void *unk2, uint32_t unk3) 544 | { 545 | setResolution(gSetResolution); 546 | if (gPermanentNetConfig) 547 | patchNetConfigOverwrite(); 548 | 549 | int32_t result = real_CMPTExPrepareLaunch(unk1, unk2, unk3); 550 | 551 | if (gPreserveSysconf && result == 0) 552 | backupSysconf(); 553 | return result; 554 | } 555 | 556 | DECL_FUNCTION(int32_t, CMPTLaunchMenu, void *dataBuffer, uint32_t bufferSize) 557 | { 558 | setResolution(gWiiMenuSetResolution); 559 | sInputRedirectionActive = false; 560 | return real_CMPTLaunchMenu(dataBuffer, bufferSize); 561 | } 562 | 563 | DECL_FUNCTION(int32_t, CMPTLaunchDataManager, void *dataBuffer, uint32_t bufferSize) 564 | { 565 | setResolution(gWiiMenuSetResolution); 566 | sInputRedirectionActive = false; 567 | return real_CMPTLaunchDataManager(dataBuffer, bufferSize); 568 | } 569 | 570 | DECL_FUNCTION(int32_t, MCP_LaunchCompat, int32_t handle, void *confBuffer, uint32_t confBufferSize, void *imgsBuffer, uint32_t imgsBufferSize) 571 | { 572 | if (gPermanentNetConfig) 573 | patchNetConfigOverwrite(); 574 | return real_MCP_LaunchCompat(handle, confBuffer, confBufferSize, imgsBuffer, imgsBufferSize); 575 | } 576 | 577 | DECL_FUNCTION(int32_t, CMPTAcctSetDrcCtrlEnabled, int32_t enable) 578 | { 579 | if (enable == 0 && !sLaunchingWiiGame) { 580 | int8_t sensorBarEnabled = 0; 581 | VPADBASEGetSensorBarSetting(VPAD_CHAN_0, &sensorBarEnabled); 582 | if (!sensorBarEnabled && VPADSetSensorBar(VPAD_CHAN_0, true) == 0) { 583 | if (gNotificationTheme != NOTIFICATION_THEME_OFF) 584 | NotificationModule_AddInfoNotification("GamePad sensor bar enabled"); 585 | } 586 | sInputRedirectionActive = true; 587 | } 588 | return real_CMPTAcctSetDrcCtrlEnabled(enable); 589 | } 590 | 591 | DECL_FUNCTION(int32_t, WPADProbe, WPADChan chan, WPADExtensionType *outExtensionType) 592 | { 593 | int32_t result = real_WPADProbe(chan, outExtensionType); 594 | if (sInputRedirectionActive && result == 0 && outExtensionType && *outExtensionType == WPAD_EXT_PRO_CONTROLLER) { 595 | *outExtensionType = WPAD_EXT_CLASSIC; 596 | } 597 | return result; 598 | } 599 | 600 | ON_APPLICATION_REQUESTS_EXIT() 601 | { 602 | sInputRedirectionActive = false; 603 | #ifdef DEBUG 604 | deinitLogging(); 605 | #endif 606 | } 607 | 608 | //replace only for Wii U Menu process 609 | WUPS_MUST_REPLACE_FOR_PROCESS(MCP_TitleList, WUPS_LOADER_LIBRARY_COREINIT, MCP_TitleList, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 610 | WUPS_MUST_REPLACE_FOR_PROCESS(ACPGetLaunchMetaXml, WUPS_LOADER_LIBRARY_NN_ACP, ACPGetLaunchMetaXml, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 611 | WUPS_MUST_REPLACE_FOR_PROCESS(ErrEulaIsDecideSelectButtonError__3RplFv, WUPS_LOADER_LIBRARY_ERREULA, ErrEulaIsDecideSelectButtonError__3RplFv, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 612 | WUPS_MUST_REPLACE_FOR_PROCESS(CMPTLaunchMenu, WUPS_LOADER_LIBRARY_NN_CMPT, CMPTLaunchMenu, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 613 | WUPS_MUST_REPLACE_FOR_PROCESS(CMPTLaunchDataManager, WUPS_LOADER_LIBRARY_NN_CMPT, CMPTLaunchDataManager, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 614 | WUPS_MUST_REPLACE_FOR_PROCESS(CMPTAcctSetDrcCtrlEnabled, WUPS_LOADER_LIBRARY_NN_CMPT, CMPTAcctSetDrcCtrlEnabled, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 615 | WUPS_MUST_REPLACE_FOR_PROCESS(WPADProbe, WUPS_LOADER_LIBRARY_PADSCORE, WPADProbe, WUPS_FP_TARGET_PROCESS_WII_U_MENU); 616 | 617 | WUPS_MUST_REPLACE_FOR_PROCESS(CMPTExPrepareLaunch, WUPS_LOADER_LIBRARY_NN_CMPT, CMPTExPrepareLaunch, WUPS_FP_TARGET_PROCESS_GAME); 618 | 619 | WUPS_MUST_REPLACE(MCP_LaunchCompat, WUPS_LOADER_LIBRARY_COREINIT, MCP_LaunchCompat); 620 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define VERSION "v1.3" 4 | #define DESCRIPTION "For launching Wii VC titles" 5 | -------------------------------------------------------------------------------- /src/mocha.cpp: -------------------------------------------------------------------------------- 1 | #include "logger.h" 2 | #include "mocha.h" 3 | 4 | // adapted from https://github.com/wiiu-env/ftpiiu_plugin/blob/00191956b81965733ad26dc34f9569201b79aff7/source/wiiu/platform.cpp#L77-L95 5 | MochaUtilsStatus MountWrapper(const char *mount, const char *dev, const char *mountTo) 6 | { 7 | auto res = Mocha_MountFS(mount, dev, mountTo); 8 | if (res == MOCHA_RESULT_ALREADY_EXISTS) { 9 | res = Mocha_MountFS(mount, nullptr, mountTo); 10 | } 11 | if (res != MOCHA_RESULT_SUCCESS) { 12 | DEBUG_FUNCTION_LINE_ERR("Failed to mount %s: %s (%d)", 13 | mount, 14 | Mocha_GetStatusStr(res), 15 | res); 16 | } 17 | return res; 18 | } 19 | 20 | MochaUtilsStatus initMocha() 21 | { 22 | auto mochaInitRes = Mocha_InitLibrary(); 23 | if (mochaInitRes != MOCHA_RESULT_SUCCESS) { 24 | DEBUG_FUNCTION_LINE_ERR("Failed to init libmocha: %s (%d)", 25 | Mocha_GetStatusStr(mochaInitRes), 26 | mochaInitRes); 27 | } 28 | return mochaInitRes; 29 | } 30 | -------------------------------------------------------------------------------- /src/mocha.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | MochaUtilsStatus MountWrapper(const char *mount, const char *dev, const char *mountTo); 6 | MochaUtilsStatus initMocha(); 7 | -------------------------------------------------------------------------------- /src/notifications.cpp: -------------------------------------------------------------------------------- 1 | #include "globals.hpp" 2 | #include "logger.h" 3 | #include 4 | 5 | void applyNotificationThemeSetting() 6 | { 7 | // NOTIFICATION_THEME_DARK 8 | NMColor notifTextColour = {255, 255, 255, 255}; 9 | NMColor notifBackgroundColour = {100, 100, 100, 255}; 10 | 11 | if (gNotificationTheme == NOTIFICATION_THEME_LIGHT) { 12 | notifTextColour = {0, 0, 0, 255}; 13 | notifBackgroundColour = {250, 250, 250, 255}; 14 | } 15 | 16 | NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, 17 | NOTIFICATION_MODULE_DEFAULT_OPTION_TEXT_COLOR, 18 | notifTextColour); 19 | NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, 20 | NOTIFICATION_MODULE_DEFAULT_OPTION_BACKGROUND_COLOR, 21 | notifBackgroundColour); 22 | } 23 | 24 | void initNotifications() 25 | { 26 | NotificationModuleStatus notifStatus = NotificationModule_InitLibrary(); 27 | if (notifStatus != NOTIFICATION_MODULE_RESULT_SUCCESS) { 28 | DEBUG_FUNCTION_LINE_ERR("NotificationModule_InitLibrary returned %s (%d)", 29 | NotificationModule_GetStatusStr(notifStatus), 30 | notifStatus); 31 | return; 32 | } 33 | 34 | NotificationModule_SetDefaultValue(NOTIFICATION_MODULE_NOTIFICATION_TYPE_INFO, 35 | NOTIFICATION_MODULE_DEFAULT_OPTION_DURATION_BEFORE_FADE_OUT, 36 | 10.0f); 37 | applyNotificationThemeSetting(); 38 | } 39 | -------------------------------------------------------------------------------- /src/notifications.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void applyNotificationThemeSetting(); 4 | void initNotifications(); 5 | -------------------------------------------------------------------------------- /src/sysconf_preserver.cpp: -------------------------------------------------------------------------------- 1 | #include "logger.h" 2 | #include "mocha.h" 3 | #include 4 | #include 5 | 6 | void backupSysconf() 7 | { 8 | if (initMocha() != MOCHA_RESULT_SUCCESS) 9 | return; 10 | 11 | if (MountWrapper("slccmpt01", "/dev/slccmpt01", "/vol/storage_slccmpt01") != MOCHA_RESULT_SUCCESS) { 12 | Mocha_DeInitLibrary(); 13 | return; 14 | } 15 | 16 | try { 17 | bool copySuccess = std::filesystem::copy_file("slccmpt01:/shared2/sys/SYSCONF", 18 | "/vol/external01/wiiu/SYSCONF", 19 | std::filesystem::copy_options::overwrite_existing); 20 | if (copySuccess) { 21 | WUPSStorageAPI::Store("restoreSysconf", true); 22 | WUPSStorageAPI::SaveStorage(); 23 | } 24 | } catch (const std::exception &e) { 25 | DEBUG_FUNCTION_LINE_ERR("Copy exception: %s", e.what()); 26 | } 27 | 28 | Mocha_UnmountFS("slccmpt01"); 29 | Mocha_DeInitLibrary(); 30 | } 31 | 32 | void restoreSysconfIfNeeded() 33 | { 34 | bool restoreCheck = false; 35 | WUPSStorageAPI::Get("restoreSysconf", restoreCheck); 36 | if (!restoreCheck) 37 | return; 38 | 39 | WUPSStorageAPI::Store("restoreSysconf", false); 40 | WUPSStorageAPI::SaveStorage(); 41 | 42 | try { 43 | auto fileSize = std::filesystem::file_size("/vol/external01/wiiu/SYSCONF"); 44 | if (fileSize != 0x4000) { 45 | DEBUG_FUNCTION_LINE_ERR("SD's SYSCONF is wrong size, should be 16,384 bytes"); 46 | return; 47 | } 48 | } catch (const std::exception &e) { 49 | DEBUG_FUNCTION_LINE_ERR("File size exception: %s", e.what()); 50 | return; 51 | } 52 | 53 | if (initMocha() != MOCHA_RESULT_SUCCESS) 54 | return; 55 | 56 | if (MountWrapper("slccmpt01", "/dev/slccmpt01", "/vol/storage_slccmpt01") != MOCHA_RESULT_SUCCESS) { 57 | Mocha_DeInitLibrary(); 58 | return; 59 | } 60 | 61 | try { 62 | std::filesystem::copy_file("/vol/external01/wiiu/SYSCONF", 63 | "slccmpt01:/shared2/sys/SYSCONF", 64 | std::filesystem::copy_options::overwrite_existing); 65 | std::filesystem::remove("/vol/external01/wiiu/SYSCONF"); 66 | } catch (const std::exception &e) { 67 | DEBUG_FUNCTION_LINE_ERR("Copy exception: %s", e.what()); 68 | } 69 | 70 | Mocha_UnmountFS("slccmpt01"); 71 | Mocha_DeInitLibrary(); 72 | } 73 | -------------------------------------------------------------------------------- /src/sysconf_preserver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void backupSysconf(); 4 | void restoreSysconfIfNeeded(); 5 | --------------------------------------------------------------------------------