Squashed 'mupen64plus-gui/' content from commit 77bfbd07

git-subtree-dir: mupen64plus-gui
git-subtree-split: 77bfbd078145de6ef7ef77d6e059bd19e4315645
This commit is contained in:
Logan McNaughton committed 2020-06-02 08:24:16 -06:00
commit 047cb0fcc6
52 files changed
+7028

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
# C++ objects and libs
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib
# Qt-es
/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
*.moc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*build-*
# QtCreator
*.autosave
# QtCtreator Qml
*.qmlproject.user
*.qmlproject.user.*
# QtCtreator CMake
CMakeLists.txt.user
build/
version.h
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/philosophy/why-not-lgpl.html>.
+34
View File
@@ -0,0 +1,34 @@
# mupen64plus-gui
![m64p](http://i.imgur.com/NIa5Btx.png)
mupen64plus-gui is written in Qt5.
It supports everything you'd expect from a mupen64plus frontend
(plugin selection, configuration editing, save state management, screenshots, pausing, etc).
You can try this out by downloading [**m64p**](https://m64p.github.io/).
**m64p** is mupen64plus + GLideN64 + this GUI
It is [free/libre software](https://www.fsf.org/blogs/rms/20140407-geneva-tedx-talk-free-software-free-society)
under [license GPL](https://www.gnu.org/licenses/gpl)v3.0.
Enjoy and happy hacking!
## Dependencies
- [Qt](https://www.qt.io/) 5.4
(this comes statically linked with the Windows binary build in m64p, so you don't need to worry about this on Windows)
- [SDL2](https://www.libsdl.org/) ***Your copy of mupen64plus-core (libmupen64plus.so.2) also needs to be linked against SDL2***
- 7za binary must be installed on your system for 7z/zip support
## Building (tested on GNU/Linux and MinGW)
On Debian and Ubuntu, you'll want to install ```qt5-default```.
```
git clone https://github.com/m64p/mupen64plus-gui.git
cd mupen64plus-gui
mkdir build
cd build
qmake ../mupen64plus-gui.pro
make -j`nproc`
```
Then you can run ```./mupen64plus-gui```.
+75
View File
@@ -0,0 +1,75 @@
#include "cheatdialog.h"
#include "cheat.h"
#include "common.h"
#include "settingclasses.h"
#include <QButtonGroup>
#include <QLabel>
#include <QScrollArea>
#include <QVBoxLayout>
CheatDialog::CheatDialog(QWidget *parent)
: QDialog(parent)
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QScrollArea *scrollArea = new QScrollArea(this);
QWidget *cheatSettings = new QWidget(this);
QGridLayout *cheatLayout = new QGridLayout(this);
QString cheatName;
QString desc;
int p = 0;
if (l_RomFound && l_CheatCodesFound != 0) {
sCheatInfo *pCur = l_CheatList;
while (pCur != NULL)
{
cheatName = pCur->Name;
QLabel* label = new QLabel(cheatName, this);
if (pCur->Description != NULL) {
desc = pCur->Description;
desc.prepend("<span style=\"color:black;\">");
desc.append("</span>");
label->setToolTip(desc);
}
label->setStyleSheet("border: 1px solid; padding: 10px");
cheatLayout->addWidget(label, p, 0);
if(pCur->VariableLine == -1) {
CheatCheckBox* checkBox = new CheatCheckBox(this);
checkBox->setStyleSheet("border: 1px solid; padding: 10px");
checkBox->setNumber(pCur->Number);
checkBox->setOption(0);
checkBox->setCheckState(pCur->active ? Qt::Checked : Qt::Unchecked);
cheatLayout->addWidget(checkBox, p, 1);
} else {
int i;
QButtonGroup *subGroup = new QButtonGroup(this);
QCheckBox * faker = new QCheckBox(this);
subGroup->addButton(faker);
subGroup->setExclusive(true);
for (i = 0; i < pCur->Codes[pCur->VariableLine].var_count; i++) {
++p;
QLabel* subLabel = new QLabel(pCur->Codes[pCur->VariableLine].variable_names[i], this);
subLabel->setStyleSheet("border: 1px solid; padding: 10px");
subLabel->setAlignment(Qt::AlignRight);
cheatLayout->addWidget(subLabel, p, 0);
CheatCheckBox* subCheckBox = new CheatCheckBox(this);
subCheckBox->setStyleSheet("border: 1px solid; padding: 10px");
subCheckBox->setNumber(pCur->Number);
subCheckBox->setOption(i);
subCheckBox->setCheckState((pCur->active && pCur->Codes[pCur->VariableLine].var_to_use == i) ? Qt::Checked : Qt::Unchecked);
subGroup->addButton(subCheckBox);
subCheckBox->setButtonGroup(faker);
cheatLayout->addWidget(subCheckBox, p, 1);
}
}
pCur = pCur->Next;
++p;
}
}
cheatSettings->setLayout(cheatLayout);
scrollArea->setWidget(cheatSettings);
scrollArea->setMinimumWidth(cheatSettings->sizeHint().width() + 20);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
mainLayout->addWidget(scrollArea);
this->setLayout(mainLayout);
}
+13
View File
@@ -0,0 +1,13 @@
#ifndef CHEATDIALOG_H
#define CHEATDIALOG_H
#include <QDialog>
class CheatDialog : public QDialog
{
Q_OBJECT
public:
CheatDialog(QWidget *parent = nullptr);
};
#endif // CHEATDIALOG_H
+327
View File
@@ -0,0 +1,327 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus - cheat.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009-2010 Richard Goedeken *
* Copyright (C) 2010 Rhett Osborne (spinout) *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cheat.h"
#include "core_interface.h"
#include "common.h"
/* local definitions */
#define CHEAT_FILE "mupencheat.txt"
/* local variables */
static char *l_IniText = NULL;
char *l_CheatGameName = NULL;
sCheatInfo *l_CheatList = NULL;
int l_CheatCodesFound = 0;
int l_RomFound = 0;
/*********************************************************************************************************
* Static (Local) functions
*/
static int isSpace(char ch)
{
return (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n');
}
/* Find cheat code */
sCheatInfo *CheatFindCode(int Number)
{
sCheatInfo *pCur = l_CheatList;
while (pCur != NULL)
{
if (pCur->Number == Number) break;
pCur = pCur->Next;
}
return pCur;
}
/* Activate a code */
void CheatActivate(sCheatInfo *pCheat)
{
int i;
/* Get a m64p_cheat_code object */
m64p_cheat_code * code = (m64p_cheat_code*) calloc(pCheat->Count, sizeof(m64p_cheat_code));
if (code == NULL)
{
DebugMessage(M64MSG_WARNING, "could not allocate memory for code '%s'", pCheat->Name);
return;
}
/* Fill in members */
for (i = 0; i < pCheat->Count; i++)
{
code[i].address = pCheat->Codes[i].address;
code[i].value = pCheat->Codes[i].variables[pCheat->Codes[i].var_to_use];
}
/* Enable cheat */
if (CoreAddCheat(pCheat->Name, code, pCheat->Count) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_WARNING, "CoreAddCheat() failed for cheat code %i (%s)", pCheat->Number, pCheat->Name);
free(code);
return;
}
free(code);
DebugMessage(M64MSG_STATUS, "activated cheat code %i: %s", pCheat->Number, pCheat->Name);
}
void CheatFreeAll(void)
{
if (l_IniText != NULL)
free(l_IniText);
l_IniText = NULL;
sCheatInfo *pCur = l_CheatList;
while (pCur != NULL)
{
sCheatInfo *pNext = pCur->Next;
if (pCur->Codes != NULL)
{
int i;
for (i=0; i < pCur->Count; i++)
{
if (pCur->Codes[i].variables != NULL)
free(pCur->Codes[i].variables);
if (pCur->Codes[i].variable_names != NULL)
free(pCur->Codes[i].variable_names);
}
free(pCur->Codes);
}
free(pCur);
pCur = pNext;
}
l_CheatList = NULL;
l_RomFound = 0;
l_CheatCodesFound = 0;
}
/* Append new code */
static sCheatInfo * NewCode(char *CheatName, int CheatNum)
{
/* allocate memory for a new sCheatInfo struct */
sCheatInfo *pNew = (sCheatInfo *) malloc(sizeof(sCheatInfo));
if (pNew == NULL) return NULL;
/* fill in the data members */
pNew->Number = CheatNum;
pNew->Count = 0;
pNew->VariableLine = -1;
pNew->Name = CheatName;
pNew->Description = NULL;
pNew->Codes = NULL;
pNew->Next = NULL;
pNew->active = false;
l_CheatCodesFound++;
/* stick it at the end of the list */
if (l_CheatList == NULL)
{
l_CheatList = pNew;
return pNew;
}
sCheatInfo *pLast = l_CheatList;
while (pLast->Next != NULL) pLast = pLast->Next;
pLast->Next = pNew;
return pNew;
}
static void CheatAddVariables(cheat_code * Code, char *varlist)
{
/* needs to be more verbose? */
Code->variables = NULL;
Code->variable_names = NULL;
Code->var_count = 0;
while (*varlist != 0)
{
if ((Code->variables = (int*) realloc(Code->variables, sizeof(int) * (Code->var_count + 1))) == NULL)
return;
if ((Code->variable_names = (char**) realloc(Code->variable_names, sizeof(char*) * (Code->var_count + 1))) == NULL)
return;
if (sscanf(varlist, "%04X", &Code->variables[Code->var_count]) != 1)
Code->variables[Code->var_count] = 0;
if (strchr(varlist, '"') == NULL)
return;
Code->variable_names[Code->var_count] = strchr(varlist, '"') + 1;
if ((varlist = strchr(Code->variable_names[Code->var_count], '"')) == NULL)
return;
*varlist++ = 0;
if (*varlist == ',')
varlist++;
Code->var_count++;
}
}
/*********************************************************************************************************
* global functions
*/
void ReadCheats(char *RomSection)
{
sCheatInfo *curr_code = NULL;
const char *romdbpath = ConfigGetSharedDataFilepath(CHEAT_FILE);
if (romdbpath == NULL)
{
DebugMessage(M64MSG_WARNING, "cheat code database file '%s' not found.", CHEAT_FILE);
return;
}
/* read the INI file into a new buffer */
FILE *fPtr = NULL;
fPtr = fopen(romdbpath, "rb");
if (fPtr == NULL)
{
DebugMessage(M64MSG_WARNING, "Couldn't open cheat code database file '%s'.", romdbpath);
return;
}
fseek(fPtr, 0L, SEEK_END);
size_t IniLength = (size_t)ftell(fPtr);
fseek(fPtr, 0L, SEEK_SET);
l_IniText = (char *) malloc(IniLength + 1);
if (l_IniText == NULL)
{
DebugMessage(M64MSG_WARNING, "Couldn't allocate %li bytes of memory to read cheat file.", IniLength);
fclose(fPtr);
return;
}
if (fread(l_IniText, 1, IniLength, fPtr) != IniLength)
{
DebugMessage(M64MSG_WARNING, "Couldn't read %li bytes from cheat file.", IniLength);
free(l_IniText);
l_IniText = NULL;
fclose(fPtr);
return;
}
fclose(fPtr);
l_IniText[IniLength] = 0; /* null-terminate the text data */
/* parse lines from cheat database */
char *curline = NULL;
char *nextline = l_IniText;
while(nextline != NULL && *nextline != 0)
{
curline = nextline;
/* get pointer to next line and NULL-terminate the current line */
nextline = strchr(curline, '\n');
if (nextline != NULL)
{
*nextline = 0;
nextline++;
}
/* remove leading and trailing white space */
while(isSpace(*curline)) curline++;
char *endptr = curline + strlen(curline) - 1;
while(isSpace(*endptr)) *endptr-- = 0;
/* ignore line if comment or empty */
if (*curline == '#' || strncmp(curline, "//", 2) == 0 || *curline == 0)
continue;
/* handle beginning of new rom section */
if (strncmp(curline, "crc ", 4) == 0)
{
/* if we have already found cheats for the given ROM file, then exit upon encountering a new ROM section */
if (l_RomFound && (l_CheatGameName != NULL || l_CheatList != NULL))
return;
/* else see if this Rom Section matches */
if (strcmp(curline+4, RomSection) == 0)
l_RomFound = 1;
continue;
}
/* if we haven't found the specified ROM section, then continue looking */
if (!l_RomFound)
continue;
/* Game name */
if (strncmp(curline, "gn ", 3) == 0)
{
l_CheatGameName = curline+3;
continue;
}
/* code name */
if (strncmp(curline, "cn ", 3) == 0)
{
curr_code = NewCode(curline + 3, l_CheatCodesFound);
if (curr_code == NULL)
DebugMessage(M64MSG_WARNING, "error getting new code (%s)", curline+3);
continue;
}
/* if curr_code is NULL, don't do these checks */
if (curr_code == NULL)
continue;
/* code description */
if (strncmp(curline, "cd ", 3) == 0)
{
curr_code->Description = curline+3;
continue;
}
/* code line */
int address;
if (sscanf(curline, "%8X %*s", &address) == 1)
{
curr_code->Codes = (cheat_code*) realloc(curr_code->Codes, sizeof(cheat_code) * (curr_code->Count + 1));
if (strncmp(curline+9, "????", 4) == 0)
{
curr_code->Codes[curr_code->Count].var_count = 0;
CheatAddVariables(&curr_code->Codes[curr_code->Count], curline+14);
curr_code->VariableLine = curr_code->Count;
}
else
{
int var;
curr_code->Codes[curr_code->Count].var_count = 1;
curr_code->Codes[curr_code->Count].variables = (int*) malloc(sizeof(int));
if(curr_code->Codes[curr_code->Count].variables == NULL)
{
DebugMessage(M64MSG_WARNING, "couldn't allocate memory; ignoring line: '%s'", curline);
continue;
}
if (sscanf(curline+9, "%04X", &var) != 1)
var = 0;
curr_code->Codes[curr_code->Count].variables[0] = var;
curr_code->Codes[curr_code->Count].variable_names = NULL;
}
curr_code->Codes[curr_code->Count].var_to_use = 0;
curr_code->Codes[curr_code->Count].address = address;
curr_code->Count++;
continue;
}
/* otherwise we don't know what this line is */
DebugMessage(M64MSG_WARNING, "unrecognized line in cheat file: '%s'", curline);
}
}
+70
View File
@@ -0,0 +1,70 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus - cheat.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef CHEAT_H
#define CHEAT_H
#include "m64p_types.h"
#ifdef M64P_BIG_ENDIAN
#define sl(mot) mot
#else
#define sl(mot) (((mot & 0xFF) << 24) | ((mot & 0xFF00) << 8) | ((mot & 0xFF0000) >> 8) | ((mot & 0xFF000000) >> 24))
#endif
typedef enum {
CHEAT_DISABLE,
CHEAT_LIST,
CHEAT_ALL,
CHEAT_SHOW_LIST
} eCheatMode;
typedef struct {
int address;
int *variables;
char **variable_names;
int var_to_use;
int var_count;
} cheat_code;
typedef struct _sCheatInfo {
int Number;
int Count;
int VariableLine;
const char *Name;
const char *Description;
cheat_code *Codes;
struct _sCheatInfo *Next;
bool active;
} sCheatInfo;
void ReadCheats(char *RomSection);
void CheatFreeAll(void);
sCheatInfo *CheatFindCode(int Number);
void CheatActivate(sCheatInfo *pCheat);
extern int l_CheatCodesFound;
extern int l_RomFound;
extern char *l_CheatGameName;
extern sCheatInfo *l_CheatList;
#endif // #define CHEAT_H
+674
View File
@@ -0,0 +1,674 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - common.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2007-2010 Richard42 *
* Copyright (C) 2008 Ebenblues Nmn Okaygo Tillin9 *
* Copyright (C) 2002 Hacktarux *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifdef __MINGW32__
#define _CRT_RAND_S
#endif
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include "common.h"
#include "plugin.h"
#include "core_interface.h"
#include <SDL_keycode.h>
#include <QProcess>
#include "version.h"
#include "cheat.h"
#include "mainwindow.h"
#include "logviewer.h"
/*********************************************************************************************************
* Callback functions from the core
*/
void DebugMessage(int level, const char *message, ...)
{
char msgbuf[1024];
va_list args;
va_start(args, message);
vsnprintf(msgbuf, 1024, message, args);
DebugCallback((char*)"GUI", level, msgbuf);
va_end(args);
}
void DebugCallback(void *Context, int level, const char *message)
{
QString output;
if (level == M64MSG_ERROR)
{
output = QString("%1 Error: %2\n").arg((const char *) Context, message);
QString netplay = QString::fromUtf8(message);
if (netplay.contains("Netplay"))
w->getWorkerThread()->showMessage(netplay);
}
else if (level == M64MSG_WARNING)
output = QString("%1 Warning: %2\n").arg((const char *) Context, message);
else if (level == M64MSG_INFO)
output = QString("%1: %2\n").arg((const char *) Context, message);
else if (level == M64MSG_STATUS)
output = QString("%1 Status: %2\n").arg((const char *) Context, message);
else if (level == M64MSG_VERBOSE)
{
if (w->getVerbose())
output = QString("%1: %2\n").arg((const char *) Context, message);
}
else
output = QString("%1 Unknown: %2\n").arg((const char *) Context, message);
if (!output.isEmpty())
w->getLogViewer()->addLog(output);
}
static char* media_loader_get_gb_cart_rom(void*, int control_id)
{
QString pathname;
if (control_id == 0)
pathname = w->getSettings()->value("Player1GBROM").toString();
else if (control_id == 1)
pathname = w->getSettings()->value("Player2GBROM").toString();
else if (control_id == 2)
pathname = w->getSettings()->value("Player3GBROM").toString();
else if (control_id == 3)
pathname = w->getSettings()->value("Player4GBROM").toString();
if (pathname.isEmpty())
return NULL;
else {
char *path = strdup(pathname.toLatin1().data());
return path;
}
}
static char* media_loader_get_gb_cart_ram(void*, int control_id)
{
QString pathname;
if (control_id == 0)
pathname = w->getSettings()->value("Player1GBRAM").toString();
else if (control_id == 1)
pathname = w->getSettings()->value("Player2GBRAM").toString();
else if (control_id == 2)
pathname = w->getSettings()->value("Player3GBRAM").toString();
else if (control_id == 3)
pathname = w->getSettings()->value("Player4GBRAM").toString();
if (pathname.isEmpty())
return NULL;
else {
char *path = strdup(pathname.toLatin1().data());
return path;
}
}
static char* media_loader_get_dd_rom(void*)
{
QString pathname = w->getSettings()->value("DD_ROM").toString();
if (pathname.isEmpty())
return NULL;
else {
char *path = strdup(pathname.toLatin1().data());
return path;
}
}
static char* media_loader_get_dd_disk(void*)
{
QString pathname = w->getSettings()->value("DD_DISK").toString();
if (pathname.isEmpty())
return NULL;
else {
char *path = strdup(pathname.toLatin1().data());
return path;
}
}
static m64p_media_loader media_loader =
{
NULL,
media_loader_get_gb_cart_rom,
media_loader_get_gb_cart_ram,
media_loader_get_dd_rom,
media_loader_get_dd_disk
};
m64p_error loadROM(std::string filename)
{
if (!QtAttachCoreLib())
return M64ERR_INVALID_STATE;
char *ROM_buffer = NULL;
size_t romlength = 0;
if (filename.find(".7z") != std::string::npos || (filename.find(".zip") != std::string::npos) || (filename.find(".ZIP") != std::string::npos))
{
QProcess process;
QString command = "7za e -so \"";
command += QString::fromStdString(filename);
command += "\" *64";
process.start(command);
process.waitForFinished(-1);
QByteArray data = process.readAllStandardOutput();
romlength = data.size();
if (romlength == 0)
{
DebugMessage(M64MSG_ERROR, "couldn't open file '%s' for reading.", filename.c_str());
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
ROM_buffer = (char *) malloc(romlength);
memcpy(ROM_buffer, data.constData(), romlength);
}
else
{
/* load ROM image */
QFile file(filename.c_str());
if (!file.open(QIODevice::ReadOnly))
{
DebugMessage(M64MSG_ERROR, "couldn't open ROM file '%s' for reading.", filename.c_str());
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
romlength = file.size();
QDataStream in(&file);
ROM_buffer = (char *) malloc(romlength);
if (in.readRawData(ROM_buffer, romlength) == -1)
{
DebugMessage(M64MSG_ERROR, "couldn't read %li bytes from ROM image file '%s'.", romlength, filename.c_str());
free(ROM_buffer);
file.close();
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
file.close();
}
/* Try to load the ROM image into the core */
if ((*CoreDoCommand)(M64CMD_ROM_OPEN, (int) romlength, ROM_buffer) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_ERROR, "core failed to open ROM image file '%s'.", filename.c_str());
free(ROM_buffer);
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
free(ROM_buffer); /* the core copies the ROM image, so we can release this buffer immediately */
return M64ERR_SUCCESS;
}
static void loadPif()
{
#if 0
/* Try to load the PIF image into the core */
if (!w->getSettings()->value("PIF_ROM").toString().isEmpty()) {
QFile pifFile(w->getSettings()->value("PIF_ROM").toString());
if (pifFile.open(QIODevice::ReadOnly)) {
QDataStream inPif(&pifFile);
char *PIF_buffer = (char *) malloc(2048);
if (inPif.readRawData(PIF_buffer, 2048) == 2048) {
if ((*CoreDoCommand)(M64CMD_PIF_OPEN, 2048, PIF_buffer) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_ERROR, "core failed to open PIF image file.");
}
}
else
{
DebugMessage(M64MSG_ERROR, "core failed to open PIF image file.");
}
free(PIF_buffer);
pifFile.close();
}
}
#endif
}
m64p_error launchGame(QString netplay_ip, int netplay_port, int netplay_player)
{
uint32_t i;
loadPif();
/* search for and load plugins */
m64p_error rval = PluginSearchLoad();
if (rval != M64ERR_SUCCESS)
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
/* attach plugins to core */
for (i = 0; i < 4; i++)
{
if ((*CoreAttachPlugin)(g_PluginMap[i].type, g_PluginMap[i].handle) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_ERROR, "core error while attaching %s plugin.", g_PluginMap[i].name);
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
}
m64p_rom_header l_RomHeader;
/* get the ROM header for the currently loaded ROM image from the core */
if ((*CoreDoCommand)(M64CMD_ROM_GET_HEADER, sizeof(l_RomHeader), &l_RomHeader) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_WARNING, "couldn't get ROM header information from core library");
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
DetachCoreLib();
return M64ERR_INVALID_STATE;
}
/* generate section name from ROM's CRC and country code */
char RomSection[24];
sprintf(RomSection, "%08X-%08X-C:%X", sl(l_RomHeader.CRC1), sl(l_RomHeader.CRC2), l_RomHeader.Country_code & 0xff);
/* parse through the cheat INI file and load up any cheat codes found for this ROM */
ReadCheats(RomSection);
if (!l_RomFound || l_CheatCodesFound == 0)
{
DebugMessage(M64MSG_WARNING, "no cheat codes found for ROM image '%.20s'", l_RomHeader.Name);
}
if ((*CoreDoCommand)(M64CMD_SET_MEDIA_LOADER, sizeof(media_loader), &media_loader) != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_WARNING, "Couldn't set media loader, transferpak and GB carts will not work.");
}
/* Save the configuration file again, just in case a plugin has altered it.
This is the last opportunity to save changes before the relatively
long-running game. */
(*ConfigSaveFile)();
if (netplay_port)
{
uint32_t version;
if ((*CoreDoCommand)(M64CMD_NETPLAY_GET_VERSION, 0x010000, &version) == M64ERR_SUCCESS)
{
DebugMessage(M64MSG_INFO, "Netplay: using core version %u", version);
if ((*CoreDoCommand)(M64CMD_NETPLAY_INIT, netplay_port, netplay_ip.toLocal8Bit().data()) == M64ERR_SUCCESS)
DebugMessage(M64MSG_INFO, "Netplay: init success");
uint32_t reg_id = 0;
while (reg_id == 0)
{
#ifdef __MINGW32__
rand_s(&reg_id);
#else
reg_id = rand();
#endif
}
if ((*CoreDoCommand)(M64CMD_NETPLAY_CONTROL_PLAYER, netplay_player, &reg_id) == M64ERR_SUCCESS)
DebugMessage(M64MSG_INFO, "Netplay: registered for player %d", netplay_player);
}
}
/* run the game */
(*CoreDoCommand)(M64CMD_EXECUTE, 0, NULL);
if (netplay_port)
(*CoreDoCommand)(M64CMD_NETPLAY_CLOSE, 0, NULL);
/* detach plugins from core and unload them */
for (i = 0; i < 4; i++)
(*CoreDetachPlugin)(g_PluginMap[i].type);
PluginUnload();
/* close the ROM image */
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
CheatFreeAll();
return M64ERR_SUCCESS;
}
int QT2SDL2MOD(Qt::KeyboardModifiers modifiers)
{
int value = 0;
if (modifiers & Qt::ShiftModifier)
value |= KMOD_SHIFT;
if (modifiers & Qt::ControlModifier)
value |= KMOD_CTRL;
if (modifiers & Qt::AltModifier)
value |= KMOD_ALT;
if (modifiers & Qt::MetaModifier)
value |= KMOD_GUI;
return value;
}
int QT2SDL2(int qtKey)
{
SDL_Scancode returnValue;
switch (qtKey) {
case Qt::Key_Escape:
returnValue = SDL_SCANCODE_ESCAPE;
break;
case Qt::Key_Tab:
returnValue = SDL_SCANCODE_TAB;
break;
case Qt::Key_Backspace:
returnValue = SDL_SCANCODE_BACKSPACE;
break;
case Qt::Key_Return:
returnValue = SDL_SCANCODE_RETURN;
break;
case Qt::Key_Enter:
returnValue = SDL_SCANCODE_KP_ENTER;
break;
case Qt::Key_Insert:
returnValue = SDL_SCANCODE_INSERT;
break;
case Qt::Key_Delete:
returnValue = SDL_SCANCODE_DELETE;
break;
case Qt::Key_Pause:
returnValue = SDL_SCANCODE_PAUSE;
break;
case Qt::Key_Print:
returnValue = SDL_SCANCODE_PRINTSCREEN;
break;
case Qt::Key_SysReq:
returnValue = SDL_SCANCODE_SYSREQ;
break;
case Qt::Key_Clear:
returnValue = SDL_SCANCODE_CLEAR;
break;
case Qt::Key_Home:
returnValue = SDL_SCANCODE_HOME;
break;
case Qt::Key_End:
returnValue = SDL_SCANCODE_END;
break;
case Qt::Key_Left:
returnValue = SDL_SCANCODE_LEFT;
break;
case Qt::Key_Right:
returnValue = SDL_SCANCODE_RIGHT;
break;
case Qt::Key_Up:
returnValue = SDL_SCANCODE_UP;
break;
case Qt::Key_Down:
returnValue = SDL_SCANCODE_DOWN;
break;
case Qt::Key_PageUp:
returnValue = SDL_SCANCODE_PAGEUP;
break;
case Qt::Key_PageDown:
returnValue = SDL_SCANCODE_PAGEDOWN;
break;
case Qt::Key_Shift:
returnValue = SDL_SCANCODE_LSHIFT;
break;
case Qt::Key_Control:
returnValue = SDL_SCANCODE_LCTRL;
break;
case Qt::Key_Meta:
returnValue = SDL_SCANCODE_LGUI;
break;
case Qt::Key_Alt:
returnValue = SDL_SCANCODE_LALT;
break;
case Qt::Key_AltGr:
returnValue = SDL_SCANCODE_RALT;
break;
case Qt::Key_CapsLock:
returnValue = SDL_SCANCODE_CAPSLOCK;
break;
case Qt::Key_NumLock:
returnValue = SDL_SCANCODE_NUMLOCKCLEAR;
break;
case Qt::Key_ScrollLock:
returnValue = SDL_SCANCODE_SCROLLLOCK;
break;
case Qt::Key_F1:
returnValue = SDL_SCANCODE_F1;
break;
case Qt::Key_F2:
returnValue = SDL_SCANCODE_F2;
break;
case Qt::Key_F3:
returnValue = SDL_SCANCODE_F3;
break;
case Qt::Key_F4:
returnValue = SDL_SCANCODE_F4;
break;
case Qt::Key_F5:
returnValue = SDL_SCANCODE_F5;
break;
case Qt::Key_F6:
returnValue = SDL_SCANCODE_F6;
break;
case Qt::Key_F7:
returnValue = SDL_SCANCODE_F7;
break;
case Qt::Key_F8:
returnValue = SDL_SCANCODE_F8;
break;
case Qt::Key_F9:
returnValue = SDL_SCANCODE_F9;
break;
case Qt::Key_F10:
returnValue = SDL_SCANCODE_F10;
break;
case Qt::Key_F11:
returnValue = SDL_SCANCODE_F11;
break;
case Qt::Key_F12:
returnValue = SDL_SCANCODE_F12;
break;
case Qt::Key_F13:
returnValue = SDL_SCANCODE_F13;
break;
case Qt::Key_F14:
returnValue = SDL_SCANCODE_F14;
break;
case Qt::Key_F15:
returnValue = SDL_SCANCODE_F15;
break;
case Qt::Key_F16:
returnValue = SDL_SCANCODE_F16;
break;
case Qt::Key_F17:
returnValue = SDL_SCANCODE_F17;
break;
case Qt::Key_F18:
returnValue = SDL_SCANCODE_F18;
break;
case Qt::Key_F19:
returnValue = SDL_SCANCODE_F19;
break;
case Qt::Key_F20:
returnValue = SDL_SCANCODE_F20;
break;
case Qt::Key_F21:
returnValue = SDL_SCANCODE_F21;
break;
case Qt::Key_F22:
returnValue = SDL_SCANCODE_F22;
break;
case Qt::Key_F23:
returnValue = SDL_SCANCODE_F23;
break;
case Qt::Key_F24:
returnValue = SDL_SCANCODE_F24;
break;
case Qt::Key_Space:
returnValue = SDL_SCANCODE_SPACE;
break;
case Qt::Key_0:
returnValue = SDL_SCANCODE_0;
break;
case Qt::Key_1:
returnValue = SDL_SCANCODE_1;
break;
case Qt::Key_2:
returnValue = SDL_SCANCODE_2;
break;
case Qt::Key_3:
returnValue = SDL_SCANCODE_3;
break;
case Qt::Key_4:
returnValue = SDL_SCANCODE_4;
break;
case Qt::Key_5:
returnValue = SDL_SCANCODE_5;
break;
case Qt::Key_6:
returnValue = SDL_SCANCODE_6;
break;
case Qt::Key_7:
returnValue = SDL_SCANCODE_7;
break;
case Qt::Key_8:
returnValue = SDL_SCANCODE_8;
break;
case Qt::Key_9:
returnValue = SDL_SCANCODE_9;
break;
case Qt::Key_A:
returnValue = SDL_SCANCODE_A;
break;
case Qt::Key_B:
returnValue = SDL_SCANCODE_B;
break;
case Qt::Key_C:
returnValue = SDL_SCANCODE_C;
break;
case Qt::Key_D:
returnValue = SDL_SCANCODE_D;
break;
case Qt::Key_E:
returnValue = SDL_SCANCODE_E;
break;
case Qt::Key_F:
returnValue = SDL_SCANCODE_F;
break;
case Qt::Key_G:
returnValue = SDL_SCANCODE_G;
break;
case Qt::Key_H:
returnValue = SDL_SCANCODE_H;
break;
case Qt::Key_I:
returnValue = SDL_SCANCODE_I;
break;
case Qt::Key_J:
returnValue = SDL_SCANCODE_J;
break;
case Qt::Key_K:
returnValue = SDL_SCANCODE_K;
break;
case Qt::Key_L:
returnValue = SDL_SCANCODE_L;
break;
case Qt::Key_M:
returnValue = SDL_SCANCODE_M;
break;
case Qt::Key_N:
returnValue = SDL_SCANCODE_N;
break;
case Qt::Key_O:
returnValue = SDL_SCANCODE_O;
break;
case Qt::Key_P:
returnValue = SDL_SCANCODE_P;
break;
case Qt::Key_Q:
returnValue = SDL_SCANCODE_Q;
break;
case Qt::Key_R:
returnValue = SDL_SCANCODE_R;
break;
case Qt::Key_S:
returnValue = SDL_SCANCODE_S;
break;
case Qt::Key_T:
returnValue = SDL_SCANCODE_T;
break;
case Qt::Key_U:
returnValue = SDL_SCANCODE_U;
break;
case Qt::Key_V:
returnValue = SDL_SCANCODE_V;
break;
case Qt::Key_W:
returnValue = SDL_SCANCODE_W;
break;
case Qt::Key_X:
returnValue = SDL_SCANCODE_X;
break;
case Qt::Key_Y:
returnValue = SDL_SCANCODE_Y;
break;
case Qt::Key_Z:
returnValue = SDL_SCANCODE_Z;
break;
case Qt::Key_BracketLeft:
returnValue = SDL_SCANCODE_LEFTBRACKET;
break;
case Qt::Key_BracketRight:
returnValue = SDL_SCANCODE_RIGHTBRACKET;
break;
case Qt::Key_Minus:
returnValue = SDL_SCANCODE_MINUS;
break;
case Qt::Key_Semicolon:
returnValue = SDL_SCANCODE_SEMICOLON;
break;
case Qt::Key_Slash:
returnValue = SDL_SCANCODE_SLASH;
break;
case Qt::Key_Backslash:
returnValue = SDL_SCANCODE_BACKSLASH;
break;
case Qt::Key_Apostrophe:
returnValue = SDL_SCANCODE_APOSTROPHE;
break;
case Qt::Key_Comma:
returnValue = SDL_SCANCODE_COMMA;
break;
case Qt::Key_Period:
returnValue = SDL_SCANCODE_PERIOD;
break;
case Qt::Key_Equal:
returnValue = SDL_SCANCODE_EQUALS;
break;
case Qt::Key_QuoteLeft:
returnValue = SDL_SCANCODE_GRAVE;
break;
default:
returnValue = SDL_SCANCODE_UNKNOWN;
break;
}
return returnValue;
}
+45
View File
@@ -0,0 +1,45 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus - common.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard42 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef __COMMON_H__
#define __COMMON_H__
#include "m64p_types.h"
#ifdef __cplusplus
#include <Qt>
#include <string>
m64p_error loadROM(std::string filename);
m64p_error launchGame(QString netplay_ip, int netplay_port, int netplay_player);
int QT2SDL2MOD(Qt::KeyboardModifiers modifiers);
extern "C" {
#endif
void DebugMessage(int level, const char *message, ...);
void DebugCallback(void *Context, int level, const char *message);
int QT2SDL2(int qtKey);
#ifdef __cplusplus
}
#endif
extern int g_Verbose;
#endif /* __COMMON_H__ */
+386
View File
@@ -0,0 +1,386 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - core_interface.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This file contains the routines for attaching to the Mupen64Plus core
* library and pointers to the core functions
*/
#include <QMessageBox>
#include <QCoreApplication>
#include <QDir>
#include <stdio.h>
#include "core_interface.h"
#include "m64p_common.h"
#include "m64p_config.h"
#include "m64p_debugger.h"
#include "m64p_frontend.h"
#include "m64p_types.h"
#include "common.h"
extern "C" {
#include "osal_dynamiclib.h"
#include "osal_preproc.h"
}
#include "version.h"
#include "vidext.h"
/* global data definitions */
int g_CoreCapabilities;
int g_CoreAPIVersion;
QString qtCoreDirPath;
QString qtConfigDir;
int coreStarted = 0;
/* definitions of pointers to Core common functions */
ptr_CoreErrorMessage CoreErrorMessage = NULL;
/* definitions of pointers to Core front-end functions */
ptr_CoreStartup CoreStartup = NULL;
ptr_CoreShutdown CoreShutdown = NULL;
ptr_CoreAttachPlugin CoreAttachPlugin = NULL;
ptr_CoreDetachPlugin CoreDetachPlugin = NULL;
ptr_CoreDoCommand CoreDoCommand = NULL;
ptr_CoreOverrideVidExt CoreOverrideVidExt = NULL;
ptr_CoreAddCheat CoreAddCheat = NULL;
ptr_CoreCheatEnabled CoreCheatEnabled = NULL;
/* definitions of pointers to Core config functions */
ptr_ConfigListSections ConfigListSections = NULL;
ptr_ConfigOpenSection ConfigOpenSection = NULL;
ptr_ConfigDeleteSection ConfigDeleteSection = NULL;
ptr_ConfigSaveSection ConfigSaveSection = NULL;
ptr_ConfigListParameters ConfigListParameters = NULL;
ptr_ConfigSaveFile ConfigSaveFile = NULL;
ptr_ConfigSetParameter ConfigSetParameter = NULL;
ptr_ConfigGetParameter ConfigGetParameter = NULL;
ptr_ConfigGetParameterType ConfigGetParameterType = NULL;
ptr_ConfigGetParameterHelp ConfigGetParameterHelp = NULL;
ptr_ConfigSetDefaultInt ConfigSetDefaultInt = NULL;
ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat = NULL;
ptr_ConfigSetDefaultBool ConfigSetDefaultBool = NULL;
ptr_ConfigSetDefaultString ConfigSetDefaultString = NULL;
ptr_ConfigGetParamInt ConfigGetParamInt = NULL;
ptr_ConfigGetParamFloat ConfigGetParamFloat = NULL;
ptr_ConfigGetParamBool ConfigGetParamBool = NULL;
ptr_ConfigGetParamString ConfigGetParamString = NULL;
ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath = NULL;
ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath = NULL;
ptr_ConfigGetUserDataPath ConfigGetUserDataPath = NULL;
ptr_ConfigGetUserCachePath ConfigGetUserCachePath = NULL;
/* definitions of pointers to Core debugger functions */
ptr_DebugSetCallbacks DebugSetCallbacks = NULL;
ptr_DebugSetCoreCompare DebugSetCoreCompare = NULL;
ptr_DebugSetRunState DebugSetRunState = NULL;
ptr_DebugGetState DebugGetState = NULL;
ptr_DebugStep DebugStep = NULL;
ptr_DebugDecodeOp DebugDecodeOp = NULL;
ptr_DebugMemGetRecompInfo DebugMemGetRecompInfo = NULL;
ptr_DebugMemGetMemInfo DebugMemGetMemInfo = NULL;
ptr_DebugMemGetPointer DebugMemGetPointer = NULL;
ptr_DebugMemRead64 DebugMemRead64 = NULL;
ptr_DebugMemRead32 DebugMemRead32 = NULL;
ptr_DebugMemRead16 DebugMemRead16 = NULL;
ptr_DebugMemRead8 DebugMemRead8 = NULL;
ptr_DebugMemWrite64 DebugMemWrite64 = NULL;
ptr_DebugMemWrite32 DebugMemWrite32 = NULL;
ptr_DebugMemWrite16 DebugMemWrite16 = NULL;
ptr_DebugMemWrite8 DebugMemWrite8 = NULL;
ptr_DebugGetCPUDataPtr DebugGetCPUDataPtr = NULL;
ptr_DebugBreakpointLookup DebugBreakpointLookup = NULL;
ptr_DebugBreakpointCommand DebugBreakpointCommand = NULL;
/* global variables */
m64p_dynlib_handle CoreHandle = NULL;
m64p_video_extension_functions vidExtFunctions = {12,
qtVidExtFuncInit,
qtVidExtFuncQuit,
qtVidExtFuncListModes,
qtVidExtFuncSetMode,
qtVidExtFuncGLGetProc,
qtVidExtFuncGLSetAttr,
qtVidExtFuncGLGetAttr,
qtVidExtFuncGLSwapBuf,
qtVidExtFuncSetCaption,
qtVidExtFuncToggleFS,
qtVidExtFuncResizeWindow,
qtVidExtFuncGLGetDefaultFramebuffer};
bool QtAttachCoreLib()
{
if (AttachCoreLib(qtCoreDirPath.toLatin1().data()) != M64ERR_SUCCESS && CoreHandle == NULL) {
QMessageBox msgBox;
msgBox.setText("Couldn't load core library, please set the path in settings.");
msgBox.exec();
return false;
}
if (!coreStarted) {
/* start the Mupen64Plus core library, load the configuration file */
m64p_error rval;
if (!qtConfigDir.isEmpty())
rval = (*CoreStartup)(CORE_API_VERSION, qtConfigDir.toLatin1().data() /*Config dir*/, QCoreApplication::applicationDirPath().toLatin1().data(), (char*)"Core", DebugCallback, NULL, NULL);
else
rval = (*CoreStartup)(CORE_API_VERSION, NULL /*Config dir*/, QCoreApplication::applicationDirPath().toLatin1().data(), (char*)"Core", DebugCallback, NULL, NULL);
if (rval != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_ERROR, "couldn't start Mupen64Plus core library.");
DetachCoreLib();
return false;
}
rval = CoreOverrideVidExt(&vidExtFunctions);
if (rval != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_ERROR, "couldn't start VidExt library.");
DetachCoreLib();
return false;
}
coreStarted = 1;
}
return true;
}
/* functions */
m64p_error AttachCoreLib(const char *CoreLibFilepath)
{
/* check if Core DLL is already attached */
if (CoreHandle != NULL)
return M64ERR_INVALID_STATE;
/* load the DLL */
m64p_error rval = M64ERR_INTERNAL;
if (CoreLibFilepath != NULL)
{
rval = osal_dynlib_open(&CoreHandle, CoreLibFilepath);
}
if (rval != M64ERR_SUCCESS || CoreHandle == NULL)
{
QString corePath = QDir(QCoreApplication::applicationDirPath()).filePath(OSAL_DEFAULT_DYNLIB_FILENAME);
rval = osal_dynlib_open(&CoreHandle, corePath.toLatin1().data());
}
/* if we haven't found a good core library by now, then we're screwed */
if (rval != M64ERR_SUCCESS || CoreHandle == NULL)
{
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: failed to find Mupen64Plus Core library");
CoreHandle = NULL;
return M64ERR_INPUT_NOT_FOUND;
}
/* attach and call the PluginGetVersion function, check the Core and API versions for compatibility with this front-end */
ptr_PluginGetVersion CoreVersionFunc;
CoreVersionFunc = (ptr_PluginGetVersion) osal_dynlib_getproc(CoreHandle, "PluginGetVersion");
if (CoreVersionFunc == NULL)
{
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' invalid; no PluginGetVersion() function found.", CoreLibFilepath);
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
return M64ERR_INPUT_INVALID;
}
m64p_plugin_type PluginType = (m64p_plugin_type) 0;
int Compatible = 0;
int CoreVersion = 0;
const char *CoreName = NULL;
(*CoreVersionFunc)(&PluginType, &CoreVersion, &g_CoreAPIVersion, &CoreName, &g_CoreCapabilities);
if (PluginType != M64PLUGIN_CORE)
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' invalid; this is not the emulator core.", CoreLibFilepath);
else if (CoreVersion < MINIMUM_CORE_VERSION)
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' incompatible; core version %i.%i.%i is below minimum supported %i.%i.%i",
CoreLibFilepath, VERSION_PRINTF_SPLIT(CoreVersion), VERSION_PRINTF_SPLIT(MINIMUM_CORE_VERSION));
else if ((g_CoreAPIVersion & 0xffff0000) != (CORE_API_VERSION & 0xffff0000))
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Shared library '%s' incompatible; core API major version %i.%i.%i doesn't match with this application (%i.%i.%i)",
CoreLibFilepath, VERSION_PRINTF_SPLIT(g_CoreAPIVersion), VERSION_PRINTF_SPLIT(CORE_API_VERSION));
else
Compatible = 1;
/* exit if not compatible */
if (Compatible == 0)
{
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
return M64ERR_INCOMPATIBLE;
}
/* attach and call the CoreGetAPIVersion function, check Config API version for compatibility */
ptr_CoreGetAPIVersions CoreAPIVersionFunc;
CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreHandle, "CoreGetAPIVersions");
if (CoreAPIVersionFunc == NULL)
{
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Library '%s' broken; no CoreAPIVersionFunc() function found.", CoreLibFilepath);
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
return M64ERR_INPUT_INVALID;
}
int ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion;
(*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL);
if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000))
{
DebugMessage(M64MSG_ERROR, "AttachCoreLib() Error: Emulator core '%s' incompatible; Config API major version %i.%i.%i doesn't match application: %i.%i.%i",
CoreLibFilepath, VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION));
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
return M64ERR_INCOMPATIBLE;
}
/* print some information about the core library */
DebugMessage(M64MSG_INFO, "attached to core library '%s' version %i.%i.%i", CoreName, VERSION_PRINTF_SPLIT(CoreVersion));
if (g_CoreCapabilities & M64CAPS_DYNAREC)
DebugMessage(M64MSG_INFO, " Includes support for Dynamic Recompiler.");
if (g_CoreCapabilities & M64CAPS_DEBUGGER)
DebugMessage(M64MSG_INFO, " Includes support for MIPS r4300 Debugger.");
if (g_CoreCapabilities & M64CAPS_CORE_COMPARE)
DebugMessage(M64MSG_INFO, " Includes support for r4300 Core Comparison.");
/* get function pointers to the common and front-end functions */
CoreErrorMessage = (ptr_CoreErrorMessage) osal_dynlib_getproc(CoreHandle, "CoreErrorMessage");
CoreStartup = (ptr_CoreStartup) osal_dynlib_getproc(CoreHandle, "CoreStartup");
CoreShutdown = (ptr_CoreShutdown) osal_dynlib_getproc(CoreHandle, "CoreShutdown");
CoreAttachPlugin = (ptr_CoreAttachPlugin) osal_dynlib_getproc(CoreHandle, "CoreAttachPlugin");
CoreDetachPlugin = (ptr_CoreDetachPlugin) osal_dynlib_getproc(CoreHandle, "CoreDetachPlugin");
CoreDoCommand = (ptr_CoreDoCommand) osal_dynlib_getproc(CoreHandle, "CoreDoCommand");
CoreOverrideVidExt = (ptr_CoreOverrideVidExt) osal_dynlib_getproc(CoreHandle, "CoreOverrideVidExt");
CoreAddCheat = (ptr_CoreAddCheat) osal_dynlib_getproc(CoreHandle, "CoreAddCheat");
CoreCheatEnabled = (ptr_CoreCheatEnabled) osal_dynlib_getproc(CoreHandle, "CoreCheatEnabled");
/* get function pointers to the configuration functions */
ConfigListSections = (ptr_ConfigListSections) osal_dynlib_getproc(CoreHandle, "ConfigListSections");
ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreHandle, "ConfigOpenSection");
ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(CoreHandle, "ConfigDeleteSection");
ConfigSaveSection = (ptr_ConfigSaveSection) osal_dynlib_getproc(CoreHandle, "ConfigSaveSection");
ConfigListParameters = (ptr_ConfigListParameters) osal_dynlib_getproc(CoreHandle, "ConfigListParameters");
ConfigSaveFile = (ptr_ConfigSaveFile) osal_dynlib_getproc(CoreHandle, "ConfigSaveFile");
ConfigSetParameter = (ptr_ConfigSetParameter) osal_dynlib_getproc(CoreHandle, "ConfigSetParameter");
ConfigGetParameter = (ptr_ConfigGetParameter) osal_dynlib_getproc(CoreHandle, "ConfigGetParameter");
ConfigGetParameterType = (ptr_ConfigGetParameterType) osal_dynlib_getproc(CoreHandle, "ConfigGetParameterType");
ConfigGetParameterHelp = (ptr_ConfigGetParameterHelp) osal_dynlib_getproc(CoreHandle, "ConfigGetParameterHelp");
ConfigSetDefaultInt = (ptr_ConfigSetDefaultInt) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultInt");
ConfigSetDefaultFloat = (ptr_ConfigSetDefaultFloat) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultFloat");
ConfigSetDefaultBool = (ptr_ConfigSetDefaultBool) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultBool");
ConfigSetDefaultString = (ptr_ConfigSetDefaultString) osal_dynlib_getproc(CoreHandle, "ConfigSetDefaultString");
ConfigGetParamInt = (ptr_ConfigGetParamInt) osal_dynlib_getproc(CoreHandle, "ConfigGetParamInt");
ConfigGetParamFloat = (ptr_ConfigGetParamFloat) osal_dynlib_getproc(CoreHandle, "ConfigGetParamFloat");
ConfigGetParamBool = (ptr_ConfigGetParamBool) osal_dynlib_getproc(CoreHandle, "ConfigGetParamBool");
ConfigGetParamString = (ptr_ConfigGetParamString) osal_dynlib_getproc(CoreHandle, "ConfigGetParamString");
ConfigGetSharedDataFilepath = (ptr_ConfigGetSharedDataFilepath) osal_dynlib_getproc(CoreHandle, "ConfigGetSharedDataFilepath");
ConfigGetUserConfigPath = (ptr_ConfigGetUserConfigPath) osal_dynlib_getproc(CoreHandle, "ConfigGetUserConfigPath");
ConfigGetUserDataPath = (ptr_ConfigGetUserDataPath) osal_dynlib_getproc(CoreHandle, "ConfigGetUserDataPath");
ConfigGetUserCachePath = (ptr_ConfigGetUserCachePath) osal_dynlib_getproc(CoreHandle, "ConfigGetUserCachePath");
/* get function pointers to the debugger functions */
DebugSetCallbacks = (ptr_DebugSetCallbacks) osal_dynlib_getproc(CoreHandle, "DebugSetCallbacks");
DebugSetCoreCompare = (ptr_DebugSetCoreCompare) osal_dynlib_getproc(CoreHandle, "DebugSetCoreCompare");
DebugSetRunState = (ptr_DebugSetRunState) osal_dynlib_getproc(CoreHandle, "DebugSetRunState");
DebugGetState = (ptr_DebugGetState) osal_dynlib_getproc(CoreHandle, "DebugGetState");
DebugStep = (ptr_DebugStep) osal_dynlib_getproc(CoreHandle, "DebugStep");
DebugDecodeOp = (ptr_DebugDecodeOp) osal_dynlib_getproc(CoreHandle, "DebugDecodeOp");
DebugMemGetRecompInfo = (ptr_DebugMemGetRecompInfo) osal_dynlib_getproc(CoreHandle, "DebugMemGetRecompInfo");
DebugMemGetMemInfo = (ptr_DebugMemGetMemInfo) osal_dynlib_getproc(CoreHandle, "DebugMemGetMemInfo");
DebugMemGetPointer = (ptr_DebugMemGetPointer) osal_dynlib_getproc(CoreHandle, "DebugMemGetPointer");
DebugMemRead64 = (ptr_DebugMemRead64) osal_dynlib_getproc(CoreHandle, "DebugMemRead64");
DebugMemRead32 = (ptr_DebugMemRead32) osal_dynlib_getproc(CoreHandle, "DebugMemRead32");
DebugMemRead16 = (ptr_DebugMemRead16) osal_dynlib_getproc(CoreHandle, "DebugMemRead16");
DebugMemRead8 = (ptr_DebugMemRead8) osal_dynlib_getproc(CoreHandle, "DebugMemRead8");
DebugMemWrite64 = (ptr_DebugMemWrite64) osal_dynlib_getproc(CoreHandle, "DebugMemRead64");
DebugMemWrite32 = (ptr_DebugMemWrite32) osal_dynlib_getproc(CoreHandle, "DebugMemRead32");
DebugMemWrite16 = (ptr_DebugMemWrite16) osal_dynlib_getproc(CoreHandle, "DebugMemRead16");
DebugMemWrite8 = (ptr_DebugMemWrite8) osal_dynlib_getproc(CoreHandle, "DebugMemRead8");
DebugGetCPUDataPtr = (ptr_DebugGetCPUDataPtr) osal_dynlib_getproc(CoreHandle, "DebugGetCPUDataPtr");
DebugBreakpointLookup = (ptr_DebugBreakpointLookup) osal_dynlib_getproc(CoreHandle, "DebugBreakpointLookup");
DebugBreakpointCommand = (ptr_DebugBreakpointCommand) osal_dynlib_getproc(CoreHandle, "DebugBreakpointCommand");
return M64ERR_SUCCESS;
}
m64p_error DetachCoreLib(void)
{
if (CoreHandle == NULL)
return M64ERR_INVALID_STATE;
(*CoreShutdown)();
/* set the core function pointers to NULL */
CoreErrorMessage = NULL;
CoreStartup = NULL;
CoreShutdown = NULL;
CoreAttachPlugin = NULL;
CoreDetachPlugin = NULL;
CoreDoCommand = NULL;
CoreOverrideVidExt = NULL;
CoreAddCheat = NULL;
CoreCheatEnabled = NULL;
ConfigListSections = NULL;
ConfigOpenSection = NULL;
ConfigDeleteSection = NULL;
ConfigSaveSection = NULL;
ConfigListParameters = NULL;
ConfigSetParameter = NULL;
ConfigGetParameter = NULL;
ConfigGetParameterType = NULL;
ConfigGetParameterHelp = NULL;
ConfigSetDefaultInt = NULL;
ConfigSetDefaultBool = NULL;
ConfigSetDefaultString = NULL;
ConfigGetParamInt = NULL;
ConfigGetParamBool = NULL;
ConfigGetParamString = NULL;
ConfigGetSharedDataFilepath = NULL;
ConfigGetUserDataPath = NULL;
ConfigGetUserCachePath = NULL;
DebugSetCallbacks = NULL;
DebugSetCoreCompare = NULL;
DebugSetRunState = NULL;
DebugGetState = NULL;
DebugStep = NULL;
DebugDecodeOp = NULL;
DebugMemGetRecompInfo = NULL;
DebugMemGetMemInfo = NULL;
DebugMemGetPointer = NULL;
DebugMemRead64 = NULL;
DebugMemRead32 = NULL;
DebugMemRead16 = NULL;
DebugMemRead8 = NULL;
DebugMemWrite64 = NULL;
DebugMemWrite32 = NULL;
DebugMemWrite16 = NULL;
DebugMemWrite8 = NULL;
DebugGetCPUDataPtr = NULL;
DebugBreakpointLookup = NULL;
DebugBreakpointCommand = NULL;
/* detach the shared library */
osal_dynlib_close(CoreHandle);
CoreHandle = NULL;
coreStarted = 0;
return M64ERR_SUCCESS;
}
+112
View File
@@ -0,0 +1,112 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - core_interface.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if !defined(CORE_INTERFACE_H)
#define CORE_INTERFACE_H
#include "m64p_common.h"
#include "m64p_config.h"
#include "m64p_debugger.h"
#include "m64p_frontend.h"
#include "m64p_types.h"
#ifdef __cplusplus
#include <QString>
extern QString qtCoreDirPath;
extern QString qtConfigDir;
#endif
/* function declarations */
m64p_error AttachCoreLib(const char *CoreLibFilepath);
m64p_error DetachCoreLib(void);
bool QtAttachCoreLib(void);
/* global variables from core_interface.c */
extern int g_CoreCapabilities;
extern int g_CoreAPIVersion;
extern int coreStarted;
/* declarations of Core library handle and pointers to common functions */
extern m64p_dynlib_handle CoreHandle;
extern ptr_CoreErrorMessage CoreErrorMessage;
/* declarations of pointers to Core front-end functions */
extern ptr_CoreStartup CoreStartup;
extern ptr_CoreShutdown CoreShutdown;
extern ptr_CoreAttachPlugin CoreAttachPlugin;
extern ptr_CoreDetachPlugin CoreDetachPlugin;
extern ptr_CoreDoCommand CoreDoCommand;
extern ptr_CoreOverrideVidExt CoreOverrideVidExt;
extern ptr_CoreAddCheat CoreAddCheat;
extern ptr_CoreCheatEnabled CoreCheatEnabled;
/* declarations of pointers to Core config functions */
extern ptr_ConfigListSections ConfigListSections;
extern ptr_ConfigOpenSection ConfigOpenSection;
extern ptr_ConfigDeleteSection ConfigDeleteSection;
extern ptr_ConfigSaveSection ConfigSaveSection;
extern ptr_ConfigListParameters ConfigListParameters;
extern ptr_ConfigSaveFile ConfigSaveFile;
extern ptr_ConfigSetParameter ConfigSetParameter;
extern ptr_ConfigGetParameter ConfigGetParameter;
extern ptr_ConfigGetParameterType ConfigGetParameterType;
extern ptr_ConfigGetParameterHelp ConfigGetParameterHelp;
extern ptr_ConfigSetDefaultInt ConfigSetDefaultInt;
extern ptr_ConfigSetDefaultFloat ConfigSetDefaultFloat;
extern ptr_ConfigSetDefaultBool ConfigSetDefaultBool;
extern ptr_ConfigSetDefaultString ConfigSetDefaultString;
extern ptr_ConfigGetParamInt ConfigGetParamInt;
extern ptr_ConfigGetParamFloat ConfigGetParamFloat;
extern ptr_ConfigGetParamBool ConfigGetParamBool;
extern ptr_ConfigGetParamString ConfigGetParamString;
extern ptr_ConfigGetSharedDataFilepath ConfigGetSharedDataFilepath;
extern ptr_ConfigGetUserConfigPath ConfigGetUserConfigPath;
extern ptr_ConfigGetUserDataPath ConfigGetUserDataPath;
extern ptr_ConfigGetUserCachePath ConfigGetUserCachePath;
/* declarations of pointers to Core debugger functions */
extern ptr_DebugSetCallbacks DebugSetCallbacks;
extern ptr_DebugSetCoreCompare DebugSetCoreCompare;
extern ptr_DebugSetRunState DebugSetRunState;
extern ptr_DebugGetState DebugGetState;
extern ptr_DebugStep DebugStep;
extern ptr_DebugDecodeOp DebugDecodeOp;
extern ptr_DebugMemGetRecompInfo DebugMemGetRecompInfo;
extern ptr_DebugMemGetMemInfo DebugMemGetMemInfo;
extern ptr_DebugMemGetPointer DebugMemGetPointer;
extern ptr_DebugMemRead64 DebugMemRead64;
extern ptr_DebugMemRead32 DebugMemRead32;
extern ptr_DebugMemRead16 DebugMemRead16;
extern ptr_DebugMemRead8 DebugMemRead8;
extern ptr_DebugMemWrite64 DebugMemWrite64;
extern ptr_DebugMemWrite32 DebugMemWrite32;
extern ptr_DebugMemWrite16 DebugMemWrite16;
extern ptr_DebugMemWrite8 DebugMemWrite8;
extern ptr_DebugGetCPUDataPtr DebugGetCPUDataPtr;
extern ptr_DebugBreakpointLookup DebugBreakpointLookup;
extern ptr_DebugBreakpointCommand DebugBreakpointCommand;
#endif /* #define CORE_INTERFACE_H */
+195
View File
@@ -0,0 +1,195 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - plugin.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard42 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <QCoreApplication>
#include "mainwindow.h"
#include "core_interface.h"
#include "m64p_common.h"
#include "m64p_types.h"
#include "common.h" /* for the debug callback function */
extern "C" {
#include "osal_dynamiclib.h"
#include "osal_files.h"
#include "osal_preproc.h"
}
#include "plugin.h"
#include "version.h"
/* global variables */
QString qtPluginDir;
QString qtGfxPlugin;
QString qtAudioPlugin;
QString qtInputPlugin;
QString qtRspPlugin;
plugin_map_node g_PluginMap[] = {{M64PLUGIN_GFX, "Video", NULL, "", "", 0 },
{M64PLUGIN_AUDIO, "Audio", NULL, "", "", 0 },
{M64PLUGIN_INPUT, "Input", NULL, "", "", 0 },
{M64PLUGIN_RSP, "RSP", NULL, "", "", 0 } };
/* local functions */
static m64p_error PluginLoadTry(std::string filepath, int MapIndex)
{
/* try to open a shared library at the given filepath */
m64p_dynlib_handle handle;
m64p_error rval = osal_dynlib_open(&handle, filepath.c_str());
if (rval != M64ERR_SUCCESS)
return rval;
/* call the GetVersion function for the plugin and check compatibility */
ptr_PluginGetVersion PluginGetVersion = (ptr_PluginGetVersion) osal_dynlib_getproc(handle, "PluginGetVersion");
if (PluginGetVersion == NULL)
{
DebugMessage(M64MSG_ERROR, "library '%s' is not a Mupen64Plus library.", filepath.c_str());
osal_dynlib_close(handle);
return M64ERR_INCOMPATIBLE;
}
m64p_plugin_type PluginType = (m64p_plugin_type) 0;
int PluginVersion = 0;
const char *PluginName = NULL;
(*PluginGetVersion)(&PluginType, &PluginVersion, NULL, &PluginName, NULL);
if (PluginType != g_PluginMap[MapIndex].type)
{
/* the type of this plugin doesn't match with the type that was requested by the caller */
osal_dynlib_close(handle);
return M64ERR_INCOMPATIBLE;
}
/* the front-end doesn't talk to the plugins, so we don't care about the plugin version or api version */
/* call the plugin's initialization function and make sure it starts okay */
ptr_PluginStartup PluginStartup = (ptr_PluginStartup) osal_dynlib_getproc(handle, "PluginStartup");
if (PluginStartup == NULL)
{
DebugMessage(M64MSG_ERROR, "library '%s' broken. No PluginStartup() function found.", filepath.c_str());
osal_dynlib_close(handle);
return M64ERR_INCOMPATIBLE;
}
rval = (*PluginStartup)(CoreHandle, g_PluginMap[MapIndex].name, DebugCallback); /* DebugCallback is in main.c */
if (rval != M64ERR_SUCCESS)
{
DebugMessage(M64MSG_ERROR, "Error: %s plugin library '%s' failed to start.", g_PluginMap[MapIndex].name, filepath.c_str());
osal_dynlib_close(handle);
return rval;
}
/* plugin loaded successfully, so set the plugin map's members */
g_PluginMap[MapIndex].handle = handle;
g_PluginMap[MapIndex].filename = filepath;
g_PluginMap[MapIndex].libname = PluginName;
g_PluginMap[MapIndex].libversion = PluginVersion;
return M64ERR_SUCCESS;
}
/* global functions */
m64p_error PluginSearchLoad()
{
osal_lib_search *lib_filelist = NULL;
int i;
/* start by checking the directory given on the command line */
if (!qtPluginDir.isEmpty())
lib_filelist = osal_library_search(qtPluginDir.toLatin1().data());
if (lib_filelist == NULL)
lib_filelist = osal_library_search(QCoreApplication::applicationDirPath().toLatin1().data());
/* try to load one of each type of plugin */
for (i = 0; i < 4; i++)
{
m64p_plugin_type type = g_PluginMap[i].type;
std::string cmdline_path;
switch (type)
{
case M64PLUGIN_RSP: cmdline_path = qtRspPlugin.toStdString(); break;
case M64PLUGIN_GFX: cmdline_path = qtGfxPlugin.toStdString(); break;
case M64PLUGIN_AUDIO: cmdline_path = qtAudioPlugin.toStdString(); break;
case M64PLUGIN_INPUT: cmdline_path = qtInputPlugin.toStdString(); break;
default: cmdline_path = "";
}
/* if full path was given, try loading exactly this file */
if (strchr(cmdline_path.c_str(), OSAL_DIR_SEPARATOR) != NULL)
{
PluginLoadTry(cmdline_path, i);
}
else /* otherwise search through the plugin directory to find a match with this name */
{
osal_lib_search *curr = lib_filelist;
while (curr != NULL && g_PluginMap[i].handle == NULL)
{
if (curr->filename == cmdline_path)
PluginLoadTry(curr->filepath, i);
curr = curr->next;
}
}
/* print out the particular plugin used */
if (g_PluginMap[i].handle == NULL)
{
QString name = g_PluginMap[i].name;
if (w->getWorkerThread() != nullptr) {
if (w->getWorkerThread()->isRunning())
w->getWorkerThread()->pluginWarning(name);
}
}
else
{
DebugMessage(M64MSG_INFO, "using %s plugin: '%s' v%i.%i.%i", g_PluginMap[i].name,
g_PluginMap[i].libname.c_str(), VERSION_PRINTF_SPLIT(g_PluginMap[i].libversion));
DebugMessage(M64MSG_VERBOSE, "%s plugin library: %s", g_PluginMap[i].name, g_PluginMap[i].filename.c_str());
}
}
/* free up the list of library files in the plugin search directory */
osal_free_lib_list(lib_filelist);
return M64ERR_SUCCESS;
}
m64p_error PluginUnload(void)
{
typedef m64p_error (*ptr_PluginShutdown)(void);
ptr_PluginShutdown PluginShutdown;
int i;
/* shutdown each type of plugin */
for (i = 0; i < 4; i++)
{
if (g_PluginMap[i].handle == NULL)
continue;
/* call the destructor function for the plugin and release the library */
PluginShutdown = (ptr_PluginShutdown) osal_dynlib_getproc(g_PluginMap[i].handle, "PluginShutdown");
if (PluginShutdown != NULL)
(*PluginShutdown)();
osal_dynlib_close(g_PluginMap[i].handle);
/* clear out the plugin map's members */
g_PluginMap[i].handle = NULL;
g_PluginMap[i].filename.clear();
g_PluginMap[i].libname.clear();
g_PluginMap[i].libversion = 0;
}
return M64ERR_SUCCESS;
}
+53
View File
@@ -0,0 +1,53 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - plugin.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard42 *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if !defined(PLUGIN_H)
#define PLUGIN_H
#include <QString>
#include <limits.h>
#include "m64p_types.h"
#include "osal_preproc.h"
extern m64p_error PluginSearchLoad(void);
extern m64p_error PluginUnload(void);
extern QString qtPluginDir;
extern QString qtGfxPlugin;
extern QString qtAudioPlugin;
extern QString qtInputPlugin;
extern QString qtRspPlugin;
typedef struct {
m64p_plugin_type type;
char name[8];
m64p_dynlib_handle handle;
std::string filename;
std::string libname;
int libversion;
} plugin_map_node;
extern plugin_map_node g_PluginMap[4];
#endif /* #define PLUGIN_H */
+664
View File
@@ -0,0 +1,664 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus - sdl_key_converter.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2013 Mupen64plus development team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "sdl_key_converter.h"
#include <stdint.h>
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
uint16_t sdl_keysym2native(uint16_t keysym)
{
return sdl_keysym2scancode(keysym);
}
uint16_t sdl_native2keysym(uint16_t native)
{
return sdl_scancode2keysym(native);
}
uint16_t sdl_keysym2scancode(uint16_t keysym)
{
static const uint16_t keysym2scancode[323] = {
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x002au, /* SDLK_BACKSPACE -> SDL_SCANCODE_BACKSPACE */
0x002bu, /* SDLK_TAB -> SDL_SCANCODE_TAB */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x009cu, /* SDLK_CLEAR -> SDL_SCANCODE_CLEAR */
0x0028u, /* SDLK_RETURN -> SDL_SCANCODE_RETURN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0048u, /* SDLK_PAUSE -> SDL_SCANCODE_PAUSE */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0029u, /* SDLK_ESCAPE -> SDL_SCANCODE_ESCAPE */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x002cu, /* SDLK_SPACE -> SDL_SCANCODE_SPACE */
0x0000u, /* SDLK_EXCLAIM -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_QUOTEDBL -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_HASH -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_DOLLAR -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_AMPERSAND -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_QUOTE -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_LEFTPAREN -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_RIGHTPAREN -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_ASTERISK -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_PLUS -> SDL_SCANCODE_UNKNOWN */
0x0036u, /* SDLK_COMMA -> SDL_SCANCODE_COMMA */
0x002du, /* SDLK_MINUS -> SDL_SCANCODE_MINUS */
0x0037u, /* SDLK_PERIOD -> SDL_SCANCODE_PERIOD */
0x0038u, /* SDLK_SLASH -> SDL_SCANCODE_SLASH */
0x0027u, /* SDLK_0 -> SDL_SCANCODE_0 */
0x001eu, /* SDLK_1 -> SDL_SCANCODE_1 */
0x001fu, /* SDLK_2 -> SDL_SCANCODE_2 */
0x0020u, /* SDLK_3 -> SDL_SCANCODE_3 */
0x0021u, /* SDLK_4 -> SDL_SCANCODE_4 */
0x0022u, /* SDLK_5 -> SDL_SCANCODE_5 */
0x0023u, /* SDLK_6 -> SDL_SCANCODE_6 */
0x0024u, /* SDLK_7 -> SDL_SCANCODE_7 */
0x0025u, /* SDLK_8 -> SDL_SCANCODE_8 */
0x0026u, /* SDLK_9 -> SDL_SCANCODE_9 */
0x0000u, /* SDLK_COLON -> SDL_SCANCODE_UNKNOWN */
0x0033u, /* SDLK_SEMICOLON -> SDL_SCANCODE_SEMICOLON */
0x0000u, /* SDLK_LESS -> SDL_SCANCODE_UNKNOWN */
0x002eu, /* SDLK_EQUALS -> SDL_SCANCODE_EQUALS */
0x0000u, /* SDLK_GREATER -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_QUESTION -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_AT -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x002fu, /* SDLK_LEFTBRACKET -> SDL_SCANCODE_LEFTBRACKET */
0x0031u, /* SDLK_BACKSLASH -> SDL_SCANCODE_BACKSLASH */
0x0030u, /* SDLK_RIGHTBRACKET -> SDL_SCANCODE_RIGHTBRACKET */
0x0000u, /* SDLK_CARET -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_UNDERSCORE -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_BACKQUOTE -> SDL_SCANCODE_UNKNOWN */
0x0004u, /* SDLK_a -> SDL_SCANCODE_A */
0x0005u, /* SDLK_b -> SDL_SCANCODE_B */
0x0006u, /* SDLK_c -> SDL_SCANCODE_C */
0x0007u, /* SDLK_d -> SDL_SCANCODE_D */
0x0008u, /* SDLK_e -> SDL_SCANCODE_E */
0x0009u, /* SDLK_f -> SDL_SCANCODE_F */
0x000au, /* SDLK_g -> SDL_SCANCODE_G */
0x000bu, /* SDLK_h -> SDL_SCANCODE_H */
0x000cu, /* SDLK_i -> SDL_SCANCODE_I */
0x000du, /* SDLK_j -> SDL_SCANCODE_J */
0x000eu, /* SDLK_k -> SDL_SCANCODE_K */
0x000fu, /* SDLK_l -> SDL_SCANCODE_L */
0x0010u, /* SDLK_m -> SDL_SCANCODE_M */
0x0011u, /* SDLK_n -> SDL_SCANCODE_N */
0x0012u, /* SDLK_o -> SDL_SCANCODE_O */
0x0013u, /* SDLK_p -> SDL_SCANCODE_P */
0x0014u, /* SDLK_q -> SDL_SCANCODE_Q */
0x0015u, /* SDLK_r -> SDL_SCANCODE_R */
0x0016u, /* SDLK_s -> SDL_SCANCODE_S */
0x0017u, /* SDLK_t -> SDL_SCANCODE_T */
0x0018u, /* SDLK_u -> SDL_SCANCODE_U */
0x0019u, /* SDLK_v -> SDL_SCANCODE_V */
0x001au, /* SDLK_w -> SDL_SCANCODE_W */
0x001bu, /* SDLK_x -> SDL_SCANCODE_X */
0x001cu, /* SDLK_y -> SDL_SCANCODE_Y */
0x001du, /* SDLK_z -> SDL_SCANCODE_Z */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x004cu, /* SDLK_DELETE -> SDL_SCANCODE_DELETE */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_0 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_1 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_2 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_3 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_4 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_5 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_6 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_7 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_8 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_9 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_10 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_11 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_12 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_13 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_14 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_15 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_16 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_17 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_18 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_19 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_20 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_21 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_22 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_23 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_24 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_25 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_26 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_27 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_28 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_29 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_30 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_31 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_32 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_33 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_34 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_35 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_36 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_37 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_38 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_39 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_40 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_41 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_42 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_43 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_44 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_45 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_46 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_47 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_48 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_49 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_50 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_51 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_52 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_53 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_54 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_55 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_56 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_57 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_58 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_59 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_60 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_61 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_62 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_63 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_64 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_65 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_66 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_67 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_68 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_69 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_70 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_71 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_72 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_73 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_74 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_75 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_76 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_77 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_78 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_79 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_80 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_81 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_82 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_83 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_84 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_85 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_86 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_87 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_88 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_89 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_90 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_91 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_92 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_93 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_94 -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_WORLD_95 -> SDL_SCANCODE_UNKNOWN */
0x0062u, /* SDLK_KP0 -> SDL_SCANCODE_KP_0 */
0x0059u, /* SDLK_KP1 -> SDL_SCANCODE_KP_1 */
0x005au, /* SDLK_KP2 -> SDL_SCANCODE_KP_2 */
0x005bu, /* SDLK_KP3 -> SDL_SCANCODE_KP_3 */
0x005cu, /* SDLK_KP4 -> SDL_SCANCODE_KP_4 */
0x005du, /* SDLK_KP5 -> SDL_SCANCODE_KP_5 */
0x005eu, /* SDLK_KP6 -> SDL_SCANCODE_KP_6 */
0x005fu, /* SDLK_KP7 -> SDL_SCANCODE_KP_7 */
0x0060u, /* SDLK_KP8 -> SDL_SCANCODE_KP_8 */
0x0061u, /* SDLK_KP9 -> SDL_SCANCODE_KP_9 */
0x0063u, /* SDLK_KP_PERIOD -> SDL_SCANCODE_KP_PERIOD */
0x0054u, /* SDLK_KP_DIVIDE -> SDL_SCANCODE_KP_DIVIDE */
0x0055u, /* SDLK_KP_MULTIPLY -> SDL_SCANCODE_KP_MULTIPLY */
0x0056u, /* SDLK_KP_MINUS -> SDL_SCANCODE_KP_MINUS */
0x0057u, /* SDLK_KP_PLUS -> SDL_SCANCODE_KP_PLUS */
0x0058u, /* SDLK_KP_ENTER -> SDL_SCANCODE_KP_ENTER */
0x0067u, /* SDLK_KP_EQUALS -> SDL_SCANCODE_KP_EQUALS */
0x0052u, /* SDLK_UP -> SDL_SCANCODE_UP */
0x0051u, /* SDLK_DOWN -> SDL_SCANCODE_DOWN */
0x004fu, /* SDLK_RIGHT -> SDL_SCANCODE_RIGHT */
0x0050u, /* SDLK_LEFT -> SDL_SCANCODE_LEFT */
0x0049u, /* SDLK_INSERT -> SDL_SCANCODE_INSERT */
0x004au, /* SDLK_HOME -> SDL_SCANCODE_HOME */
0x004du, /* SDLK_END -> SDL_SCANCODE_END */
0x004bu, /* SDLK_PAGEUP -> SDL_SCANCODE_PAGEUP */
0x004eu, /* SDLK_PAGEDOWN -> SDL_SCANCODE_PAGEDOWN */
0x003au, /* SDLK_F1 -> SDL_SCANCODE_F1 */
0x003bu, /* SDLK_F2 -> SDL_SCANCODE_F2 */
0x003cu, /* SDLK_F3 -> SDL_SCANCODE_F3 */
0x003du, /* SDLK_F4 -> SDL_SCANCODE_F4 */
0x003eu, /* SDLK_F5 -> SDL_SCANCODE_F5 */
0x003fu, /* SDLK_F6 -> SDL_SCANCODE_F6 */
0x0040u, /* SDLK_F7 -> SDL_SCANCODE_F7 */
0x0041u, /* SDLK_F8 -> SDL_SCANCODE_F8 */
0x0042u, /* SDLK_F9 -> SDL_SCANCODE_F9 */
0x0043u, /* SDLK_F10 -> SDL_SCANCODE_F10 */
0x0044u, /* SDLK_F11 -> SDL_SCANCODE_F11 */
0x0045u, /* SDLK_F12 -> SDL_SCANCODE_F12 */
0x0068u, /* SDLK_F13 -> SDL_SCANCODE_F13 */
0x0069u, /* SDLK_F14 -> SDL_SCANCODE_F14 */
0x006au, /* SDLK_F15 -> SDL_SCANCODE_F15 */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* unassigned -> SDL_SCANCODE_UNKNOWN */
0x0053u, /* SDLK_NUMLOCK -> SDL_SCANCODE_NUMLOCKCLEAR */
0x0039u, /* SDLK_CAPSLOCK -> SDL_SCANCODE_CAPSLOCK */
0x0000u, /* SDLK_SCROLLOCK -> SDL_SCANCODE_UNKNOWN */
0x00e5u, /* SDLK_RSHIFT -> SDL_SCANCODE_RSHIFT */
0x00e1u, /* SDLK_LSHIFT -> SDL_SCANCODE_LSHIFT */
0x00e4u, /* SDLK_RCTRL -> SDL_SCANCODE_RCTRL */
0x00e0u, /* SDLK_LCTRL -> SDL_SCANCODE_LCTRL */
0x00e6u, /* SDLK_RALT -> SDL_SCANCODE_RALT */
0x00e2u, /* SDLK_LALT -> SDL_SCANCODE_LALT */
0x0000u, /* SDLK_RMETA -> SDL_SCANCODE_UNKNOWN */
0x0000u, /* SDLK_LMETA -> SDL_SCANCODE_UNKNOWN */
0x00e3u, /* SDLK_LSUPER -> SDL_SCANCODE_LGUI */
0x00e7u, /* SDLK_RSUPER -> SDL_SCANCODE_RGUI */
0x0101u, /* SDLK_MODE -> SDL_SCANCODE_MODE */
0x0000u, /* SDLK_COMPOSE -> SDL_SCANCODE_UNKNOWN */
0x0075u, /* SDLK_HELP -> SDL_SCANCODE_HELP */
0x0000u, /* SDLK_PRINT -> SDL_SCANCODE_UNKNOWN */
0x009au, /* SDLK_SYSREQ -> SDL_SCANCODE_SYSREQ */
0x0000u, /* SDLK_BREAK -> SDL_SCANCODE_UNKNOWN */
0x0076u, /* SDLK_MENU -> SDL_SCANCODE_MENU */
0x0066u, /* SDLK_POWER -> SDL_SCANCODE_POWER */
0x0000u, /* SDLK_EURO -> SDL_SCANCODE_UNKNOWN */
0x007au, /* SDLK_UNDO -> SDL_SCANCODE_UNDO */
};
if (keysym >= ARRAY_SIZE(keysym2scancode))
return 0;
return keysym2scancode[keysym];
}
uint16_t sdl_scancode2keysym(uint16_t scancode)
{
static const uint16_t scancode2keysym[285] = {
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0061u, /* SDL_SCANCODE_A -> SDLK_a */
0x0062u, /* SDL_SCANCODE_B -> SDLK_b */
0x0063u, /* SDL_SCANCODE_C -> SDLK_c */
0x0064u, /* SDL_SCANCODE_D -> SDLK_d */
0x0065u, /* SDL_SCANCODE_E -> SDLK_e */
0x0066u, /* SDL_SCANCODE_F -> SDLK_f */
0x0067u, /* SDL_SCANCODE_G -> SDLK_g */
0x0068u, /* SDL_SCANCODE_H -> SDLK_h */
0x0069u, /* SDL_SCANCODE_I -> SDLK_i */
0x006au, /* SDL_SCANCODE_J -> SDLK_j */
0x006bu, /* SDL_SCANCODE_K -> SDLK_k */
0x006cu, /* SDL_SCANCODE_L -> SDLK_l */
0x006du, /* SDL_SCANCODE_M -> SDLK_m */
0x006eu, /* SDL_SCANCODE_N -> SDLK_n */
0x006fu, /* SDL_SCANCODE_O -> SDLK_o */
0x0070u, /* SDL_SCANCODE_P -> SDLK_p */
0x0071u, /* SDL_SCANCODE_Q -> SDLK_q */
0x0072u, /* SDL_SCANCODE_R -> SDLK_r */
0x0073u, /* SDL_SCANCODE_S -> SDLK_s */
0x0074u, /* SDL_SCANCODE_T -> SDLK_t */
0x0075u, /* SDL_SCANCODE_U -> SDLK_u */
0x0076u, /* SDL_SCANCODE_V -> SDLK_v */
0x0077u, /* SDL_SCANCODE_W -> SDLK_w */
0x0078u, /* SDL_SCANCODE_X -> SDLK_x */
0x0079u, /* SDL_SCANCODE_Y -> SDLK_y */
0x007au, /* SDL_SCANCODE_Z -> SDLK_z */
0x0031u, /* SDL_SCANCODE_1 -> SDLK_1 */
0x0032u, /* SDL_SCANCODE_2 -> SDLK_2 */
0x0033u, /* SDL_SCANCODE_3 -> SDLK_3 */
0x0034u, /* SDL_SCANCODE_4 -> SDLK_4 */
0x0035u, /* SDL_SCANCODE_5 -> SDLK_5 */
0x0036u, /* SDL_SCANCODE_6 -> SDLK_6 */
0x0037u, /* SDL_SCANCODE_7 -> SDLK_7 */
0x0038u, /* SDL_SCANCODE_8 -> SDLK_8 */
0x0039u, /* SDL_SCANCODE_9 -> SDLK_9 */
0x0030u, /* SDL_SCANCODE_0 -> SDLK_0 */
0x000du, /* SDL_SCANCODE_RETURN -> SDLK_RETURN */
0x001bu, /* SDL_SCANCODE_ESCAPE -> SDLK_ESCAPE */
0x0008u, /* SDL_SCANCODE_BACKSPACE -> SDLK_BACKSPACE */
0x0009u, /* SDL_SCANCODE_TAB -> SDLK_TAB */
0x0020u, /* SDL_SCANCODE_SPACE -> SDLK_SPACE */
0x002du, /* SDL_SCANCODE_MINUS -> SDLK_MINUS */
0x003du, /* SDL_SCANCODE_EQUALS -> SDLK_EQUALS */
0x005bu, /* SDL_SCANCODE_LEFTBRACKET -> SDLK_LEFTBRACKET */
0x005du, /* SDL_SCANCODE_RIGHTBRACKET -> SDLK_RIGHTBRACKET */
0x005cu, /* SDL_SCANCODE_BACKSLASH -> SDLK_BACKSLASH */
0x0000u, /* SDL_SCANCODE_NONUSHASH -> SDLK_UNKNOWN */
0x003bu, /* SDL_SCANCODE_SEMICOLON -> SDLK_SEMICOLON */
0x0000u, /* SDL_SCANCODE_APOSTROPHE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_GRAVE -> SDLK_UNKNOWN */
0x002cu, /* SDL_SCANCODE_COMMA -> SDLK_COMMA */
0x002eu, /* SDL_SCANCODE_PERIOD -> SDLK_PERIOD */
0x002fu, /* SDL_SCANCODE_SLASH -> SDLK_SLASH */
0x012du, /* SDL_SCANCODE_CAPSLOCK -> SDLK_CAPSLOCK */
0x011au, /* SDL_SCANCODE_F1 -> SDLK_F1 */
0x011bu, /* SDL_SCANCODE_F2 -> SDLK_F2 */
0x011cu, /* SDL_SCANCODE_F3 -> SDLK_F3 */
0x011du, /* SDL_SCANCODE_F4 -> SDLK_F4 */
0x011eu, /* SDL_SCANCODE_F5 -> SDLK_F5 */
0x011fu, /* SDL_SCANCODE_F6 -> SDLK_F6 */
0x0120u, /* SDL_SCANCODE_F7 -> SDLK_F7 */
0x0121u, /* SDL_SCANCODE_F8 -> SDLK_F8 */
0x0122u, /* SDL_SCANCODE_F9 -> SDLK_F9 */
0x0123u, /* SDL_SCANCODE_F10 -> SDLK_F10 */
0x0124u, /* SDL_SCANCODE_F11 -> SDLK_F11 */
0x0125u, /* SDL_SCANCODE_F12 -> SDLK_F12 */
0x0000u, /* SDL_SCANCODE_PRINTSCREEN -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_SCROLLLOCK -> SDLK_UNKNOWN */
0x0013u, /* SDL_SCANCODE_PAUSE -> SDLK_PAUSE */
0x0115u, /* SDL_SCANCODE_INSERT -> SDLK_INSERT */
0x0116u, /* SDL_SCANCODE_HOME -> SDLK_HOME */
0x0118u, /* SDL_SCANCODE_PAGEUP -> SDLK_PAGEUP */
0x007fu, /* SDL_SCANCODE_DELETE -> SDLK_DELETE */
0x0117u, /* SDL_SCANCODE_END -> SDLK_END */
0x0119u, /* SDL_SCANCODE_PAGEDOWN -> SDLK_PAGEDOWN */
0x0113u, /* SDL_SCANCODE_RIGHT -> SDLK_RIGHT */
0x0114u, /* SDL_SCANCODE_LEFT -> SDLK_LEFT */
0x0112u, /* SDL_SCANCODE_DOWN -> SDLK_DOWN */
0x0111u, /* SDL_SCANCODE_UP -> SDLK_UP */
0x012cu, /* SDL_SCANCODE_NUMLOCKCLEAR -> SDLK_NUMLOCK */
0x010bu, /* SDL_SCANCODE_KP_DIVIDE -> SDLK_KP_DIVIDE */
0x010cu, /* SDL_SCANCODE_KP_MULTIPLY -> SDLK_KP_MULTIPLY */
0x010du, /* SDL_SCANCODE_KP_MINUS -> SDLK_KP_MINUS */
0x010eu, /* SDL_SCANCODE_KP_PLUS -> SDLK_KP_PLUS */
0x010fu, /* SDL_SCANCODE_KP_ENTER -> SDLK_KP_ENTER */
0x0101u, /* SDL_SCANCODE_KP_1 -> SDLK_KP1 */
0x0102u, /* SDL_SCANCODE_KP_2 -> SDLK_KP2 */
0x0103u, /* SDL_SCANCODE_KP_3 -> SDLK_KP3 */
0x0104u, /* SDL_SCANCODE_KP_4 -> SDLK_KP4 */
0x0105u, /* SDL_SCANCODE_KP_5 -> SDLK_KP5 */
0x0106u, /* SDL_SCANCODE_KP_6 -> SDLK_KP6 */
0x0107u, /* SDL_SCANCODE_KP_7 -> SDLK_KP7 */
0x0108u, /* SDL_SCANCODE_KP_8 -> SDLK_KP8 */
0x0109u, /* SDL_SCANCODE_KP_9 -> SDLK_KP9 */
0x0100u, /* SDL_SCANCODE_KP_0 -> SDLK_KP0 */
0x010au, /* SDL_SCANCODE_KP_PERIOD -> SDLK_KP_PERIOD */
0x0000u, /* SDL_SCANCODE_NONUSBACKSLASH -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_APPLICATION -> SDLK_UNKNOWN */
0x0140u, /* SDL_SCANCODE_POWER -> SDLK_POWER */
0x0110u, /* SDL_SCANCODE_KP_EQUALS -> SDLK_KP_EQUALS */
0x0126u, /* SDL_SCANCODE_F13 -> SDLK_F13 */
0x0127u, /* SDL_SCANCODE_F14 -> SDLK_F14 */
0x0128u, /* SDL_SCANCODE_F15 -> SDLK_F15 */
0x0000u, /* SDL_SCANCODE_F16 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F17 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F18 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F19 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F20 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F21 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F22 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F23 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_F24 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_EXECUTE -> SDLK_UNKNOWN */
0x013bu, /* SDL_SCANCODE_HELP -> SDLK_HELP */
0x013fu, /* SDL_SCANCODE_MENU -> SDLK_MENU */
0x0000u, /* SDL_SCANCODE_SELECT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_STOP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AGAIN -> SDLK_UNKNOWN */
0x0142u, /* SDL_SCANCODE_UNDO -> SDLK_UNDO */
0x0000u, /* SDL_SCANCODE_CUT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_COPY -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_PASTE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_FIND -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_MUTE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_VOLUMEUP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_VOLUMEDOWN -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_COMMA -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_EQUALSAS400 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL1 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL2 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL3 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL4 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL5 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL6 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL7 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL8 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_INTERNATIONAL9 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG1 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG2 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG3 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG4 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG5 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG6 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG7 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG8 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_LANG9 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_ALTERASE -> SDLK_UNKNOWN */
0x013du, /* SDL_SCANCODE_SYSREQ -> SDLK_SYSREQ */
0x0000u, /* SDL_SCANCODE_CANCEL -> SDLK_UNKNOWN */
0x000cu, /* SDL_SCANCODE_CLEAR -> SDLK_CLEAR */
0x0000u, /* SDL_SCANCODE_PRIOR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_RETURN2 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_SEPARATOR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_OUT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_OPER -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_CLEARAGAIN -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_CRSEL -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_EXSEL -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_00 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_000 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_THOUSANDSSEPARATOR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_DECIMALSEPARATOR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_CURRENCYUNIT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_CURRENCYSUBUNIT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_LEFTPAREN -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_RIGHTPAREN -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_LEFTBRACE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_RIGHTBRACE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_TAB -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_BACKSPACE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_A -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_B -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_C -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_D -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_E -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_F -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_XOR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_POWER -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_PERCENT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_LESS -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_GREATER -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_AMPERSAND -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_DBLAMPERSAND -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_VERTICALBAR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_DBLVERTICALBAR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_COLON -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_HASH -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_SPACE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_AT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_EXCLAM -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMSTORE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMRECALL -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMCLEAR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMADD -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMSUBTRACT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMMULTIPLY -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_MEMDIVIDE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_PLUSMINUS -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_CLEAR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_CLEARENTRY -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_BINARY -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_OCTAL -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_DECIMAL -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KP_HEXADECIMAL -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0132u, /* SDL_SCANCODE_LCTRL -> SDLK_LCTRL */
0x0130u, /* SDL_SCANCODE_LSHIFT -> SDLK_LSHIFT */
0x0134u, /* SDL_SCANCODE_LALT -> SDLK_LALT */
0x0137u, /* SDL_SCANCODE_LGUI -> SDLK_LSUPER */
0x0131u, /* SDL_SCANCODE_RCTRL -> SDLK_RCTRL */
0x012fu, /* SDL_SCANCODE_RSHIFT -> SDLK_RSHIFT */
0x0133u, /* SDL_SCANCODE_RALT -> SDLK_RALT */
0x0138u, /* SDL_SCANCODE_RGUI -> SDLK_RSUPER */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0000u, /* unassigned -> SDLK_UNKNOWN */
0x0139u, /* SDL_SCANCODE_MODE -> SDLK_MODE */
0x0000u, /* SDL_SCANCODE_AUDIONEXT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AUDIOPREV -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AUDIOSTOP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AUDIOPLAY -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AUDIOMUTE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_MEDIASELECT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_WWW -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_MAIL -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_CALCULATOR -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_COMPUTER -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_SEARCH -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_HOME -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_BACK -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_FORWARD -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_STOP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_REFRESH -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_AC_BOOKMARKS -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_BRIGHTNESSDOWN -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_BRIGHTNESSUP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_DISPLAYSWITCH -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KBDILLUMTOGGLE -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KBDILLUMDOWN -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_KBDILLUMUP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_EJECT -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_SLEEP -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_APP1 -> SDLK_UNKNOWN */
0x0000u, /* SDL_SCANCODE_APP2 -> SDLK_UNKNOWN */
};
if (scancode >= ARRAY_SIZE(scancode2keysym))
return 0;
return scancode2keysym[scancode];
}
+42
View File
@@ -0,0 +1,42 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus - sdl_key_converter.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2013 Mupen64plus development team *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef __SDL_KEY_CONVH__
#define __SDL_KEY_CONVH__
#include <SDL.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
uint16_t sdl_keysym2scancode(uint16_t keysym);
uint16_t sdl_scancode2keysym(uint16_t scancode);
uint16_t sdl_keysym2native(uint16_t keysym);
uint16_t sdl_native2keysym(uint16_t native);
#ifdef __cplusplus
}
#endif
#endif
+39
View File
@@ -0,0 +1,39 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - version.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This header file is for versioning information
*
*/
#if !defined(VERSION_H)
#define VERSION_H
#define CONSOLE_UI_NAME "Mupen64Plus Console User-Interface"
#define CONSOLE_UI_VERSION 0x020500
#define CORE_API_VERSION 0x020001
#define CONFIG_API_VERSION 0x020000
#define MINIMUM_CORE_VERSION 0x016300
#define VERSION_PRINTF_SPLIT(x) (((x) >> 16) & 0xffff), (((x) >> 8) & 0xff), ((x) & 0xff)
#endif /* #define VERSION_H */
+35
View File
@@ -0,0 +1,35 @@
#include "keypressfilter.h"
#include "core_interface.h"
#include "common.h"
#include <QKeyEvent>
KeyPressFilter::KeyPressFilter(QObject *parent)
: QObject(parent)
{
}
bool KeyPressFilter::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::KeyPress) {
if (coreStarted) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
int modValue = QT2SDL2MOD(keyEvent->modifiers());
int keyValue = QT2SDL2(keyEvent->key());
if (keyValue != 0)
(*CoreDoCommand)(M64CMD_SEND_SDL_KEYDOWN, (modValue << 16) + keyValue, NULL);
}
return true;
} else if (event->type() == QEvent::KeyRelease){
if (coreStarted) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
int modValue = QT2SDL2MOD(keyEvent->modifiers());
int keyValue = QT2SDL2(keyEvent->key());
if (keyValue != 0)
(*CoreDoCommand)(M64CMD_SEND_SDL_KEYUP, (modValue << 16) + keyValue, NULL);
}
return true;
} else {
// standard event processing
return QObject::eventFilter(obj, event);
}
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef KEYPRESSFILTER_H
#define KEYPRESSFILTER_H
#include <QObject>
class KeyPressFilter : public QObject
{
Q_OBJECT
public:
explicit KeyPressFilter(QObject *parent = 0);
protected:
bool eventFilter(QObject *obj, QEvent *event);
};
#endif
+49
View File
@@ -0,0 +1,49 @@
#include "logviewer.h"
LogViewer::LogViewer(QWidget *parent)
: QDialog(parent)
{
file.open();
this->resize(640,480);
QVBoxLayout *mainLayout = new QVBoxLayout(this);
textArea = new QPlainTextEdit(this);
textArea->setReadOnly(1);
mainLayout->addWidget(textArea);
setLayout(mainLayout);
}
LogViewer::~LogViewer()
{
file.close();
}
void LogViewer::showEvent(QShowEvent *event)
{
file.flush();
qint64 pos = file.pos();
file.seek(0);
QTextStream in(&file);
QString data;
while (!in.atEnd()) {
data += in.readLine();
data += "\n";
}
file.seek(pos);
textArea->setPlainText(data);
QWidget::showEvent( event );
}
void LogViewer::addLog(QString text)
{
QTextStream out(&file);
out << text;
}
void LogViewer::clearLog()
{
file.seek(0);
file.resize(0);
file.flush();
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef LOGVIEWER_H
#define LOGVIEWER_H
#include <QDialog>
#include <QPlainTextEdit>
#include <QVBoxLayout>
#include <QTemporaryFile>
#include <QTextStream>
class LogViewer : public QDialog
{
Q_OBJECT
public:
explicit LogViewer(QWidget *parent = 0);
~LogViewer();
void addLog(QString text);
void clearLog();
protected:
void showEvent(QShowEvent *event);
private:
QTemporaryFile file;
QPlainTextEdit *textArea = nullptr;
};
#endif // LOGVIEWER_H
+38
View File
@@ -0,0 +1,38 @@
#include "mainwindow.h"
#include <QApplication>
#include <QCommandLineParser>
MainWindow *w;
int main(int argc, char *argv[])
{
srand (time(NULL));
QApplication a(argc, argv);
QCoreApplication::setApplicationName("mupen64plus-gui");
QCommandLineParser parser;
parser.addHelpOption();
QCommandLineOption verboseOption({"v", "verbose"}, "Verbose mode. Prints out more information to log.");
QCommandLineOption noGUIOption("nogui", "Disable GUI elements.");
QCommandLineOption GLESOption("gles", "Request an OpenGL ES Context.");
parser.addOption(verboseOption);
parser.addOption(noGUIOption);
parser.addOption(GLESOption);
parser.addPositionalArgument("ROM", QCoreApplication::translate("main", "ROM to open."));
parser.process(a);
const QStringList args = parser.positionalArguments();
w = new MainWindow();
w->show();
if (parser.isSet(verboseOption))
w->setVerbose();
if (parser.isSet(noGUIOption))
w->setNoGUI();
if (parser.isSet(GLESOption))
w->setGLES();
if (args.size() > 0)
w->openROM(args.at(0), "", 0, 0);
return a.exec();
}
+830
View File
@@ -0,0 +1,830 @@
#include <QString>
#include <QFileDialog>
#include <QMessageBox>
#include <QCloseEvent>
#include <QActionGroup>
#include <QDesktopServices>
#include "settingsdialog.h"
#include "plugindialog.h"
extern "C" {
#include "osal_dynamiclib.h"
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "common.h"
#include "core_interface.h"
#include "plugin.h"
#include "cheatdialog.h"
#include "netplay/createroom.h"
#include "netplay/joinroom.h"
#define RECENT_SIZE 10
void MainWindow::resetTitle()
{
this->setWindowTitle(m_title);
}
void MainWindow::updatePlugins()
{
QDir PluginDir(qtPluginDir);
PluginDir.setFilter(QDir::Files);
QStringList Filter;
Filter.append("");
QStringList current;
QString default_value;
if (!settings->contains("videoPlugin")) {
Filter.replace(0,"mupen64plus-video*");
current = PluginDir.entryList(Filter);
default_value = "mupen64plus-video-GLideN64";
default_value += OSAL_DLL_EXTENSION;
if (current.isEmpty())
settings->setValue("videoPlugin", "dummy");
else if (current.indexOf(default_value) != -1)
settings->setValue("videoPlugin", default_value);
else
settings->setValue("videoPlugin", current.at(0));
}
if (!settings->contains("audioPlugin")) {
Filter.replace(0,"mupen64plus-audio*");
current = PluginDir.entryList(Filter);
default_value = "mupen64plus-audio-sdl2";
default_value += OSAL_DLL_EXTENSION;
if (current.isEmpty())
settings->setValue("audioPlugin", "dummy");
else if (current.indexOf(default_value) != -1)
settings->setValue("audioPlugin", default_value);
else
settings->setValue("audioPlugin", current.at(0));
}
if (!settings->contains("rspPlugin")) {
Filter.replace(0,"mupen64plus-rsp*");
current = PluginDir.entryList(Filter);
default_value = "mupen64plus-rsp-hle";
default_value += OSAL_DLL_EXTENSION;
if (current.isEmpty())
settings->setValue("rspPlugin", "dummy");
else if (current.indexOf(default_value) != -1)
settings->setValue("rspPlugin", default_value);
else
settings->setValue("rspPlugin", current.at(0));
}
if (!settings->contains("inputPlugin")) {
Filter.replace(0,"mupen64plus-input*");
current = PluginDir.entryList(Filter);
default_value = "mupen64plus-input-qt";
default_value += OSAL_DLL_EXTENSION;
if (current.isEmpty())
settings->setValue("inputPlugin", "dummy");
else if (current.indexOf(default_value) != -1)
settings->setValue("inputPlugin", default_value);
else
settings->setValue("inputPlugin", current.at(0));
}
qtGfxPlugin = settings->value("videoPlugin").toString();
qtAudioPlugin = settings->value("audioPlugin").toString();
qtRspPlugin = settings->value("rspPlugin").toString();
qtInputPlugin = settings->value("inputPlugin").toString();
}
void MainWindow::updatePIF(Ui::MainWindow *ui)
{
QMenu *PIF = new QMenu(this);
PIF->setTitle("PIF ROM");
ui->menuFile->insertMenu(ui->actionTake_Screenshot, PIF);
QAction *fileSelect = new QAction(this);
QString current = settings->value("PIF_ROM").toString();
fileSelect->setText("PIF ROM: " + current);
PIF->addAction(fileSelect);
connect(fileSelect, &QAction::triggered, [=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("PIF ROM"), NULL, tr("PIF ROM File (*.bin)"));
if (!filename.isNull()) {
settings->setValue("PIF_ROM", filename);
QString current = filename;
fileSelect->setText("PIF ROM: " + current);
}
});
QAction *clearSelect = new QAction(this);
clearSelect->setText("Clear PIF ROM Selection");
PIF->addAction(clearSelect);
connect(clearSelect, &QAction::triggered,[=](){
settings->remove("PIF_ROM");
fileSelect->setText("PIF ROM: ");
});
}
void MainWindow::updateDD(Ui::MainWindow *ui)
{
QMenu *DD = new QMenu(this);
DD->setTitle("64DD");
ui->menuFile->insertMenu(ui->actionTake_Screenshot, DD);
QAction *fileSelect = new QAction(this);
QString current = settings->value("DD_ROM").toString();
fileSelect->setText("64DD IPL ROM: " + current);
DD->addAction(fileSelect);
connect(fileSelect, &QAction::triggered, [=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("64DD IPL ROM"), NULL, tr("64DD ROM File (*.n64)"));
if (!filename.isNull()) {
settings->setValue("DD_ROM", filename);
QString current = filename;
fileSelect->setText("64DD IPL ROM: " + current);
}
});
QAction *fileSelect2 = new QAction(this);
current = settings->value("DD_DISK").toString();
fileSelect2->setText("64DD Disk: " + current);
DD->addAction(fileSelect2);
connect(fileSelect2, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("64DD Disk File"), NULL, tr("64DD Disk File (*.ndd)"));
if (!filename.isNull()) {
settings->setValue("DD_DISK", filename);
QString current = filename;
fileSelect2->setText("64DD Disk: " + current);
}
});
QAction *clearSelect = new QAction(this);
clearSelect->setText("Clear 64DD Selections");
DD->addAction(clearSelect);
connect(clearSelect, &QAction::triggered,[=](){
settings->remove("DD_ROM");
settings->remove("DD_DISK");
fileSelect->setText("64DD IPL ROM: ");
fileSelect2->setText("64DD Disk: ");
});
//DD->addSeparator();
//QAction *startGame = new QAction(this);
//startGame->setText("Start 64DD");
//DD->addAction(startGame);
//connect(startGame, &QAction::triggered,[=](){
// openROM("");
//});
}
void MainWindow::updateGB(Ui::MainWindow *ui)
{
QMenu *GB = new QMenu(this);
GB->setTitle("Game Boy Cartridges");
ui->menuFile->insertMenu(ui->actionTake_Screenshot, GB);
QAction *fileSelect = new QAction(this);
QString current = settings->value("Player1GBROM").toString();
fileSelect->setText("Player 1 ROM: " + current);
GB->addAction(fileSelect);
connect(fileSelect, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB ROM File"), NULL, tr("GB ROM Files (*.gb)"));
if (!filename.isNull()) {
settings->setValue("Player1GBROM", filename);
QString current = filename;
fileSelect->setText("Player 1 ROM: " + current);
}
});
QAction *fileSelect2 = new QAction(this);
current = settings->value("Player1GBRAM").toString();
fileSelect2->setText("Player 1 RAM: " + current);
GB->addAction(fileSelect2);
connect(fileSelect2, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB RAM File"), NULL, tr("GB RAM Files (*.sav)"));
if (!filename.isNull()) {
settings->setValue("Player1GBRAM", filename);
QString current = filename;
fileSelect2->setText("Player 1 RAM: " + current);
}
});
QAction *clearSelect = new QAction(this);
clearSelect->setText("Clear Player 1 Selections");
GB->addAction(clearSelect);
connect(clearSelect, &QAction::triggered,[=](){
settings->remove("Player1GBROM");
settings->remove("Player1GBRAM");
fileSelect->setText("Player 1 ROM: ");
fileSelect2->setText("Player 1 RAM: ");
});
GB->addSeparator();
fileSelect = new QAction(this);
current = settings->value("Player2GBROM").toString();
fileSelect->setText("Player 2 ROM: " + current);
GB->addAction(fileSelect);
connect(fileSelect, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB ROM File"), NULL, tr("GB ROM Files (*.gb)"));
if (!filename.isNull()) {
settings->setValue("Player2GBROM", filename);
QString current = filename;
fileSelect->setText("Player 2 ROM: " + current);
}
});
fileSelect2 = new QAction(this);
current = settings->value("Player2GBRAM").toString();
fileSelect2->setText("Player 2 RAM: " + current);
GB->addAction(fileSelect2);
connect(fileSelect2, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB RAM File"), NULL, tr("GB RAM Files (*.sav)"));
if (!filename.isNull()) {
settings->setValue("Player2GBRAM", filename);
QString current = filename;
fileSelect2->setText("Player 2 RAM: " + current);
}
});
clearSelect = new QAction(this);
clearSelect->setText("Clear Player 2 Selections");
GB->addAction(clearSelect);
connect(clearSelect, &QAction::triggered,[=](){
settings->remove("Player2GBROM");
settings->remove("Player2GBRAM");
fileSelect->setText("Player 2 ROM: ");
fileSelect2->setText("Player 2 RAM: ");
});
GB->addSeparator();
fileSelect = new QAction(this);
current = settings->value("Player3GBROM").toString();
fileSelect->setText("Player 3 ROM: " + current);
GB->addAction(fileSelect);
connect(fileSelect, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB ROM File"), NULL, tr("GB ROM Files (*.gb)"));
if (!filename.isNull()) {
settings->setValue("Player3GBROM", filename);
QString current = filename;
fileSelect->setText("Player 3 ROM: " + current);
}
});
fileSelect2 = new QAction(this);
current = settings->value("Player3GBRAM").toString();
fileSelect2->setText("Player 3 RAM: " + current);
GB->addAction(fileSelect2);
connect(fileSelect2, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB RAM File"), NULL, tr("GB RAM Files (*.sav)"));
if (!filename.isNull()) {
settings->setValue("Player3GBRAM", filename);
QString current = filename;
fileSelect2->setText("Player 3 RAM: " + current);
}
});
clearSelect = new QAction(this);
clearSelect->setText("Clear Player 3 Selections");
GB->addAction(clearSelect);
connect(clearSelect, &QAction::triggered,[=](){
settings->remove("Player3GBROM");
settings->remove("Player3GBRAM");
fileSelect->setText("Player 3 ROM: ");
fileSelect2->setText("Player 3 RAM: ");
});
GB->addSeparator();
fileSelect = new QAction(this);
current = settings->value("Player4GBROM").toString();
fileSelect->setText("Player 4 ROM: " + current);
GB->addAction(fileSelect);
connect(fileSelect, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB ROM File"), NULL, tr("GB ROM Files (*.gb)"));
if (!filename.isNull()) {
settings->setValue("Player4GBROM", filename);
QString current = filename;
fileSelect->setText("Player 4 ROM: " + current);
}
});
fileSelect2 = new QAction(this);
current = settings->value("Player4GBRAM").toString();
fileSelect2->setText("Player 4 RAM: " + current);
GB->addAction(fileSelect2);
connect(fileSelect2, &QAction::triggered,[=](){
QString filename = QFileDialog::getOpenFileName(this,
tr("GB RAM File"), NULL, tr("GB RAM Files (*.sav)"));
if (!filename.isNull()) {
settings->setValue("Player4GBRAM", filename);
QString current = filename;
fileSelect2->setText("Player 4 RAM: " + current);
}
});
clearSelect = new QAction(this);
clearSelect->setText("Clear Player 4 Selections");
GB->addAction(clearSelect);
connect(clearSelect, &QAction::triggered,[=](){
settings->remove("Player4GBROM");
settings->remove("Player4GBRAM");
fileSelect->setText("Player 4 ROM: ");
fileSelect2->setText("Player 4 RAM: ");
});
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
verbose = 0;
nogui = 0;
gles = 0;
ui->setupUi(this);
m_title = "mupen64plus-gui Build Date: ";
m_title += __DATE__;
resetTitle();
QString ini_path = QDir(QCoreApplication::applicationDirPath()).filePath("mupen64plus-gui.ini");
settings = new QSettings(ini_path, QSettings::IniFormat, this);
if (!settings->isWritable()) {
settings->deleteLater();
settings = new QSettings("mupen64plus", "gui", this);
}
restoreGeometry(settings->value("geometry").toByteArray());
restoreState(settings->value("windowState").toByteArray());
QActionGroup *my_slots_group = new QActionGroup(this);
QAction *my_slots[10];
OpenRecent = new QMenu(this);
QMenu * SaveSlot = new QMenu(this);
OpenRecent->setTitle("Open Recent");
SaveSlot->setTitle("Change Save Slot");
ui->menuFile->insertMenu(ui->actionSave_State, OpenRecent);
ui->menuFile->insertSeparator(ui->actionSave_State);
ui->menuFile->insertMenu(ui->actionSave_State_To, SaveSlot);
ui->menuFile->insertSeparator(ui->actionSave_State_To);
for (int i = 0; i < 10; ++i) {
my_slots[i] = new QAction(this);
my_slots[i]->setCheckable(true);
my_slots[i]->setText("Slot " + QString::number(i));
my_slots[i]->setActionGroup(my_slots_group);
SaveSlot->addAction(my_slots[i]);
QAction *temp_slot = my_slots[i];
connect(temp_slot, &QAction::triggered,[=](bool checked){
if (checked) {
int slot = temp_slot->text().remove("Slot ").toInt();
if (QtAttachCoreLib())
(*CoreDoCommand)(M64CMD_STATE_SET_SLOT, slot, NULL);
}
});
}
my_slots[0]->setChecked(true);
updateOpenRecent();
updateGB(ui);
updateDD(ui);
updatePIF(ui);
if (!settings->contains("coreLibPath"))
settings->setValue("coreLibPath", QDir(QCoreApplication::applicationDirPath()).filePath(OSAL_DEFAULT_DYNLIB_FILENAME));
if (!settings->contains("pluginDirPath"))
settings->setValue("pluginDirPath", QCoreApplication::applicationDirPath());
if (!settings->value("coreLibPath").isNull())
qtCoreDirPath = settings->value("coreLibPath").toString();
if (!settings->value("pluginDirPath").isNull())
qtPluginDir = settings->value("pluginDirPath").toString();
if (!settings->value("configDirPath").isNull())
qtConfigDir = settings->value("configDirPath").toString();
updatePlugins();
}
MainWindow::~MainWindow()
{
DetachCoreLib();
delete ui;
}
void MainWindow::setVerbose()
{
verbose = 1;
}
void MainWindow::setNoGUI()
{
nogui = 1;
if (!menuBar()->isNativeMenuBar())
menuBar()->hide();
statusBar()->hide();
}
void MainWindow::setGLES()
{
gles = 1;
}
int MainWindow::getNoGUI()
{
return nogui;
}
int MainWindow::getVerbose()
{
return verbose;
}
int MainWindow::getGLES()
{
return gles;
}
void MainWindow::resizeMainWindow(int Width, int Height)
{
QSize size = this->size();
Height += (menuBar()->isNativeMenuBar() ? 0 : ui->menuBar->height()) + ui->statusBar->height();
if (size.width() != Width || size.height() != Height)
resize(Width, Height);
}
void MainWindow::toggleFS(int force)
{
int response = M64VIDEO_NONE;
if (force == M64VIDEO_NONE)
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_VIDEO_MODE, &response);
if (response == M64VIDEO_WINDOWED || force == M64VIDEO_FULLSCREEN) {
if (!menuBar()->isNativeMenuBar())
menuBar()->hide();
statusBar()->hide();
showFullScreen();
} else if (response == M64VIDEO_FULLSCREEN || force == M64VIDEO_WINDOWED) {
if (!nogui) {
if (!menuBar()->isNativeMenuBar())
menuBar()->show();
statusBar()->show();
}
showNormal();
}
}
void MainWindow::findRecursion(const QString &path, const QString &pattern, QStringList *result)
{
QDir currentDir(path);
const QString prefix = path + QLatin1Char('/');
foreach (const QString &match, currentDir.entryList(QStringList(pattern), QDir::Files))
result->append(prefix + match);
foreach (const QString &dir, currentDir.entryList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot))
findRecursion(prefix + dir, pattern, result);
}
void MainWindow::closeEvent (QCloseEvent *event)
{
stopGame();
settings->setValue("geometry", saveGeometry());
settings->setValue("windowState", saveState());
event->accept();
}
void MainWindow::updateOpenRecent()
{
OpenRecent->clear();
QAction *recent[RECENT_SIZE];
QStringList list = settings->value("RecentROMs").toString().split(";");
if (list.first() == "") {
OpenRecent->setEnabled(false);
return;
}
OpenRecent->setEnabled(true);
for (int i = 0; i < list.size() && i < RECENT_SIZE; ++i) {
recent[i] = new QAction(this);
recent[i]->setText(list.at(i));
OpenRecent->addAction(recent[i]);
QAction *temp_recent = recent[i];
connect(temp_recent, &QAction::triggered,[=](){
openROM(temp_recent->text(), "", 0, 0);
});
}
OpenRecent->addSeparator();
QAction *clearRecent = new QAction(this);
clearRecent->setText("Clear List");
OpenRecent->addAction(clearRecent);
connect(clearRecent, &QAction::triggered,[=](){
settings->remove("RecentROMs");
updateOpenRecent();
});
}
void MainWindow::setTitle(std::string title)
{
QString _title = QString::fromStdString(title);
_title.prepend("mupen64plus: ");
this->setWindowTitle(_title);
}
void MainWindow::pluginWarning(QString name)
{
QMessageBox msgBox;
msgBox.setText("No " + name + " plugin attached. Please go to \"Settings->Plugin Selection\" and choose one.");
msgBox.exec();
}
void MainWindow::showMessage(QString message)
{
QMessageBox *msgBox = new QMessageBox(this);
msgBox->setText(message);
msgBox->show();
}
void MainWindow::createOGLWindow(QSurfaceFormat* format)
{
if (my_window) my_window->deleteLater();
my_window = new OGLWindow();
QWidget *container = QWidget::createWindowContainer(my_window);
container->setFocusPolicy(Qt::StrongFocus);
my_window->setCursor(Qt::BlankCursor);
my_window->setFormat(*format);
setCentralWidget(container);
my_window->installEventFilter(&keyPressFilter);
this->installEventFilter(&keyPressFilter);
}
void MainWindow::deleteOGLWindow()
{
QWidget *container = new QWidget(this);
setCentralWidget(container);
my_window->doneCurrent();
my_window->deleteLater();
my_window = nullptr;
}
void MainWindow::stopGame()
{
if (coreStarted)
{
int response;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &response);
if (response == M64EMU_RUNNING)
{
(*CoreDoCommand)(M64CMD_STOP, 0, NULL);
while (workerThread->isRunning())
QCoreApplication::processEvents();
}
}
PluginUnload();
DetachCoreLib();
}
void MainWindow::openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player)
{
stopGame();
logViewer.clearLog();
workerThread = new WorkerThread(netplay_ip, netplay_port, netplay_player, this);
workerThread->setFileName(filename);
connect(workerThread, SIGNAL(finished()), workerThread, SLOT(deleteLater()));
workerThread->start();
QStringList list;
if (settings->contains("RecentROMs"))
list = settings->value("RecentROMs").toString().split(";");
list.removeAll(filename);
list.prepend(filename);
if (list.size() > RECENT_SIZE)
list.removeLast();
settings->setValue("RecentROMs",list.join(";"));
updateOpenRecent();
}
void MainWindow::on_actionOpen_ROM_triggered()
{
QString filename = QFileDialog::getOpenFileName(this,
tr("Open ROM"), settings->value("ROMdir").toString(), tr("ROM Files (*.n64 *.N64 *.z64 *.Z64 *.v64 *.V64 *.zip *.ZIP *.7z)"));
if (!filename.isNull()) {
QFileInfo info(filename);
settings->setValue("ROMdir", info.absoluteDir().absolutePath());
openROM(filename, "", 0, 0);
}
}
void MainWindow::on_actionPlugin_Paths_triggered()
{
SettingsDialog *settings = new SettingsDialog(this);
settings->show();
}
void MainWindow::on_actionStop_Game_triggered()
{
stopGame();
}
void MainWindow::on_actionExit_triggered()
{
this->close();
}
void MainWindow::on_actionPlugin_Settings_triggered()
{
if (QtAttachCoreLib()) {
PluginDialog *settings = new PluginDialog(this);
settings->show();
}
}
void MainWindow::on_actionPause_Game_triggered()
{
if (coreStarted) {
int response;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &response);
if (response == M64EMU_RUNNING)
(*CoreDoCommand)(M64CMD_PAUSE, 0, NULL);
else if (response == M64EMU_PAUSED)
(*CoreDoCommand)(M64CMD_RESUME, 0, NULL);
}
}
void MainWindow::on_actionMute_triggered()
{
if (coreStarted) {
int response;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_AUDIO_MUTE, &response);
if (response == 0) {
response = 1;
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_AUDIO_MUTE, &response);
} else if (response == 1) {
response = 0;
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_AUDIO_MUTE, &response);
}
}
}
void MainWindow::on_actionHard_Reset_triggered()
{
if (coreStarted)
(*CoreDoCommand)(M64CMD_RESET, 1, NULL);
}
void MainWindow::on_actionSoft_Reset_triggered()
{
if (coreStarted)
(*CoreDoCommand)(M64CMD_RESET, 0, NULL);
}
void MainWindow::on_actionTake_Screenshot_triggered()
{
if (coreStarted)
(*CoreDoCommand)(M64CMD_TAKE_NEXT_SCREENSHOT, 0, NULL);
}
void MainWindow::on_actionSave_State_triggered()
{
if (coreStarted)
(*CoreDoCommand)(M64CMD_STATE_SAVE, 1, NULL);
}
void MainWindow::on_actionLoad_State_triggered()
{
if (coreStarted)
(*CoreDoCommand)(M64CMD_STATE_LOAD, 1, NULL);
}
void MainWindow::on_actionToggle_Fullscreen_triggered()
{
if (coreStarted) {
int response;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_VIDEO_MODE, &response);
if (response == M64VIDEO_WINDOWED) {
response = M64VIDEO_FULLSCREEN;
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_VIDEO_MODE, &response);
} else if (response == M64VIDEO_FULLSCREEN) {
response = M64VIDEO_WINDOWED;
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_VIDEO_MODE, &response);
}
}
}
void MainWindow::on_actionSave_State_To_triggered()
{
QString filename = QFileDialog::getSaveFileName(this,
tr("Save State File"), NULL, NULL);
if (!filename.isNull()) {
if (!filename.contains(".st"))
filename.append(".state");
if (coreStarted) {
(*CoreDoCommand)(M64CMD_STATE_SAVE, 1, filename.toLatin1().data());
}
}
}
void MainWindow::on_actionLoad_State_From_triggered()
{
QString filename = QFileDialog::getOpenFileName(this,
tr("Open Save State"), NULL, tr("State Files (*.st* *.pj*)"));
if (!filename.isNull()) {
if (coreStarted) {
(*CoreDoCommand)(M64CMD_STATE_LOAD, 1, filename.toLatin1().data());
}
}
}
void MainWindow::on_actionCheats_triggered()
{
CheatDialog *cheats = new CheatDialog(this);
cheats->show();
}
void MainWindow::on_actionController_Configuration_triggered()
{
if (QtAttachCoreLib()) {
PluginSearchLoad();
typedef void (*Config_Func)();
Config_Func Config_DoConfig = (Config_Func) osal_dynlib_getproc(g_PluginMap[2].handle, "Config_DoConfig");
if (Config_DoConfig)
Config_DoConfig();
}
}
void MainWindow::on_actionToggle_Speed_Limiter_triggered()
{
if (coreStarted) {
int value;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_SPEED_LIMITER, &value);
value = !value;
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_SPEED_LIMITER, &value);
}
}
void MainWindow::on_actionView_Log_triggered()
{
logViewer.show();
}
void MainWindow::on_actionVideo_Settings_triggered()
{
if (QtAttachCoreLib()) {
PluginSearchLoad();
typedef void (*Config_Func)();
Config_Func Config_DoConfig = (Config_Func) osal_dynlib_getproc(g_PluginMap[0].handle, "Config_DoConfig");
if (Config_DoConfig)
Config_DoConfig();
}
}
void MainWindow::on_actionCreate_Room_triggered()
{
if (QtAttachCoreLib()) {
CreateRoom *createRoom = new CreateRoom(this);
createRoom->show();
}
}
void MainWindow::on_actionJoin_Room_triggered()
{
if (QtAttachCoreLib()) {
JoinRoom *joinRoom = new JoinRoom(this);
joinRoom->show();
}
}
void MainWindow::on_actionSupport_on_Patreon_triggered()
{
QDesktopServices::openUrl(QUrl("https://www.patreon.com/m64p"));
}
void MainWindow::on_actionOpen_Discord_Channel_triggered()
{
QDesktopServices::openUrl(QUrl("https://discord.gg/B5svWhR"));
}
WorkerThread* MainWindow::getWorkerThread()
{
return workerThread;
}
OGLWindow* MainWindow::getOGLWindow()
{
return my_window;
}
QSettings* MainWindow::getSettings()
{
return settings;
}
LogViewer* MainWindow::getLogViewer()
{
return &logViewer;
}
+123
View File
@@ -0,0 +1,123 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "oglwindow.h"
#include "workerthread.h"
#include "logviewer.h"
#include "keypressfilter.h"
#include <QMainWindow>
#include <QSettings>
#include <QSurfaceFormat>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
WorkerThread* getWorkerThread();
OGLWindow* getOGLWindow();
QSettings* getSettings();
LogViewer* getLogViewer();
void openROM(QString filename, QString netplay_ip, int netplay_port, int netplay_player);
void resetTitle();
void setVerbose();
int getVerbose();
void setNoGUI();
int getNoGUI();
void setGLES();
int getGLES();
void updatePlugins();
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
protected:
void closeEvent(QCloseEvent *event);
public slots:
void resizeMainWindow(int Width, int Height);
void toggleFS(int force);
void createOGLWindow(QSurfaceFormat* format);
void deleteOGLWindow();
void setTitle(std::string title);
void pluginWarning(QString name);
void showMessage(QString message);
private slots:
void on_actionOpen_ROM_triggered();
void on_actionPlugin_Paths_triggered();
void on_actionStop_Game_triggered();
void on_actionExit_triggered();
void on_actionPlugin_Settings_triggered();
void on_actionPause_Game_triggered();
void on_actionMute_triggered();
void on_actionHard_Reset_triggered();
void on_actionSoft_Reset_triggered();
void on_actionTake_Screenshot_triggered();
void on_actionSave_State_triggered();
void on_actionLoad_State_triggered();
void on_actionToggle_Fullscreen_triggered();
void on_actionSave_State_To_triggered();
void on_actionLoad_State_From_triggered();
void on_actionCheats_triggered();
void on_actionController_Configuration_triggered();
void on_actionToggle_Speed_Limiter_triggered();
void on_actionView_Log_triggered();
void on_actionVideo_Settings_triggered();
void on_actionCreate_Room_triggered();
void on_actionJoin_Room_triggered();
void on_actionSupport_on_Patreon_triggered();
void on_actionOpen_Discord_Channel_triggered();
private:
void stopGame();
void updateOpenRecent();
void updateGB(Ui::MainWindow *ui);
void updateDD(Ui::MainWindow *ui);
void updatePIF(Ui::MainWindow *ui);
void findRecursion(const QString &path, const QString &pattern, QStringList *result);
Ui::MainWindow *ui;
QMenu * OpenRecent;
int verbose;
int nogui;
int gles;
QString m_title;
OGLWindow *my_window = nullptr;
WorkerThread *workerThread = nullptr;
LogViewer logViewer;
QSettings *settings = nullptr;
KeyPressFilter keyPressFilter;
};
extern MainWindow *w;
#endif // MAINWINDOW_H
+219
View File
@@ -0,0 +1,219 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>mupen64plus</string>
</property>
<widget class="QWidget" name="centralWidget"/>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>25</height>
</rect>
</property>
<property name="nativeMenuBar">
<bool>true</bool>
</property>
<widget class="QMenu" name="menuFile">
<property name="title">
<string>File</string>
</property>
<addaction name="actionOpen_ROM"/>
<addaction name="actionSave_State"/>
<addaction name="actionLoad_State"/>
<addaction name="actionSave_State_To"/>
<addaction name="actionLoad_State_From"/>
<addaction name="separator"/>
<addaction name="actionTake_Screenshot"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="menuSettings">
<property name="title">
<string>Settings</string>
</property>
<addaction name="actionPlugin_Paths"/>
<addaction name="actionPlugin_Settings"/>
<addaction name="actionController_Configuration"/>
<addaction name="actionVideo_Settings"/>
</widget>
<widget class="QMenu" name="menuEmulation">
<property name="title">
<string>Emulation</string>
</property>
<addaction name="actionToggle_Fullscreen"/>
<addaction name="separator"/>
<addaction name="actionPause_Game"/>
<addaction name="actionMute"/>
<addaction name="separator"/>
<addaction name="actionStop_Game"/>
<addaction name="actionHard_Reset"/>
<addaction name="actionSoft_Reset"/>
<addaction name="actionToggle_Speed_Limiter"/>
<addaction name="separator"/>
<addaction name="actionCheats"/>
<addaction name="separator"/>
<addaction name="actionView_Log"/>
</widget>
<widget class="QMenu" name="menuNetplay">
<property name="title">
<string>Netplay</string>
</property>
<addaction name="actionCreate_Room"/>
<addaction name="actionJoin_Room"/>
<addaction name="actionOpen_Discord_Channel"/>
<addaction name="actionSupport_on_Patreon"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuEmulation"/>
<addaction name="menuSettings"/>
<addaction name="menuNetplay"/>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<action name="actionOpen_ROM">
<property name="text">
<string>Open ROM</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="actionPlugin_Paths">
<property name="text">
<string>Plugin and Path Selection</string>
</property>
</action>
<action name="actionStop_Game">
<property name="text">
<string>Stop Game (Escape)</string>
</property>
</action>
<action name="actionPlugin_Settings">
<property name="text">
<string>Advanced Settings</string>
</property>
</action>
<action name="actionOpen_Recent">
<property name="text">
<string>Open Recent</string>
</property>
</action>
<action name="actionSave_State">
<property name="text">
<string>Save State (F5)</string>
</property>
</action>
<action name="actionLoad_State">
<property name="text">
<string>Load State (F7)</string>
</property>
</action>
<action name="actionChange_State_Slot">
<property name="text">
<string>Change State Slot</string>
</property>
</action>
<action name="actionSave_State_To">
<property name="text">
<string>Save State To...</string>
</property>
</action>
<action name="actionLoad_State_From">
<property name="text">
<string>Load State From...</string>
</property>
</action>
<action name="actionTake_Screenshot">
<property name="text">
<string>Take Screenshot (F12)</string>
</property>
</action>
<action name="actionPause_Game">
<property name="text">
<string>Pause/Resume Game (p)</string>
</property>
</action>
<action name="actionMute">
<property name="text">
<string>Mute/Unmute (m)</string>
</property>
</action>
<action name="actionHard_Reset">
<property name="text">
<string>Hard Reset</string>
</property>
</action>
<action name="actionSoft_Reset">
<property name="text">
<string>Soft Reset (F9)</string>
</property>
</action>
<action name="actionToggle_Fullscreen">
<property name="text">
<string>Toggle Fullscreen (Alt + Return)</string>
</property>
</action>
<action name="actionCheats">
<property name="text">
<string>Cheats</string>
</property>
</action>
<action name="actionController_Configuration">
<property name="text">
<string>Controller Configuration</string>
</property>
</action>
<action name="actionToggle_Speed_Limiter">
<property name="text">
<string>Toggle Speed Limiter</string>
</property>
</action>
<action name="actionView_Log">
<property name="text">
<string>View Log</string>
</property>
</action>
<action name="actionVideo_Settings">
<property name="text">
<string>Video Settings</string>
</property>
</action>
<action name="actionCreate_Room">
<property name="text">
<string>Create Room</string>
</property>
</action>
<action name="actionJoin_Room">
<property name="text">
<string>Join Room</string>
</property>
</action>
<action name="actionSupport_on_Patreon">
<property name="text">
<string>Support on Patreon</string>
</property>
</action>
<action name="actionOpen_Discord_Channel">
<property name="text">
<string>Join Discord Channel</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
+97
View File
@@ -0,0 +1,97 @@
#-------------------------------------------------
#
# Project created by QtCreator 2017-02-16T19:17:45
#
#-------------------------------------------------
QT += widgets websockets
TARGET = mupen64plus-gui
TEMPLATE = app
RC_ICONS = mupen64plus.ico
ICON = mupen64plus.icns
DEFINES += "NETPLAY_VER=6"
INCLUDEPATH += \
"../../mupen64plus-core/src/api"
SOURCES += main.cpp \
mainwindow.cpp \
vidext.cpp \
settingsdialog.cpp \
interface/common.cpp \
interface/core_interface.cpp \
interface/plugin.cpp \
plugindialog.cpp \
oglwindow.cpp \
workerthread.cpp \
settingclasses.cpp \
cheatdialog.cpp \
interface/cheat.cpp \
interface/sdl_key_converter.c \
logviewer.cpp \
keypressfilter.cpp \
netplay/createroom.cpp \
netplay/joinroom.cpp \
netplay/waitroom.cpp
win32 {
SOURCES += osal/osal_dynamiclib_win32.c \
osal/osal_files_win32.c
win32-msvc* {
!contains(QMAKE_TARGET.arch, x86_64) {
message("x86 build")
LIBS += ../mupen64plus-win32-deps/SDL2-2.0.6/lib/x86/SDL2.lib
} else {
message("x86_64 build")
LIBS += ../mupen64plus-win32-deps/SDL2-2.0.6/lib/x64/SDL2.lib
}
INCLUDEPATH += ../mupen64plus-win32-deps/SDL2-2.0.6/include
} else {
DEFINES -= UNICODE
LIBS += -Wl,-Bdynamic -lSDL2
INCLUDEPATH += /mingw64/include/SDL2 /mingw32/include/SDL2
}
}
!win32 {
QT += dbus
SOURCES += osal/osal_dynamiclib_unix.c \
osal/osal_files_unix.c
LIBS += -L/usr/local/lib -ldl -lSDL2 -lz
INCLUDEPATH += /usr/local/include /usr/include/SDL2 /usr/local/include/SDL2
}
HEADERS += mainwindow.h \
vidext.h \
interface/common.h \
interface/core_interface.h \
interface/plugin.h \
settingsdialog.h \
osal/osal_dynamiclib.h \
workerthread.h \
plugindialog.h \
oglwindow.h \
settingclasses.h \
cheatdialog.h \
interface/cheat.h \
interface/sdl_key_converter.h \
logviewer.h \
keypressfilter.h \
netplay/createroom.h \
netplay/joinroom.h \
netplay/waitroom.h \
version.h
FORMS += mainwindow.ui
QMAKE_INCDIR += api osal interface
CONFIG += c++11
QMAKE_PROJECT_DEPTH = 0
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

+174
View File
@@ -0,0 +1,174 @@
#include "mainwindow.h"
#include "createroom.h"
#include "waitroom.h"
#include "version.h"
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QFileDialog>
#include <QMessageBox>
#include <QJsonObject>
#include <QJsonDocument>
CreateRoom::CreateRoom(QWidget *parent)
: QDialog(parent)
{
QGridLayout *layout = new QGridLayout(this);
QLabel *nameLabel = new QLabel("Room Name", this);
layout->addWidget(nameLabel, 0, 0);
nameEdit = new QLineEdit(this);
layout->addWidget(nameEdit, 0, 1);
QLabel *passwordLabel = new QLabel("Password (Optional)", this);
layout->addWidget(passwordLabel, 1, 0);
passwordEdit = new QLineEdit(this);
layout->addWidget(passwordEdit, 1, 1);
QLabel *romLabel = new QLabel("ROM", this);
layout->addWidget(romLabel, 2, 0);
romButton = new QPushButton("ROM Path", this);
connect(romButton, SIGNAL (released()), this, SLOT (handleRomButton()));
layout->addWidget(romButton, 2, 1);
QLabel *playerNameLabel = new QLabel("Player Name", this);
layout->addWidget(playerNameLabel, 3, 0);
playerNameEdit = new QLineEdit(this);
layout->addWidget(playerNameEdit, 3, 1);
QLabel *serverLabel = new QLabel("Server", this);
layout->addWidget(serverLabel, 4, 0);
serverChooser = new QComboBox(this);
serverChooser->setSizeAdjustPolicy(QComboBox::AdjustToContents);
layout->addWidget(serverChooser, 4, 1);
QFrame* lineH1 = new QFrame(this);
lineH1->setFrameShape(QFrame::HLine);
lineH1->setFrameShadow(QFrame::Sunken);
layout->addWidget(lineH1, 5, 0, 1, 2);
createButton = new QPushButton("Create Game", this);
connect(createButton, SIGNAL (released()), this, SLOT (handleCreateButton()));
layout->addWidget(createButton, 6, 0, 1, 2);
setLayout(layout);
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(downloadFinished(QNetworkReply*)));
connect(this, SIGNAL (finished(int)), this, SLOT (onFinished(int)));
QNetworkRequest request(QUrl(QStringLiteral("https://m64p.s3.amazonaws.com/servers.json")));
manager.get(request);
launched = 0;
}
void CreateRoom::onFinished(int)
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
if (!launched && webSocket)
{
webSocket->close();
webSocket->deleteLater();
}
}
void CreateRoom::handleRomButton()
{
filename = QFileDialog::getOpenFileName(this,
tr("Open ROM"), w->getSettings()->value("ROMdir").toString(), tr("ROM Files (*.n64 *.N64 *.z64 *.Z64 *.v64 *.V64 *.zip *.ZIP *.7z)"));
if (!filename.isNull())
{
romButton->setText(filename);
}
}
void CreateRoom::handleCreateButton()
{
QMessageBox msgBox;
if (nameEdit->text().isEmpty())
{
msgBox.setText("Room name can not be empty");
msgBox.exec();
return;
}
if (playerNameEdit->text().isEmpty())
{
msgBox.setText("Player name can not be empty");
msgBox.exec();
return;
}
if (loadROM(romButton->text().toStdString()) == M64ERR_SUCCESS)
{
createButton->setEnabled(false);
if (webSocket)
{
webSocket->close();
webSocket->deleteLater();
}
webSocket = new QWebSocket;
(*CoreDoCommand)(M64CMD_ROM_GET_SETTINGS, sizeof(rom_settings), &rom_settings);
connect(webSocket, &QWebSocket::connected, this, &CreateRoom::onConnected);
webSocket->open(QUrl(serverChooser->currentData().toString()));
}
else
{
msgBox.setText("Could not open ROM");
msgBox.exec();
}
}
void CreateRoom::onConnected()
{
connect(webSocket, &QWebSocket::binaryMessageReceived,
this, &CreateRoom::processBinaryMessage);
QJsonObject json;
json.insert("type", "create_room");
json.insert("room_name", nameEdit->text());
json.insert("player_name", playerNameEdit->text());
json.insert("password", passwordEdit->text());
json.insert("MD5", QString(rom_settings.MD5));
json.insert("game_name", QString(rom_settings.goodname));
json.insert("client_sha", QStringLiteral(GUI_VERSION));
json.insert("netplay_version", NETPLAY_VER);
QJsonDocument json_doc(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
}
void CreateRoom::processBinaryMessage(QByteArray message)
{
QMessageBox msgBox;
msgBox.setTextFormat(Qt::RichText);
msgBox.setTextInteractionFlags(Qt::TextBrowserInteraction);
QJsonDocument json_doc = QJsonDocument::fromBinaryData(message);
QJsonObject json = json_doc.object();
if (json.value("type").toString() == "message")
{
msgBox.setText(json.value("message").toString());
msgBox.exec();
}
else if (json.value("type").toString() == "send_room_create")
{
json.remove("type");
launched = 1;
WaitRoom *waitRoom = new WaitRoom(filename, json, webSocket, parentWidget());
waitRoom->show();
accept();
}
}
void CreateRoom::downloadFinished(QNetworkReply *reply)
{
if (!reply->error())
{
QJsonDocument json_doc = QJsonDocument::fromJson(reply->readAll());
QJsonObject json = json_doc.object();
QStringList servers = json.keys();
for (int i = 0; i < servers.size(); ++i)
serverChooser->addItem(servers.at(i), json.value(servers.at(i)).toString());
}
reply->deleteLater();
}
+37
View File
@@ -0,0 +1,37 @@
#ifndef CREATEROOM_H
#define CREATEROOM_H
#include <QDialog>
#include <QPushButton>
#include <QWebSocket>
#include <QComboBox>
#include <QtNetwork>
#include "interface/common.h"
class CreateRoom : public QDialog
{
Q_OBJECT
public:
CreateRoom(QWidget *parent = nullptr);
private slots:
void handleRomButton();
void handleCreateButton();
void onConnected();
void downloadFinished(QNetworkReply *reply);
void processBinaryMessage(QByteArray message);
void onFinished(int result);
private:
QPushButton *romButton;
QPushButton *createButton;
QWebSocket *webSocket = nullptr;
QNetworkAccessManager manager;
QComboBox *serverChooser;
m64p_rom_settings rom_settings;
QLineEdit *nameEdit;
QLineEdit *passwordEdit;
QLineEdit *playerNameEdit;
int launched;
QString filename;
};
#endif // CREATEROOM_H
+250
View File
@@ -0,0 +1,250 @@
#include "joinroom.h"
#include "waitroom.h"
#include "mainwindow.h"
#include "version.h"
#include <QGridLayout>
#include <QLabel>
#include <QJsonObject>
#include <QJsonDocument>
#include <QHeaderView>
#include <QMessageBox>
#include <QFileDialog>
JoinRoom::JoinRoom(QWidget *parent)
: QDialog(parent)
{
setMinimumWidth(1000);
setMinimumHeight(500);
QGridLayout *layout = new QGridLayout(this);
layout->setColumnMinimumWidth(1, 500);
playerName = new QLineEdit(this);
playerName->setPlaceholderText("Player Name");
layout->addWidget(playerName, 0, 0);
QLabel *serverLabel = new QLabel("Server", this);
serverLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
layout->addWidget(serverLabel, 0, 1);
serverChooser = new QComboBox(this);
serverChooser->setSizeAdjustPolicy(QComboBox::AdjustToContents);
connect(serverChooser, SIGNAL(currentTextChanged(QString)), this, SLOT(serverChanged(QString)));
layout->addWidget(serverChooser, 0, 2);
refreshButton = new QPushButton(this);
refreshButton->setText("Refresh");
layout->addWidget(refreshButton, 0, 3);
connect(refreshButton, &QPushButton::released, this, &JoinRoom::refresh);
listWidget = new QTableWidget(this);
listWidget->setSelectionBehavior(QAbstractItemView::SelectRows);
resetList();
layout->addWidget(listWidget, 1, 0, 1, 4);
passwordEdit = new QLineEdit(this);
passwordEdit->setPlaceholderText("Password (if required)");
layout->addWidget(passwordEdit, 2, 0);
joinButton = new QPushButton(this);
connect(joinButton, &QPushButton::released, this, &JoinRoom::joinGame);
joinButton->setText("Join Game");
layout->addWidget(joinButton, 2, 2, 1, 2);
setLayout(layout);
connect(&manager, SIGNAL(finished(QNetworkReply*)),
SLOT(downloadFinished(QNetworkReply*)));
connect(this, SIGNAL (finished(int)), this, SLOT (onFinished(int)));
QNetworkRequest request(QUrl(QStringLiteral("https://m64p.s3.amazonaws.com/servers.json")));
manager.get(request);
launched = 0;
}
void JoinRoom::onFinished(int)
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
if (!launched && webSocket)
{
webSocket->close();
webSocket->deleteLater();
}
}
void JoinRoom::resetList()
{
row = 0;
rooms.clear();
listWidget->clear();
listWidget->setColumnCount(4);
listWidget->setRowCount(row);
QStringList headers;
headers.append("Room Name");
headers.append("Game Name");
headers.append("Game MD5");
headers.append("Password Protected");
listWidget->setHorizontalHeaderLabels(headers);
listWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
}
void JoinRoom::downloadFinished(QNetworkReply *reply)
{
if (!reply->error())
{
QJsonDocument json_doc = QJsonDocument::fromJson(reply->readAll());
QJsonObject json = json_doc.object();
QStringList servers = json.keys();
for (int i = 0; i < servers.size(); ++i)
serverChooser->addItem(servers.at(i), json.value(servers.at(i)).toString());
}
reply->deleteLater();
}
void JoinRoom::refresh()
{
serverChanged("");
}
void JoinRoom::joinGame()
{
QMessageBox msgBox;
if (webSocket && webSocket->state() != QAbstractSocket::ConnectedState)
{
msgBox.setText("Could not connect to server");
msgBox.exec();
return;
}
if (playerName->text().isEmpty())
{
msgBox.setText("Player name can not be empty");
msgBox.exec();
return;
}
filename = QFileDialog::getOpenFileName(this,
tr("Open ROM"), w->getSettings()->value("ROMdir").toString(), tr("ROM Files (*.n64 *.N64 *.z64 *.Z64 *.v64 *.V64 *.zip *.ZIP *.7z)"));
if (!filename.isNull())
{
if (loadROM(filename.toStdString()) == M64ERR_SUCCESS)
{
QJsonObject json = rooms.at(listWidget->currentRow());
m64p_rom_settings rom_settings;
(*CoreDoCommand)(M64CMD_ROM_GET_SETTINGS, sizeof(rom_settings), &rom_settings);
if (QString(rom_settings.MD5) == json.value("MD5").toString())
{
json.insert("type", "join_room");
json.insert("player_name", playerName->text());
json.insert("password", passwordEdit->text());
json.insert("client_sha", QStringLiteral(GUI_VERSION));
QJsonDocument json_doc(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
}
else
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
msgBox.setText("ROM does not match room ROM");
msgBox.exec();
}
}
else
{
msgBox.setText("Could not open ROM");
msgBox.exec();
}
}
}
void JoinRoom::serverChanged(QString)
{
if (webSocket)
{
webSocket->close();
webSocket->deleteLater();
}
resetList();
webSocket = new QWebSocket();
connect(webSocket, &QWebSocket::connected, this, &JoinRoom::onConnected);
webSocket->open(QUrl(serverChooser->currentData().toString()));
}
void JoinRoom::onConnected()
{
connect(webSocket, &QWebSocket::binaryMessageReceived,
this, &JoinRoom::processBinaryMessage);
QJsonObject json;
json.insert("type", "get_rooms");
json.insert("netplay_version", NETPLAY_VER);
QJsonDocument json_doc(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
}
void JoinRoom::processBinaryMessage(QByteArray message)
{
QJsonDocument json_doc = QJsonDocument::fromBinaryData(message);
QJsonObject json = json_doc.object();
QMessageBox msgBox;
msgBox.setTextFormat(Qt::RichText);
msgBox.setTextInteractionFlags(Qt::TextBrowserInteraction);
if (json.value("type").toString() == "message")
{
msgBox.setText(json.value("message").toString());
msgBox.exec();
}
else if (json.value("type").toString() == "send_room")
{
json.remove("type");
rooms << json;
listWidget->insertRow(row);
QTableWidgetItem *newItem = new QTableWidgetItem(json.value("room_name").toString());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
listWidget->setItem(row, 0, newItem);
newItem = new QTableWidgetItem(json.value("game_name").toString());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
listWidget->setItem(row, 1, newItem);
newItem = new QTableWidgetItem(json.value("MD5").toString());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
listWidget->setItem(row, 2, newItem);
newItem = new QTableWidgetItem(json.value("protected").toString());
newItem->setFlags(newItem->flags() & ~Qt::ItemIsEditable);
listWidget->setItem(row, 3, newItem);
++row;
}
else if (json.value("type").toString() == "accept_join")
{
if (json.value("accept").toInt() == 0)
{
json.remove("type");
json.remove("accept");
launched = 1;
WaitRoom *waitRoom = new WaitRoom(filename, json, webSocket, parentWidget());
waitRoom->show();
accept();
}
else if (json.value("accept").toInt() == 1)
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
msgBox.setText("Bad password");
msgBox.exec();
}
else if (json.value("accept").toInt() == 2)
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
msgBox.setText("client versions do not match");
msgBox.exec();
}
else
{
(*CoreDoCommand)(M64CMD_ROM_CLOSE, 0, NULL);
msgBox.setText("Could not join room");
msgBox.exec();
}
}
}
+41
View File
@@ -0,0 +1,41 @@
#ifndef JOINROOM_H
#define JOINROOM_H
#include <QDialog>
#include <QComboBox>
#include <QtNetwork>
#include <QTableWidget>
#include <QWebSocket>
#include <QLineEdit>
#include <QPushButton>
class JoinRoom : public QDialog
{
Q_OBJECT
public:
JoinRoom(QWidget *parent = nullptr);
private slots:
void downloadFinished(QNetworkReply *reply);
void serverChanged(QString server);
void onConnected();
void processBinaryMessage(QByteArray message);
void refresh();
void joinGame();
void onFinished(int result);
private:
void resetList();
QComboBox *serverChooser;
QNetworkAccessManager manager;
QTableWidget *listWidget;
QWebSocket *webSocket = nullptr;
QLineEdit *playerName;
QLineEdit *passwordEdit;
QPushButton *joinButton;
QPushButton *refreshButton;
QList<QJsonObject> rooms;
int row = 0;
int launched;
QString filename;
};
#endif // JOINROOM_H
+184
View File
@@ -0,0 +1,184 @@
#include "waitroom.h"
#include "mainwindow.h"
#include <QGridLayout>
#include <QMessageBox>
WaitRoom::WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidget *parent)
: QDialog(parent)
{
this->resize(640,480);
player_name = room.value("player_name").toString();
room_port = room.value("port").toInt();
room_name = room.value("room_name").toString();
file_name = filename;
webSocket = socket;
connect(webSocket, &QWebSocket::binaryMessageReceived,
this, &WaitRoom::processBinaryMessage);
connect(webSocket, &QWebSocket::pong, this, &WaitRoom::updatePing);
QGridLayout *layout = new QGridLayout(this);
QLabel *nameLabel = new QLabel("Room Name:", this);
layout->addWidget(nameLabel, 0, 0);
QLabel *roomName = new QLabel(room_name, this);
layout->addWidget(roomName, 0, 1);
QLabel *gameLabel = new QLabel("Game Name:", this);
layout->addWidget(gameLabel, 1, 0);
QLabel *gameName = new QLabel(room.value("game_name").toString(), this);
layout->addWidget(gameName, 1, 1);
QLabel *pingLabel = new QLabel("Your ping:", this);
layout->addWidget(pingLabel, 2, 0);
pingValue = new QLabel(this);
layout->addWidget(pingValue, 2, 1);
QLabel *p1Label = new QLabel("Player 1:", this);
layout->addWidget(p1Label, 3, 0);
QLabel *p2Label = new QLabel("Player 2:", this);
layout->addWidget(p2Label, 4, 0);
QLabel *p3Label = new QLabel("Player 3:", this);
layout->addWidget(p3Label, 5, 0);
QLabel *p4Label = new QLabel("Player 4:", this);
layout->addWidget(p4Label, 6, 0);
for (int i = 0; i < 4; ++i)
{
pName[i] = new QLabel(this);
layout->addWidget(pName[i], i+3, 1);
}
chatWindow = new QPlainTextEdit(this);
chatWindow->setReadOnly(1);
layout->addWidget(chatWindow, 7, 0, 3, 2);
chatEdit = new QLineEdit(this);
chatEdit->setPlaceholderText("Enter chat message here");
connect(chatEdit, &QLineEdit::returnPressed, this, &WaitRoom::sendChat);
layout->addWidget(chatEdit, 10, 0, 1, 2);
startGameButton = new QPushButton(this);
startGameButton->setText("Start Game");
startGameButton->setAutoDefault(0);
connect(startGameButton, &QPushButton::released, this, &WaitRoom::startGame);
layout->addWidget(startGameButton, 11, 0, 1, 2);
discordLink = new QLabel(this);
discordLink->setTextFormat(Qt::RichText);
discordLink->setTextInteractionFlags(Qt::TextBrowserInteraction);
discordLink->setOpenExternalLinks(true);
discordLink->setAlignment(Qt::AlignCenter);
layout->addWidget(discordLink, 12, 0, 1, 2);
setLayout(layout);
connect(this, SIGNAL (finished(int)), this, SLOT (onFinished(int)));
QJsonObject json;
json.insert("type", "request_players");
json.insert("port", room_port);
QJsonDocument json_doc = QJsonDocument(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &WaitRoom::sendPing);
timer->start(5000);
}
void WaitRoom::sendPing()
{
if (discordLink->text().isEmpty())
{
QJsonObject json;
json.insert("type", "get_discord");
json.insert("room_name", room_name);
QJsonDocument json_doc = QJsonDocument(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
}
webSocket->ping();
}
void WaitRoom::updatePing(quint64 elapsedTime, const QByteArray&)
{
pingValue->setText(QString::number(elapsedTime) + " ms");
}
void WaitRoom::startGame()
{
if (player_name == pName[0]->text())
{
QJsonObject json;
json.insert("type", "start_game");
json.insert("port", room_port);
QJsonDocument json_doc = QJsonDocument(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
}
else
{
QMessageBox msgBox;
msgBox.setText("Only player 1 can start the game");
msgBox.exec();
}
}
void WaitRoom::sendChat()
{
if (!chatEdit->text().isEmpty())
{
QJsonObject json;
json.insert("type", "chat_message");
json.insert("port", room_port);
json.insert("player_name", player_name);
json.insert("message", chatEdit->text());
QJsonDocument json_doc = QJsonDocument(json);
webSocket->sendBinaryMessage(json_doc.toBinaryData());
chatEdit->clear();
}
}
void WaitRoom::onFinished(int)
{
timer->stop();
webSocket->close();
webSocket->deleteLater();
}
void WaitRoom::processBinaryMessage(QByteArray message)
{
QJsonDocument json_doc = QJsonDocument::fromBinaryData(message);
QJsonObject json = json_doc.object();
if (json.value("type").toString() == "room_players")
{
for (int i = 0; i < 4; ++i)
{
if (json.contains(QString::number(i)))
{
pName[i]->setText(json.value(QString::number(i)).toString());
if (pName[i]->text() == player_name)
player_number = i + 1;
}
else
pName[i]->clear();
}
}
else if (json.value("type").toString() == "chat_update")
{
chatWindow->appendPlainText(json.value("message").toString());
}
else if (json.value("type").toString() == "begin_game")
{
w->openROM(file_name, webSocket->peerAddress().toString(), room_port, player_number);
accept();
}
else if (json.value("type").toString() == "discord_link")
{
QString link = json.value("link").toString();
discordLink->setText("Discord Voice Chat <a href=\"discord://" + link + "\">App Link</a> - <a href=\"http://" + link + "\">Web Link</a>");
}
}
+42
View File
@@ -0,0 +1,42 @@
#ifndef WAITROOM_H
#define WAITROOM_H
#include <QDialog>
#include <QJsonObject>
#include <QJsonDocument>
#include <QWebSocket>
#include <QLabel>
#include <QPlainTextEdit>
#include <QLineEdit>
#include <QPushButton>
#include <QTimer>
class WaitRoom : public QDialog
{
Q_OBJECT
public:
WaitRoom(QString filename, QJsonObject room, QWebSocket *socket, QWidget *parent = nullptr);
private slots:
void processBinaryMessage(QByteArray message);
void onFinished(int);
void sendChat();
void startGame();
void updatePing(quint64 elapsedTime, const QByteArray &payload);
void sendPing();
private:
QWebSocket *webSocket = nullptr;
QLabel *pName[4];
QPlainTextEdit *chatWindow;
QLineEdit *chatEdit;
QString player_name;
int player_number;
QString file_name;
int room_port;
QString room_name;
QPushButton *startGameButton;
QLabel *pingValue;
QLabel *discordLink;
QTimer *timer;
};
#endif // WAITROOM_H
+28
View File
@@ -0,0 +1,28 @@
#include "oglwindow.h"
extern QThread* rendering_thread;
void OGLWindow::initializeGL() {
doneCurrent();
context()->moveToThread(rendering_thread);
}
void OGLWindow::resizeEvent(QResizeEvent *event) {
QOpenGLWindow::resizeEvent(event);
if (timerId) {
killTimer(timerId);
timerId = 0;
}
timerId = startTimer(500);
m_width = event->size().width();
m_height = event->size().height();
}
void OGLWindow::timerEvent(QTimerEvent *te) {
int size = (m_width << 16) + m_height;
if (coreStarted)
(*CoreDoCommand)(M64CMD_CORE_STATE_SET, M64CORE_VIDEO_SIZE, &size);
killTimer(te->timerId());
timerId = 0;
requestActivate();
}
+25
View File
@@ -0,0 +1,25 @@
#ifndef OGLWINDOW_H
#define OGLWINDOW_H
#include <QCloseEvent>
#include <QOpenGLWindow>
#include <QOpenGLFunctions>
#include "common.h"
#include "core_interface.h"
class OGLWindow : public QOpenGLWindow
{
protected:
void exposeEvent(QExposeEvent *) Q_DECL_OVERRIDE {}
void initializeGL() Q_DECL_OVERRIDE;
void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
void timerEvent(QTimerEvent *te) Q_DECL_OVERRIDE;
private:
int m_width;
int m_height;
int timerId = 0;
};
#endif // OGLWINDOW_H
+34
View File
@@ -0,0 +1,34 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_dynamiclib.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#if !defined(OSAL_DYNAMICLIB_H)
#define OSAL_DYNAMICLIB_H
#include "m64p_types.h"
m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath);
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName);
m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle);
#endif /* #define OSAL_DYNAMICLIB_H */
+71
View File
@@ -0,0 +1,71 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_dynamiclib_unix.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "m64p_types.h"
#include "common.h"
#include "osal_dynamiclib.h"
m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)
{
if (pLibHandle == NULL || pccLibraryPath == NULL)
return M64ERR_INPUT_ASSERT;
*pLibHandle = dlopen(pccLibraryPath, RTLD_NOW);
if (*pLibHandle == NULL)
{
/* only print an error message if there is a directory separator (/) in the pathname */
/* this prevents us from throwing an error for the use case where Mupen64Plus is not installed */
if (strchr(pccLibraryPath, '/') != NULL)
DebugMessage(M64MSG_ERROR, "dlopen('%s') failed: %s", pccLibraryPath, dlerror());
return M64ERR_INPUT_NOT_FOUND;
}
return M64ERR_SUCCESS;
}
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
{
if (pccProcedureName == NULL)
return NULL;
return dlsym(LibHandle, pccProcedureName);
}
m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
{
int rval = dlclose(LibHandle);
if (rval != 0)
{
DebugMessage(M64MSG_ERROR, "dlclose() failed: %s", dlerror());
return M64ERR_INTERNAL;
}
return M64ERR_SUCCESS;
}
+75
View File
@@ -0,0 +1,75 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_dynamiclib_win32.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include "m64p_types.h"
#include "common.h"
#include "osal_dynamiclib.h"
m64p_error osal_dynlib_open(m64p_dynlib_handle *pLibHandle, const char *pccLibraryPath)
{
if (pLibHandle == NULL || pccLibraryPath == NULL)
return M64ERR_INPUT_ASSERT;
*pLibHandle = LoadLibrary(pccLibraryPath);
if (*pLibHandle == NULL)
{
char *pchErrMsg;
DWORD dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
DebugMessage(M64MSG_ERROR, "LoadLibrary('%s') error: %s", pccLibraryPath, pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INPUT_NOT_FOUND;
}
return M64ERR_SUCCESS;
}
void * osal_dynlib_getproc(m64p_dynlib_handle LibHandle, const char *pccProcedureName)
{
if (pccProcedureName == NULL)
return NULL;
return GetProcAddress(LibHandle, pccProcedureName);
}
m64p_error osal_dynlib_close(m64p_dynlib_handle LibHandle)
{
int rval = FreeLibrary(LibHandle);
if (rval == 0)
{
char *pchErrMsg;
DWORD dwErr = GetLastError();
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwErr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &pchErrMsg, 0, NULL);
DebugMessage(M64MSG_ERROR, "FreeLibrary() error: %s", pchErrMsg);
LocalFree(pchErrMsg);
return M64ERR_INTERNAL;
}
return M64ERR_SUCCESS;
}
+49
View File
@@ -0,0 +1,49 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_files.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This header file is for all kinds of system-dependent file handling
*
*/
#if !defined(OSAL_FILES_H)
#define OSAL_FILES_H
#include "m64p_types.h"
#include "osal_preproc.h"
/* data structure for linked list of shared libraries found in a directory */
typedef struct _osal_lib_search {
char filepath[PATH_MAX];
char *filename;
m64p_plugin_type plugin_type;
struct _osal_lib_search *next;
} osal_lib_search;
/* const definitions for system directories to search when looking for mupen64plus plugins */
extern const int osal_libsearchdirs;
extern const char *osal_libsearchpath[];
/* functions for searching for shared libraries in a given directory */
extern osal_lib_search *osal_library_search(const char *searchpath);
extern void osal_free_lib_list(osal_lib_search *head);
#endif /* #define OSAL_FILES_H */
+105
View File
@@ -0,0 +1,105 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_files_unix.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This implements all kinds of system-dependent file handling
*
*/
#include <dirent.h> // for opendir(), readdir(), closedir()
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include "m64p_types.h"
#include "common.h"
#include "osal_files.h"
#include "osal_preproc.h"
osal_lib_search *osal_library_search(const char *searchpath)
{
osal_lib_search *head = NULL, *curr = NULL;
DIR *dir;
struct dirent *entry;
#ifdef __APPLE__
const char* suffix = ".dylib";
#else
const char* suffix = ".so";
#endif
dir = opendir(searchpath);
if (dir == NULL)
return NULL;
/* look for any shared libraries in this folder */
while ((entry = readdir(dir)) != NULL)
{
osal_lib_search *newlib = NULL;
if (strcmp(entry->d_name + strlen(entry->d_name) - strlen(suffix), suffix) != 0)
continue;
/* this is a .so file, so add it to the list */
newlib = malloc(sizeof(osal_lib_search));
if (newlib == NULL)
{
DebugMessage(M64MSG_ERROR, "Memory allocation error in osal_library_search()!");
osal_free_lib_list(head);
closedir(dir);
return NULL;
}
if (head == NULL)
{
head = curr = newlib;
}
else
{
curr->next = newlib;
curr = newlib;
}
/* set up the filepath and filename members */
strncpy(curr->filepath, searchpath, PATH_MAX-2);
curr->filepath[PATH_MAX-2] = 0;
if (curr->filepath[strlen(curr->filepath)-1] != '/')
strcat(curr->filepath, "/");
int pathlen = strlen(curr->filepath);
curr->filename = curr->filepath + pathlen;
strncat(curr->filepath, entry->d_name, PATH_MAX - pathlen - 1);
curr->filepath[PATH_MAX-1] = 0;
/* set plugin_type and next pointer */
curr->plugin_type = 0;
curr->next = NULL;
}
closedir(dir);
return head;
}
void osal_free_lib_list(osal_lib_search *head)
{
while (head != NULL)
{
osal_lib_search *next = head->next;
free(head);
head = next;
}
}
+102
View File
@@ -0,0 +1,102 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_files_win32.c *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This implements all kinds of system-dependent file handling
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include "m64p_types.h"
#include "common.h"
#include "osal_files.h"
#include "osal_preproc.h"
osal_lib_search *osal_library_search(const char *searchpath)
{
osal_lib_search *head = NULL, *curr = NULL;
WIN32_FIND_DATA entry;
HANDLE hDir;
char *pchSearchPath = (char *) malloc(strlen(searchpath) + 16);
if (pchSearchPath == NULL)
{
DebugMessage(M64MSG_ERROR, "Couldn't allocate memory for file search path in osal_library_search()!");
return NULL;
}
sprintf(pchSearchPath, "%s\\*.dll", searchpath);
hDir = FindFirstFile(pchSearchPath, &entry);
free(pchSearchPath);
if (hDir == INVALID_HANDLE_VALUE)
return NULL;
/* look for any shared libraries in this folder */
do
{
osal_lib_search *newlib = NULL;
/* this is a .dll file, so add it to the list */
newlib = (osal_lib_search *) malloc(sizeof(osal_lib_search));
if (newlib == NULL)
{
DebugMessage(M64MSG_ERROR, "Memory allocation error in osal_library_search()!");
osal_free_lib_list(head);
FindClose(hDir);
return NULL;
}
if (head == NULL)
{
head = curr = newlib;
}
else
{
curr->next = newlib;
curr = newlib;
}
/* set up the filepath and filename members */
strncpy(curr->filepath, searchpath, PATH_MAX-2);
curr->filepath[PATH_MAX-2] = 0;
if (curr->filepath[strlen(curr->filepath)-1] != '\\')
strcat(curr->filepath, "\\");
int pathlen = (int) strlen(curr->filepath);
curr->filename = curr->filepath + pathlen;
strncat(curr->filepath, entry.cFileName, PATH_MAX - pathlen - 1);
curr->filepath[PATH_MAX-1] = 0;
/* set plugin_type and next pointer */
curr->plugin_type = (m64p_plugin_type) 0;
curr->next = NULL;
} while (FindNextFile(hDir, &entry));
FindClose(hDir);
return head;
}
void osal_free_lib_list(osal_lib_search *head)
{
while (head != NULL)
{
osal_lib_search *next = head->next;
free(head);
head = next;
}
}
+76
View File
@@ -0,0 +1,76 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Mupen64plus-ui-console - osal_preproc.h *
* Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ *
* Copyright (C) 2009 Richard Goedeken *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* This header file is for OS-specific #includes and #defines
*
*/
#if !defined(OSAL_PREPROC_H)
#define OSAL_PREPROC_H
#if defined(WIN32)
#include <windows.h>
#ifndef PATH_MAX
#define PATH_MAX 2048
#endif
#define OSAL_DEFAULT_DYNLIB_FILENAME "mupen64plus.dll"
#define OSAL_DIR_SEPARATOR '\\'
#define OSAL_CURRENT_DIR ".\\"
#define OSAL_DLL_EXTENSION ".dll"
#define osal_insensitive_strcmp(x, y) _stricmp(x, y)
#elif defined(__APPLE__)
#include <limits.h> // for PATH_MAX
#define OSAL_DEFAULT_DYNLIB_FILENAME "libmupen64plus.dylib"
#define OSAL_DIR_SEPARATOR '/'
#define OSAL_CURRENT_DIR "./"
#define OSAL_DLL_EXTENSION ".dylib"
#define osal_insensitive_strcmp(x, y) strcasecmp(x, y)
#else /* Linux-like UNIX */
#if defined(ANDROID)
#include <android/log.h>
#define printf(...) __android_log_print(ANDROID_LOG_VERBOSE, "UI-Console", __VA_ARGS__)
#endif
#include <limits.h> // for PATH_MAX
#define OSAL_DEFAULT_DYNLIB_FILENAME "libmupen64plus.so.2"
#define OSAL_DIR_SEPARATOR '/'
#define OSAL_CURRENT_DIR "./"
#define OSAL_DLL_EXTENSION ".so"
#define osal_insensitive_strcmp(x, y) strcasecmp(x, y)
/* PATH_MAX only may be defined by limits.h */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#endif
#endif /* #define OSAL_PREPROC_H */
+144
View File
@@ -0,0 +1,144 @@
#include "plugindialog.h"
#include "mainwindow.h"
#include "core_interface.h"
#include "osal_preproc.h"
#include "plugin.h"
#include <QLabel>
#include <QScrollArea>
#include <QSettings>
#include <QTabWidget>
#include <QGridLayout>
#include <QValidator>
#include <QMessageBox>
#include "settingclasses.h"
m64p_handle coreConfigHandle;
QGridLayout *coreLayout;
int coreLayoutRow;
static void paramListCallback(void * context, const char *ParamName, m64p_type ParamType)
{
QGridLayout *my_layout = nullptr;
int * my_row = nullptr;
m64p_handle current_handle = nullptr;
if (strcmp((char*)context, "Core") == 0) {
my_layout = coreLayout;
my_row = &coreLayoutRow;
current_handle = coreConfigHandle;
}
int l_ParamInt;
bool l_ParamBool;
float l_ParamFloat;
QString l_ParamString;
QString helper = (*ConfigGetParameterHelp)(current_handle, ParamName);
QLabel *desc = new QLabel(ParamName);
if (!helper.isEmpty()) {
helper.prepend("<span style=\"color:black;\">");
helper.append("</span>");
desc->setToolTip(helper);
}
desc->setStyleSheet("border: 1px solid; padding: 10px");
my_layout->addWidget(desc, *my_row, 0);
void *my_Widget = nullptr;
switch (ParamType) {
case M64TYPE_INT:
my_Widget = new CustomLineEdit();
((CustomLineEdit*)my_Widget)->setConfigHandle(current_handle);
((CustomLineEdit*)my_Widget)->setParamType(ParamType);
((CustomLineEdit*)my_Widget)->setParamName(ParamName);
((CustomLineEdit*)my_Widget)->setStyleSheet("border: 1px solid; padding: 10px");
l_ParamInt = (*ConfigGetParamInt)(current_handle, ParamName);
((CustomLineEdit*)my_Widget)->setText(QString::number(l_ParamInt));
((CustomLineEdit*)my_Widget)->setValidator(new QIntValidator());
break;
case M64TYPE_FLOAT:
my_Widget = new CustomLineEdit();
((CustomLineEdit*)my_Widget)->setConfigHandle(current_handle);
((CustomLineEdit*)my_Widget)->setParamType(ParamType);
((CustomLineEdit*)my_Widget)->setParamName(ParamName);
((CustomLineEdit*)my_Widget)->setStyleSheet("border: 1px solid; padding: 10px");
l_ParamFloat = (*ConfigGetParamFloat)(current_handle, ParamName);
((CustomLineEdit*)my_Widget)->setText(QString::number(l_ParamFloat));
((CustomLineEdit*)my_Widget)->setValidator(new QDoubleValidator());
break;
case M64TYPE_BOOL:
my_Widget = new CustomCheckBox();
((CustomCheckBox*)my_Widget)->setConfigHandle(current_handle);
((CustomCheckBox*)my_Widget)->setParamType(ParamType);
((CustomCheckBox*)my_Widget)->setParamName(ParamName);
((CustomCheckBox*)my_Widget)->setStyleSheet("border: 1px solid; padding: 10px");
l_ParamBool = (*ConfigGetParamBool)(current_handle, ParamName);
((CustomCheckBox*)my_Widget)->setCheckState(l_ParamBool ? Qt::Checked : Qt::Unchecked);
break;
case M64TYPE_STRING:
my_Widget = new CustomLineEdit();
((CustomLineEdit*)my_Widget)->setConfigHandle(current_handle);
((CustomLineEdit*)my_Widget)->setParamType(ParamType);
((CustomLineEdit*)my_Widget)->setParamName(ParamName);
((CustomLineEdit*)my_Widget)->setStyleSheet("border: 1px solid; padding: 10px");
l_ParamString = (*ConfigGetParamString)(current_handle, ParamName);
((CustomLineEdit*)my_Widget)->setText(l_ParamString);
break;
}
my_layout->addWidget((QWidget*)my_Widget, *my_row, 1);
++*my_row;
}
void PluginDialog::handleResetButton()
{
int value;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &value);
if (value == M64EMU_STOPPED) {
(*ConfigDeleteSection)("Core");
(*ConfigDeleteSection)("Video-General");
(*ConfigSaveFile)();
DetachCoreLib();
this->close();
}
else {
QMessageBox msgBox;
msgBox.setText("Emulator must be stopped.");
msgBox.exec();
}
}
PluginDialog::PluginDialog(QWidget *parent)
: QDialog(parent)
{
m64p_error res;
int value;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &value);
if (value == M64EMU_STOPPED) {
PluginSearchLoad();
PluginUnload();
}
coreLayoutRow = 0;
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QTabWidget *tabWidget = new QTabWidget(this);
tabWidget->setUsesScrollButtons(false);
QWidget *coreSettings = new QWidget(this);
coreLayout = new QGridLayout(this);
coreSettings->setLayout(coreLayout);
res = (*ConfigOpenSection)("Core", &coreConfigHandle);
if (res == M64ERR_SUCCESS)
(*ConfigListParameters)(coreConfigHandle, (char*)"Core", paramListCallback);
QScrollArea *coreScroll = new QScrollArea(this);
coreScroll->setWidget(coreSettings);
coreScroll->setMinimumWidth(coreSettings->sizeHint().width() + 20);
coreScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
tabWidget->addTab(coreScroll, tr("Core"));
QLabel *myLabel = new QLabel("Hover your mouse over the configuration item name for a description.\n", this);
myLabel->setStyleSheet("font-weight: bold");
mainLayout->addWidget(myLabel);
mainLayout->addWidget(tabWidget);
QPushButton *resetButton = new QPushButton("Reset All Settings", this);
resetButton->setAutoDefault(false);
connect(resetButton, SIGNAL (released()),this, SLOT (handleResetButton()));
mainLayout->addWidget(resetButton);
setLayout(mainLayout);
}
+17
View File
@@ -0,0 +1,17 @@
#ifndef PLUGINDIALOG_H
#define PLUGINDIALOG_H
#include <QDialog>
class PluginDialog : public QDialog
{
Q_OBJECT
public:
PluginDialog(QWidget *parent = nullptr);
private slots:
void handleResetButton();
private:
QString AudioName;
};
#endif // PLUGINDIALOG_H
+74
View File
@@ -0,0 +1,74 @@
#include "settingclasses.h"
#include "core_interface.h"
#include "plugin.h"
#include "cheat.h"
#include "common.h"
#include <SDL.h>
#include <QLabel>
#include <QVBoxLayout>
CustomLineEdit::CustomLineEdit(QWidget *parent)
: QLineEdit(parent)
{
connect(this, &QLineEdit::editingFinished, [=](){
int i_value = this->text().toInt();
float f_value = this->text().toFloat();
switch (m_ParamType) {
case M64TYPE_INT:
(*ConfigSetParameter)(m_CurrentHandle, m_ParamName.c_str(), m_ParamType, &i_value);
break;
case M64TYPE_FLOAT:
(*ConfigSetParameter)(m_CurrentHandle, m_ParamName.c_str(), m_ParamType, &f_value);
break;
case M64TYPE_STRING:
(*ConfigSetParameter)(m_CurrentHandle, m_ParamName.c_str(), m_ParamType, this->text().toLatin1().data());
break;
default:
break;
}
(*ConfigSaveFile)();
});
}
CustomCheckBox::CustomCheckBox(QWidget *parent)
: QCheckBox(parent)
{
connect(this, &QCheckBox::stateChanged, [=](int state){
int value = state == Qt::Checked ? 1 : 0;
(*ConfigSetParameter)(m_CurrentHandle, m_ParamName.c_str(), m_ParamType, &value);
(*ConfigSaveFile)();
});
}
CheatCheckBox::CheatCheckBox(QWidget *parent)
: QCheckBox(parent)
{
m_Checked = false;
connect(this, &QAbstractButton::clicked, [=](bool checked){
sCheatInfo *pCheat;
pCheat = CheatFindCode(m_Number);
if (checked && !m_Checked) {
if (pCheat == NULL)
DebugMessage(M64MSG_WARNING, "invalid cheat code number %i", m_Number);
else
{
if (pCheat->VariableLine != -1 && pCheat->Count > pCheat->VariableLine && m_Option < pCheat->Codes[pCheat->VariableLine].var_count)
pCheat->Codes[pCheat->VariableLine].var_to_use = m_Option;
CheatActivate(pCheat);
pCheat->active = true;
}
m_Checked = true;
}
else {
(*CoreCheatEnabled)(pCheat->Name, 0);
pCheat->active = false;
if (m_ButtonGroup != nullptr)
m_ButtonGroup->setChecked(true);
}
});
connect(this, &QCheckBox::stateChanged, [=](int state){
int value = state == Qt::Checked ? 1 : 0;
if (!value)
m_Checked = false;
});
}
+73
View File
@@ -0,0 +1,73 @@
#ifndef SETTINGCLASSES_H
#define SETTINGCLASSES_H
#include <QLabel>
#include <QCheckBox>
#include <QLineEdit>
#include <QComboBox>
#include <QSlider>
#include <QPushButton>
#include "m64p_types.h"
class CustomLineEdit : public QLineEdit
{
public:
explicit CustomLineEdit(QWidget *parent = 0);
void setParamName(const char* ParamName) {
m_ParamName = ParamName;
}
void setParamType(m64p_type ParamType) {
m_ParamType = ParamType;
}
void setConfigHandle(m64p_handle CurrentHandle) {
m_CurrentHandle = CurrentHandle;
}
private:
m64p_type m_ParamType;
std::string m_ParamName;
m64p_handle m_CurrentHandle;
};
class CustomCheckBox : public QCheckBox
{
public:
explicit CustomCheckBox(QWidget *parent = 0);
void setParamName(const char* ParamName) {
m_ParamName = ParamName;
}
void setParamType(m64p_type ParamType) {
m_ParamType = ParamType;
}
void setConfigHandle(m64p_handle CurrentHandle) {
m_CurrentHandle = CurrentHandle;
}
private:
m64p_type m_ParamType;
std::string m_ParamName;
m64p_handle m_CurrentHandle;
};
class CheatCheckBox : public QCheckBox
{
public:
explicit CheatCheckBox(QWidget *parent = 0);
void setNumber(int num) {
m_Number = num;
}
void setOption(int opt) {
m_Option = opt;
}
void setButtonGroup (QCheckBox* bgroup) {
m_ButtonGroup = bgroup;
}
private:
int m_Number;
int m_Option;
bool m_Checked;
QCheckBox* m_ButtonGroup;
};
#endif // SETTINGCLASSES_H
+164
View File
@@ -0,0 +1,164 @@
#include "settingsdialog.h"
#include "core_interface.h"
#include "mainwindow.h"
#include "plugin.h"
#include <QPushButton>
#include <QSettings>
#include <QFileDialog>
#include <QMessageBox>
void SettingsDialog::handleCoreButton()
{
QString fileName = QFileDialog::getOpenFileName(this,
tr("Locate Core Library"), NULL, tr("Shared Libraries (*.dylib *.so* *.dll)"));
if (!fileName.isNull()) {
corePath->setText(fileName);
w->getSettings()->setValue("coreLibPath", fileName);
qtCoreDirPath = w->getSettings()->value("coreLibPath").toString();
}
}
void SettingsDialog::handlePluginButton()
{
QString fileName = QFileDialog::getExistingDirectory(this, tr("Locate Plugin Directory"),
NULL,
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (!fileName.isNull()) {
pluginPath->setText(fileName);
w->getSettings()->setValue("pluginDirPath", fileName);
qtPluginDir = w->getSettings()->value("pluginDirPath").toString();
w->getSettings()->remove("inputPlugin");
w->getSettings()->remove("videoPlugin");
w->getSettings()->remove("audioPlugin");
w->getSettings()->remove("rspPlugin");
w->updatePlugins();
initStuff();
}
}
void SettingsDialog::handleConfigButton()
{
QString fileName = QFileDialog::getExistingDirectory(this, tr("Set Config Directory"),
NULL,
QFileDialog::ShowDirsOnly
| QFileDialog::DontResolveSymlinks);
if (!fileName.isNull()) {
configPath->setText(fileName);
w->getSettings()->setValue("configDirPath", fileName);
qtConfigDir = w->getSettings()->value("configDirPath").toString();
}
}
void SettingsDialog::handleClearConfigButton()
{
configPath->setText("");
w->getSettings()->remove("configDirPath");
qtConfigDir = QString();
}
void SettingsDialog::handleCoreEdit()
{
w->getSettings()->setValue("coreLibPath", corePath->text());
qtCoreDirPath = w->getSettings()->value("coreLibPath").toString();
}
void SettingsDialog::handlePluginEdit()
{
w->getSettings()->setValue("pluginDirPath", pluginPath->text());
qtPluginDir = w->getSettings()->value("pluginDirPath").toString();
w->getSettings()->remove("inputPlugin");
w->getSettings()->remove("videoPlugin");
w->getSettings()->remove("audioPlugin");
w->getSettings()->remove("rspPlugin");
w->updatePlugins();
initStuff();
}
void SettingsDialog::handleConfigEdit()
{
w->getSettings()->setValue("configDirPath", configPath->text());
qtConfigDir = w->getSettings()->value("configDirPath").toString();
}
void SettingsDialog::initStuff()
{
layout = new QGridLayout(this);
QLabel *coreLabel = new QLabel("Core Library Path", this);
corePath = new QLineEdit(this);
corePath->setText(w->getSettings()->value("coreLibPath").toString());
QPushButton *coreButton = new QPushButton("Set Path", this);
connect(coreButton, SIGNAL (released()),this, SLOT (handleCoreButton()));
connect(corePath, SIGNAL (editingFinished()),this, SLOT (handleCoreEdit()));
corePath->setStyleSheet("border: 1px solid; padding: 10px");
layout->addWidget(coreLabel,0,0);
layout->addWidget(corePath,0,1);
layout->addWidget(coreButton,0,2);
QLabel *pluginLabel = new QLabel("Plugin Dir Path", this);
pluginPath = new QLineEdit(this);
pluginPath->setText(w->getSettings()->value("pluginDirPath").toString());
QPushButton *pluginButton = new QPushButton("Set Path", this);
connect(pluginButton, SIGNAL (released()),this, SLOT (handlePluginButton()));
connect(pluginPath, SIGNAL (editingFinished()),this, SLOT (handlePluginEdit()));
pluginPath->setStyleSheet("border: 1px solid; padding: 10px");
layout->addWidget(pluginLabel,1,0);
layout->addWidget(pluginPath,1,1);
layout->addWidget(pluginButton,1,2);
QLabel *note = new QLabel("Note: If you change the Config Path, you need to close and re-open mupen64plus-gui before it will take effect.", this);
QLabel *configLabel = new QLabel("Config Dir Path", this);
configPath = new QLineEdit(this);
QString configDirPath = w->getSettings()->value("configDirPath").toString();
if (!configDirPath.isEmpty())
configPath->setText(configDirPath);
else if (QtAttachCoreLib())
configPath->setText(ConfigGetUserConfigPath());
QPushButton *configButton = new QPushButton("Set Path", this);
connect(configButton, SIGNAL (released()),this, SLOT (handleConfigButton()));
connect(configPath, SIGNAL (editingFinished()),this, SLOT (handleConfigEdit()));
QPushButton *clearConfigButton = new QPushButton("Clear", this);
connect(clearConfigButton, SIGNAL (released()),this, SLOT (handleClearConfigButton()));
configPath->setStyleSheet("border: 1px solid; padding: 10px");
layout->addWidget(note,2,0,1,-1);
layout->addWidget(configLabel,3,0);
layout->addWidget(configPath,3,1);
layout->addWidget(configButton,3,2);
layout->addWidget(clearConfigButton,3,3);
QDir PluginDir(qtPluginDir);
QStringList Filter;
Filter.append("");
QStringList current;
QLabel *inputLabel = new QLabel("Input Plugin", this);
layout->addWidget(inputLabel,5,0);
QComboBox *inputChoice = new QComboBox(this);
Filter.replace(0,"mupen64plus-input*");
current = PluginDir.entryList(Filter);
inputChoice->addItems(current);
int my_index = inputChoice->findText(qtInputPlugin);
if (my_index == -1) {
inputChoice->addItem(qtInputPlugin);
my_index = inputChoice->findText(qtInputPlugin);
}
inputChoice->setCurrentIndex(my_index);
connect(inputChoice, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
[=](const QString &text) {
w->getSettings()->setValue("inputPlugin", text);
qtInputPlugin = w->getSettings()->value("inputPlugin").toString();
});
layout->addWidget(inputChoice,5,1);
setLayout(layout);
}
SettingsDialog::SettingsDialog(QWidget *parent)
: QDialog(parent)
{
initStuff();
}
+32
View File
@@ -0,0 +1,32 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include <QLineEdit>
#include <QLabel>
#include <QComboBox>
#include <QGridLayout>
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
SettingsDialog(QWidget *parent = nullptr);
private slots:
void handleCoreButton();
void handlePluginButton();
void handleConfigButton();
void handleClearConfigButton();
void handleCoreEdit();
void handlePluginEdit();
void handleConfigEdit();
private:
void initStuff();
QLineEdit *corePath;
QLineEdit *pluginPath;
QLineEdit *configPath;
QGridLayout *layout = nullptr;
};
#endif // SETTINGSDIALOG_H
+233
View File
@@ -0,0 +1,233 @@
#include "vidext.h"
#include "common.h"
#include "workerthread.h"
#include "mainwindow.h"
#include <stdio.h>
#include <QDesktopWidget>
#include <QScreen>
static int init;
static int needs_toggle;
static QSurfaceFormat format;
QThread* rendering_thread;
m64p_error qtVidExtFuncInit(void)
{
init = 0;
format = QSurfaceFormat::defaultFormat();
format.setOption(QSurfaceFormat::DeprecatedFunctions, 1);
format.setDepthBufferSize(24);
format.setProfile(QSurfaceFormat::CompatibilityProfile);
format.setMajorVersion(2);
format.setMinorVersion(1);
if (w->getGLES())
format.setRenderableType(QSurfaceFormat::OpenGLES);
rendering_thread = QThread::currentThread();
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncQuit(void)
{
init = 0;
w->getWorkerThread()->toggleFS(M64VIDEO_WINDOWED);
if (w->getOGLWindow() != nullptr) {
w->getOGLWindow()->doneCurrent();
w->getOGLWindow()->context()->moveToThread(QApplication::instance()->thread());
w->getWorkerThread()->deleteOGLWindow();
}
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncListModes(m64p_2d_size *SizeArray, int *NumSizes)
{
QList<QScreen *> screens = QGuiApplication::screens();
QRect size = screens.first()->geometry();
SizeArray[0].uiWidth = size.width();
SizeArray[0].uiHeight = size.height();
*NumSizes = 1;
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncSetMode(int Width, int Height, int, int ScreenMode, int)
{
if (!init) {
w->getWorkerThread()->createOGLWindow(&format);
while (!w->getOGLWindow()->isValid()) {}
w->getWorkerThread()->resizeMainWindow(Width, Height);
w->getOGLWindow()->makeCurrent();
init = 1;
needs_toggle = ScreenMode;
}
return M64ERR_SUCCESS;
}
m64p_function qtVidExtFuncGLGetProc(const char* Proc)
{
if (!init) return NULL;
return w->getOGLWindow()->context()->getProcAddress(Proc);
}
m64p_error qtVidExtFuncGLSetAttr(m64p_GLattr Attr, int Value)
{
switch (Attr) {
case M64P_GL_DOUBLEBUFFER:
if (Value == 1)
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
else if (Value == 0)
format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
break;
case M64P_GL_BUFFER_SIZE:
break;
case M64P_GL_DEPTH_SIZE:
format.setDepthBufferSize(Value);
break;
case M64P_GL_RED_SIZE:
format.setRedBufferSize(Value);
break;
case M64P_GL_GREEN_SIZE:
format.setGreenBufferSize(Value);
break;
case M64P_GL_BLUE_SIZE:
format.setBlueBufferSize(Value);
break;
case M64P_GL_ALPHA_SIZE:
format.setAlphaBufferSize(Value);
break;
case M64P_GL_SWAP_CONTROL:
format.setSwapInterval(Value);
break;
case M64P_GL_MULTISAMPLEBUFFERS:
break;
case M64P_GL_MULTISAMPLESAMPLES:
format.setSamples(Value);
break;
case M64P_GL_CONTEXT_MAJOR_VERSION:
format.setMajorVersion(Value);
break;
case M64P_GL_CONTEXT_MINOR_VERSION:
format.setMinorVersion(Value);
break;
case M64P_GL_CONTEXT_PROFILE_MASK:
switch (Value) {
case M64P_GL_CONTEXT_PROFILE_CORE:
format.setProfile(QSurfaceFormat::CoreProfile);
break;
case M64P_GL_CONTEXT_PROFILE_COMPATIBILITY:
format.setProfile(QSurfaceFormat::CompatibilityProfile);
break;
case M64P_GL_CONTEXT_PROFILE_ES:
format.setRenderableType(QSurfaceFormat::OpenGLES);
break;
}
break;
}
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncGLGetAttr(m64p_GLattr Attr, int *pValue)
{
if (!init) return M64ERR_NOT_INIT;
QSurfaceFormat::SwapBehavior SB = w->getOGLWindow()->format().swapBehavior();
switch (Attr) {
case M64P_GL_DOUBLEBUFFER:
if (SB == QSurfaceFormat::SingleBuffer)
*pValue = 0;
else
*pValue = 1;
break;
case M64P_GL_BUFFER_SIZE:
*pValue = w->getOGLWindow()->format().alphaBufferSize() + w->getOGLWindow()->format().redBufferSize() + w->getOGLWindow()->format().greenBufferSize() + w->getOGLWindow()->format().blueBufferSize();
break;
case M64P_GL_DEPTH_SIZE:
*pValue = w->getOGLWindow()->format().depthBufferSize();
break;
case M64P_GL_RED_SIZE:
*pValue = w->getOGLWindow()->format().redBufferSize();
break;
case M64P_GL_GREEN_SIZE:
*pValue = w->getOGLWindow()->format().greenBufferSize();
break;
case M64P_GL_BLUE_SIZE:
*pValue = w->getOGLWindow()->format().blueBufferSize();
break;
case M64P_GL_ALPHA_SIZE:
*pValue = w->getOGLWindow()->format().alphaBufferSize();
break;
case M64P_GL_SWAP_CONTROL:
*pValue = w->getOGLWindow()->format().swapInterval();
break;
case M64P_GL_MULTISAMPLEBUFFERS:
break;
case M64P_GL_MULTISAMPLESAMPLES:
*pValue = w->getOGLWindow()->format().samples();
break;
case M64P_GL_CONTEXT_MAJOR_VERSION:
*pValue = w->getOGLWindow()->format().majorVersion();
break;
case M64P_GL_CONTEXT_MINOR_VERSION:
*pValue = w->getOGLWindow()->format().minorVersion();
break;
case M64P_GL_CONTEXT_PROFILE_MASK:
switch (w->getOGLWindow()->format().profile()) {
case QSurfaceFormat::CoreProfile:
*pValue = M64P_GL_CONTEXT_PROFILE_CORE;
break;
case QSurfaceFormat::CompatibilityProfile:
*pValue = M64P_GL_CONTEXT_PROFILE_COMPATIBILITY;
break;
case QSurfaceFormat::NoProfile:
*pValue = M64P_GL_CONTEXT_PROFILE_COMPATIBILITY;
break;
}
break;
}
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncGLSwapBuf(void)
{
if (needs_toggle) {
int value;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_EMU_STATE, &value);
if (value > M64EMU_STOPPED) {
w->getWorkerThread()->toggleFS(needs_toggle);
needs_toggle = 0;
}
}
if (QThread::currentThread() == rendering_thread) {
w->getOGLWindow()->context()->swapBuffers(w->getOGLWindow());
w->getOGLWindow()->context()->makeCurrent(w->getOGLWindow());
}
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncSetCaption(const char * _title)
{
std::string title = _title;
w->getWorkerThread()->setTitle(title);
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncToggleFS(void)
{
w->getWorkerThread()->toggleFS(M64VIDEO_NONE);
return M64ERR_SUCCESS;
}
m64p_error qtVidExtFuncResizeWindow(int width, int height)
{
int response = M64VIDEO_NONE;
(*CoreDoCommand)(M64CMD_CORE_STATE_QUERY, M64CORE_VIDEO_MODE, &response);
if (response == M64VIDEO_WINDOWED)
w->getWorkerThread()->resizeMainWindow(width, height);
return M64ERR_SUCCESS;
}
uint32_t qtVidExtFuncGLGetDefaultFramebuffer(void)
{
return 0;
}
+28
View File
@@ -0,0 +1,28 @@
#ifndef VIDEXT_H
#define VIDEXT_H
#include "m64p_types.h"
#ifdef __cplusplus
#include "oglwindow.h"
extern "C" {
#endif
m64p_error qtVidExtFuncInit(void);
m64p_error qtVidExtFuncQuit(void);
m64p_error qtVidExtFuncListModes(m64p_2d_size *SizeArray, int *NumSizes);
m64p_error qtVidExtFuncSetMode(int Width, int Height, int, int, int);
m64p_function qtVidExtFuncGLGetProc(const char*Proc);
m64p_error qtVidExtFuncGLSetAttr(m64p_GLattr Attr, int Value);
m64p_error qtVidExtFuncGLGetAttr(m64p_GLattr Attr, int *pValue);
m64p_error qtVidExtFuncGLSwapBuf(void);
m64p_error qtVidExtFuncSetCaption(const char *_title);
m64p_error qtVidExtFuncToggleFS(void);
m64p_error qtVidExtFuncResizeWindow(int, int);
uint32_t qtVidExtFuncGLGetDefaultFramebuffer(void);
#ifdef __cplusplus
}
#endif
#endif // VIDEXT_H
+62
View File
@@ -0,0 +1,62 @@
#include "workerthread.h"
#include "vidext.h"
#include "mainwindow.h"
#ifndef _WIN32
#include <QDBusConnection>
#include <QDBusReply>
#include <QDBusInterface>
#endif
WorkerThread::WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_player, QObject *parent)
: QThread(parent)
{
netplay_ip = _netplay_ip;
netplay_port = _netplay_port;
netplay_player = _netplay_player;
}
void WorkerThread::run()
{
connect(this, SIGNAL(resizeMainWindow(int,int)), w, SLOT(resizeMainWindow(int, int)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(toggleFS(int)), w, SLOT(toggleFS(int)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(createOGLWindow(QSurfaceFormat*)), w, SLOT(createOGLWindow(QSurfaceFormat*)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(deleteOGLWindow()), w, SLOT(deleteOGLWindow()), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(setTitle(std::string)), w, SLOT(setTitle(std::string)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(pluginWarning(QString)), w, SLOT(pluginWarning(QString)), Qt::BlockingQueuedConnection);
connect(this, SIGNAL(showMessage(QString)), w, SLOT(showMessage(QString)), Qt::BlockingQueuedConnection);
#ifdef _WIN32
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
#else
uint32_t cookieID = 0;
QDBusInterface screenSaverInterface("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver");
if (screenSaverInterface.isValid()) {
QDBusReply<uint32_t> reply = screenSaverInterface.call("Inhibit", "mupen64plus-gui", "game");
if (reply.isValid())
cookieID = reply.value();
}
#endif
m64p_error res = loadROM(m_fileName.toStdString());
if (res == M64ERR_SUCCESS)
res = launchGame(netplay_ip, netplay_port, netplay_player);
#ifdef _WIN32
SetThreadExecutionState(ES_CONTINUOUS);
#else
if (cookieID)
screenSaverInterface.call("UnInhibit", cookieID);
#endif
if (res == M64ERR_SUCCESS) {
(*ConfigSaveFile)();
if (w->getNoGUI())
QApplication::quit();
}
w->resetTitle();
}
void WorkerThread::setFileName(QString filename)
{
m_fileName = filename;
}
+34
View File
@@ -0,0 +1,34 @@
#ifndef WORKERTHREAD_H
#define WORKERTHREAD_H
#include <QThread>
#include <QApplication>
#include <QString>
#include <QSurfaceFormat>
#include "common.h"
class WorkerThread : public QThread
{
Q_OBJECT
void run() Q_DECL_OVERRIDE;
public:
explicit WorkerThread(QString _netplay_ip, int _netplay_port, int _netplay_player, QObject *parent = 0);
void setFileName(QString filename);
signals:
void resizeMainWindow(int Width, int Height);
void toggleFS(int force);
void createOGLWindow(QSurfaceFormat* format);
void deleteOGLWindow();
void setTitle(std::string title);
void pluginWarning(QString name);
void showMessage(QString message);
private:
QString m_fileName;
QString netplay_ip;
int netplay_port;
int netplay_player;
};
#endif // WORKERTHREAD_H