mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Merge branch 'master' into more-emscripten-fixes
This commit is contained in:
commit
78a3d0f828
674
cores/libretro-mpv/LICENSE
Normal file
674
cores/libretro-mpv/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
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
|
||||
<http://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
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
159
cores/libretro-mpv/Makefile
Normal file
159
cores/libretro-mpv/Makefile
Normal file
@ -0,0 +1,159 @@
|
||||
STATIC_LINKING := 0
|
||||
AR := ar
|
||||
DEBUG := 0
|
||||
TARGET_NAME := mpv
|
||||
PREFIX := /usr
|
||||
LIBDIR := $(PREFIX)/lib
|
||||
LIBRETRO_DIR := libretro
|
||||
|
||||
ifeq ($(platform),)
|
||||
platform = unix
|
||||
ifeq ($(shell uname -s),)
|
||||
EXE_EXT = .exe
|
||||
platform = win
|
||||
else ifneq ($(findstring MINGW,$(shell uname -s)),)
|
||||
platform = win
|
||||
else ifneq ($(findstring Darwin,$(shell uname -s)),)
|
||||
platform = osx
|
||||
ifeq ($(shell uname -p),powerpc)
|
||||
arch = ppc
|
||||
else
|
||||
arch = intel
|
||||
endif
|
||||
else ifneq ($(findstring win,$(shell uname -s)),)
|
||||
platform = win
|
||||
endif
|
||||
else ifneq (,$(findstring armv,$(platform)))
|
||||
override platform += unix
|
||||
else ifneq (,$(findstring rpi3,$(platform)))
|
||||
override platform += unix
|
||||
endif
|
||||
|
||||
ifeq ($(ARCHFLAGS),)
|
||||
ifeq ($(archs),ppc)
|
||||
ARCHFLAGS = -arch ppc -arch ppc64
|
||||
else
|
||||
ARCHFLAGS = -arch i386 -arch x86_64
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(platform), osx)
|
||||
ifndef ($(NOUNIVERSAL))
|
||||
CFLAGS += $(ARCHFLAGS)
|
||||
LFLAGS += $(ARCHFLAGS)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
EXT := a
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring unix,$(platform)))
|
||||
EXT ?= so
|
||||
TARGET := $(TARGET_NAME)_libretro.$(EXT)
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifneq (,$(findstring osx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
else ifneq (,$(findstring ios,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_ios.dylib
|
||||
fpic := -fPIC
|
||||
SHARED := -dynamiclib
|
||||
ifeq ($(IOSSDK),)
|
||||
IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path)
|
||||
endif
|
||||
DEFINES := -DIOS
|
||||
CC = cc -arch armv7 -isysroot $(IOSSDK)
|
||||
ifeq ($(platform),ios9)
|
||||
CC += -miphoneos-version-min=8.0
|
||||
CFLAGS += -miphoneos-version-min=8.0
|
||||
else
|
||||
CC += -miphoneos-version-min=5.0
|
||||
CFLAGS += -miphoneos-version-min=5.0
|
||||
endif #ifneq ios
|
||||
else ifneq (,$(findstring qnx,$(platform)))
|
||||
TARGET := $(TARGET_NAME)_libretro_qnx.so
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), emscripten)
|
||||
TARGET := $(TARGET_NAME)_libretro_emscripten.bc
|
||||
fpic := -fPIC
|
||||
SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined
|
||||
else ifeq ($(platform), vita)
|
||||
TARGET := $(TARGET_NAME)_vita.a
|
||||
CC = arm-vita-eabi-gcc
|
||||
AR = arm-vita-eabi-ar
|
||||
CFLAGS += -Wl,-q -Wall -O3
|
||||
STATIC_LINKING = 1
|
||||
else
|
||||
CC = gcc
|
||||
TARGET := $(TARGET_NAME)_libretro.dll
|
||||
SHARED := -shared -static-libgcc -static-libstdc++ \
|
||||
-Wl,--version-script=link.T -Wl,--no-undefined
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring gles,$(platform)))
|
||||
CFLAGS += -DHAVE_OPENGLES
|
||||
endif
|
||||
|
||||
ifneq (,$(findstring qnx,$(platform)))
|
||||
CFLAGS += -Wc,-std=c99
|
||||
else
|
||||
CFLAGS += -std=gnu99
|
||||
endif
|
||||
|
||||
# Locale support should be enabled by default, as it's most common.
|
||||
ifneq ($(locale),false)
|
||||
CFLAGS += -DHAVE_LOCALE
|
||||
endif
|
||||
|
||||
# Always have some debugging information.
|
||||
CFLAGS += -g
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -Og
|
||||
else
|
||||
CFLAGS += -Ofast
|
||||
endif
|
||||
|
||||
CFLAGS += -I../../libretro-common/include
|
||||
|
||||
OBJECTS := mpv-libretro.o
|
||||
LDFLAGS += -lmpv
|
||||
CFLAGS += -Wall -pedantic
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
ifeq ($(STATIC_LINKING), 1)
|
||||
$(AR) rcs $@ $(OBJECTS)
|
||||
else
|
||||
$(CC) $(fpic) $(SHARED) $(CFLAGS) -o $@ $(OBJECTS) $(LDFLAGS)
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) $(fpic) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f $(OBJECTS) $(TARGET)
|
||||
|
||||
install:
|
||||
install -D -m 755 $(TARGET) $(DESTDIR)$(LIBDIR)/$(LIBRETRO_DIR)/$(TARGET)
|
||||
|
||||
install-snip:
|
||||
install -D -s -m 755 $(TARGET) $(DESTDIR)$(LIBDIR)/$(LIBRETRO_DIR)/$(TARGET)
|
||||
|
||||
uninstall:
|
||||
rm $(DESTDIR)$(LIBDIR)/$(LIBRETRO_DIR)/$(TARGET)
|
||||
|
||||
help:
|
||||
@echo 'make <target> [flags]'
|
||||
@echo 'Targets:'
|
||||
@echo ' clean install install-snip uninstall help'
|
||||
@echo 'Flags:'
|
||||
@echo ' platform String containing platform details.'
|
||||
@echo ' locale Support toolchain with locale support.'
|
||||
@echo ' false: disable support, otherwise enabled (default).'
|
||||
|
||||
.PHONY: clean
|
17
cores/libretro-mpv/README.md
Normal file
17
cores/libretro-mpv/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# libretro-mpv
|
||||
|
||||
mpv media player as a libretro core. A proof of concept release is now available.
|
||||
|
||||
Aims to use features already established in mpv that are not currently available in Retroarch movieplayer.
|
||||
|
||||
I want to be able to use Retroarch as my movie player on my embedded devices (Raspberry Pi) and desktop using hardware acceleration without having to use Kodi or mpv directly. Thus allowing for a more integrated experience, and smaller root filesystem.
|
||||
|
||||
## Compiling
|
||||
|
||||
Retroarch must be compiled with `--disable-ffmpeg` to stop the integrated movieplayer from playing the input file.
|
||||
|
||||
FFmpeg (preferably master branch) must be compiled with `--enable-shared`.
|
||||
|
||||
mpv must be compiled with `--enable-libmpv-shared`.
|
||||
|
||||
Then run `make` in the mpv-libretro folder.
|
4
cores/libretro-mpv/link.T
Normal file
4
cores/libretro-mpv/link.T
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
global: retro_*;
|
||||
local: *;
|
||||
};
|
564
cores/libretro-mpv/mpv-libretro.c
Normal file
564
cores/libretro-mpv/mpv-libretro.c
Normal file
@ -0,0 +1,564 @@
|
||||
/* mpv media player libretro core
|
||||
* Copyright (C) 2018 Mahyar Koshkouei
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef HAVE_LOCALE
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <mpv/client.h>
|
||||
#include <mpv/opengl_cb.h>
|
||||
|
||||
#include "libretro.h"
|
||||
#include "version.h"
|
||||
|
||||
static struct retro_hw_render_callback hw_render;
|
||||
|
||||
static struct retro_log_callback logging;
|
||||
static retro_log_printf_t log_cb;
|
||||
|
||||
static retro_video_refresh_t video_cb;
|
||||
static retro_audio_sample_t audio_cb;
|
||||
static retro_audio_sample_batch_t audio_batch_cb;
|
||||
static retro_environment_t environ_cb;
|
||||
static retro_input_poll_t input_poll_cb;
|
||||
static retro_input_state_t input_state_cb;
|
||||
|
||||
static mpv_handle *mpv;
|
||||
static mpv_opengl_cb_context *mpv_gl;
|
||||
|
||||
/* Keep track of the number of events in mpv queue */
|
||||
static unsigned int event_waiting = 0;
|
||||
|
||||
/* Save the current playback time for context changes */
|
||||
static int64_t *playback_time = 0;
|
||||
|
||||
/* filepath required globaly as mpv is reopened on context change */
|
||||
static char *filepath = NULL;
|
||||
|
||||
static void fallback_log(enum retro_log_level level, const char *fmt, ...)
|
||||
{
|
||||
(void)level;
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
vfprintf(stderr, fmt, va);
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
static void on_mpv_events(void *mpv)
|
||||
{
|
||||
event_waiting++;
|
||||
}
|
||||
|
||||
void retro_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void retro_deinit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned retro_api_version(void)
|
||||
{
|
||||
return RETRO_API_VERSION;
|
||||
}
|
||||
|
||||
void retro_set_controller_port_device(unsigned port, unsigned device)
|
||||
{
|
||||
log_cb(RETRO_LOG_INFO, "Plugging device %u into port %u.\n", device, port);
|
||||
return;
|
||||
}
|
||||
|
||||
void retro_get_system_info(struct retro_system_info *info)
|
||||
{
|
||||
memset(info, 0, sizeof(*info));
|
||||
info->library_name = "mpv";
|
||||
info->library_version = LIBRETRO_MPV_VERSION;
|
||||
info->need_fullpath = true; /* Allow MPV to load the file on its own */
|
||||
info->valid_extensions = "264|265|302|669|722|3g2|3gp|aa|aa3|aac|abc|ac3|"
|
||||
"acm|adf|adp|ads|adx|aea|afc|aix|al|amf|ams|ans|ape|apl|aqt|art|asc|"
|
||||
"ast|avc|avi|avr|avs|bcstm|bfstm|bin|bit|bmv|brstm|cdata|cdg|cdxl|cgi|"
|
||||
"cif|daud|dbm|dif|diz|dmf|dsm|dss|dtk|dts|dtshd|dv|eac3|fap|far|flac|"
|
||||
"flm|flv|fsb|g722|g723_1|g729|genh|gsm|h261|h264|h265|h26l|hevc|ice|"
|
||||
"idf|idx|ircam|it|itgz|itr|itz|ivr|j2k|lvf|m2a|m3u8|m4a|m4s|m4v|mac|"
|
||||
"mdgz|mdl|mdr|mdz|med|mid|mj2|mjpeg|mjpg|mk3d|mka|mks|mkv|mlp|mod|mov|"
|
||||
"mp2|mp3|mp4|mpa|mpc|mpeg|mpegts|mpg|mpl2|mpo|msf|mt2|mtaf|mtm|musx|"
|
||||
"mvi|mxg|nfo|nist|nut|oga|ogg|ogv|okt|oma|omg|paf|pjs|psm|ptm|pvf|qcif|"
|
||||
"rco|rgb|rsd|rso|rt|s3gz|s3m|s3r|s3z|sami|sb|sbg|scc|sdr2|sds|sdx|sf|"
|
||||
"shn|sln|smi|son|sph|ss2|stl|stm|str|sub|sup|svag|sw|tak|tco|thd|ts|"
|
||||
"tta|txt|ub|ul|ult|umx|uw|v|v210|vag|vb|vc1|viv|vob|vpk|vqe|vqf|vql|vt|"
|
||||
"vtt|wav|wsd|xl|xm|xmgz|xmr|xmv|xmz|xvag|y4m|yop|yuv|yuv10";
|
||||
}
|
||||
|
||||
void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||
{
|
||||
float sampling_rate = 48000.0f;
|
||||
|
||||
struct retro_variable var = { .key = "test_aspect" };
|
||||
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var);
|
||||
|
||||
var.key = "test_samplerate";
|
||||
|
||||
if(environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
sampling_rate = strtof(var.value, NULL);
|
||||
|
||||
info->timing = (struct retro_system_timing) {
|
||||
.fps = 60.0,
|
||||
.sample_rate = sampling_rate,
|
||||
};
|
||||
|
||||
info->geometry = (struct retro_game_geometry) {
|
||||
.base_width = 256,
|
||||
.base_height = 144,
|
||||
.max_width = 1920,
|
||||
.max_height = 1080,
|
||||
.aspect_ratio = -1,
|
||||
};
|
||||
}
|
||||
|
||||
void retro_set_environment(retro_environment_t cb)
|
||||
{
|
||||
environ_cb = cb;
|
||||
|
||||
static const struct retro_variable vars[] = {
|
||||
{ "test_samplerate", "Sample Rate; 48000|30000|20000" },
|
||||
{ "test_opt0", "Test option #0; false|true" },
|
||||
{ "test_opt1", "Test option #1; 0" },
|
||||
{ "test_opt2", "Test option #2; 0|1|foo|3" },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars);
|
||||
|
||||
if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logging))
|
||||
log_cb = logging.log;
|
||||
else
|
||||
log_cb = fallback_log;
|
||||
}
|
||||
|
||||
static void *get_proc_address_mpv(void *fn_ctx, const char *name)
|
||||
{
|
||||
/* The "ISO C forbids conversion of function pointer to object pointer
|
||||
* type" warning is suppressed.
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
void *proc_addr = (void *) hw_render.get_proc_address(name);
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
if(proc_addr == NULL)
|
||||
log_cb(RETRO_LOG_ERROR, "Failure obtaining %s proc address\n", name);
|
||||
|
||||
return proc_addr;
|
||||
}
|
||||
|
||||
static void context_reset(void)
|
||||
{
|
||||
const char *cmd[] = {"loadfile", filepath, NULL};
|
||||
|
||||
#ifdef HAVE_LOCALE
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
#endif
|
||||
|
||||
mpv = mpv_create();
|
||||
|
||||
if(!mpv)
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "failed creating context\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(mpv_initialize(mpv) < 0)
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "mpv init failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* When normal mpv events are available. */
|
||||
mpv_set_wakeup_callback(mpv, on_mpv_events, NULL);
|
||||
|
||||
if(mpv_request_log_messages(mpv, "info") < 0)
|
||||
log_cb(RETRO_LOG_ERROR, "mpv logging failed\n");
|
||||
|
||||
/* The OpenGL API is somewhat separate from the normal mpv API. This only
|
||||
* returns NULL if no OpenGL support is compiled.
|
||||
*/
|
||||
mpv_gl = mpv_get_sub_api(mpv, MPV_SUB_API_OPENGL_CB);
|
||||
|
||||
if(!mpv_gl)
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "failed to create mpv GL API handle\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(mpv_opengl_cb_init_gl(mpv_gl, NULL, get_proc_address_mpv, NULL) < 0)
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "failed to initialize mpv GL context\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Actually using the opengl_cb state has to be explicitly requested.
|
||||
* Otherwise, mpv will create a separate platform window.
|
||||
*/
|
||||
if(mpv_set_option_string(mpv, "vo", "opengl-cb") < 0)
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "failed to set video output to OpenGL\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if(mpv_set_option_string(mpv, "hwdec", "auto") < 0)
|
||||
log_cb(RETRO_LOG_ERROR, "failed to set hwdec option\n");
|
||||
|
||||
if(mpv_command(mpv, cmd) != 0)
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "failed to issue mpv_command\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Keep trying until mpv accepts the property. This is done to seek to the
|
||||
* point in the file after the previous context was destroyed. If no
|
||||
* context was destroyed previously, the file seeks to 0.
|
||||
*
|
||||
* This also seems to fix some black screen issues.
|
||||
*/
|
||||
while(mpv_set_property(mpv,
|
||||
"playback-time", MPV_FORMAT_INT64, &playback_time) < 0)
|
||||
{}
|
||||
|
||||
log_cb(RETRO_LOG_INFO, "Context reset.\n");
|
||||
}
|
||||
|
||||
static void context_destroy(void)
|
||||
{
|
||||
mpv_get_property(mpv, "playback-time", MPV_FORMAT_INT64, &playback_time);
|
||||
mpv_opengl_cb_uninit_gl(mpv_gl);
|
||||
mpv_terminate_destroy(mpv);
|
||||
log_cb(RETRO_LOG_INFO, "Context destroyed.\n");
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENGLES
|
||||
static bool retro_init_hw_context(void)
|
||||
{
|
||||
#if defined(HAVE_OPENGLES_3_1)
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES_VERSION;
|
||||
hw_render.version_major = 3;
|
||||
hw_render.version_minor = 1;
|
||||
#elif defined(HAVE_OPENGLES3)
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES3;
|
||||
#else
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES2;
|
||||
#endif
|
||||
hw_render.context_reset = context_reset;
|
||||
hw_render.context_destroy = context_destroy;
|
||||
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
static bool retro_init_hw_context(void)
|
||||
{
|
||||
hw_render.context_type = RETRO_HW_CONTEXT_OPENGL;
|
||||
hw_render.context_reset = context_reset;
|
||||
hw_render.context_destroy = context_destroy;
|
||||
|
||||
if (!environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
void retro_set_audio_sample(retro_audio_sample_t cb)
|
||||
{
|
||||
audio_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_audio_sample_batch(retro_audio_sample_batch_t cb)
|
||||
{
|
||||
audio_batch_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_input_poll(retro_input_poll_t cb)
|
||||
{
|
||||
input_poll_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_input_state(retro_input_state_t cb)
|
||||
{
|
||||
input_state_cb = cb;
|
||||
}
|
||||
|
||||
void retro_set_video_refresh(retro_video_refresh_t cb)
|
||||
{
|
||||
video_cb = cb;
|
||||
}
|
||||
|
||||
void retro_reset(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void audio_callback(void)
|
||||
{
|
||||
static unsigned phase;
|
||||
|
||||
for (unsigned i = 0; i < 30000 / 60; i++, phase++)
|
||||
{
|
||||
int16_t val = 0x800 * sinf(2.0f * M_PI * phase * 300.0f / 30000.0f);
|
||||
audio_cb(val, val);
|
||||
}
|
||||
|
||||
phase %= 100;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void retropad_update_input(void)
|
||||
{
|
||||
struct Input
|
||||
{
|
||||
unsigned int l : 1;
|
||||
unsigned int r : 1;
|
||||
unsigned int a : 1;
|
||||
};
|
||||
struct Input current;
|
||||
static struct Input last;
|
||||
|
||||
input_poll_cb();
|
||||
|
||||
/* Commands that are called on rising edge only */
|
||||
|
||||
/* A ternary operator is used since input_state_cb returns an int16_t, but
|
||||
* we only care about whether the button is on or off which is why we store
|
||||
* the value in a single bit for each button.
|
||||
*
|
||||
* Unsure if saving the memory is worth the extra checks, costing CPU time,
|
||||
* but both are incredibly miniscule anyway.
|
||||
*/
|
||||
current.l = input_state_cb(0, RETRO_DEVICE_JOYPAD,
|
||||
0, RETRO_DEVICE_ID_JOYPAD_L) != 0 ? 1 : 0;
|
||||
current.r = input_state_cb(0, RETRO_DEVICE_JOYPAD,
|
||||
0, RETRO_DEVICE_ID_JOYPAD_R) != 0 ? 1 : 0;
|
||||
current.a = input_state_cb(0, RETRO_DEVICE_JOYPAD,
|
||||
0, RETRO_DEVICE_ID_JOYPAD_A) != 0 ? 1 : 0;
|
||||
|
||||
if(current.l == 1 && last.l == 0)
|
||||
mpv_command_string(mpv, "cycle audio");
|
||||
|
||||
if(current.r == 1 && last.r == 0)
|
||||
mpv_command_string(mpv, "cycle sub");
|
||||
|
||||
if(current.a == 1 && last.a == 0)
|
||||
mpv_command_string(mpv, "cycle pause");
|
||||
|
||||
/* TODO #3: Press and hold commands with small delay */
|
||||
if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0,
|
||||
RETRO_DEVICE_ID_JOYPAD_LEFT))
|
||||
mpv_command_string(mpv, "seek -5");
|
||||
|
||||
if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0,
|
||||
RETRO_DEVICE_ID_JOYPAD_RIGHT))
|
||||
mpv_command_string(mpv, "seek 5");
|
||||
|
||||
if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0,
|
||||
RETRO_DEVICE_ID_JOYPAD_UP))
|
||||
mpv_command_string(mpv, "seek 60");
|
||||
|
||||
if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0,
|
||||
RETRO_DEVICE_ID_JOYPAD_DOWN))
|
||||
mpv_command_string(mpv, "seek -60");
|
||||
|
||||
/* Press and hold commands */
|
||||
if(input_state_cb(0, RETRO_DEVICE_JOYPAD, 0,
|
||||
RETRO_DEVICE_ID_JOYPAD_X))
|
||||
mpv_command_string(mpv, "show-progress");
|
||||
|
||||
/* Instead of copying the structs as though they were a union, we assign
|
||||
* each variable one-by-one to avoid endian issues.
|
||||
*/
|
||||
last.l = current.l;
|
||||
last.r = current.r;
|
||||
last.a = current.a;
|
||||
}
|
||||
|
||||
void retro_run(void)
|
||||
{
|
||||
/* We only need to update the base video size once, and we do it here since
|
||||
* the input file is not processed during the first
|
||||
* retro_get_system_av_info() call.
|
||||
*/
|
||||
static bool updated_video_dimensions = false;
|
||||
static int64_t width, height;
|
||||
|
||||
if(updated_video_dimensions == false)
|
||||
{
|
||||
mpv_get_property(mpv, "dwidth", MPV_FORMAT_INT64, &width);
|
||||
mpv_get_property(mpv, "dheight", MPV_FORMAT_INT64, &height);
|
||||
|
||||
struct retro_game_geometry geometry = {
|
||||
.base_width = width,
|
||||
.base_height = height,
|
||||
/* max_width and max_height are ignored */
|
||||
.max_width = width,
|
||||
.max_height = height,
|
||||
/* Aspect ratio calculated automatically from base dimensions */
|
||||
.aspect_ratio = -1,
|
||||
};
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &geometry);
|
||||
updated_video_dimensions = true;
|
||||
}
|
||||
|
||||
/* Print out mpv logs */
|
||||
if(event_waiting > 0)
|
||||
{
|
||||
while(1)
|
||||
{
|
||||
mpv_event *mp_event = mpv_wait_event(mpv, 0);
|
||||
if(mp_event->event_id == MPV_EVENT_NONE)
|
||||
break;
|
||||
|
||||
log_cb(RETRO_LOG_INFO, "mpv: ");
|
||||
if(mp_event->event_id == MPV_EVENT_LOG_MESSAGE)
|
||||
{
|
||||
struct mpv_event_log_message *msg =
|
||||
(struct mpv_event_log_message *)mp_event->data;
|
||||
log_cb(RETRO_LOG_INFO, "[%s] %s: %s",
|
||||
msg->prefix, msg->level, msg->text);
|
||||
}
|
||||
else
|
||||
log_cb(RETRO_LOG_INFO, "%s\n", mpv_event_name(mp_event->event_id));
|
||||
}
|
||||
|
||||
event_waiting = 0;
|
||||
}
|
||||
|
||||
retropad_update_input();
|
||||
/* TODO #2: Implement an audio callback feature in to libmpv */
|
||||
/* audio_callback(); */
|
||||
|
||||
mpv_opengl_cb_draw(mpv_gl, hw_render.get_current_framebuffer(), width, height);
|
||||
video_cb(RETRO_HW_FRAME_BUFFER_VALID, width, height, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/* No save-state support */
|
||||
size_t retro_serialize_size(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool retro_serialize(void *data_, size_t size)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool retro_unserialize(const void *data_, size_t size)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool retro_load_game(const struct retro_game_info *info)
|
||||
{
|
||||
/* Supported on most systems. */
|
||||
enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_XRGB8888;
|
||||
struct retro_input_descriptor desc[] = {
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A, "Pause/Play" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X, "Show Progress" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT, "Seek -5 seconds" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP, "Seek +60 seconds" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN, "Seek -60 seconds" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT, "Seek +5 seconds" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L, "Cycle Audio Track" },
|
||||
{ 0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R, "Cycle Subtitle Track" },
|
||||
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
/* Copy the file path to a global variable as we need it in context_reset()
|
||||
* where mpv is initialised.
|
||||
*/
|
||||
filepath = strdup(info->path);
|
||||
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS, desc);
|
||||
|
||||
/* Not bothered if this fails. Assuming the default is selected anyway. */
|
||||
if(!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "XRGB8888 is not supported.\n");
|
||||
|
||||
/* Try RGB565 */
|
||||
fmt = RETRO_PIXEL_FORMAT_RGB565;
|
||||
environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt);
|
||||
}
|
||||
|
||||
if(!retro_init_hw_context())
|
||||
{
|
||||
log_cb(RETRO_LOG_ERROR, "HW Context could not be initialized\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool retro_load_game_special(unsigned type, const struct retro_game_info *info,
|
||||
size_t num)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void retro_unload_game(void)
|
||||
{
|
||||
free(filepath);
|
||||
filepath = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned retro_get_region(void)
|
||||
{
|
||||
return RETRO_REGION_NTSC;
|
||||
}
|
||||
|
||||
void *retro_get_memory_data(unsigned id)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t retro_get_memory_size(unsigned id)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void retro_cheat_reset(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||
{
|
||||
return;
|
||||
}
|
3
cores/libretro-mpv/version.h
Normal file
3
cores/libretro-mpv/version.h
Normal file
@ -0,0 +1,3 @@
|
||||
#ifndef LIBRETRO_MPV_VERSION
|
||||
#define LIBRETRO_MPV_VERSION "0.2.alpha"
|
||||
#endif
|
@ -65,118 +65,6 @@
|
||||
#include "paths.h"
|
||||
#include "verbosity.h"
|
||||
|
||||
void fill_pathname_expand_special(char *out_path,
|
||||
const char *in_path, size_t size)
|
||||
{
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
if (*in_path == '~')
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
if (home)
|
||||
{
|
||||
size_t src_size = strlcpy(out_path, home, size);
|
||||
retro_assert(src_size < size);
|
||||
|
||||
out_path += src_size;
|
||||
size -= src_size;
|
||||
in_path++;
|
||||
}
|
||||
}
|
||||
else if ((in_path[0] == ':') &&
|
||||
(
|
||||
(in_path[1] == '/')
|
||||
#ifdef _WIN32
|
||||
|| (in_path[1] == '\\')
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
size_t src_size;
|
||||
char *application_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
application_dir[0] = '\0';
|
||||
|
||||
fill_pathname_application_path(application_dir,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
path_basedir_wrapper(application_dir);
|
||||
|
||||
src_size = strlcpy(out_path, application_dir, size);
|
||||
retro_assert(src_size < size);
|
||||
|
||||
free(application_dir);
|
||||
|
||||
out_path += src_size;
|
||||
size -= src_size;
|
||||
in_path += 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
retro_assert(strlcpy(out_path, in_path, size) < size);
|
||||
}
|
||||
|
||||
|
||||
void fill_pathname_abbreviate_special(char *out_path,
|
||||
const char *in_path, size_t size)
|
||||
{
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
unsigned i;
|
||||
const char *candidates[3];
|
||||
const char *notations[3];
|
||||
char *application_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
const char *home = getenv("HOME");
|
||||
|
||||
application_dir[0] = '\0';
|
||||
|
||||
/* application_dir could be zero-string. Safeguard against this.
|
||||
*
|
||||
* Keep application dir in front of home, moving app dir to a
|
||||
* new location inside home would break otherwise. */
|
||||
|
||||
/* ugly hack - use application_dir pointer
|
||||
* before filling it in. C89 reasons */
|
||||
candidates[0] = application_dir;
|
||||
candidates[1] = home;
|
||||
candidates[2] = NULL;
|
||||
|
||||
notations [0] = ":";
|
||||
notations [1] = "~";
|
||||
notations [2] = NULL;
|
||||
|
||||
fill_pathname_application_path(application_dir,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
path_basedir_wrapper(application_dir);
|
||||
|
||||
for (i = 0; candidates[i]; i++)
|
||||
{
|
||||
if (!string_is_empty(candidates[i]) &&
|
||||
strstr(in_path, candidates[i]) == in_path)
|
||||
{
|
||||
size_t src_size = strlcpy(out_path, notations[i], size);
|
||||
|
||||
retro_assert(src_size < size);
|
||||
|
||||
out_path += src_size;
|
||||
size -= src_size;
|
||||
in_path += strlen(candidates[i]);
|
||||
|
||||
if (!path_char_is_slash(*in_path))
|
||||
{
|
||||
retro_assert(strlcpy(out_path,
|
||||
path_default_slash(), size) < size);
|
||||
out_path++;
|
||||
size--;
|
||||
}
|
||||
|
||||
break; /* Don't allow more abbrevs to take place. */
|
||||
}
|
||||
}
|
||||
|
||||
free(application_dir);
|
||||
#endif
|
||||
|
||||
retro_assert(strlcpy(out_path, in_path, size) < size);
|
||||
}
|
||||
|
||||
bool fill_pathname_application_data(char *s, size_t len)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(_XBOX)
|
||||
@ -240,103 +128,6 @@ bool fill_pathname_application_data(char *s, size_t len)
|
||||
return false;
|
||||
}
|
||||
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
void fill_pathname_application_path(char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
#ifdef __APPLE__
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
DWORD ret;
|
||||
wchar_t wstr[PATH_MAX_LENGTH] = {0};
|
||||
#endif
|
||||
#ifdef __HAIKU__
|
||||
image_info info;
|
||||
int32_t cookie = 0;
|
||||
#endif
|
||||
(void)i;
|
||||
|
||||
if (!len)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef LEGACY_WIN32
|
||||
ret = GetModuleFileNameA(GetModuleHandle(NULL), s, len);
|
||||
#else
|
||||
ret = GetModuleFileNameW(GetModuleHandle(NULL), wstr, ARRAY_SIZE(wstr));
|
||||
|
||||
if (*wstr)
|
||||
{
|
||||
char *str = utf16_to_utf8_string_alloc(wstr);
|
||||
|
||||
if (str)
|
||||
{
|
||||
strlcpy(s, str, len);
|
||||
free(str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
s[ret] = '\0';
|
||||
#elif defined(__APPLE__)
|
||||
if (bundle)
|
||||
{
|
||||
CFURLRef bundle_url = CFBundleCopyBundleURL(bundle);
|
||||
CFStringRef bundle_path = CFURLCopyPath(bundle_url);
|
||||
CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8);
|
||||
CFRelease(bundle_path);
|
||||
CFRelease(bundle_url);
|
||||
|
||||
retro_assert(strlcat(s, "nobin", len) < len);
|
||||
return;
|
||||
}
|
||||
#elif defined(__HAIKU__)
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK)
|
||||
{
|
||||
if (info.type == B_APP_IMAGE)
|
||||
{
|
||||
strlcpy(s, info.name, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#elif defined(__QNX__)
|
||||
char *buff = malloc(len);
|
||||
|
||||
if(_cmdname(buff))
|
||||
strlcpy(s, buff, len);
|
||||
|
||||
free(buff);
|
||||
#else
|
||||
{
|
||||
pid_t pid;
|
||||
static const char *exts[] = { "exe", "file", "path/a.out" };
|
||||
char link_path[255];
|
||||
|
||||
link_path[0] = *s = '\0';
|
||||
pid = getpid();
|
||||
|
||||
/* Linux, BSD and Solaris paths. Not standardized. */
|
||||
for (i = 0; i < ARRAY_SIZE(exts); i++)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
|
||||
(unsigned)pid, exts[i]);
|
||||
ret = readlink(link_path, s, len - 1);
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
s[ret] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RARCH_ERR("Cannot resolve application path! This should not happen.\n");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XMB
|
||||
const char* xmb_theme_ident(void);
|
||||
#endif
|
||||
@ -626,31 +417,3 @@ void fill_short_pathname_representation_wrapper(char* out_rep,
|
||||
fill_short_pathname_representation(out_rep, in_path, size);
|
||||
free(path_short);
|
||||
}
|
||||
|
||||
/**
|
||||
* path_basedir:
|
||||
* @path : path
|
||||
*
|
||||
* Extracts base directory by mutating path.
|
||||
* Keeps trailing '/'.
|
||||
**/
|
||||
void path_basedir_wrapper(char *path)
|
||||
{
|
||||
char *last = NULL;
|
||||
if (strlen(path) < 2)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_COMPRESSION
|
||||
/* We want to find the directory with the archive in basedir. */
|
||||
last = (char*)path_get_archive_delim(path);
|
||||
if (last)
|
||||
*last = '\0';
|
||||
#endif
|
||||
|
||||
last = find_last_slash(path);
|
||||
|
||||
if (last)
|
||||
last[1] = '\0';
|
||||
else
|
||||
snprintf(path, 3, ".%s", path_default_slash());
|
||||
}
|
||||
|
@ -130,15 +130,6 @@ enum application_special_type
|
||||
void fill_short_pathname_representation_wrapper(char* out_rep,
|
||||
const char *in_path, size_t size);
|
||||
|
||||
/**
|
||||
* path_basedir:
|
||||
* @path : path
|
||||
*
|
||||
* Extracts base directory by mutating path.
|
||||
* Keeps trailing '/'.
|
||||
**/
|
||||
void path_basedir_wrapper(char *path);
|
||||
|
||||
const char *file_path_str(enum file_path_enum enum_idx);
|
||||
|
||||
bool fill_pathname_application_data(char *s, size_t len);
|
||||
|
@ -1183,6 +1183,27 @@ bool d3d_set_vertex_shader(LPDIRECT3DDEVICE dev, unsigned index,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool d3d_set_vertex_shader_constantf(LPDIRECT3DDEVICE dev,
|
||||
UINT start_register,const float* constant_data,
|
||||
unsigned vector4f_count)
|
||||
{
|
||||
#if defined(HAVE_D3D9)
|
||||
#ifdef __cplusplus
|
||||
return (dev->SetVertexShaderConstantF(
|
||||
start_register, constant_data, vector4f_count) == D3D_OK);
|
||||
#else
|
||||
#ifdef _XBOX
|
||||
IDirect3DDevice9_SetVertexShaderConstantF(dev,
|
||||
start_register, constant_data, vector4f_count);
|
||||
return true;
|
||||
#else
|
||||
return (IDirect3DDevice9_SetVertexShaderConstantF(dev,
|
||||
start_register, constant_data, vector4f_count) == D3D_OK);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void d3d_texture_blit(unsigned pixel_size,
|
||||
LPDIRECT3DTEXTURE tex, D3DLOCKED_RECT *lr, const void *frame,
|
||||
@ -1208,6 +1229,31 @@ void d3d_texture_blit(unsigned pixel_size,
|
||||
}
|
||||
}
|
||||
|
||||
bool d3d_get_render_state(void *data, D3DRENDERSTATETYPE state, DWORD *value)
|
||||
{
|
||||
LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data;
|
||||
|
||||
if (!dev)
|
||||
return false;
|
||||
|
||||
#if defined(HAVE_D3D9) && !defined(__cplusplus)
|
||||
#ifdef _XBOX
|
||||
IDirect3DDevice9_GetRenderState(dev, state, value);
|
||||
return true;
|
||||
#else
|
||||
if (IDirect3DDevice9_GetRenderState(dev, state, value) == D3D_OK)
|
||||
return true;
|
||||
#endif
|
||||
#elif defined(HAVE_D3D8) && !defined(__cplusplus)
|
||||
if (IDirect3DDevice8_GetRenderState(dev, state, value) == D3D_OK)
|
||||
return true;
|
||||
#else
|
||||
if (dev->GetRenderState(state, value) == D3D_OK)
|
||||
return true;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value)
|
||||
{
|
||||
LPDIRECT3DDEVICE dev = (LPDIRECT3DDEVICE)data;
|
||||
|
@ -111,6 +111,9 @@ bool d3d_set_pixel_shader(LPDIRECT3DDEVICE dev, void *data);
|
||||
bool d3d_set_vertex_shader(LPDIRECT3DDEVICE dev, unsigned index,
|
||||
void *data);
|
||||
|
||||
bool d3d_set_vertex_shader_constantf(LPDIRECT3DDEVICE dev,
|
||||
UINT start_register,const float* constant_data, unsigned vector4f_count);
|
||||
|
||||
void d3d_texture_blit(unsigned pixel_size,
|
||||
LPDIRECT3DTEXTURE tex,
|
||||
D3DLOCKED_RECT *lr, const void *frame,
|
||||
@ -144,7 +147,11 @@ bool d3d_device_get_render_target(LPDIRECT3DDEVICE dev,
|
||||
void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
|
||||
void *data);
|
||||
|
||||
void d3d_set_render_state(void *data, D3DRENDERSTATETYPE state, DWORD value);
|
||||
bool d3d_get_render_state(void *data,
|
||||
D3DRENDERSTATETYPE state, DWORD *value);
|
||||
|
||||
void d3d_set_render_state(void *data,
|
||||
D3DRENDERSTATETYPE state, DWORD value);
|
||||
|
||||
void d3d_device_set_render_target(LPDIRECT3DDEVICE dev, unsigned idx,
|
||||
void *data);
|
||||
|
@ -339,6 +339,14 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp)
|
||||
d3d->renderchain_driver->viewport_info(d3d, vp);
|
||||
}
|
||||
|
||||
static void d3d_set_mvp(void *data,
|
||||
void *shader_data,
|
||||
const void *mat_data)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
d3d->renderchain_driver->set_mvp(d3d, d3d->renderchain_data, shader_data, mat_data);
|
||||
}
|
||||
|
||||
static void d3d_overlay_render(d3d_video_t *d3d,
|
||||
video_frame_info_t *video_info,
|
||||
overlay_t *overlay)
|
||||
@ -347,7 +355,6 @@ static void d3d_overlay_render(d3d_video_t *d3d,
|
||||
void *verts;
|
||||
unsigned i;
|
||||
float vert[4][9];
|
||||
float overlay_width, overlay_height;
|
||||
unsigned width = video_info->width;
|
||||
unsigned height = video_info->height;
|
||||
|
||||
@ -374,21 +381,14 @@ static void d3d_overlay_render(d3d_video_t *d3d,
|
||||
|
||||
d3d_viewport_info(d3d, &vp);
|
||||
|
||||
overlay_width = vp.width;
|
||||
overlay_height = vp.height;
|
||||
|
||||
vert[0][0] = overlay->vert_coords[0] * overlay_width;
|
||||
vert[1][0] = (overlay->vert_coords[0] + overlay->vert_coords[2])
|
||||
* overlay_width;
|
||||
vert[2][0] = overlay->vert_coords[0] * overlay_width;
|
||||
vert[3][0] = (overlay->vert_coords[0] + overlay->vert_coords[2])
|
||||
* overlay_width;
|
||||
vert[0][1] = overlay->vert_coords[1] * overlay_height;
|
||||
vert[1][1] = overlay->vert_coords[1] * overlay_height;
|
||||
vert[2][1] = (overlay->vert_coords[1] + overlay->vert_coords[3])
|
||||
* overlay_height;
|
||||
vert[3][1] = (overlay->vert_coords[1] + overlay->vert_coords[3])
|
||||
* overlay_height;
|
||||
vert[0][0] = overlay->vert_coords[0];
|
||||
vert[1][0] = overlay->vert_coords[0] + overlay->vert_coords[2];
|
||||
vert[2][0] = overlay->vert_coords[0];
|
||||
vert[3][0] = overlay->vert_coords[0] + overlay->vert_coords[2];
|
||||
vert[0][1] = overlay->vert_coords[1];
|
||||
vert[1][1] = overlay->vert_coords[1];
|
||||
vert[2][1] = overlay->vert_coords[1] + overlay->vert_coords[3];
|
||||
vert[3][1] = overlay->vert_coords[1] + overlay->vert_coords[3];
|
||||
|
||||
vert[0][3] = overlay->tex_coords[0];
|
||||
vert[1][3] = overlay->tex_coords[0] + overlay->tex_coords[2];
|
||||
@ -399,13 +399,6 @@ static void d3d_overlay_render(d3d_video_t *d3d,
|
||||
vert[2][4] = overlay->tex_coords[1] + overlay->tex_coords[3];
|
||||
vert[3][4] = overlay->tex_coords[1] + overlay->tex_coords[3];
|
||||
|
||||
/* Align texels and vertices. */
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
vert[i][0] -= 0.5f;
|
||||
vert[i][1] += 0.5f;
|
||||
}
|
||||
|
||||
verts = d3d_vertex_buffer_lock(overlay->vert_buf);
|
||||
memcpy(verts, vert, sizeof(vert));
|
||||
d3d_vertex_buffer_unlock(overlay->vert_buf);
|
||||
@ -825,6 +818,13 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
unsigned width, height;
|
||||
bool ret = true;
|
||||
settings_t *settings = config_get_ptr();
|
||||
static const D3DVERTEXELEMENT VertexElements[] =
|
||||
{
|
||||
{ 0, 0 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||
{ 0, 2 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
||||
{ 0, 4 * sizeof(float), D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
||||
D3DDECL_END()
|
||||
};
|
||||
|
||||
if (!d3d)
|
||||
return false;
|
||||
@ -877,14 +877,6 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
info->is_threaded,
|
||||
FONT_DRIVER_RENDER_DIRECT3D_API);
|
||||
|
||||
static const D3DVERTEXELEMENT VertexElements[] =
|
||||
{
|
||||
{ 0, 0 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
|
||||
{ 0, 2 * sizeof(float), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
|
||||
{ 0, 4 * sizeof(float), D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_COLOR, 0 },
|
||||
D3DDECL_END()
|
||||
};
|
||||
|
||||
if (!d3d_vertex_declaration_new(d3d->dev,
|
||||
(void*)VertexElements, (void**)&d3d->menu_display.decl))
|
||||
return false;
|
||||
@ -899,6 +891,11 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info)
|
||||
if (!d3d->menu_display.buffer)
|
||||
return false;
|
||||
|
||||
d3d_matrix_ortho_off_center_lh(&d3d->mvp_transposed, 0, 1, 0, 1, 0, 1);
|
||||
d3d_matrix_transpose(&d3d->mvp, &d3d->mvp_transposed);
|
||||
|
||||
d3d_set_render_state(d3d->dev, D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1537,16 +1534,18 @@ static bool d3d_frame(void *data, const void *frame,
|
||||
return false;
|
||||
}
|
||||
|
||||
d3d->renderchain_driver->set_mvp(d3d->renderchain_data, d3d, screen_vp.Width, screen_vp.Height, 0);
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (d3d->menu && d3d->menu->enabled)
|
||||
{
|
||||
d3d_set_mvp(d3d, NULL, &d3d->mvp);
|
||||
d3d_overlay_render(d3d, video_info, d3d->menu);
|
||||
|
||||
d3d->menu_display.offset = 0;
|
||||
d3d_set_vertex_declaration(d3d->dev, d3d->menu_display.decl);
|
||||
d3d_set_stream_source(d3d->dev, 0, d3d->menu_display.buffer, 0, 8 * sizeof(float));
|
||||
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
menu_driver_frame(video_info);
|
||||
}
|
||||
#endif
|
||||
@ -1554,13 +1553,17 @@ static bool d3d_frame(void *data, const void *frame,
|
||||
#ifdef HAVE_OVERLAY
|
||||
if (d3d->overlays_enabled)
|
||||
{
|
||||
d3d_set_mvp(d3d, NULL, &d3d->mvp);
|
||||
for (i = 0; i < d3d->overlays_size; i++)
|
||||
d3d_overlay_render(d3d, video_info, &d3d->overlays[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (msg && *msg)
|
||||
{
|
||||
d3d_set_viewports(d3d->dev, &screen_vp);
|
||||
font_driver_render_msg(video_info, NULL, msg, NULL);
|
||||
}
|
||||
|
||||
video_info->cb_update_window_title(
|
||||
video_info->context_data, video_info);
|
||||
@ -1724,9 +1727,11 @@ static void video_texture_load_d3d(d3d_video_t *d3d,
|
||||
LPDIRECT3DTEXTURE tex = NULL;
|
||||
unsigned usage = 0;
|
||||
|
||||
#ifndef _XBOX
|
||||
if((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) ||
|
||||
(filter_type == TEXTURE_FILTER_MIPMAP_NEAREST))
|
||||
usage |= D3DUSAGE_AUTOGENMIPMAP;
|
||||
#endif
|
||||
|
||||
tex = d3d_texture_new(d3d->dev, NULL,
|
||||
ti->width, ti->height, 0,
|
||||
@ -1809,18 +1814,6 @@ static void d3d_unload_texture(void *data, uintptr_t id)
|
||||
d3d_texture_free(texid);
|
||||
}
|
||||
|
||||
static void d3d_set_mvp(void *data,
|
||||
void *shader_data,
|
||||
const void *mat_data)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
if (d3d && d3d->renderchain_driver->set_mvp)
|
||||
d3d->renderchain_driver->set_mvp(
|
||||
d3d->renderchain_data,
|
||||
data,
|
||||
640, 480, 0);
|
||||
}
|
||||
|
||||
static const video_poke_interface_t d3d_poke_interface = {
|
||||
NULL, /* set_coords */
|
||||
d3d_set_mvp,
|
||||
|
@ -17,6 +17,8 @@
|
||||
#ifndef __D3DVIDEO_INTF_H__
|
||||
#define __D3DVIDEO_INTF_H__
|
||||
|
||||
#include <gfx/math/matrix_4x4.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
@ -83,6 +85,8 @@ typedef struct d3d_video
|
||||
|
||||
RECT font_rect;
|
||||
RECT font_rect_shifted;
|
||||
math_matrix_4x4 mvp;
|
||||
math_matrix_4x4 mvp_transposed;
|
||||
|
||||
struct video_viewport vp;
|
||||
struct video_shader shader;
|
||||
|
@ -39,8 +39,8 @@ typedef struct
|
||||
#else
|
||||
ID3DXFont *font;
|
||||
#endif
|
||||
uint32_t color;
|
||||
uint32_t font_size;
|
||||
uint32_t ascent;
|
||||
} d3dfonts_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -49,9 +49,11 @@ typedef struct
|
||||
|
||||
#if !defined(__cplusplus) || defined(CINTERFACE)
|
||||
#define IDirect3DXFont_DrawTextA(p, a, b, c, d, e, f) (p)->lpVtbl->DrawTextA(p, a, b, c, d, e, f)
|
||||
#define IDirect3DXFont_GetTextMetricsA(p, a) (p)->lpVtbl->GetTextMetricsA(p, a)
|
||||
#define IDirect3DXFont_Release(p) (p)->lpVtbl->Release(p)
|
||||
#else
|
||||
#define IDirect3DXFont_DrawTextA(p, a, b, c, d, e, f) (p)->DrawTextA(a, b, c, d, e, f)
|
||||
#define IDirect3DXFont_GetTextMetricsA(p, a) (p)->GetTextMetricsA(a)
|
||||
#define IDirect3DXFont_Release(p) (p)->Release()
|
||||
#endif
|
||||
|
||||
@ -74,24 +76,20 @@ static void *d3dfonts_w32_init_font(void *video_data,
|
||||
#endif
|
||||
};
|
||||
d3dfonts_t *d3dfonts = (d3dfonts_t*)calloc(1, sizeof(*d3dfonts));
|
||||
uint32_t r = (settings->floats.video_msg_color_r * 255);
|
||||
uint32_t g = (settings->floats.video_msg_color_g * 255);
|
||||
uint32_t b = (settings->floats.video_msg_color_b * 255);
|
||||
r &= 0xff;
|
||||
g &= 0xff;
|
||||
b &= 0xff;
|
||||
|
||||
if (!d3dfonts)
|
||||
return NULL;
|
||||
|
||||
d3dfonts->font_size = font_size;
|
||||
d3dfonts->font_size = font_size * 1.2; /* to match the other font drivers */
|
||||
d3dfonts->d3d = (d3d_video_t*)video_data;
|
||||
d3dfonts->color = D3DCOLOR_XRGB(r, g, b);
|
||||
|
||||
desc.Height = d3dfonts->font_size;
|
||||
if (!d3dx_create_font_indirect(d3dfonts->d3d->dev,
|
||||
&desc, (void**)&d3dfonts->font))
|
||||
goto error;
|
||||
|
||||
IDirect3DXFont_GetTextMetricsA(d3dfonts->font, &metrics);
|
||||
d3dfonts->ascent = metrics.tmAscent;
|
||||
|
||||
return d3dfonts;
|
||||
|
||||
error:
|
||||
@ -131,7 +129,8 @@ static int d3dfonts_w32_get_message_width(void* data, const char* msg,
|
||||
static void d3dfonts_w32_render_msg(video_frame_info_t *video_info, void *data, const char *msg,
|
||||
const void *userdata)
|
||||
{
|
||||
unsigned color, format;
|
||||
unsigned format;
|
||||
unsigned a, r, g, b;
|
||||
RECT rect, *p_rect;
|
||||
RECT rect_shifted, *p_rect_shifted;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -152,22 +151,18 @@ static void d3dfonts_w32_render_msg(video_frame_info_t *video_info, void *data,
|
||||
if (!d3d_begin_scene(d3dfonts->d3d->dev))
|
||||
return;
|
||||
|
||||
color = d3dfonts->color;
|
||||
format = DT_LEFT;
|
||||
p_rect = &d3dfonts->d3d->font_rect;
|
||||
p_rect_shifted = &d3dfonts->d3d->font_rect_shifted;
|
||||
|
||||
if(params)
|
||||
{
|
||||
unsigned a, r, g, b;
|
||||
|
||||
a = FONT_COLOR_GET_ALPHA(params->color);
|
||||
r = FONT_COLOR_GET_RED(params->color);
|
||||
g = FONT_COLOR_GET_GREEN(params->color);
|
||||
b = FONT_COLOR_GET_BLUE(params->color);
|
||||
|
||||
color = D3DCOLOR_ARGB(a, r, g, b);
|
||||
|
||||
switch (params->text_align)
|
||||
{
|
||||
case TEXT_ALIGN_RIGHT:
|
||||
@ -188,7 +183,7 @@ static void d3dfonts_w32_render_msg(video_frame_info_t *video_info, void *data,
|
||||
break;
|
||||
}
|
||||
|
||||
rect.top = (1.0 - params->y) * height - d3dfonts->font_size;
|
||||
rect.top = (1.0 - params->y) * height - d3dfonts->ascent;
|
||||
rect.bottom = height;
|
||||
p_rect = ▭
|
||||
|
||||
@ -207,22 +202,30 @@ static void d3dfonts_w32_render_msg(video_frame_info_t *video_info, void *data,
|
||||
p_rect_shifted = &rect_shifted;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
a = 255;
|
||||
r = video_info->font_msg_color_r * 255;
|
||||
g = video_info->font_msg_color_g * 255;
|
||||
b = video_info->font_msg_color_b * 255;
|
||||
}
|
||||
|
||||
if(drop_x || drop_y)
|
||||
{
|
||||
unsigned a, r, g, b;
|
||||
unsigned drop_a, drop_r, drop_g, drop_b;
|
||||
|
||||
a = FONT_COLOR_GET_ALPHA(color) * drop_alpha;
|
||||
r = FONT_COLOR_GET_RED(color) * drop_mod;
|
||||
g = FONT_COLOR_GET_GREEN(color) * drop_mod;
|
||||
b = FONT_COLOR_GET_BLUE(color) * drop_mod;
|
||||
drop_a = a * drop_alpha;
|
||||
drop_r = r * drop_mod;
|
||||
drop_g = g * drop_mod;
|
||||
drop_b = b * drop_mod;
|
||||
|
||||
IDirect3DXFont_DrawTextA(d3dfonts->font, NULL, msg, -1,
|
||||
p_rect_shifted, format, D3DCOLOR_ARGB(a, r, g, b));
|
||||
IDirect3DXFont_DrawTextA(d3dfonts->font, NULL, msg, -1, p_rect_shifted, format,
|
||||
D3DCOLOR_ARGB(drop_a , drop_r, drop_g, drop_b));
|
||||
}
|
||||
|
||||
|
||||
IDirect3DXFont_DrawTextA(d3dfonts->font, NULL, msg, -1,
|
||||
p_rect, format, color);
|
||||
p_rect, format, D3DCOLOR_ARGB(a, r, g, b));
|
||||
|
||||
d3d_end_scene(d3dfonts->d3d->dev);
|
||||
}
|
||||
|
@ -79,7 +79,6 @@ class PackedResource
|
||||
|
||||
XBRESOURCE* m_pResourceTags; /* Tags to associate names with the resources */
|
||||
DWORD m_dwNumResourceTags; /* Number of resource tags */
|
||||
BOOL m_bInitialized; /* Resource is fully initialized */
|
||||
|
||||
public:
|
||||
/* Loads the resources out of the specified bundle */
|
||||
@ -92,7 +91,7 @@ class PackedResource
|
||||
|
||||
void Destroy();
|
||||
|
||||
BOOL Initialized() const;
|
||||
BOOL m_bInitialized; /* Resource is fully initialized */
|
||||
|
||||
#ifdef _XBOX360
|
||||
/* Retrieves the resource tags */
|
||||
@ -120,30 +119,11 @@ class PackedResource
|
||||
return pResource;
|
||||
}
|
||||
|
||||
/* Functions to retrieve resources by their offset */
|
||||
void *GetData( DWORD dwOffset ) const
|
||||
{ return &m_pSysMemData[dwOffset]; }
|
||||
|
||||
LPDIRECT3DRESOURCE GetResource( DWORD dwOffset ) const
|
||||
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData(dwOffset) ); }
|
||||
|
||||
LPDIRECT3DTEXTURE GetTexture( DWORD dwOffset ) const
|
||||
{ return (LPDIRECT3DTEXTURE)GetResource( dwOffset ); }
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( DWORD dwOffset ) const
|
||||
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( dwOffset ); }
|
||||
|
||||
/* Functions to retrieve resources by their name */
|
||||
void *GetData( const char* strName ) const;
|
||||
|
||||
LPDIRECT3DRESOURCE GetResource( const char* strName ) const
|
||||
{ return RegisterResource( (LPDIRECT3DRESOURCE)GetData( strName ) ); }
|
||||
|
||||
LPDIRECT3DTEXTURE GetTexture( const char* strName ) const
|
||||
{ return (LPDIRECT3DTEXTURE)GetResource( strName ); }
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER GetVertexBuffer( const char* strName ) const
|
||||
{ return (LPDIRECT3DVERTEXBUFFER)GetResource( strName ); }
|
||||
{ return (LPDIRECT3DTEXTURE)RegisterResource((LPDIRECT3DRESOURCE)GetData(strName)); }
|
||||
|
||||
/* Constructor/destructor */
|
||||
PackedResource();
|
||||
@ -152,13 +132,13 @@ class PackedResource
|
||||
|
||||
PackedResource::PackedResource()
|
||||
{
|
||||
m_pSysMemData = NULL;
|
||||
m_dwSysMemDataSize = 0L;
|
||||
m_pVidMemData = NULL;
|
||||
m_dwVidMemDataSize = 0L;
|
||||
m_pResourceTags = NULL;
|
||||
m_pSysMemData = NULL;
|
||||
m_pVidMemData = NULL;
|
||||
m_pResourceTags = NULL;
|
||||
m_dwSysMemDataSize = 0L;
|
||||
m_dwVidMemDataSize = 0L;
|
||||
m_dwNumResourceTags = 0L;
|
||||
m_bInitialized = FALSE;
|
||||
m_bInitialized = false;
|
||||
}
|
||||
|
||||
|
||||
@ -169,18 +149,18 @@ PackedResource::~PackedResource()
|
||||
|
||||
void *PackedResource::GetData(const char *strName) const
|
||||
{
|
||||
if (m_pResourceTags == NULL || strName == NULL)
|
||||
if (!m_pResourceTags || !strName)
|
||||
return NULL;
|
||||
|
||||
#if defined(_XBOX1)
|
||||
for (DWORD i=0; m_pResourceTags[i].strName; i++)
|
||||
#elif defined(_XBOX360)
|
||||
for (DWORD i = 0; i < m_dwNumResourceTags; i++)
|
||||
for (DWORD i = 0; i < m_dwNumResourceTags; i++)
|
||||
#endif
|
||||
{
|
||||
if (string_is_equal_noncase(strName, m_pResourceTags[i].strName))
|
||||
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
|
||||
}
|
||||
{
|
||||
if (string_is_equal_noncase(strName, m_pResourceTags[i].strName))
|
||||
return &m_pSysMemData[m_pResourceTags[i].dwOffset];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -210,7 +190,7 @@ char g_strMediaPath[512] = "D:\\Media\\";
|
||||
|
||||
static HRESULT FindMediaFile(char *strPath, const char *strFilename, size_t strPathsize)
|
||||
{
|
||||
if(strFilename == NULL || strPath == NULL)
|
||||
if (!strFilename || !strPath)
|
||||
return E_INVALIDARG;
|
||||
|
||||
strlcpy(strPath, strFilename, strPathsize);
|
||||
@ -242,10 +222,10 @@ HRESULT PackedResource::Create(const char *strFilename)
|
||||
HANDLE hFile;
|
||||
DWORD dwNumBytesRead;
|
||||
XPR_HEADER xprh;
|
||||
bool retval;
|
||||
bool retval = false;
|
||||
#ifdef _XBOX1
|
||||
BOOL bHasResourceOffsetsTable = FALSE;
|
||||
char strResourcePath[512];
|
||||
bool bHasResourceOffsetsTable = false;
|
||||
|
||||
if (FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath))))
|
||||
return E_FAIL;
|
||||
@ -261,9 +241,9 @@ HRESULT PackedResource::Create(const char *strFilename)
|
||||
|
||||
#if defined(_XBOX1)
|
||||
if(xprh.dwMagic == XPR0_MAGIC_VALUE)
|
||||
bHasResourceOffsetsTable = FALSE;
|
||||
bHasResourceOffsetsTable = false;
|
||||
else if(xprh.dwMagic == XPR1_MAGIC_VALUE)
|
||||
bHasResourceOffsetsTable = TRUE;
|
||||
bHasResourceOffsetsTable = true;
|
||||
else
|
||||
#elif defined(_XBOX360)
|
||||
if(!retval)
|
||||
@ -290,7 +270,8 @@ HRESULT PackedResource::Create(const char *strFilename)
|
||||
|
||||
/* Allocate memory */
|
||||
m_pSysMemData = (BYTE*)malloc(m_dwSysMemDataSize);
|
||||
if (m_pSysMemData == NULL)
|
||||
|
||||
if (!m_pSysMemData)
|
||||
{
|
||||
m_dwSysMemDataSize = 0;
|
||||
return E_FAIL;
|
||||
@ -304,7 +285,7 @@ HRESULT PackedResource::Create(const char *strFilename)
|
||||
#endif
|
||||
);
|
||||
|
||||
if(m_pVidMemData == NULL)
|
||||
if(!m_pVidMemData)
|
||||
{
|
||||
m_dwSysMemDataSize = 0;
|
||||
m_dwVidMemDataSize = 0;
|
||||
@ -360,7 +341,7 @@ HRESULT PackedResource::Create(const char *strFilename)
|
||||
}
|
||||
#endif
|
||||
|
||||
m_bInitialized = TRUE;
|
||||
m_bInitialized = true;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
@ -380,24 +361,18 @@ void PackedResource::GetResourceTags(DWORD* pdwNumResourceTags,
|
||||
void PackedResource::Destroy()
|
||||
{
|
||||
free(m_pSysMemData);
|
||||
m_pSysMemData = NULL;
|
||||
m_dwSysMemDataSize = 0L;
|
||||
|
||||
if (m_pVidMemData != NULL)
|
||||
FreeContiguousMemory(m_pVidMemData);
|
||||
|
||||
m_pVidMemData = NULL;
|
||||
m_dwVidMemDataSize = 0L;
|
||||
|
||||
m_pResourceTags = NULL;
|
||||
m_pSysMemData = NULL;
|
||||
m_pVidMemData = NULL;
|
||||
m_pResourceTags = NULL;
|
||||
m_dwSysMemDataSize = 0L;
|
||||
m_dwVidMemDataSize = 0L;
|
||||
m_dwNumResourceTags = 0L;
|
||||
|
||||
m_bInitialized = FALSE;
|
||||
}
|
||||
|
||||
BOOL PackedResource::Initialized() const
|
||||
{
|
||||
return m_bInitialized;
|
||||
m_bInitialized = false;
|
||||
}
|
||||
|
||||
typedef struct GLYPH_ATTR
|
||||
@ -605,7 +580,7 @@ static void xdk360_free_font(void *data, bool is_threaded)
|
||||
font->s_FontLocals.m_pFontVertexShader = NULL;
|
||||
font->s_FontLocals.m_pFontVertexDecl = NULL;
|
||||
|
||||
if (m_xprResource.Initialized())
|
||||
if (m_xprResource.m_bInitialized)
|
||||
m_xprResource.Destroy();
|
||||
|
||||
free(font);
|
||||
@ -630,7 +605,8 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
|
||||
LPDIRECT3DDEVICE d3dr = font->d3d->dev;
|
||||
|
||||
/* Save state. */
|
||||
d3dr->GetRenderState( D3DRS_VIEWPORTENABLE, (DWORD*)&font->m_dwSavedState );
|
||||
d3d_get_render_state(d3dr, D3DRS_VIEWPORTENABLE,
|
||||
(DWORD*)&font->m_dwSavedState );
|
||||
|
||||
/* Set the texture scaling factor as a vertex shader constant. */
|
||||
/* Get the description */
|
||||
@ -639,8 +615,7 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
|
||||
/* Set render state. */
|
||||
d3d_set_texture(d3dr, 0, font->m_pFontTexture);
|
||||
|
||||
/* Read the TextureDesc here to ensure no load/hit/store from d3d_texture_get_level_desc(). */
|
||||
vTexScale[0] = 1.0f / TextureDesc.Width; /* LHS due to int->float conversion. */
|
||||
vTexScale[0] = 1.0f / TextureDesc.Width;
|
||||
vTexScale[1] = 1.0f / TextureDesc.Height;
|
||||
vTexScale[2] = 0.0f;
|
||||
vTexScale[3] = 0.0f;
|
||||
@ -649,11 +624,7 @@ static void xdk360_render_msg_pre(xdk360_video_font_t * font)
|
||||
d3d_set_vertex_declaration(d3dr, font->s_FontLocals.m_pFontVertexDecl);
|
||||
d3d_set_vertex_shader(d3dr, 0, font->s_FontLocals.m_pFontVertexShader);
|
||||
d3d_set_pixel_shader(d3dr, font->s_FontLocals.m_pFontPixelShader);
|
||||
|
||||
/* Set the texture scaling factor as a vertex shader constant.
|
||||
* Call here to avoid load hit store from writing to vTexScale above
|
||||
*/
|
||||
d3dr->SetVertexShaderConstantF( 2, vTexScale, 1 );
|
||||
d3d_set_vertex_shader_constantf(d3dr, 2, vTexScale, 1);
|
||||
}
|
||||
|
||||
static void xdk360_draw_text(xdk360_video_font_t *font,
|
||||
@ -670,10 +641,7 @@ static void xdk360_draw_text(xdk360_video_font_t *font,
|
||||
vColor[2] = ((0xffffffff & 0x000000ff) >> 0L) / 255.0f;
|
||||
vColor[3] = ((0xffffffff & 0xff000000) >> 24L) / 255.0f;
|
||||
|
||||
/* Perform the actual storing of the color constant here to prevent
|
||||
* a load-hit-store by inserting work between the store and the use of
|
||||
* the vColor array. */
|
||||
d3dr->SetVertexShaderConstantF(1, vColor, 1);
|
||||
d3d_set_vertex_shader_constantf(d3dr, 1, vColor, 1);
|
||||
|
||||
m_fCursorX = floorf(x);
|
||||
m_fCursorY = floorf(y);
|
||||
|
@ -42,23 +42,19 @@ typedef struct d3d8_renderchain
|
||||
} d3d8_renderchain_t;
|
||||
|
||||
static void d3d8_renderchain_set_mvp(
|
||||
void *data,
|
||||
void *chain_data,
|
||||
void *data, unsigned vp_width,
|
||||
unsigned vp_height, unsigned rotation)
|
||||
void *shader_data,
|
||||
const void *mat_data)
|
||||
{
|
||||
D3DMATRIX identity;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||
D3DMATRIX p_out, p_rotate, mat;
|
||||
|
||||
(void)chain_data;
|
||||
d3d_matrix_identity(&identity);
|
||||
|
||||
d3d_matrix_ortho_off_center_lh(&mat, 0, vp_width, vp_height, 0, 0.0f, 1.0f);
|
||||
d3d_matrix_identity(&p_out);
|
||||
d3d_matrix_rotation_z(&p_rotate, rotation * (M_PI / 2.0));
|
||||
|
||||
d3d_set_transform(d3dr, D3DTS_WORLD, &p_rotate);
|
||||
d3d_set_transform(d3dr, D3DTS_VIEW, &p_out);
|
||||
d3d_set_transform(d3dr, D3DTS_PROJECTION, &p_out);
|
||||
d3d_set_transform(d3d->dev, D3DTS_WORLD, &identity);
|
||||
d3d_set_transform(d3d->dev, D3DTS_VIEW, &identity);
|
||||
d3d_set_transform(d3d->dev, D3DTS_PROJECTION, mat_data);
|
||||
}
|
||||
|
||||
static void d3d8_renderchain_clear(void *data)
|
||||
|
@ -1182,6 +1182,14 @@ static void d3d9_cg_renderchain_end_render(cg_renderchain_t *chain)
|
||||
}
|
||||
|
||||
static void d3d9_cg_renderchain_set_shader_mvp(
|
||||
cg_renderchain_t *chain, CGprogram vPrg, D3DMATRIX *matrix)
|
||||
{
|
||||
CGparameter cgpModelViewProj = cgGetNamedParameter(vPrg, "modelViewProj");
|
||||
if (cgpModelViewProj)
|
||||
cgD3D9SetUniformMatrix(cgpModelViewProj, matrix);
|
||||
}
|
||||
|
||||
static void d3d9_cg_renderchain_calc_and_set_shader_mvp(
|
||||
cg_renderchain_t *chain, CGprogram vPrg,
|
||||
unsigned vp_width, unsigned vp_height,
|
||||
unsigned rotation)
|
||||
@ -1195,20 +1203,28 @@ static void d3d9_cg_renderchain_set_shader_mvp(
|
||||
d3d_matrix_multiply(&proj, &ortho, &rot);
|
||||
d3d_matrix_transpose(&matrix, &proj);
|
||||
|
||||
CGparameter cgpModelViewProj = cgGetNamedParameter(vPrg, "modelViewProj");
|
||||
if (cgpModelViewProj)
|
||||
cgD3D9SetUniformMatrix(cgpModelViewProj, &matrix);
|
||||
d3d9_cg_renderchain_set_shader_mvp(chain, vPrg, &matrix);
|
||||
}
|
||||
|
||||
static void d3d9_cg_renderchain_set_mvp(
|
||||
void *chain_data,
|
||||
void *data,
|
||||
unsigned vp_width, unsigned vp_height,
|
||||
unsigned rotation)
|
||||
{
|
||||
void *data,
|
||||
void *chain_data,
|
||||
void *shader_data,
|
||||
const void *mat_data)
|
||||
{
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
|
||||
#if 0
|
||||
cg_renderchain_t *chain = (cg_renderchain_t*)chain_data;
|
||||
|
||||
d3d9_cg_renderchain_set_shader_mvp(chain, chain->vStock, vp_width, vp_height, rotation);
|
||||
if(shader_data)
|
||||
d3d9_cg_renderchain_set_shader_mvp(chain, shader_data, mat_data);
|
||||
else
|
||||
d3d9_cg_renderchain_set_shader_mvp(chain, chain->vStock, mat_data);
|
||||
#else
|
||||
d3d_set_vertex_shader_constantf(d3d->dev, 0, mat_data, 4);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
static void cg_d3d9_renderchain_set_vertices(
|
||||
@ -1298,7 +1314,7 @@ static void cg_d3d9_renderchain_set_vertices(
|
||||
|
||||
if (chain)
|
||||
{
|
||||
d3d9_cg_renderchain_set_shader_mvp(
|
||||
d3d9_cg_renderchain_calc_and_set_shader_mvp(
|
||||
chain, pass->vPrg, vp_width, vp_height, rotation);
|
||||
if (pass)
|
||||
d3d9_cg_renderchain_set_shader_params(chain, pass,
|
||||
@ -1562,7 +1578,7 @@ static bool d3d9_cg_renderchain_render(
|
||||
d3d9_cg_renderchain_end_render(chain);
|
||||
cgD3D9BindProgram(chain->fStock);
|
||||
cgD3D9BindProgram(chain->vStock);
|
||||
d3d9_cg_renderchain_set_shader_mvp(
|
||||
d3d9_cg_renderchain_calc_and_set_shader_mvp(
|
||||
chain, chain->vStock, chain->final_viewport->Width,
|
||||
chain->final_viewport->Height, 0);
|
||||
}
|
||||
|
@ -45,28 +45,17 @@ typedef struct hlsl_d3d9_renderchain
|
||||
void hlsl_set_proj_matrix(void *data, void *matrix_data);
|
||||
|
||||
static void hlsl_d3d9_renderchain_set_mvp(
|
||||
void *data,
|
||||
void *chain_data,
|
||||
void *data, unsigned vp_width,
|
||||
unsigned vp_height, unsigned rotation)
|
||||
void *shader_data,
|
||||
const void *mat_data)
|
||||
{
|
||||
video_shader_ctx_mvp_t mvp;
|
||||
D3DMATRIX proj, ortho, rot, tmp;
|
||||
d3d_video_t *d3d = (d3d_video_t*)data;
|
||||
LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev;
|
||||
|
||||
d3d_matrix_ortho_off_center_lh(&ortho, 0, vp_width, 0, vp_height, 0, 1);
|
||||
d3d_matrix_identity(&rot);
|
||||
d3d_matrix_rotation_z(&rot, rotation * (M_PI / 2.0));
|
||||
|
||||
d3d_matrix_multiply(&proj, &ortho, &rot);
|
||||
d3d_matrix_transpose(&tmp, &proj);
|
||||
|
||||
hlsl_set_proj_matrix((void*)&d3d->shader, &rot);
|
||||
|
||||
mvp.data = d3d;
|
||||
mvp.matrix = &rot;
|
||||
|
||||
video_driver_set_mvp(&mvp);
|
||||
if(shader_data)
|
||||
hlsl_set_proj_matrix(shader_data, mat_data);
|
||||
else
|
||||
hlsl_set_proj_matrix((void*)&d3d->shader, mat_data);
|
||||
}
|
||||
|
||||
static void hlsl_d3d9_renderchain_clear(void *data)
|
||||
|
@ -798,9 +798,10 @@ typedef struct video_driver
|
||||
|
||||
typedef struct d3d_renderchain_driver
|
||||
{
|
||||
void (*set_mvp)(void *chain_data,
|
||||
void *data, unsigned vp_width,
|
||||
unsigned vp_height, unsigned rotation);
|
||||
void (*set_mvp)(void *data,
|
||||
void *chain_data,
|
||||
void *shader_data,
|
||||
const void *mat_data);
|
||||
void (*chain_free)(void *data);
|
||||
void *(*chain_new)(void);
|
||||
bool (*reinit)(void *data, const void *info_data);
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include <boolean.h>
|
||||
#include <file/file_path.h>
|
||||
#include <retro_assert.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#ifndef __MACH__
|
||||
#include <compat/strl.h>
|
||||
@ -912,3 +914,239 @@ void fill_short_pathname_representation_noext(char* out_rep,
|
||||
fill_short_pathname_representation(out_rep, in_path, size);
|
||||
path_remove_extension(out_rep);
|
||||
}
|
||||
|
||||
void fill_pathname_expand_special(char *out_path,
|
||||
const char *in_path, size_t size)
|
||||
{
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
if (*in_path == '~')
|
||||
{
|
||||
const char *home = getenv("HOME");
|
||||
if (home)
|
||||
{
|
||||
size_t src_size = strlcpy(out_path, home, size);
|
||||
retro_assert(src_size < size);
|
||||
|
||||
out_path += src_size;
|
||||
size -= src_size;
|
||||
in_path++;
|
||||
}
|
||||
}
|
||||
else if ((in_path[0] == ':') &&
|
||||
(
|
||||
(in_path[1] == '/')
|
||||
#ifdef _WIN32
|
||||
|| (in_path[1] == '\\')
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
size_t src_size;
|
||||
char *application_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
|
||||
application_dir[0] = '\0';
|
||||
|
||||
fill_pathname_application_path(application_dir,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
path_basedir_wrapper(application_dir);
|
||||
|
||||
src_size = strlcpy(out_path, application_dir, size);
|
||||
retro_assert(src_size < size);
|
||||
|
||||
free(application_dir);
|
||||
|
||||
out_path += src_size;
|
||||
size -= src_size;
|
||||
in_path += 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
retro_assert(strlcpy(out_path, in_path, size) < size);
|
||||
}
|
||||
|
||||
void fill_pathname_abbreviate_special(char *out_path,
|
||||
const char *in_path, size_t size)
|
||||
{
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
unsigned i;
|
||||
const char *candidates[3];
|
||||
const char *notations[3];
|
||||
char *application_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char));
|
||||
const char *home = getenv("HOME");
|
||||
|
||||
application_dir[0] = '\0';
|
||||
|
||||
/* application_dir could be zero-string. Safeguard against this.
|
||||
*
|
||||
* Keep application dir in front of home, moving app dir to a
|
||||
* new location inside home would break otherwise. */
|
||||
|
||||
/* ugly hack - use application_dir pointer
|
||||
* before filling it in. C89 reasons */
|
||||
candidates[0] = application_dir;
|
||||
candidates[1] = home;
|
||||
candidates[2] = NULL;
|
||||
|
||||
notations [0] = ":";
|
||||
notations [1] = "~";
|
||||
notations [2] = NULL;
|
||||
|
||||
fill_pathname_application_path(application_dir,
|
||||
PATH_MAX_LENGTH * sizeof(char));
|
||||
path_basedir_wrapper(application_dir);
|
||||
|
||||
for (i = 0; candidates[i]; i++)
|
||||
{
|
||||
if (!string_is_empty(candidates[i]) &&
|
||||
strstr(in_path, candidates[i]) == in_path)
|
||||
{
|
||||
size_t src_size = strlcpy(out_path, notations[i], size);
|
||||
|
||||
retro_assert(src_size < size);
|
||||
|
||||
out_path += src_size;
|
||||
size -= src_size;
|
||||
in_path += strlen(candidates[i]);
|
||||
|
||||
if (!path_char_is_slash(*in_path))
|
||||
{
|
||||
retro_assert(strlcpy(out_path,
|
||||
path_default_slash(), size) < size);
|
||||
out_path++;
|
||||
size--;
|
||||
}
|
||||
|
||||
break; /* Don't allow more abbrevs to take place. */
|
||||
}
|
||||
}
|
||||
|
||||
free(application_dir);
|
||||
#endif
|
||||
|
||||
retro_assert(strlcpy(out_path, in_path, size) < size);
|
||||
}
|
||||
|
||||
/**
|
||||
* path_basedir:
|
||||
* @path : path
|
||||
*
|
||||
* Extracts base directory by mutating path.
|
||||
* Keeps trailing '/'.
|
||||
**/
|
||||
void path_basedir_wrapper(char *path)
|
||||
{
|
||||
char *last = NULL;
|
||||
if (strlen(path) < 2)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_COMPRESSION
|
||||
/* We want to find the directory with the archive in basedir. */
|
||||
last = (char*)path_get_archive_delim(path);
|
||||
if (last)
|
||||
*last = '\0';
|
||||
#endif
|
||||
|
||||
last = find_last_slash(path);
|
||||
|
||||
if (last)
|
||||
last[1] = '\0';
|
||||
else
|
||||
snprintf(path, 3, ".%s", path_default_slash());
|
||||
}
|
||||
|
||||
#if !defined(RARCH_CONSOLE)
|
||||
void fill_pathname_application_path(char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
#ifdef __APPLE__
|
||||
CFBundleRef bundle = CFBundleGetMainBundle();
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
DWORD ret;
|
||||
wchar_t wstr[PATH_MAX_LENGTH] = {0};
|
||||
#endif
|
||||
#ifdef __HAIKU__
|
||||
image_info info;
|
||||
int32_t cookie = 0;
|
||||
#endif
|
||||
(void)i;
|
||||
|
||||
if (!len)
|
||||
return;
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef LEGACY_WIN32
|
||||
ret = GetModuleFileNameA(GetModuleHandle(NULL), s, len);
|
||||
#else
|
||||
ret = GetModuleFileNameW(GetModuleHandle(NULL), wstr, ARRAY_SIZE(wstr));
|
||||
|
||||
if (*wstr)
|
||||
{
|
||||
char *str = utf16_to_utf8_string_alloc(wstr);
|
||||
|
||||
if (str)
|
||||
{
|
||||
strlcpy(s, str, len);
|
||||
free(str);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
s[ret] = '\0';
|
||||
#elif defined(__APPLE__)
|
||||
if (bundle)
|
||||
{
|
||||
CFURLRef bundle_url = CFBundleCopyBundleURL(bundle);
|
||||
CFStringRef bundle_path = CFURLCopyPath(bundle_url);
|
||||
CFStringGetCString(bundle_path, s, len, kCFStringEncodingUTF8);
|
||||
CFRelease(bundle_path);
|
||||
CFRelease(bundle_url);
|
||||
|
||||
retro_assert(strlcat(s, "nobin", len) < len);
|
||||
return;
|
||||
}
|
||||
#elif defined(__HAIKU__)
|
||||
while (get_next_image_info(0, &cookie, &info) == B_OK)
|
||||
{
|
||||
if (info.type == B_APP_IMAGE)
|
||||
{
|
||||
strlcpy(s, info.name, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#elif defined(__QNX__)
|
||||
char *buff = malloc(len);
|
||||
|
||||
if(_cmdname(buff))
|
||||
strlcpy(s, buff, len);
|
||||
|
||||
free(buff);
|
||||
#else
|
||||
{
|
||||
pid_t pid;
|
||||
static const char *exts[] = { "exe", "file", "path/a.out" };
|
||||
char link_path[255];
|
||||
|
||||
link_path[0] = *s = '\0';
|
||||
pid = getpid();
|
||||
|
||||
/* Linux, BSD and Solaris paths. Not standardized. */
|
||||
for (i = 0; i < ARRAY_SIZE(exts); i++)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
||||
snprintf(link_path, sizeof(link_path), "/proc/%u/%s",
|
||||
(unsigned)pid, exts[i]);
|
||||
ret = readlink(link_path, s, len - 1);
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
s[ret] = '\0';
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* RARCH_ERR("Cannot resolve application path! This should not happen.\n"); */
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -389,6 +389,15 @@ void fill_pathname_expand_special(char *out_path,
|
||||
void fill_pathname_abbreviate_special(char *out_path,
|
||||
const char *in_path, size_t size);
|
||||
|
||||
/**
|
||||
* path_basedir:
|
||||
* @path : path
|
||||
*
|
||||
* Extracts base directory by mutating path.
|
||||
* Keeps trailing '/'.
|
||||
**/
|
||||
void path_basedir_wrapper(char *path);
|
||||
|
||||
/**
|
||||
* path_char_is_slash:
|
||||
* @c : character
|
||||
|
@ -57,18 +57,10 @@ static const float *menu_display_d3d_get_default_tex_coords(void)
|
||||
|
||||
static void *menu_display_d3d_get_default_mvp(void)
|
||||
{
|
||||
static math_matrix_4x4 default_mvp;
|
||||
D3DMATRIX ortho, mvp;
|
||||
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
|
||||
static math_matrix_4x4 id;
|
||||
matrix_4x4_identity(id);
|
||||
|
||||
if (!d3d)
|
||||
return NULL;
|
||||
d3d_matrix_ortho_off_center_lh(&ortho, 0,
|
||||
1, 0, 1, 0, 1);
|
||||
d3d_matrix_transpose(&mvp, &ortho);
|
||||
memcpy(default_mvp.data, (float*)&mvp, sizeof(default_mvp.data));
|
||||
|
||||
return &default_mvp;
|
||||
return &id;
|
||||
}
|
||||
|
||||
static unsigned menu_display_prim_to_d3d_enum(
|
||||
@ -112,12 +104,13 @@ static void menu_display_d3d_viewport(void *data)
|
||||
#if 0
|
||||
D3DVIEWPORT vp = {0};
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
|
||||
|
||||
if (!d3d || !draw)
|
||||
return;
|
||||
|
||||
vp.X = draw->x;
|
||||
vp.Y = draw->y;
|
||||
vp.Y = d3d->video_info.height - (draw->y + draw->height);
|
||||
vp.Width = draw->width;
|
||||
vp.Height = draw->height;
|
||||
vp.MinZ = 0.0f;
|
||||
@ -148,7 +141,10 @@ static void menu_display_d3d_bind_texture(void *data)
|
||||
static void menu_display_d3d_draw(void *data)
|
||||
{
|
||||
unsigned i;
|
||||
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
|
||||
video_shader_ctx_mvp_t mvp;
|
||||
math_matrix_4x4 mop, m1, m2;
|
||||
unsigned width, height;
|
||||
d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(false);
|
||||
menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data;
|
||||
float* pv = NULL;
|
||||
const float *vertex = NULL;
|
||||
@ -158,13 +154,12 @@ static void menu_display_d3d_draw(void *data)
|
||||
if (!d3d || !draw)
|
||||
return;
|
||||
|
||||
if(draw->pipeline.id)
|
||||
return;
|
||||
|
||||
if(d3d->menu_display.offset + draw->coords->vertices > d3d->menu_display.size)
|
||||
return;
|
||||
|
||||
if (!draw->coords->vertex)
|
||||
draw->coords->vertex = menu_display_d3d_get_default_vertices();
|
||||
if (!draw->coords->tex_coord)
|
||||
draw->coords->tex_coord = menu_display_d3d_get_default_tex_coords();
|
||||
|
||||
pv = (float*)d3d_vertex_buffer_lock(d3d->menu_display.buffer);
|
||||
pv += d3d->menu_display.offset * 8;
|
||||
@ -172,12 +167,17 @@ static void menu_display_d3d_draw(void *data)
|
||||
tex_coord = draw->coords->tex_coord;
|
||||
color = draw->coords->color;
|
||||
|
||||
if (!vertex)
|
||||
vertex = menu_display_d3d_get_default_vertices();
|
||||
if (!tex_coord)
|
||||
tex_coord = menu_display_d3d_get_default_tex_coords();
|
||||
|
||||
for (i = 0; i < draw->coords->vertices; i++)
|
||||
{
|
||||
*pv++ = (*vertex++ * draw->width) + draw->x;
|
||||
*pv++ = ((1.0 - *vertex++) * draw->height) + draw->y;
|
||||
*pv++ = *vertex++;
|
||||
*pv++ = *vertex++;
|
||||
*pv++ = *tex_coord++;
|
||||
*pv++ = *tex_coord++;
|
||||
*pv++ = 1.0f - *tex_coord++;
|
||||
*pv++ = *color++;
|
||||
*pv++ = *color++;
|
||||
*pv++ = *color++;
|
||||
@ -185,6 +185,25 @@ static void menu_display_d3d_draw(void *data)
|
||||
}
|
||||
d3d_vertex_buffer_unlock(d3d->menu_display.buffer);
|
||||
|
||||
if(!draw->matrix_data)
|
||||
draw->matrix_data = menu_display_d3d_get_default_mvp();
|
||||
|
||||
/* ugh */
|
||||
video_driver_get_size(&width, &height);
|
||||
matrix_4x4_scale(m1, 2.0, 2.0, 0);
|
||||
matrix_4x4_translate(mop, -1.0, -1.0, 0);
|
||||
matrix_4x4_multiply(m2, mop, m1);
|
||||
matrix_4x4_multiply(m1, *((math_matrix_4x4*)draw->matrix_data), m2);
|
||||
matrix_4x4_scale(mop, (draw->width / 2.0) / width, (draw->height / 2.0) / height, 0);
|
||||
matrix_4x4_multiply(m2, mop, m1);
|
||||
matrix_4x4_translate(mop, (draw->x + (draw->width / 2.0)) / width, (draw->y + (draw->height / 2.0)) / height,0);
|
||||
matrix_4x4_multiply(m1, mop, m2);
|
||||
matrix_4x4_multiply(m2, d3d->mvp_transposed, m1);
|
||||
d3d_matrix_transpose(&m1, &m2);
|
||||
|
||||
mvp.data = d3d;
|
||||
mvp.matrix = &m1;
|
||||
video_driver_set_mvp(&mvp);
|
||||
menu_display_d3d_bind_texture(draw);
|
||||
d3d_draw_primitive(d3d->dev, menu_display_prim_to_d3d_enum(draw->prim_type), d3d->menu_display.offset,
|
||||
draw->coords->vertices - (draw->prim_type == MENU_DISPLAY_PRIM_TRIANGLESTRIP? 2 : 0));
|
||||
|
@ -1,99 +0,0 @@
|
||||
/**
|
||||
* RetroArch Web Player
|
||||
*
|
||||
* This provides the basic styling for the RetroArch web player.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Make sure the background of the player is black.
|
||||
*/
|
||||
.webplayer-container {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
/**
|
||||
* Webplayer Preview when not loaded.
|
||||
*/
|
||||
.webplayer-preview {
|
||||
margin: 0 auto;
|
||||
cursor: wait;
|
||||
opacity: 0.2;
|
||||
transition: all 0.8s;
|
||||
-webkit-animation: loading 0.8s ease-in-out infinite alternate;
|
||||
-moz-animation: loading 0.8s ease-in-out infinite alternate;
|
||||
animation: loading 0.8s ease-in-out infinite alternate;
|
||||
}
|
||||
.webplayer-preview.loaded {
|
||||
cursor: pointer;
|
||||
opacity: 1;
|
||||
-webkit-animation: loaded 0.8s ease-in-out;
|
||||
-moz-animation: loaded 0.8s ease-in-out;
|
||||
animation: loaded 0.8s ease-in-out;
|
||||
}
|
||||
@keyframes loaded {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-moz-keyframes loaded {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes loaded {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes loading{
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
@-moz-keyframes loading{
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes loading {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the border around the player.
|
||||
*/
|
||||
canvas.webplayer {
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font-family: monospace;
|
||||
font-size: 0.7em;
|
||||
height: 95%;
|
||||
width: 95%;
|
||||
border-style: none;
|
||||
border-color: transparent;
|
||||
overflow: auto;
|
||||
resize: none;
|
||||
}
|
@ -1,429 +0,0 @@
|
||||
/**
|
||||
* RetroArch Web Player
|
||||
*
|
||||
* This provides the basic JavaScript for the RetroArch web player.
|
||||
*/
|
||||
var client = new Dropbox.Client({ key: "--your-api-key--" }); /* setup key*/
|
||||
var BrowserFS = BrowserFS;
|
||||
var afs;
|
||||
|
||||
var showError = function(error) {
|
||||
switch (error.status) {
|
||||
case Dropbox.ApiError.INVALID_TOKEN:
|
||||
// If you're using dropbox.js, the only cause behind this error is that
|
||||
// the user token expired.
|
||||
// Get the user through the authentication flow again.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NOT_FOUND:
|
||||
// The file or folder you tried to access is not in the user's Dropbox.
|
||||
// Handling this error is specific to your application.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.OVER_QUOTA:
|
||||
// The user is over their Dropbox quota.
|
||||
// Tell them their Dropbox is full. Refreshing the page won't help.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.RATE_LIMITED:
|
||||
// Too many API requests. Tell the user to try again later.
|
||||
// Long-term, optimize your code to use fewer API calls.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NETWORK_ERROR:
|
||||
// An error occurred at the XMLHttpRequest layer.
|
||||
// Most likely, the user's network connection is down.
|
||||
// API calls will not succeed until the user gets back online.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.INVALID_PARAM:
|
||||
case Dropbox.ApiError.OAUTH_ERROR:
|
||||
case Dropbox.ApiError.INVALID_METHOD:
|
||||
default:
|
||||
// Caused by a bug in dropbox.js, in your application, or in Dropbox.
|
||||
// Tell the user an error occurred, ask them to refresh the page.
|
||||
}
|
||||
};
|
||||
|
||||
function cleanupStorage()
|
||||
{
|
||||
localStorage.clear();
|
||||
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
||||
{
|
||||
var req = indexedDB.deleteDatabase("RetroArch");
|
||||
req.onsuccess = function () {
|
||||
console.log("Deleted database successfully");
|
||||
};
|
||||
req.onerror = function () {
|
||||
console.log("Couldn't delete database");
|
||||
};
|
||||
req.onblocked = function () {
|
||||
console.log("Couldn't delete database due to the operation being blocked");
|
||||
};
|
||||
}
|
||||
|
||||
document.getElementById("btnClean").disabled = true;
|
||||
}
|
||||
|
||||
|
||||
function dropboxInit()
|
||||
{
|
||||
//document.getElementById("btnDrop").disabled = true;
|
||||
//$('#icnDrop').removeClass('fa-dropbox');
|
||||
//$('#icnDrop').addClass('fa-spinner fa-spin');
|
||||
|
||||
|
||||
client.authDriver(new Dropbox.AuthDriver.Redirect());
|
||||
client.authenticate({ rememberUser: true }, function(error, client)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
return showError(error);
|
||||
}
|
||||
dropboxSync(client, dropboxSyncComplete);
|
||||
});
|
||||
}
|
||||
|
||||
function dropboxSync(dropboxClient, cb)
|
||||
{
|
||||
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
|
||||
// Wrap in afsFS.
|
||||
afs = new BrowserFS.FileSystem.AsyncMirror(
|
||||
new BrowserFS.FileSystem.InMemory(), dbfs);
|
||||
|
||||
afs.initialize(function(err)
|
||||
{
|
||||
// Initialize it as the root file system.
|
||||
//BrowserFS.initialize(afs);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function dropboxSyncComplete()
|
||||
{
|
||||
//$('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
//$('#icnDrop').addClass('fa-check');
|
||||
console.log("WEBPLAYER: Dropbox sync successful");
|
||||
|
||||
setupFileSystem("dropbox");
|
||||
preLoadingComplete();
|
||||
}
|
||||
|
||||
function idbfsInit()
|
||||
{
|
||||
document.getElementById("btnLocal").disabled = true;
|
||||
$('#icnLocal').removeClass('fa-globe');
|
||||
$('#icnLocal').addClass('fa-spinner fa-spin');
|
||||
var imfs = new BrowserFS.FileSystem.InMemory();
|
||||
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
||||
{
|
||||
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
|
||||
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
//fallback to imfs
|
||||
afs = new BrowserFS.FileSystem.InMemory();
|
||||
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
|
||||
setupFileSystem("browser");
|
||||
preLoadingComplete();
|
||||
}
|
||||
else
|
||||
{
|
||||
// initialize afs by copying files from async storage to sync storage.
|
||||
afs.initialize(function (e)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
afs = new BrowserFS.FileSystem.InMemory();
|
||||
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
|
||||
setupFileSystem("browser");
|
||||
preLoadingComplete();
|
||||
}
|
||||
else
|
||||
{
|
||||
idbfsSyncComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"RetroArch"));
|
||||
}
|
||||
}
|
||||
|
||||
function idbfsSyncComplete()
|
||||
{
|
||||
$('#icnLocal').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
$('#icnLocal').addClass('fa-check');
|
||||
console.log("WEBPLAYER: idbfs setup successful");
|
||||
|
||||
setupFileSystem("browser");
|
||||
preLoadingComplete();
|
||||
}
|
||||
|
||||
function preLoadingComplete()
|
||||
{
|
||||
/* Make the Preview image clickable to start RetroArch. */
|
||||
$('.webplayer-preview').addClass('loaded').click(function () {
|
||||
startRetroArch();
|
||||
return false;
|
||||
});
|
||||
document.getElementById("btnRun").disabled = false;
|
||||
$('#btnRun').removeClass('disabled');
|
||||
}
|
||||
|
||||
function setupFileSystem(backend)
|
||||
{
|
||||
/* create a mountable filesystem that will server as a root
|
||||
mountpoint for browserfs */
|
||||
var mfs = new BrowserFS.FileSystem.MountableFileSystem();
|
||||
|
||||
/* setup this if you setup your server to serve assets or core assets,
|
||||
you can find more information in the included README */
|
||||
|
||||
/* create an XmlHttpRequest filesystem for the bundled data
|
||||
uncomment this section if you want XMB assets, Overlays, Shaders, etc.
|
||||
var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
("--your-assets-index-file-name--", "--your-index-url--");*/
|
||||
/* create an XmlHttpRequest filesystem for content
|
||||
uncomment this section if you want to serve content
|
||||
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
("--your-content-index-file-name--", "--your-index-url--");*/
|
||||
|
||||
console.log("WEBPLAYER: initializing filesystem: " + backend);
|
||||
mfs.mount('/home/web_user/retroarch/userdata', afs);
|
||||
|
||||
/* setup this if you setup your server to serve assets or core assets,
|
||||
you can find more information in the included README */
|
||||
/*
|
||||
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
|
||||
mfs.mount('/home/web_user/retroarch/userdata/content/', xfs2);
|
||||
*/
|
||||
BrowserFS.initialize(mfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
FS.mount(BFS, {root: '/home'}, '/home');
|
||||
console.log("WEBPLAYER: " + backend + " filesystem initialization successful");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the value of the given GET parameter.
|
||||
*/
|
||||
function getParam(name) {
|
||||
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
||||
if (results) {
|
||||
return results[1] || null;
|
||||
}
|
||||
}
|
||||
|
||||
function startRetroArch()
|
||||
{
|
||||
$('.webplayer').show();
|
||||
$('.webplayer-preview').hide();
|
||||
//document.getElementById("btnDrop").disabled = true;
|
||||
document.getElementById("btnRun").disabled = true;
|
||||
|
||||
$('#btnFullscreen').removeClass('disabled');
|
||||
$('#btnMenu').removeClass('disabled');
|
||||
$('#btnAdd').removeClass('disabled');
|
||||
$('#btnRom').removeClass('disabled');
|
||||
|
||||
document.getElementById("btnAdd").disabled = false;
|
||||
document.getElementById("btnRom").disabled = false;
|
||||
document.getElementById("btnMenu").disabled = false;
|
||||
document.getElementById("btnFullscreen").disabled = false;
|
||||
|
||||
Module['callMain'](Module['arguments']);
|
||||
document.getElementById('canvas').focus();
|
||||
}
|
||||
|
||||
function selectFiles(files)
|
||||
{
|
||||
$('#btnAdd').addClass('disabled');
|
||||
$('#icnAdd').removeClass('fa-plus');
|
||||
$('#icnAdd').addClass('fa-spinner spinning');
|
||||
var count = files.length;
|
||||
|
||||
for (var i = 0; i < files.length; i++)
|
||||
{
|
||||
filereader = new FileReader();
|
||||
filereader.file_name = files[i].name;
|
||||
filereader.readAsArrayBuffer(files[i]);
|
||||
filereader.onload = function(){uploadData(this.result, this.file_name)};
|
||||
filereader.onloadend = function(evt)
|
||||
{
|
||||
console.log("WEBPLAYER: file: " + this.file_name + " upload complete");
|
||||
if (evt.target.readyState == FileReader.DONE)
|
||||
{
|
||||
$('#btnAdd').removeClass('disabled');
|
||||
$('#icnAdd').removeClass('fa-spinner spinning');
|
||||
$('#icnAdd').addClass('fa-plus');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function uploadData(data,name)
|
||||
{
|
||||
var dataView = new Uint8Array(data);
|
||||
FS.createDataFile('/', name, dataView, true, false);
|
||||
|
||||
var data = FS.readFile(name,{ encoding: 'binary' });
|
||||
FS.writeFile('/home/web_user/retroarch/userdata/content/' + name, data ,{ encoding: 'binary' });
|
||||
FS.unlink(name);
|
||||
}
|
||||
|
||||
var Module =
|
||||
{
|
||||
noInitialRun: true,
|
||||
arguments: ["-v", "--menu"],
|
||||
preRun: [],
|
||||
postRun: [],
|
||||
print: (function()
|
||||
{
|
||||
var element = document.getElementById('output');
|
||||
element.value = ''; // clear browser cache
|
||||
return function(text)
|
||||
{
|
||||
text = Array.prototype.slice.call(arguments).join(' ');
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = 99999; // focus on bottom
|
||||
};
|
||||
})(),
|
||||
|
||||
printErr: function(text)
|
||||
{
|
||||
var text = Array.prototype.slice.call(arguments).join(' ');
|
||||
var element = document.getElementById('output');
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = 99999; // focus on bottom
|
||||
},
|
||||
canvas: document.getElementById('canvas'),
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies: function(left)
|
||||
{
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
}
|
||||
};
|
||||
|
||||
function switchCore(corename) {
|
||||
localStorage.setItem("core", corename);
|
||||
}
|
||||
|
||||
function switchStorage(backend) {
|
||||
if (backend != localStorage.getItem("backend"))
|
||||
{
|
||||
localStorage.setItem("backend", backend);
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// When the browser has loaded everything.
|
||||
$(function() {
|
||||
/**
|
||||
* Attempt to disable some default browser keys.
|
||||
*/
|
||||
var keys = {
|
||||
9: "tab",
|
||||
13: "enter",
|
||||
16: "shift",
|
||||
18: "alt",
|
||||
27: "esc",
|
||||
33: "rePag",
|
||||
34: "avPag",
|
||||
35: "end",
|
||||
36: "home",
|
||||
37: "left",
|
||||
38: "up",
|
||||
39: "right",
|
||||
40: "down",
|
||||
112: "F1",
|
||||
113: "F2",
|
||||
114: "F3",
|
||||
115: "F4",
|
||||
116: "F5",
|
||||
117: "F6",
|
||||
118: "F7",
|
||||
119: "F8",
|
||||
120: "F9",
|
||||
121: "F10",
|
||||
122: "F11",
|
||||
123: "F12"
|
||||
};
|
||||
window.addEventListener('keydown', function (e) {
|
||||
if (keys[e.which]) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Switch the core when selecting one.
|
||||
$('#core-selector a').click(function () {
|
||||
var coreChoice = $(this).data('core');
|
||||
switchCore(coreChoice);
|
||||
});
|
||||
|
||||
// Find which core to load.
|
||||
var core = localStorage.getItem("core", core);
|
||||
if (!core) {
|
||||
core = 'gambatte';
|
||||
}
|
||||
// Make the core the selected core in the UI.
|
||||
var coreTitle = $('#core-selector a[data-core="' + core + '"]').addClass('active').text();
|
||||
$('#dropdownMenu1').text(coreTitle);
|
||||
|
||||
// Load the Core's related JavaScript.
|
||||
$.getScript(core + '_libretro.js', function ()
|
||||
{
|
||||
$('#icnRun').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
$('#icnRun').addClass('fa-play');
|
||||
|
||||
if (localStorage.getItem("backend") == "dropbox")
|
||||
{
|
||||
$('#lblDrop').addClass('active');
|
||||
$('#lblLocal').removeClass('active');
|
||||
dropboxInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#lblDrop').removeClass('active');
|
||||
$('#lblLocal').addClass('active');
|
||||
idbfsInit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function keyPress(k)
|
||||
{
|
||||
kp(k, "keydown");
|
||||
setTimeout(function(){kp(k, "keyup")}, 50);
|
||||
}
|
||||
|
||||
kp = function(k, event) {
|
||||
var oEvent = document.createEvent('KeyboardEvent');
|
||||
|
||||
// Chromium Hack
|
||||
Object.defineProperty(oEvent, 'keyCode', {
|
||||
get : function() {
|
||||
return this.keyCodeVal;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(oEvent, 'which', {
|
||||
get : function() {
|
||||
return this.keyCodeVal;
|
||||
}
|
||||
});
|
||||
|
||||
if (oEvent.initKeyboardEvent) {
|
||||
oEvent.initKeyboardEvent(event, true, true, document.defaultView, false, false, false, false, k, k);
|
||||
} else {
|
||||
oEvent.initKeyEvent(event, true, true, document.defaultView, false, false, false, false, k, 0);
|
||||
}
|
||||
|
||||
oEvent.keyCodeVal = k;
|
||||
|
||||
if (oEvent.keyCode !== k) {
|
||||
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
|
||||
}
|
||||
|
||||
document.dispatchEvent(oEvent);
|
||||
document.getElementById('canvas').focus();
|
||||
}
|
@ -1,152 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<base target="_parent" />
|
||||
<title>RetroArch Web Player</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
|
||||
<!-- Material Design Bootstrap -->
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.1.1/css/mdb.min.css" rel="stylesheet">
|
||||
<link href="embed.css" rel="stylesheet" type="text/css">
|
||||
<link rel="shortcut icon" href="media/retroarch.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<!--Navbar-->
|
||||
<nav class="navbar navbar-dark bg-warning">
|
||||
<div class="container">
|
||||
<!--Collapse content-->
|
||||
<div class="collapse navbar-toggleable-xs" id="collapseEx2">
|
||||
<!--Links-->
|
||||
<ul class="nav navbar-nav">
|
||||
<div class="dropdown">
|
||||
<li class="nav-item dropdown">
|
||||
<button class="btn btn-warning dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Core Selection</button>
|
||||
<div class="dropdown-menu dropdown-warning" aria-labelledby="dropdownMenu1" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut" id="core-selector">
|
||||
<a class="dropdown-item" href="." data-core="2048">2048</a>
|
||||
<a class="dropdown-item" href="." data-core="4do">4DO</a>
|
||||
<a class="dropdown-item" href="." data-core="bluemsx">BlueMSX</a>
|
||||
<a class="dropdown-item" href="." data-core="craft">Craft</a>
|
||||
<a class="dropdown-item" href="." data-core="desmume">DeSmuME</a>
|
||||
<a class="dropdown-item" href="." data-core="dosbox">DOSBox</a>
|
||||
<a class="dropdown-item" href="." data-core="easyrpg">EasyRPG</a>
|
||||
<a class="dropdown-item" href="." data-core="fbalpha2012">FB Alpha 2012</a>
|
||||
<a class="dropdown-item" href="." data-core="fbalpha2012_cps1">FB Alpha 2012 CPS1</a>
|
||||
<a class="dropdown-item" href="." data-core="fbalpha2012_cps2">FB Alpha 2012 CPS2</a>
|
||||
<a class="dropdown-item" href="." data-core="fbalpha2012_neo">FB Alpha 2012 NeoGeo</a>
|
||||
<a class="dropdown-item" href="." data-core="fceumm">FCEUmm</a>
|
||||
<a class="dropdown-item" href="." data-core="ffmpeg">FFmpeg</a>
|
||||
<a class="dropdown-item" href="." data-core="gambatte">Gambatte</a>
|
||||
<a class="dropdown-item" href="." data-core="glupen64">GLupeN64</a>
|
||||
<a class="dropdown-item" href="." data-core="genesis_plus_gx">Genesis Plus GX</a>
|
||||
<a class="dropdown-item" href="." data-core="gme">Game Music Emu</a>
|
||||
<a class="dropdown-item" href="." data-core="gpsp">gPSP</a>
|
||||
<a class="dropdown-item" href="." data-core="handy">Handy</a>
|
||||
<a class="dropdown-item" href="." data-core="mame2000">MAME 2000</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_lynx">Mednafen Lynx</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_ngp">Mednafen Neo Geo Pocket</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_pce_fast">Mednafen PC Engine Fast</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_pcfx">Mednafen/Beetle PCFX</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_psx">Mednafen/Beetle PSX</a>
|
||||
<!--<a class="dropdown-item" href="." data-core="mednafen_saturn">Mednafen/Beetle Saturn</a>-->
|
||||
<a class="dropdown-item" href="." data-core="mednafen_snes">Mednafen/Beetle SNES</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_vb">Mednafen/Beetle Virtual Boy</a>
|
||||
<a class="dropdown-item" href="." data-core="mednafen_wswan">Mednafen/Beetle WonderSwan</a>
|
||||
<a class="dropdown-item" href="." data-core="mupen64plus">Mupen64 Plus</a>
|
||||
<a class="dropdown-item" href="." data-core="nestopia">Nestopia</a>
|
||||
<a class="dropdown-item" href="." data-core="nxengine">NX Engine</a>
|
||||
<a class="dropdown-item" href="." data-core="o2em">O2em</a>
|
||||
<a class="dropdown-item" href="." data-core="picodrive">PicoDrive</a>
|
||||
<a class="dropdown-item" href="." data-core="prboom">PrBoom</a>
|
||||
<a class="dropdown-item" href="." data-core="quicknes">QuickNES</a>
|
||||
<a class="dropdown-item" href="." data-core="snes9x2002">Snes9x 2002</a>
|
||||
<a class="dropdown-item" href="." data-core="snes9x2005">Snes9x 2005</a>
|
||||
<a class="dropdown-item" href="." data-core="snes9x2010">Snes9x 2010</a>
|
||||
<a class="dropdown-item" href="." data-core="snes9x">Snes9x</a>
|
||||
<a class="dropdown-item" href="." data-core="stella">Stella</a>
|
||||
<a class="dropdown-item" href="." data-core="tgbdual">TGB Dual</a>
|
||||
<a class="dropdown-item" href="." data-core="tyrquake">TyrQuake</a>
|
||||
<a class="dropdown-item" href="." data-core="vba_next">VBA Next</a>
|
||||
<a class="dropdown-item" href="." data-core="vecx">Vecx</a>
|
||||
<a class="dropdown-item" href="." data-core="virtualjaguar">Virtual Jaguar</a>
|
||||
<a class="dropdown-item" href="." data-core="yabause">Yabause</a>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-warning disabled" id="btnRun" onclick="startRetroArch()" disabled>
|
||||
<span class="fa fa-spinner fa-spin" id="icnRun"></span> Run
|
||||
</button>
|
||||
<button class="btn btn-warning disabled" id="btnAdd" onclick="document.getElementById('btnRom').click()" disabled>
|
||||
<span class="fa fa-plus" id="icnAdd"></span> Add Content
|
||||
</button>
|
||||
<button class="btn btn-warning" id="btnClean" onclick="cleanupStorage();" title="Cleanup">
|
||||
<span class="fa fa-trash-o" id="icnClean"></span> <span class="sr-only">Cleanup</span>
|
||||
</button>
|
||||
<input class="btn btn-warning disabled" style="display: none" type="file" id="btnRom" name="upload" onclick="document.getElementById('btnAdd').click();" onchange="selectFiles(event.target.files)" multiple />
|
||||
<button class="btn btn-warning disabled" id="btnFullscreen" onclick="Module.requestFullScreen()" title="Fullscreen" disabled>
|
||||
<span class="fa fa-desktop" id="icnAdd"></span> <span class="sr-only">Fullscreen</span>
|
||||
</button>
|
||||
<button class="btn btn-warning disabled" id="btnMenu" onclick="keyPress(112);" title="Menu toggle" disabled>
|
||||
<span class="fa fa-bars" id="btnMenu"></span> <span class="sr-only">Menu</span>
|
||||
</button>
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.Collapse content-->
|
||||
</div>
|
||||
</nav>
|
||||
<div class="bg-inverse webplayer-container">
|
||||
<div class="container">
|
||||
<div class="webplayer_border text-xs-center" id="canvas_div">
|
||||
<canvas class="webplayer" id="canvas" tabindex="1" oncontextmenu="event.preventDefault()" style="display: none"></canvas>
|
||||
<img class="webplayer-preview img-fluid" src="media/canvas.png" width="960px" height="720px" alt="RetroArch Logo">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2">
|
||||
<div class="btn-group" data-toggle="buttons">
|
||||
<label class="btn btn-warning" id="lblLocal" onclick=switchStorage("browser")>
|
||||
<input type="radio" name="options" id="btnLocal" autocomplete="off" checked>
|
||||
<span class="fa fa-globe" id="icnLocal"></span> Browser
|
||||
</input>
|
||||
</label>
|
||||
<!--uncomment for dropbox support
|
||||
<label class="btn btn-warning" id="lblDrop" onclick=switchStorage("dropbox")>
|
||||
<input type="radio" name="options" id="btnDrop" autocomplete="off">
|
||||
<span class="fa fa-dropbox" id="icnDrop"></span> Dropbox
|
||||
</input>
|
||||
</label>-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2">
|
||||
<div class="card">
|
||||
<div class="view overlay hm-white-slight" align="center">
|
||||
<textarea id="output" rows="15"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div align="center">
|
||||
<p>For now, we recommend you use <a href="https://www.google.com/chrome/">Google Chrome</a> for the best possible performance.</p>
|
||||
<a href="http://www.libretro.com"><img align="center" src="media/libretro-logo.png" /></a>
|
||||
</div>
|
||||
|
||||
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<script src="//rawgit.com/jeresig/jquery.hotkeys/master/jquery.hotkeys.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.4/js/tether.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js"></script>
|
||||
<!--script src="//wzrd.in/standalone/browserfs@0.6.1"></script-->
|
||||
<script src="//bot.libretro.com/web/browserfs.min.js"></script>
|
||||
<script src="embed.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -1,139 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<base target="_parent" />
|
||||
<title>RetroArch Web Player</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
|
||||
<!-- Material Design Bootstrap -->
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.1.1/css/mdb.min.css" rel="stylesheet">
|
||||
|
||||
<link href="itch.css" rel="stylesheet" type="text/css">
|
||||
<link rel="shortcut icon" href="https://buildbot.libretro.com/web/media/retroarch.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<!--Navbar-->
|
||||
<nav class="navbar navbar-dark bg-danger">
|
||||
<div class="container">
|
||||
<!--Collapse content-->
|
||||
<div class="collapse navbar-toggleable-xs" id="collapseEx2">
|
||||
<!--Navbar Brand-->
|
||||
<!--Links-->
|
||||
<ul class="nav navbar-nav">
|
||||
<div class="dropdown">
|
||||
<li class="nav-item dropdown">
|
||||
<button class="btn btn-danger dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Core Selection</button>
|
||||
<div class="dropdown-menu dropdown-danger" aria-labelledby="dropdownMenu1" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut" id="core-selector">
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="2048">2048</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="4do">4DO</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="bluemsx">BlueMSX</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="craft">Craft</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="desmume">DeSmuME</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="dosbox">DOSBox</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="easyrpg">EasyRPG</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="fbalpha2012">FB Alpha 2012</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="fbalpha2012_cps1">FB Alpha 2012 CPS1</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="fbalpha2012_cps2">FB Alpha 2012 CPS2</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="fbalpha2012_neo">FB Alpha 2012 NeoGeo</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="fceumm">FCEUmm</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="ffmpeg">FFmpeg</a>-->
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="gambatte">Gambatte (GB/GBC)</a>
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="genesis_plus_gx">Genesis Plus GX (MD / GG / SMS)</a>
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="glupen64">GLupeN64 (Nintendo 64)</a>
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="gme">Game Music Emu</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="gpsp">gPSP</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="handy">Handy</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mame2000">MAME 2000</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_lynx">Mednafen Lynx</a>-->
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_ngp">Mednafen NeoPop (NGP)</a>
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_pce_fast">Mednafen PCE-Fast (PC-E/TG-16)</a>
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_pcfx">Mednafen/Beetle PCFX</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_psx">Mednafen/Beetle PSX</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_saturn">Mednafen/Beetle Saturn</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_snes">Mednafen/Beetle SNES</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_vb">Mednafen/Beetle Virtual Boy</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mednafen_wswan">Mednafen/Beetle WonderSwan</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="mupen64plus">Mupen64 Plus</a>-->
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="nestopia">Nestopia (NES)</a>
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="nxengine">NX Engine</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="o2em">O2em</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="picodrive">PicoDrive</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="prboom">PrBoom</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="quicknes">QuickNES</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="snes9x2002">Snes9x 2002</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="snes9x2005">Snes9x 2005</a>-->
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="snes9x2010">Snes9x 2010 (SNES)</a>
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="snes9x">Snes9x</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="stella">Stella</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="tgbdual">TGB Dual</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="tyrquake">TyrQuake</a>-->
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="vba_next">VBA Next (Gameboy Advance)</a>
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="vecx">Vecx</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="virtualjaguar">Virtual Jaguar</a>-->
|
||||
<!--<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="yabause">Yabause</a>-->
|
||||
</div>
|
||||
<button class="btn btn-danger disabled" id="btnRun" onclick="startRetroArch()" title="Start RetroArch" disabled>
|
||||
<span class="fa fa-spinner fa-spin" id="icnRun"></span> <span class="sr-only"></span>
|
||||
</button>
|
||||
<button class="btn btn-danger disabled" id="btnAdd" onclick="document.getElementById('btnRom').click()" title="Add Games" disabled>
|
||||
<span class="fa fa-plus" id="icnAdd"></span> </span> <span class="sr-only"></span>
|
||||
</button>
|
||||
<button class="btn btn-danger" id="btnClean" onclick="cleanupStorage();" title="Cleanup">
|
||||
<span class="fa fa-trash-o" id="icnClean"></span> <span class="sr-only">Cleanup</span>
|
||||
</button>
|
||||
<input class="btn btn-danger disabled" style="display: none" type="file" id="btnRom" name="upload" onclick="document.getElementById('btnAdd').click();" onchange="selectFiles(event.target.files)" multiple />
|
||||
<button class="btn btn-danger disabled" id="btnFullscreen" onclick="Module.requestFullScreen()" title="Fullscreen" disabled>
|
||||
<span class="fa fa-desktop" id="icnAdd"></span> <span class="sr-only">Fullscreen</span>
|
||||
</button>
|
||||
<button class="btn btn-danger disabled" id="btnMenu" onclick="keyPress(112);" title="Menu toggle" disabled>
|
||||
<span class="fa fa-bars" id="btnMenu"></span> <span class="sr-only"></span>
|
||||
</button>
|
||||
<!--<button class="btn btn-danger" id="btnDrop" onclick=switchStorage() title="Storage backend">
|
||||
<span class="fa fa-globe" id="icnDrop"></span> <span class="sr-only"></span>
|
||||
</button>-->
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.Collapse content-->
|
||||
</div>
|
||||
</nav>
|
||||
<div class="bg-inverse webplayer-container">
|
||||
<div class="container">
|
||||
<div class="webplayer_border text-xs-center" id="canvas_div">
|
||||
<canvas class="webplayer" id="canvas" tabindex="1" oncontextmenu="event.preventDefault()" style="display: none"></canvas>
|
||||
<img class="webplayer-preview img-fluid" src="https://buildbot.libretro.com/web/media/canvas.png" width="960px" height="720px" alt="RetroArch Logo">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2">
|
||||
<div class="card">
|
||||
<div class="view overlay hm-white-slight" align="center">
|
||||
<textarea id="output" rows="15"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<script src="//rawgit.com/jeresig/jquery.hotkeys/master/jquery.hotkeys.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.4/js/tether.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js"></script>
|
||||
<!--script src="//wzrd.in/standalone/browserfs@0.6.1"></script-->
|
||||
<script src="//bot.libretro.com/web/browserfs.min.js"></script>
|
||||
<script src="itch.js"></script>
|
||||
<div align="center">
|
||||
<a href="https://www.patreon.com/libretro">
|
||||
<img src="http://patreon_public_assets.s3.amazonaws.com/sized/becomeAPatronBanner.png" width="350" height"116"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,99 +0,0 @@
|
||||
/**
|
||||
* RetroArch Web Player
|
||||
*
|
||||
* This provides the basic styling for the RetroArch web player.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Make sure the background of the player is black.
|
||||
*/
|
||||
.webplayer-container {
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
/**
|
||||
* Webplayer Preview when not loaded.
|
||||
*/
|
||||
.webplayer-preview {
|
||||
margin: 0 auto;
|
||||
cursor: wait;
|
||||
opacity: 0.2;
|
||||
transition: all 0.8s;
|
||||
-webkit-animation: loading 0.8s ease-in-out infinite alternate;
|
||||
-moz-animation: loading 0.8s ease-in-out infinite alternate;
|
||||
animation: loading 0.8s ease-in-out infinite alternate;
|
||||
}
|
||||
.webplayer-preview.loaded {
|
||||
cursor: pointer;
|
||||
opacity: 1;
|
||||
-webkit-animation: loaded 0.8s ease-in-out;
|
||||
-moz-animation: loaded 0.8s ease-in-out;
|
||||
animation: loaded 0.8s ease-in-out;
|
||||
}
|
||||
@keyframes loaded {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-moz-keyframes loaded {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes loaded {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
@keyframes loading{
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
@-moz-keyframes loading{
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
@-webkit-keyframes loading {
|
||||
from {
|
||||
opacity: 0.2;
|
||||
}
|
||||
to {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the border around the player.
|
||||
*/
|
||||
canvas.webplayer {
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font-family: monospace;
|
||||
font-size: 0.7em;
|
||||
height: 95%;
|
||||
width: 95%;
|
||||
border-style: none;
|
||||
border-color: transparent;
|
||||
overflow: auto;
|
||||
resize: none;
|
||||
}
|
@ -1,423 +0,0 @@
|
||||
/**
|
||||
* RetroArch Web Player
|
||||
*
|
||||
* This provides the basic JavaScript for the RetroArch web player.
|
||||
*/
|
||||
var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" });
|
||||
var BrowserFS = BrowserFS;
|
||||
var afs;
|
||||
|
||||
var showError = function(error) {
|
||||
switch (error.status) {
|
||||
case Dropbox.ApiError.INVALID_TOKEN:
|
||||
// If you're using dropbox.js, the only cause behind this error is that
|
||||
// the user token expired.
|
||||
// Get the user through the authentication flow again.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NOT_FOUND:
|
||||
// The file or folder you tried to access is not in the user's Dropbox.
|
||||
// Handling this error is specific to your application.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.OVER_QUOTA:
|
||||
// The user is over their Dropbox quota.
|
||||
// Tell them their Dropbox is full. Refreshing the page won't help.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.RATE_LIMITED:
|
||||
// Too many API requests. Tell the user to try again later.
|
||||
// Long-term, optimize your code to use fewer API calls.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NETWORK_ERROR:
|
||||
// An error occurred at the XMLHttpRequest layer.
|
||||
// Most likely, the user's network connection is down.
|
||||
// API calls will not succeed until the user gets back online.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.INVALID_PARAM:
|
||||
case Dropbox.ApiError.OAUTH_ERROR:
|
||||
case Dropbox.ApiError.INVALID_METHOD:
|
||||
default:
|
||||
// Caused by a bug in dropbox.js, in your application, or in Dropbox.
|
||||
// Tell the user an error occurred, ask them to refresh the page.
|
||||
}
|
||||
};
|
||||
|
||||
function cleanupStorage()
|
||||
{
|
||||
localStorage.clear();
|
||||
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
||||
{
|
||||
var req = indexedDB.deleteDatabase("RetroArch");
|
||||
req.onsuccess = function () {
|
||||
console.log("Deleted database successfully");
|
||||
};
|
||||
req.onerror = function () {
|
||||
console.log("Couldn't delete database");
|
||||
};
|
||||
req.onblocked = function () {
|
||||
console.log("Couldn't delete database due to the operation being blocked");
|
||||
};
|
||||
}
|
||||
|
||||
document.getElementById("btnClean").disabled = true;
|
||||
}
|
||||
|
||||
|
||||
function dropboxInit()
|
||||
{
|
||||
document.getElementById('btnRun').disabled = true;
|
||||
//document.getElementById('btnDrop').disabled = true;
|
||||
//$('#icnDrop').removeClass('fa-dropbox');
|
||||
//$('#icnDrop').addClass('fa-spinner fa-spin');
|
||||
|
||||
|
||||
client.authDriver(new Dropbox.AuthDriver.Redirect());
|
||||
client.authenticate({ rememberUser: true }, function(error, client)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
return showError(error);
|
||||
}
|
||||
dropboxSync(client, dropboxSyncComplete);
|
||||
});
|
||||
}
|
||||
|
||||
function dropboxSync(dropboxClient, cb)
|
||||
{
|
||||
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
|
||||
// Wrap in afsFS.
|
||||
afs = new BrowserFS.FileSystem.AsyncMirror(
|
||||
new BrowserFS.FileSystem.InMemory(), dbfs);
|
||||
|
||||
afs.initialize(function(err)
|
||||
{
|
||||
// Initialize it as the root file system.
|
||||
//BrowserFS.initialize(afs);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function dropboxSyncComplete()
|
||||
{
|
||||
document.getElementById('btnRun').disabled = false;
|
||||
//document.getElementById('btnDrop').disabled = false;
|
||||
//$('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
//$('#icnDrop').addClass('fa-dropbox');
|
||||
console.log("WEBPLAYER: Dropbox sync successful");
|
||||
|
||||
setupFileSystem("dropbox");
|
||||
preLoadingComplete();
|
||||
}
|
||||
|
||||
function idbfsInit()
|
||||
{
|
||||
document.getElementById("btnRun").disabled = true;
|
||||
var imfs = new BrowserFS.FileSystem.InMemory();
|
||||
if (BrowserFS.FileSystem.IndexedDB.isAvailable())
|
||||
{
|
||||
afs = new BrowserFS.FileSystem.AsyncMirror(imfs,
|
||||
new BrowserFS.FileSystem.IndexedDB(function(e, fs)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
//fallback to imfs
|
||||
afs = new BrowserFS.FileSystem.InMemory();
|
||||
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
|
||||
setupFileSystem("browser");
|
||||
preLoadingComplete();
|
||||
}
|
||||
else
|
||||
{
|
||||
// initialize afs by copying files from async storage to sync storage.
|
||||
afs.initialize(function (e)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
afs = new BrowserFS.FileSystem.InMemory();
|
||||
console.log("WEBPLAYER: error: " + e + " falling back to in-memory filesystem");
|
||||
setupFileSystem("browser");
|
||||
preLoadingComplete();
|
||||
}
|
||||
else
|
||||
{
|
||||
idbfsSyncComplete();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"RetroArch"));
|
||||
}
|
||||
}
|
||||
|
||||
function idbfsSyncComplete()
|
||||
{
|
||||
$('#icnRun').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
$('#icnRun').addClass('fa-play');
|
||||
console.log("WEBPLAYER: idbfs setup successful");
|
||||
|
||||
setupFileSystem("browser");
|
||||
preLoadingComplete();
|
||||
}
|
||||
|
||||
function preLoadingComplete()
|
||||
{
|
||||
/* Make the Preview image clickable to start RetroArch. */
|
||||
$('.webplayer-preview').addClass('loaded').click(function () {
|
||||
startRetroArch();
|
||||
return false;
|
||||
});
|
||||
document.getElementById("btnRun").disabled = false;
|
||||
$('#btnRun').removeClass('disabled');
|
||||
}
|
||||
|
||||
function setupFileSystem(backend)
|
||||
{
|
||||
/* create a mountable filesystem that will server as a root
|
||||
mountpoint for browserfs */
|
||||
var mfs = new BrowserFS.FileSystem.MountableFileSystem();
|
||||
|
||||
/* create an XmlHttpRequest filesystem for the bundled data */
|
||||
var xfs1 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/assets/frontend/bundle/");
|
||||
/* create an XmlHttpRequest filesystem for core assets */
|
||||
var xfs2 = new BrowserFS.FileSystem.XmlHttpRequest
|
||||
(".index-xhr", "https://bot.libretro.com/assets/cores/");
|
||||
|
||||
console.log("WEBPLAYER: initializing filesystem: " + backend);
|
||||
mfs.mount('/home/web_user/retroarch/userdata', afs);
|
||||
|
||||
mfs.mount('/home/web_user/retroarch/bundle', xfs1);
|
||||
mfs.mount('/home/web_user/retroarch/userdata/content/downloads', xfs2);
|
||||
BrowserFS.initialize(mfs);
|
||||
var BFS = new BrowserFS.EmscriptenFS();
|
||||
FS.mount(BFS, {root: '/home'}, '/home');
|
||||
console.log("WEBPLAYER: " + backend + " filesystem initialization successful");
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the value of the given GET parameter.
|
||||
*/
|
||||
function getParam(name) {
|
||||
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
||||
if (results) {
|
||||
return results[1] || null;
|
||||
}
|
||||
}
|
||||
|
||||
function startRetroArch()
|
||||
{
|
||||
$('.webplayer').show();
|
||||
$('.webplayer-preview').hide();
|
||||
//document.getElementById('btnDrop').disabled = true;
|
||||
document.getElementById('btnRun').disabled = true;
|
||||
|
||||
$('#btnFullscreen').removeClass('disabled');
|
||||
$('#btnMenu').removeClass('disabled');
|
||||
$('#btnAdd').removeClass('disabled');
|
||||
$('#btnRom').removeClass('disabled');
|
||||
|
||||
document.getElementById("btnAdd").disabled = false;
|
||||
document.getElementById("btnRom").disabled = false;
|
||||
document.getElementById("btnMenu").disabled = false;
|
||||
document.getElementById("btnFullscreen").disabled = false;
|
||||
|
||||
Module['callMain'](Module['arguments']);
|
||||
document.getElementById('canvas').focus();
|
||||
}
|
||||
|
||||
function selectFiles(files)
|
||||
{
|
||||
$('#btnAdd').addClass('disabled');
|
||||
$('#icnAdd').removeClass('fa-plus');
|
||||
$('#icnAdd').addClass('fa-spinner spinning');
|
||||
var count = files.length;
|
||||
|
||||
for (var i = 0; i < files.length; i++)
|
||||
{
|
||||
filereader = new FileReader();
|
||||
filereader.file_name = files[i].name;
|
||||
filereader.readAsArrayBuffer(files[i]);
|
||||
filereader.onload = function(){uploadData(this.result, this.file_name)};
|
||||
filereader.onloadend = function(evt)
|
||||
{
|
||||
console.log("WEBPLAYER: file: " + this.file_name + " upload complete");
|
||||
if (evt.target.readyState == FileReader.DONE)
|
||||
{
|
||||
$('#btnAdd').removeClass('disabled');
|
||||
$('#icnAdd').removeClass('fa-spinner spinning');
|
||||
$('#icnAdd').addClass('fa-plus');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function uploadData(data,name)
|
||||
{
|
||||
var dataView = new Uint8Array(data);
|
||||
FS.createDataFile('/', name, dataView, true, false);
|
||||
|
||||
var data = FS.readFile(name,{ encoding: 'binary' });
|
||||
FS.writeFile('/home/web_user/retroarch/userdata/content/' + name, data ,{ encoding: 'binary' });
|
||||
FS.unlink(name);
|
||||
}
|
||||
|
||||
var Module =
|
||||
{
|
||||
noInitialRun: true,
|
||||
arguments: ["-v", "--menu"],
|
||||
preRun: [],
|
||||
postRun: [],
|
||||
print: (function()
|
||||
{
|
||||
var element = document.getElementById('output');
|
||||
element.value = ''; // clear browser cache
|
||||
return function(text)
|
||||
{
|
||||
text = Array.prototype.slice.call(arguments).join(' ');
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = 99999; // focus on bottom
|
||||
};
|
||||
})(),
|
||||
|
||||
printErr: function(text)
|
||||
{
|
||||
var text = Array.prototype.slice.call(arguments).join(' ');
|
||||
var element = document.getElementById('output');
|
||||
element.value += text + "\n";
|
||||
element.scrollTop = 99999; // focus on bottom
|
||||
},
|
||||
canvas: document.getElementById('canvas'),
|
||||
totalDependencies: 0,
|
||||
monitorRunDependencies: function(left)
|
||||
{
|
||||
this.totalDependencies = Math.max(this.totalDependencies, left);
|
||||
}
|
||||
};
|
||||
|
||||
function switchCore(corename) {
|
||||
localStorage.setItem("core", corename);
|
||||
}
|
||||
|
||||
function switchStorage() {
|
||||
if (localStorage.getItem("backend") == "dropbox")
|
||||
{
|
||||
localStorage.setItem("backend", "browser");
|
||||
location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
localStorage.setItem("backend", "dropbox");
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// When the browser has loaded everything.
|
||||
$(function() {
|
||||
/**
|
||||
* Attempt to disable some default browser keys.
|
||||
*/
|
||||
var keys = {
|
||||
9: "tab",
|
||||
13: "enter",
|
||||
16: "shift",
|
||||
18: "alt",
|
||||
27: "esc",
|
||||
33: "rePag",
|
||||
34: "avPag",
|
||||
35: "end",
|
||||
36: "home",
|
||||
37: "left",
|
||||
38: "up",
|
||||
39: "right",
|
||||
40: "down",
|
||||
112: "F1",
|
||||
113: "F2",
|
||||
114: "F3",
|
||||
115: "F4",
|
||||
116: "F5",
|
||||
117: "F6",
|
||||
118: "F7",
|
||||
119: "F8",
|
||||
120: "F9",
|
||||
121: "F10",
|
||||
122: "F11",
|
||||
123: "F12"
|
||||
};
|
||||
window.addEventListener('keydown', function (e) {
|
||||
if (keys[e.which]) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Switch the core when selecting one.
|
||||
$('#core-selector a').click(function () {
|
||||
var coreChoice = $(this).data('core');
|
||||
switchCore(coreChoice);
|
||||
});
|
||||
|
||||
// Find which core to load.
|
||||
var core = localStorage.getItem("core", core);
|
||||
if (!core) {
|
||||
core = 'gambatte';
|
||||
}
|
||||
// Make the core the selected core in the UI.
|
||||
var coreTitle = $('#core-selector a[data-core="' + core + '"]').addClass('active').text();
|
||||
$('#dropdownMenu1').text(coreTitle);
|
||||
|
||||
// Load the Core's related JavaScript.
|
||||
$.getScript(core + '_libretro.js', function ()
|
||||
{
|
||||
if (localStorage.getItem("backend") == "dropbox")
|
||||
{
|
||||
//$('#icnDrop').removeClass('fa-globe');
|
||||
//$('#icnDrop').addClass('fa-dropbox');
|
||||
dropboxInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
//$('#icnDrop').addClass('fa-globe');
|
||||
//$('#icnDrop').removeClass('fa-dropbox');
|
||||
idbfsInit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function keyPress(k)
|
||||
{
|
||||
kp(k, "keydown");
|
||||
setInterval(function(){kp(k, "keyup")}, 1000);
|
||||
}
|
||||
|
||||
kp = function(k, event) {
|
||||
var oEvent = document.createEvent('KeyboardEvent');
|
||||
|
||||
// Chromium Hack
|
||||
Object.defineProperty(oEvent, 'keyCode', {
|
||||
get : function() {
|
||||
return this.keyCodeVal;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(oEvent, 'which', {
|
||||
get : function() {
|
||||
return this.keyCodeVal;
|
||||
}
|
||||
});
|
||||
|
||||
if (oEvent.initKeyboardEvent) {
|
||||
oEvent.initKeyboardEvent(event, true, true, document.defaultView, false, false, false, false, k, k);
|
||||
} else {
|
||||
oEvent.initKeyEvent(event, true, true, document.defaultView, false, false, false, false, k, 0);
|
||||
}
|
||||
|
||||
oEvent.keyCodeVal = k;
|
||||
|
||||
if (oEvent.keyCode !== k) {
|
||||
alert("keyCode mismatch " + oEvent.keyCode + "(" + oEvent.which + ")");
|
||||
}
|
||||
|
||||
document.dispatchEvent(oEvent);
|
||||
document.getElementById('canvas').focus();
|
||||
}
|
100
pkg/emscripten/libretro/embed.html
Normal file
100
pkg/emscripten/libretro/embed.html
Normal file
@ -0,0 +1,100 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>RetroArch Web Player</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<!-- Font Awesome -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.0/css/font-awesome.min.css">
|
||||
<!-- Material Design Bootstrap -->
|
||||
<link href="//cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.1.1/css/mdb.min.css" rel="stylesheet">
|
||||
|
||||
<link href="libretro.css" rel="stylesheet" type="text/css">
|
||||
<link rel="shortcut icon" href="https://web.libretro.com/media/retroarch.ico" />
|
||||
</head>
|
||||
<body>
|
||||
<!--Navbar-->
|
||||
<nav class="navbar navbar-dark bg-primary">
|
||||
<div class="container">
|
||||
<!--Collapse content-->
|
||||
<div class="collapse navbar-toggleable-xs" id="collapseEx2">
|
||||
|
||||
<!--Links-->
|
||||
<ul class="nav navbar-nav">
|
||||
<div class="dropdown">
|
||||
<li class="nav-item dropdown">
|
||||
<button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Core Selection</button>
|
||||
<div class="dropdown-menu dropdown-primary" aria-labelledby="dropdownMenu1" data-dropdown-in="fadeIn" data-dropdown-out="fadeOut" id="core-selector">
|
||||
<a class="dropdown-item" href="." data-core="fceumm">FCEUmm</a>
|
||||
<a class="dropdown-item" href="." data-core="gambatte">Gambatte</a>
|
||||
<a class="dropdown-item" href="." data-core="genesis_plus_gx">Genesis Plus GX</a>
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="nestopia">Nestopia (NES)</a>
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="snes9x2010">Snes9x 2010 (SNES)</a>
|
||||
<a class="dropdown-item" href="https://libretro.itch.io/retroarch" data-core="vba_next">VBA Next (Gameboy Advance)</a>
|
||||
</div>
|
||||
<button class="btn btn-primary disabled" id="btnRun" onclick="startRetroArch()" disabled>
|
||||
<span class="fa fa-spinner fa-spin" id="icnRun"></span> Run
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary disabled" id="btnAdd" onclick="document.getElementById('btnRom').click()" disabled>
|
||||
<span class="fa fa-plus" id="icnAdd"></span> Add Content
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary tooltip-enable" id="btnClean" onclick="cleanupStorage();" title="Cleanup storage">
|
||||
<span class="fa fa-trash-o" id="icnClean"></span> <span class="sr-only">Cleanup</span>
|
||||
</button>
|
||||
|
||||
<input class="btn btn-primary disabled" style="display: none" type="file" id="btnRom" name="upload" onclick="document.getElementById('btnAdd').click();" onchange="selectFiles(event.target.files)" multiple />
|
||||
<button class="btn btn-primary disabled tooltip-enable" id="btnMenu" onclick="keyPress(112);" title="Menu toggle" disabled>
|
||||
<span class="fa fa-bars" id="btnMenu"></span> <span class="sr-only">Menu</span>
|
||||
</button>
|
||||
|
||||
<button class="btn btn-primary disabled tooltip-enable" id="btnFullscreen" onclick="Module.requestFullScreen()" title="Fullscreen" disabled>
|
||||
<span class="fa fa-desktop" id="icnAdd"></span> <span class="sr-only">Fullscreen</span>
|
||||
</button>
|
||||
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.Collapse content-->
|
||||
</div>
|
||||
</nav>
|
||||
<div class="bg-inverse webplayer-container">
|
||||
<div class="container">
|
||||
<div class="webplayer_border text-xs-center" id="canvas_div">
|
||||
<canvas class="webplayer" id="canvas" tabindex="1" oncontextmenu="event.preventDefault()" style="display: none"></canvas>
|
||||
<img class="webplayer-preview img-fluid" src="media/canvas.png" width="960px" height="720px" alt="RetroArch Logo">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-center p-t-2">
|
||||
<div class="card">
|
||||
<div class="view overlay hm-white-slight" align="center">
|
||||
<textarea id="output" rows="15"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<script src="//rawgit.com/jeresig/jquery.hotkeys/master/jquery.hotkeys.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.4/js/tether.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"></script>
|
||||
<script src="analytics.js"></script>
|
||||
<!--script src="//wzrd.in/standalone/browserfs@0.6.1"></script-->
|
||||
<script src="//web.libretro.com/browserfs.min.js"></script>
|
||||
<script src="libretro.js"></script>
|
||||
<div align="center">
|
||||
<a href="https://www.patreon.com/libretro">
|
||||
<img src="https://patreon_public_assets.s3.amazonaws.com/sized/becomeAPatronBanner.png" width="350" height="116"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -95,51 +95,38 @@
|
||||
</li>
|
||||
</div>
|
||||
</ul>
|
||||
<div class="toggleMenu">
|
||||
<button class="btn btn-primary" id="btnHideMenu" title="Toggle Menu">
|
||||
<span class="fa fa-chevron-up" id="icnHideMenu"></span> <span class="sr-only">Hide Top Navigation</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<!--/.Collapse content-->
|
||||
</div>
|
||||
</nav>
|
||||
<div class="bg-inverse webplayer-container">
|
||||
<div class="webplayer_border text-xs-center" id="canvas_div">
|
||||
<canvas class="webplayer" id="canvas" tabindex="1" oncontextmenu="event.preventDefault()" style="display: none"></canvas>
|
||||
<img class="webplayer-preview img-fluid" src="media/canvas.png" width="960px" height="720px" alt="RetroArch Logo">
|
||||
<div class="showMenu">
|
||||
<button type="button" class="btn btn-link">
|
||||
<span class="fa fa-chevron-down" id="icnShowMenu"></span> <span class="sr-only">Show Top Navigation</span>
|
||||
</button>
|
||||
</div>
|
||||
<canvas class="webplayer" id="canvas" tabindex="1" oncontextmenu="event.preventDefault()" style="display: none"></canvas>
|
||||
<img class="webplayer-preview img-fluid" src="media/canvas.png" width="960px" height="720px" alt="RetroArch Logo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-sm-12 form-group btn-group text-xs-left p-t-2">
|
||||
<div class="btn-group" data-toggle="buttons">
|
||||
<label class="btn btn-primary tooltip-enable" id="lblLocal" onclick="switchStorage('browser')" title="Store content in your browser's cache. May take up space on disk.">
|
||||
<input type="radio" name="options" id="btnLocal" autocomplete="off" checked >
|
||||
<span class="fa fa-globe" id="icnLocal"></span> Browser
|
||||
</input>
|
||||
</label>
|
||||
<label class="btn btn-primary tooltip-enable" id="lblDrop" onclick="switchStorage('dropbox')" title="Stores content in a folder under Dropbox storage. Requires a Dropbox account.">
|
||||
<input type="radio" name="options" id="btnDrop" autocomplete="off">
|
||||
<span class="fa fa-dropbox" id="icnDrop"></span> Dropbox
|
||||
</input>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div align="center">
|
||||
<p>For now, we recommend you use <a href="https://www.google.com/chrome/">Google Chrome</a> for the best possible performance.</p>
|
||||
<a href="http://www.libretro.com"><img align="center" src="media/libretro-logo.png" /></a>
|
||||
</div>
|
||||
|
||||
<script src="//code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<script src="//rawgit.com/jeresig/jquery.hotkeys/master/jquery.hotkeys.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/tether/1.3.4/js/tether.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"></script>
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.10.2/dropbox.min.js"></script>
|
||||
<script src="analytics.js"></script>
|
||||
<!--script src="//wzrd.in/standalone/browserfs@0.6.1"></script-->
|
||||
<script src="//web.libretro.com/browserfs.min.js"></script>
|
||||
<script src="libretro.js"></script>
|
||||
<div align="center">
|
||||
<a href="https://www.patreon.com/libretro">
|
||||
<img src="http://patreon_public_assets.s3.amazonaws.com/sized/becomeAPatronBanner.png" width="350" height"116"></a>
|
||||
<img src="https://patreon_public_assets.s3.amazonaws.com/sized/becomeAPatronBanner.png" width="350" height="116"></a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -98,6 +98,21 @@ textarea {
|
||||
resize: none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle Top Navigation
|
||||
*/
|
||||
.toggleMenu {
|
||||
float: right;
|
||||
}
|
||||
.showMenu {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
#icnShowMenu {
|
||||
color: #565656 !important;
|
||||
}
|
||||
|
||||
/* fix weird white bar in chrome when fullscreen */
|
||||
:-webkit-full-screen {
|
||||
height: 100%;
|
||||
|
@ -3,48 +3,9 @@
|
||||
*
|
||||
* This provides the basic JavaScript for the RetroArch web player.
|
||||
*/
|
||||
var client = new Dropbox.Client({ key: "il6e10mfd7pgf8r" });
|
||||
var BrowserFS = BrowserFS;
|
||||
var afs;
|
||||
|
||||
var showError = function(error) {
|
||||
switch (error.status) {
|
||||
case Dropbox.ApiError.INVALID_TOKEN:
|
||||
// If you're using dropbox.js, the only cause behind this error is that
|
||||
// the user token expired.
|
||||
// Get the user through the authentication flow again.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NOT_FOUND:
|
||||
// The file or folder you tried to access is not in the user's Dropbox.
|
||||
// Handling this error is specific to your application.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.OVER_QUOTA:
|
||||
// The user is over their Dropbox quota.
|
||||
// Tell them their Dropbox is full. Refreshing the page won't help.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.RATE_LIMITED:
|
||||
// Too many API requests. Tell the user to try again later.
|
||||
// Long-term, optimize your code to use fewer API calls.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.NETWORK_ERROR:
|
||||
// An error occurred at the XMLHttpRequest layer.
|
||||
// Most likely, the user's network connection is down.
|
||||
// API calls will not succeed until the user gets back online.
|
||||
break;
|
||||
|
||||
case Dropbox.ApiError.INVALID_PARAM:
|
||||
case Dropbox.ApiError.OAUTH_ERROR:
|
||||
case Dropbox.ApiError.INVALID_METHOD:
|
||||
default:
|
||||
// Caused by a bug in dropbox.js, in your application, or in Dropbox.
|
||||
// Tell the user an error occurred, ask them to refresh the page.
|
||||
}
|
||||
};
|
||||
|
||||
function cleanupStorage()
|
||||
{
|
||||
localStorage.clear();
|
||||
@ -65,52 +26,8 @@ function cleanupStorage()
|
||||
document.getElementById("btnClean").disabled = true;
|
||||
}
|
||||
|
||||
function dropboxInit()
|
||||
{
|
||||
document.getElementById("btnDrop").disabled = true;
|
||||
$('#icnDrop').removeClass('fa-dropbox');
|
||||
$('#icnDrop').addClass('fa-spinner fa-spin');
|
||||
|
||||
|
||||
client.authDriver(new Dropbox.AuthDriver.Redirect());
|
||||
client.authenticate({ rememberUser: true }, function(error, client)
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
return showError(error);
|
||||
}
|
||||
dropboxSync(client, dropboxSyncComplete);
|
||||
});
|
||||
}
|
||||
|
||||
function dropboxSync(dropboxClient, cb)
|
||||
{
|
||||
var dbfs = new BrowserFS.FileSystem.Dropbox(dropboxClient);
|
||||
// Wrap in afsFS.
|
||||
afs = new BrowserFS.FileSystem.AsyncMirror(
|
||||
new BrowserFS.FileSystem.InMemory(), dbfs);
|
||||
|
||||
afs.initialize(function(err)
|
||||
{
|
||||
// Initialize it as the root file system.
|
||||
//BrowserFS.initialize(afs);
|
||||
cb();
|
||||
});
|
||||
}
|
||||
|
||||
function dropboxSyncComplete()
|
||||
{
|
||||
$('#icnDrop').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
$('#icnDrop').addClass('fa-check');
|
||||
console.log("WEBPLAYER: Dropbox sync successful");
|
||||
|
||||
setupFileSystem("dropbox");
|
||||
preLoadingComplete();
|
||||
}
|
||||
|
||||
function idbfsInit()
|
||||
{
|
||||
document.getElementById("btnLocal").disabled = true;
|
||||
$('#icnLocal').removeClass('fa-globe');
|
||||
$('#icnLocal').addClass('fa-spinner fa-spin');
|
||||
var imfs = new BrowserFS.FileSystem.InMemory();
|
||||
@ -209,7 +126,6 @@ function startRetroArch()
|
||||
{
|
||||
$('.webplayer').show();
|
||||
$('.webplayer-preview').hide();
|
||||
document.getElementById("btnDrop").disabled = true;
|
||||
document.getElementById("btnRun").disabled = true;
|
||||
|
||||
$('#btnFullscreen').removeClass('disabled');
|
||||
@ -303,6 +219,13 @@ $(function() {
|
||||
placement: 'right'
|
||||
});
|
||||
|
||||
// Allow hiding the top menu.
|
||||
$('.showMenu').hide();
|
||||
$('#btnHideMenu, .showMenu').click(function () {
|
||||
$('nav').slideToggle('slow');
|
||||
$('.showMenu').toggle('slow');
|
||||
});
|
||||
|
||||
/**
|
||||
* Attempt to disable some default browser keys.
|
||||
*/
|
||||
@ -359,19 +282,9 @@ $(function() {
|
||||
{
|
||||
$('#icnRun').removeClass('fa-spinner').removeClass('fa-spin');
|
||||
$('#icnRun').addClass('fa-play');
|
||||
|
||||
if (localStorage.getItem("backend") == "dropbox")
|
||||
{
|
||||
$('#lblDrop').addClass('active');
|
||||
$('#lblLocal').removeClass('active');
|
||||
dropboxInit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#lblDrop').removeClass('active');
|
||||
$('#lblLocal').addClass('active');
|
||||
idbfsInit();
|
||||
}
|
||||
$('#lblDrop').removeClass('active');
|
||||
$('#lblLocal').addClass('active');
|
||||
idbfsInit();
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user