Compare commits

..
86 changed files with 2492 additions and 3191 deletions

No files matched your search

+2 -2
View File
@@ -56,9 +56,9 @@ jobs:
branch: buildjre17-21
name: jre21-pojav
- uses: gradle/actions/setup-gradle@v4
- uses: gradle/gradle-build-action@v2
with:
gradle-version: "8.11"
gradle-version: 7.6.1
- name: Build JRE JAR files
run: |
+633 -124
View File
@@ -1,165 +1,674 @@
GNU LESSER GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
0. Additional Definitions.
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.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
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.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
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.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
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.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
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.
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
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.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
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.
1. Exception to Section 3 of the GNU GPL.
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.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
The precise terms and conditions for copying, distribution and
modification follow.
2. Conveying Modified Versions.
TERMS AND CONDITIONS
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
0. Definitions.
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
"This License" refers to version 3 of the GNU General Public License.
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
3. Object Code Incorporating Material from Library Header Files.
"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.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
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) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
A "covered work" means either the unmodified Program or a work based
on the Program.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
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.
4. Combined Works.
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.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
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.
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
1. Source Code.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
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.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
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.
d) Do one of the following:
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.
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
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.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
The Corresponding Source for a work in source code form is that
same work.
5. Combined Libraries.
2. Basic Permissions.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
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.
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
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.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
6. Revised Versions of the GNU Lesser General Public License.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser 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.
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.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
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.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
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.
PojavLauncher - A Minecraft: Java Edition Launcher for Android and iOS
Copyright (C) 2021 Tran Hoang Khanh Duy and contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
PojavLauncher Copyright (C) 2021 Tran Hoang Khanh Duy
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+3 -3
View File
@@ -5,7 +5,7 @@
[![Android CI](https://github.com/PojavLauncherTeam/PojavLauncher/workflows/Android%20CI/badge.svg)](https://github.com/PojavLauncherTeam/PojavLauncher/actions)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/PojavLauncherTeam/PojavLauncher)](https://github.com/PojavLauncherTeam/PojavLauncher/actions)
[![Crowdin](https://badges.crowdin.net/pojavlauncher/localized.svg)](https://crowdin.com/project/pojavlauncher)
[![Discord](https://img.shields.io/discord/724163890803638273.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.com/invite/aenk3EUvER)
[![Discord](https://img.shields.io/discord/724163890803638273.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.com/invite/pojavlauncher-724163890803638273)
[![Twitter Follow](https://img.shields.io/twitter/follow/plaunchteam?color=blue&style=flat-square)](https://twitter.com/PLaunchTeam)
* From [Boardwalk](https://github.com/zhuowei/Boardwalk)'s ashes here comes PojavLauncher!
@@ -14,10 +14,10 @@
* It can run almost every version of Minecraft, allowing you to use .jar only installers to install modloaders such as [Forge](https://files.minecraftforge.net/) and [Fabric](http://fabricmc.net/), mods like [OptiFine](https://optifine.net) and [LabyMod](https://www.labymod.net/en), as well as hack clients like [Wurst](https://www.wurstclient.net/), and much more!
* For more details [check out our wiki](https://pojavlauncherteam.github.io/)
* For more details [check out our wiki](https://github.com/PojavLauncherTeam/PojavLauncher/wiki)
## Some notes to start with
- We do not have an official TikTok account. No one from the dev team makes TikTok videos.
- The official Twitter for PojavLauncher is [@PLaunchTeam](https://twitter.com/PLaunchTeam). Any others (most notably @PojavLauncher) are fake.
- The official Twitter for PojavLauncher is [@PLaunchTeam](https://twitter.com/PLaunchTeam). Any others (most notably @PojavLauncher) are fake, please report them to Twitter's moderation team.
## Navigation
- [Introduction](#introduction)
+3 -13
View File
@@ -1,5 +1,5 @@
plugins {
id 'com.android.application' version '8.7.2'
id 'com.android.application' version '7.4.2'
}
static def getDate() { return new Date().format('yyyyMMdd') }
@@ -137,10 +137,6 @@ android {
minifyEnabled true
shrinkResources true
}
proguardNoDebug {
initWith proguard
debuggable false
}
release {
// Don't set to true or java.awt will be a.a or something similar.
@@ -186,15 +182,9 @@ android {
buildFeatures {
prefab true
buildConfig true
}
buildToolsVersion = '34.0.0'
}
afterEvaluate {
// Explicit dependencies for which the apk relies on
tasks.mergeDebugAssets.dependsOn(":forge_installer:jar", ":arc_dns_injector:jar", ":jre_lwjgl3glfw:jar")
buildToolsVersion = '33.0.2'
}
dependencies {
@@ -214,7 +204,7 @@ dependencies {
implementation 'com.github.PojavLauncherTeam:portrait-ssp:6c02fd739b'
implementation 'com.github.Mathias-Boulay:ExtendedView:1.0.0'
implementation 'com.github.Mathias-Boulay:android_gamepad_remapper:2.0.3'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:1.14'
implementation 'com.github.Mathias-Boulay:virtual-joystick-android:2e7aa25e50'
// implementation 'com.intuit.sdp:sdp-android:1.0.5'
// implementation 'com.intuit.ssp:ssp-android:1.0.5'
@@ -106,7 +106,7 @@
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|keyboard|navigation|uiMode"
android:launchMode="singleTop"
android:launchMode="standard"
android:process=":game"
android:screenOrientation="sensorLandscape" />
@@ -1 +1 @@
1732218529630
1720909595576
@@ -1,138 +0,0 @@
package com.kdt;
import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.SeekBar;
/**
* Seekbar with ability to handle ranges and increments
*/
@SuppressLint("AppCompatCustomView")
public class CustomSeekbar extends SeekBar {
private int mMin = 0;
private int mIncrement = 1;
private SeekBar.OnSeekBarChangeListener mListener;
/** When using increments, this flag is used to prevent double calls to the listener */
private boolean mInternalChanges = false;
public CustomSeekbar(Context context) {
super(context);
setup();
}
public CustomSeekbar(Context context, AttributeSet attrs) {
super(context, attrs);
setup();
}
public CustomSeekbar(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
setup();
}
public CustomSeekbar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
setup();
}
public void setIncrement(int increment) {
mIncrement = increment;
}
public void setRange(int min, int max) {
mMin = min;
setMax(max - min);
}
@Override
public synchronized void setProgress(int progress) {
super.setProgress(applyIncrement(progress - mMin));
}
@Override
public void setProgress(int progress, boolean animate) {
super.setProgress(applyIncrement(progress - mMin), animate);
}
@Override
public synchronized int getProgress() {
return applyIncrement(super.getProgress() + mMin);
}
@Override
public synchronized void setMin(int min) {
super.setMin(min);
mMin = min;
}
/**
* Wrapper to allow for a listener to be set around the internal listener
*/
@Override
public void setOnSeekBarChangeListener(OnSeekBarChangeListener l) {
mListener = l;
}
public void setup() {
super.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
/** Store the previous progress to prevent double calls with increments */
private int previousProgress = 0;
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (mInternalChanges) return;
mInternalChanges = true;
progress += mMin;
progress = applyIncrement(progress);
if (progress != previousProgress) {
if (mListener != null) {
previousProgress = progress;
mListener.onProgressChanged(seekBar, progress, fromUser);
}
}
// Forces the thumb to snap to the increment
setProgress(progress);
mInternalChanges = false;
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
if (mInternalChanges) return;
if (mListener != null) {
mListener.onStartTrackingTouch(seekBar);
}
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
if (mInternalChanges) return;
mInternalChanges = true;
setProgress(seekBar.getProgress());
if (mListener != null) {
mListener.onStopTrackingTouch(seekBar);
}
mInternalChanges = false;
}
});
}
/**
* Apply increment to the progress
* @param progress Progress to apply increment to
* @return Progress with increment applied
*/
private int applyIncrement(int progress) {
if (mIncrement < 1) return progress;
progress = progress / mIncrement;
progress = progress * mIncrement;
return progress;
}
}
@@ -1,251 +0,0 @@
package com.kdt;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.Button;
import android.widget.TextView;
import androidx.annotation.CallSuper;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.core.content.res.ResourcesCompat;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
/**
* The base class for side dialog views
* A side dialog is a dialog appearing from one side of the screen
*/
public abstract class SideDialogView {
private final ViewGroup mParent;
private final @LayoutRes int mLayoutId;
private ViewGroup mDialogLayout;
private DefocusableScrollView mScrollView;
protected View mDialogContent;
protected final int mMargin;
private ObjectAnimator mSideDialogAnimator;
protected boolean mDisplaying = false;
/* Whether the layout is built */
private boolean mIsInstantiated = false;
/* UI elements */
private Button mStartButton, mEndButton;
private TextView mTitleTextview;
private View mTitleDivider;
/* Data to store when the UI element has yet to be inflated */
private @StringRes int mStartButtonStringId, mEndButtonStringId, mTitleStringId;
private View.OnClickListener mStartButtonListener, mEndButtonListener;
public SideDialogView(Context context, ViewGroup parent, @LayoutRes int layoutId) {
mMargin = context.getResources().getDimensionPixelOffset(R.dimen._20sdp);
mParent = parent;
mLayoutId = layoutId;
}
public void setTitle(@StringRes int textId) {
mTitleStringId = textId;
if (mIsInstantiated) {
mTitleTextview.setText(textId);
mTitleTextview.setVisibility(View.VISIBLE);
mTitleDivider.setVisibility(View.VISIBLE);
}
}
public final void setStartButtonListener(@StringRes int textId, @Nullable View.OnClickListener listener) {
mStartButtonStringId = textId;
mStartButtonListener = listener;
if (mIsInstantiated) setButton(mStartButton, textId, listener);
}
public final void setEndButtonListener(@StringRes int textId, @Nullable View.OnClickListener listener) {
mEndButtonStringId = textId;
mEndButtonListener = listener;
if (mIsInstantiated) setButton(mEndButton, textId, listener);
}
private void setButton(@NonNull Button button, @StringRes int textId, @Nullable View.OnClickListener listener) {
button.setText(textId);
button.setOnClickListener(listener);
button.setVisibility(View.VISIBLE);
}
private void inflateLayout() {
if(mIsInstantiated) {
Log.w("SideDialogView", "Layout already inflated");
return;
}
// Inflate layouts
mDialogLayout = (ViewGroup) LayoutInflater.from(mParent.getContext()).inflate(R.layout.dialog_side_dialog, mParent, false);
mScrollView = mDialogLayout.findViewById(R.id.side_dialog_scrollview);
mStartButton = mDialogLayout.findViewById(R.id.side_dialog_start_button);
mEndButton = mDialogLayout.findViewById(R.id.side_dialog_end_button);
mTitleTextview = mDialogLayout.findViewById(R.id.side_dialog_title_textview);
mTitleDivider = mDialogLayout.findViewById(R.id.side_dialog_title_divider);
LayoutInflater.from(mParent.getContext()).inflate(mLayoutId, mScrollView, true);
mDialogContent = mScrollView.getChildAt(0);
// Attach layouts
mParent.addView(mDialogLayout);
mSideDialogAnimator = ObjectAnimator.ofFloat(mDialogLayout, "x", 0).setDuration(600);
mSideDialogAnimator.setInterpolator(new AccelerateDecelerateInterpolator());
mDialogLayout.setElevation(10);
mDialogLayout.setTranslationZ(10);
mDialogLayout.setVisibility(View.VISIBLE);
mDialogLayout.setBackground(ResourcesCompat.getDrawable(mDialogLayout.getResources(), R.drawable.background_control_editor, null));
//TODO offset better according to view width
mDialogLayout.setX(-mDialogLayout.getResources().getDimensionPixelOffset(R.dimen._280sdp));
mIsInstantiated = true;
// Set up UI elements
if (mTitleStringId != 0) setTitle(mTitleStringId);
if (mStartButtonStringId != 0) setStartButtonListener(mStartButtonStringId, mStartButtonListener);
if (mEndButtonStringId != 0) setEndButtonListener(mEndButtonStringId, mEndButtonListener);
}
/** Destroy the layout, cleanup variables */
private void deflateLayout() {
if(!mIsInstantiated) {
Log.w("SideDialogView", "Layout not inflated");
return;
}
mParent.removeView(mDialogLayout);
mIsInstantiated = false;
mScrollView = null;
mSideDialogAnimator = null;
mDialogLayout = null;
mDialogContent = null;
mTitleTextview = null;
mTitleDivider = null;
mStartButton = null;
mEndButton = null;
}
/**
* Slide the layout into the visible screen area
*/
@CallSuper
public final void appear(boolean fromRight) {
if (!mIsInstantiated) {
inflateLayout();
onInflate();
}
// To avoid UI sizing issue when the dialog is not fully inflated
onAppear();
Tools.runOnUiThread(() -> {
if (fromRight) {
if (!mDisplaying || !isAtRight()) {
mSideDialogAnimator.setFloatValues(currentDisplayMetrics.widthPixels, currentDisplayMetrics.widthPixels - mScrollView.getWidth() - mMargin);
mSideDialogAnimator.start();
mDisplaying = true;
}
} else {
if (!mDisplaying || isAtRight()) {
mSideDialogAnimator.setFloatValues(-mDialogLayout.getWidth(), mMargin);
mSideDialogAnimator.start();
mDisplaying = true;
}
}
});
}
protected final boolean isAtRight() {
return mDialogLayout.getX() > currentDisplayMetrics.widthPixels / 2f;
}
/**
* Slide out the layout
* @param destroy Whether the layout should be destroyed after disappearing.
* Recommended to be true if the layout is not going to be used anymore
*/
@CallSuper
public final void disappear(boolean destroy) {
if(!mIsInstantiated) {
Log.w("SideDialogView", "Layout not inflated");
return;
}
if (!mDisplaying) {
if(destroy) {
onDisappear();
onDestroy();
deflateLayout();
}
return;
}
mDisplaying = false;
if (isAtRight())
mSideDialogAnimator.setFloatValues(currentDisplayMetrics.widthPixels - mDialogLayout.getWidth() - mMargin, currentDisplayMetrics.widthPixels);
else
mSideDialogAnimator.setFloatValues(mMargin, -mDialogLayout.getWidth());
if(destroy) {
onDisappear();
onDestroy();
mSideDialogAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mSideDialogAnimator.removeListener(this);
deflateLayout();
}
});
}
mSideDialogAnimator.start();
}
/** @return Whether the dialog is currently displaying */
public final boolean isDisplaying(){
return mDisplaying;
}
/**
* Called when the dialog is inflated, ideal for setting up UI elements bindings
*/
protected void onInflate() {}
/**
* Called after the dialog has appeared
*/
protected void onAppear() {}
/**
* Called after the dialog has disappeared
*/
protected void onDisappear() {}
/**
* Called before the dialog gets destroyed (removing views from parent)
* Ideal for cleaning up resources
*/
protected void onDestroy() {}
}
@@ -1,10 +1,7 @@
package net.kdt.pojavlaunch;
import androidx.annotation.Keep;
import dalvik.annotation.optimization.CriticalNative;
@Keep
public class CriticalNativeTest {
@CriticalNative
public static native void testCriticalNative(int arg0, int arg1);
@@ -4,6 +4,7 @@ import static net.kdt.pojavlaunch.Tools.shareLog;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
@@ -20,26 +21,21 @@ public class ExitActivity extends AppCompatActivity {
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int code = -1;
boolean isSignal = false;
Bundle extras = getIntent().getExtras();
if(extras != null) {
code = extras.getInt("code",-1);
isSignal = extras.getBoolean("isSignal", false);
}
int message = isSignal ? R.string.mcn_signal_title : R.string.mcn_exit_title;
new AlertDialog.Builder(this)
.setMessage(getString(message,code))
.setMessage(getString(R.string.mcn_exit_title,code))
.setPositiveButton(R.string.main_share_logs, (dialog, which) -> shareLog(this))
.setOnDismissListener(dialog -> ExitActivity.this.finish())
.show();
}
public static void showExitMessage(Context ctx, int code, boolean isSignal) {
public static void showExitMessage(Context ctx, int code) {
Intent i = new Intent(ctx,ExitActivity.class);
i.putExtra("code",code);
i.putExtra("isSignal", isSignal);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ctx.startActivity(i);
@@ -89,8 +89,8 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
mMousePointerImageView.post(() -> {
ViewGroup.LayoutParams params = mMousePointerImageView.getLayoutParams();
params.width = (int) (36 * LauncherPreferences.PREF_MOUSESCALE);
params.height = (int) (54 * LauncherPreferences.PREF_MOUSESCALE);
params.width = (int) (36 / 100f * LauncherPreferences.PREF_MOUSESCALE);
params.height = (int) (54 / 100f * LauncherPreferences.PREF_MOUSESCALE);
});
mTouchPad.setOnTouchListener(new View.OnTouchListener() {
@@ -177,7 +177,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
getOnBackPressedDispatcher().addCallback(new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
Tools.dialogForceClose(JavaGUILauncherActivity.this);
MainActivity.dialogForceClose(JavaGUILauncherActivity.this);
}
});
}
@@ -336,7 +336,7 @@ public class JavaGUILauncherActivity extends BaseActivity implements View.OnTouc
}
public void forceClose(View v) {
Tools.dialogForceClose(this);
MainActivity.dialogForceClose(this);
}
public void openLogOutput(View v) {
@@ -156,12 +156,7 @@ public class LauncherActivity extends BaseActivity {
@Override
protected boolean shouldIgnoreNotch() {
return getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT;
}
@Override
public boolean setFullscreen() {
return false;
return getResources().getConfiguration().orientation == ORIENTATION_PORTRAIT || super.shouldIgnoreNotch();
}
@Override
@@ -232,6 +227,11 @@ public class LauncherActivity extends BaseActivity {
mInstallTracker.detach();
}
@Override
public boolean setFullscreen() {
return false;
}
@Override
protected void onStart() {
super.onStart();
@@ -15,7 +15,6 @@ public class Logger {
public static native void begin(String logFilePath);
/** Small listener for anything listening to the log */
@Keep
public interface eventLogListener {
void onEventLogged(String text);
}
@@ -1,7 +1,6 @@
package net.kdt.pojavlaunch;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_ENABLE_GYRO;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_SUSTAINED_PERFORMANCE;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_USE_ALTERNATE_SURFACE;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_VIRTUAL_MOUSE_START;
@@ -28,15 +27,17 @@ import android.provider.DocumentsContract;
import android.util.Log;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.MimeTypeMap;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;
@@ -54,11 +55,9 @@ import net.kdt.pojavlaunch.customcontrols.EditorExitable;
import net.kdt.pojavlaunch.customcontrols.keyboard.LwjglCharSender;
import net.kdt.pojavlaunch.customcontrols.keyboard.TouchCharInput;
import net.kdt.pojavlaunch.customcontrols.mouse.GyroControl;
import net.kdt.pojavlaunch.customcontrols.mouse.HotbarView;
import net.kdt.pojavlaunch.customcontrols.mouse.Touchpad;
import net.kdt.pojavlaunch.lifecycle.ContextExecutor;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.prefs.QuickSettingSideDialog;
import net.kdt.pojavlaunch.services.GameService;
import net.kdt.pojavlaunch.utils.JREUtils;
import net.kdt.pojavlaunch.utils.MCOptionUtils;
@@ -85,8 +84,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
private ListView navDrawer;
private View mDrawerPullButton;
private GyroControl mGyroControl = null;
private ControlLayout mControlLayout;
private HotbarView mHotbarView;
public static ControlLayout mControlLayout;
MinecraftProfile minecraftProfile;
@@ -96,8 +94,6 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
public AdapterView.OnItemClickListener ingameControlsEditorListener;
private GameService.LocalBinder mServiceBinder;
private QuickSettingSideDialog mQuickSettingSideDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -110,8 +106,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
initLayout(R.layout.activity_basemain);
CallbackBridge.addGrabListener(touchpad);
CallbackBridge.addGrabListener(minecraftGLView);
mGyroControl = new GyroControl(this);
if(LauncherPreferences.PREF_ENABLE_GYRO) mGyroControl = new GyroControl(this);
// Enabling this on TextureView results in a broken white result
if(PREF_USE_ALTERNATE_SURFACE) getWindow().setBackgroundDrawable(null);
@@ -190,10 +185,12 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.menu_ingame));
gameActionClickListener = (parent, view, position, id) -> {
switch(position) {
case 0: openLogOutput(); break;
case 1: dialogSendCustomKey(); break;
case 2: openQuickSettings(); break;
case 3: openCustomControls(); break;
case 0: dialogForceClose(MainActivity.this); break;
case 1: openLogOutput(); break;
case 2: dialogSendCustomKey(); break;
case 3: adjustMouseSpeedLive(); break;
case 4: adjustGyroSensitivityLive(); break;
case 5: openCustomControls(); break;
}
drawerLayout.closeDrawers();
};
@@ -201,6 +198,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
navDrawer.setOnItemClickListener(gameActionClickListener);
drawerLayout.closeDrawers();
final String finalVersion = version;
minecraftGLView.setSurfaceReadyListener(() -> {
try {
@@ -242,12 +240,8 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
@Override
public void onAttachedToWindow() {
// Post to get the correct display dimensions after layout.
mControlLayout.post(()->{
LauncherPreferences.computeNotchSize(this);
Tools.getDisplayMetrics(this);
loadControls();
});
LauncherPreferences.computeNotchSize(this);
loadControls();
}
/** Boilerplate binding */
@@ -261,25 +255,21 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
mControlLayout = findViewById(R.id.main_control_layout);
touchCharInput = findViewById(R.id.mainTouchCharInput);
mDrawerPullButton = findViewById(R.id.drawer_button);
mHotbarView = findViewById(R.id.hotbar_view);
}
@Override
public void onResume() {
super.onResume();
if(PREF_ENABLE_GYRO) mGyroControl.enable();
if(mGyroControl != null) mGyroControl.enable();
CallbackBridge.nativeSetWindowAttrib(LwjglGlfwKeycode.GLFW_HOVERED, 1);
}
@Override
protected void onPause() {
mGyroControl.disable();
if(mGyroControl != null) mGyroControl.disable();
if (CallbackBridge.isGrabbing()){
sendKeyPress(LwjglGlfwKeycode.GLFW_KEY_ESCAPE);
}
if(mQuickSettingSideDialog != null) {
mQuickSettingSideDialog.cancel();
}
CallbackBridge.nativeSetWindowAttrib(LwjglGlfwKeycode.GLFW_HOVERED, 0);
super.onPause();
}
@@ -309,16 +299,9 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
super.onConfigurationChanged(newConfig);
if(mGyroControl != null) mGyroControl.updateOrientation();
// Layout resize is practically guaranteed on a configuration change, and `onConfigurationChanged`
// does not implicitly start a layout. So, request a layout and expect the screen dimensions to be valid after the]
// post.
mControlLayout.requestLayout();
mControlLayout.post(()->{
// Child of mControlLayout, so refreshing size here is correct
minecraftGLView.refreshSize();
Tools.updateWindowSize(this);
mControlLayout.refreshControlButtonPositions();
});
Tools.updateWindowSize(this);
minecraftGLView.refreshSize();
runOnUiThread(() -> mControlLayout.refreshControlButtonPositions());
}
@Override
@@ -343,6 +326,14 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
}
}
public static void fullyExit() {
android.os.Process.killProcess(android.os.Process.myPid());
}
public static boolean isAndroid8OrHigher() {
return Build.VERSION.SDK_INT >= 26;
}
private void runCraft(String versionId, JMinecraftVersionList.Version version) throws Throwable {
if(Tools.LOCAL_RENDERER == null) {
Tools.LOCAL_RENDERER = LauncherPreferences.PREF_RENDERER;
@@ -355,8 +346,8 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
Tools.releaseRenderersCache();
}
MinecraftAccount minecraftAccount = PojavProfile.getCurrentProfileContent(this, null);
Logger.appendToLog("--------- Starting game with Launcher Debug!");
Tools.printLauncherInfo(versionId, Tools.isValidString(minecraftProfile.javaArgs) ? minecraftProfile.javaArgs : LauncherPreferences.PREF_CUSTOM_JAVA_ARGS);
Logger.appendToLog("--------- beginning with launcher debug");
printLauncherInfo(versionId, Tools.isValidString(minecraftProfile.javaArgs) ? minecraftProfile.javaArgs : LauncherPreferences.PREF_CUSTOM_JAVA_ARGS);
JREUtils.redirectAndPrintJRELog();
LauncherProfiles.load();
int requiredJavaVersion = 8;
@@ -366,6 +357,15 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
Tools.runOnUiThread(()-> mServiceBinder.isActive = false);
}
private void printLauncherInfo(String gameVersion, String javaArguments) {
Logger.appendToLog("Info: Launcher version: " + BuildConfig.VERSION_NAME);
Logger.appendToLog("Info: Architecture: " + Architecture.archAsString(Tools.DEVICE_ARCHITECTURE));
Logger.appendToLog("Info: Device model: " + Build.MANUFACTURER + " " +Build.MODEL);
Logger.appendToLog("Info: API version: " + Build.VERSION.SDK_INT);
Logger.appendToLog("Info: Selected Minecraft version: " + gameVersion);
Logger.appendToLog("Info: Custom Java arguments: \"" + javaArguments + "\"");
}
private void dialogSendCustomKey() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.control_customkey);
@@ -388,29 +388,6 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
loggerView.setVisibility(View.VISIBLE);
}
private void openQuickSettings() {
if(mQuickSettingSideDialog == null) {
mQuickSettingSideDialog = new QuickSettingSideDialog(this, mControlLayout) {
@Override
public void onResolutionChanged() {
minecraftGLView.refreshSize();
mHotbarView.onResolutionChanged();
}
@Override
public void onGyroStateChanged() {
mGyroControl.updateOrientation();
if (PREF_ENABLE_GYRO) {
mGyroControl.enable();
} else {
mGyroControl.disable();
}
}
};
}
mQuickSettingSideDialog.appear(true);
}
public static void toggleMouse(Context ctx) {
if (CallbackBridge.isGrabbing()) return;
@@ -419,6 +396,19 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
Toast.LENGTH_SHORT).show();
}
public static void dialogForceClose(Context ctx) {
new AlertDialog.Builder(ctx)
.setMessage(R.string.mcn_exit_confirm)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, (p1, p2) -> {
try {
fullyExit();
} catch (Throwable th) {
Log.w(Tools.APP_NAME, "Could not enable System.exit() method!", th);
}
}).show();
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if(isInEditor) {
@@ -443,40 +433,134 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
if(touchCharInput != null) touchCharInput.switchKeyboardState();
}
@Keep
int tmpMouseSpeed;
public void adjustMouseSpeedLive() {
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle(R.string.mcl_setting_title_mousespeed);
View v = LayoutInflater.from(this).inflate(R.layout.dialog_live_mouse_speed_editor,null);
final SeekBar sb = v.findViewById(R.id.mouseSpeed);
final TextView tv = v.findViewById(R.id.mouseSpeedTV);
sb.setMax(275);
tmpMouseSpeed = (int) ((LauncherPreferences.PREF_MOUSESPEED*100));
sb.setProgress(tmpMouseSpeed-25);
tv.setText(getString(R.string.percent_format, tmpMouseSpeed));
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
tmpMouseSpeed = i+25;
tv.setText(getString(R.string.percent_format, tmpMouseSpeed));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
b.setView(v);
b.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
LauncherPreferences.PREF_MOUSESPEED = ((float)tmpMouseSpeed)/100f;
LauncherPreferences.DEFAULT_PREF.edit().putInt("mousespeed",tmpMouseSpeed).apply();
dialogInterface.dismiss();
System.gc();
});
b.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> {
dialogInterface.dismiss();
System.gc();
});
b.show();
}
int tmpGyroSensitivity;
public void adjustGyroSensitivityLive() {
if(!LauncherPreferences.PREF_ENABLE_GYRO) {
Toast.makeText(this, R.string.toast_turn_on_gyro, Toast.LENGTH_LONG).show();
return;
}
AlertDialog.Builder b = new AlertDialog.Builder(this);
b.setTitle(R.string.preference_gyro_sensitivity_title);
View v = LayoutInflater.from(this).inflate(R.layout.dialog_live_mouse_speed_editor,null);
final SeekBar sb = v.findViewById(R.id.mouseSpeed);
final TextView tv = v.findViewById(R.id.mouseSpeedTV);
sb.setMax(275);
tmpGyroSensitivity = (int) ((LauncherPreferences.PREF_GYRO_SENSITIVITY*100));
sb.setProgress(tmpGyroSensitivity -25);
tv.setText(getString(R.string.percent_format, tmpGyroSensitivity));
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
tmpGyroSensitivity = i+25;
tv.setText(getString(R.string.percent_format, tmpGyroSensitivity));
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
b.setView(v);
b.setPositiveButton(android.R.string.ok, (dialogInterface, i) -> {
LauncherPreferences.PREF_GYRO_SENSITIVITY = ((float) tmpGyroSensitivity)/100f;
LauncherPreferences.DEFAULT_PREF.edit().putInt("gyroSensitivity", tmpGyroSensitivity).apply();
dialogInterface.dismiss();
System.gc();
});
b.setNegativeButton(android.R.string.cancel, (dialogInterface, i) -> {
dialogInterface.dismiss();
System.gc();
});
b.show();
}
private static void setUri(Context context, String input, Intent intent) {
if(input.startsWith("file:")) {
int truncLength = 5;
if(input.startsWith("file://")) truncLength = 7;
input = input.substring(truncLength);
Log.i("MainActivity", input);
boolean isDirectory = new File(input).isDirectory();
if(isDirectory) {
intent.setType(DocumentsContract.Document.MIME_TYPE_DIR);
}else{
String type = null;
String extension = MimeTypeMap.getFileExtensionFromUrl(input);
if(extension != null) type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if(type == null) type = "*/*";
intent.setType(type);
}
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.setData(DocumentsContract.buildDocumentUri(
context.getString(R.string.storageProviderAuthorities), input
));
return;
}
intent.setDataAndType(Uri.parse(input), "*/*");
}
public static void openLink(String link) {
Context ctx = touchpad.getContext(); // no more better way to obtain a context statically
((Activity)ctx).runOnUiThread(() -> {
try {
if(link.startsWith("file:")) {
int truncLength = 5;
if(link.startsWith("file://")) truncLength = 7;
String path = link.substring(truncLength);
Tools.openPath(ctx, new File(path), false);
}else {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(link), "*/*");
ctx.startActivity(intent);
}
Intent intent = new Intent(Intent.ACTION_VIEW);
setUri(ctx, link, intent);
ctx.startActivity(intent);
} catch (Throwable th) {
Tools.showError(ctx, th);
}
});
}
@SuppressWarnings("unused") //TODO: actually use it
public static void openPath(String path) {
Context ctx = touchpad.getContext(); // no more better way to obtain a context statically
((Activity)ctx).runOnUiThread(() -> {
try {
Tools.openPath(ctx, new File(path), false);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(DocumentsContract.buildDocumentUri(ctx.getString(R.string.storageProviderAuthorities), path), "*/*");
ctx.startActivity(intent);
} catch (Throwable th) {
Tools.showError(ctx, th);
}
});
}
@Keep
public static void querySystemClipboard() {
Tools.runOnUiThread(()->{
ClipData clipData = GLOBAL_CLIPBOARD.getPrimaryClip();
@@ -495,7 +579,6 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
});
}
@Keep
public static void putClipboardData(String data, String mimeType) {
Tools.runOnUiThread(()-> {
ClipData clipData = null;
@@ -519,10 +602,10 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
@Override
public void exitEditor() {
try {
mControlLayout.loadLayout((CustomControls)null);
mControlLayout.setModifiable(false);
MainActivity.mControlLayout.loadLayout((CustomControls)null);
MainActivity.mControlLayout.setModifiable(false);
System.gc();
mControlLayout.loadLayout(
MainActivity.mControlLayout.loadLayout(
minecraftProfile.controlFile == null
? LauncherPreferences.PREF_DEFAULTCTRL_PATH
: Tools.CTRLMAP_PATH + "/" + minecraftProfile.controlFile);
@@ -530,7 +613,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
} catch (IOException e) {
Tools.showError(this,e);
}
//((MainActivity) this).mControlLayout.loadLayout((CustomControls)null);
navDrawer.setAdapter(gameActionArrayAdapter);
navDrawer.setOnItemClickListener(gameActionClickListener);
isInEditor = false;
@@ -566,7 +649,7 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
@Override
public boolean dispatchTrackballEvent(MotionEvent ev) {
if(Tools.isAndroid8OrHigher() && checkCaptureDispatchConditions(ev))
if(MainActivity.isAndroid8OrHigher() && checkCaptureDispatchConditions(ev))
return minecraftGLView.dispatchCapturedPointerEvent(ev);
else return super.dispatchTrackballEvent(ev);
}
@@ -66,6 +66,8 @@ public class MinecraftGLSurface extends View implements GrabListener {
.remapRightTrigger(true)
.remapDpad(true));
/* Resolution scaler option, allow downsizing a window */
private final float mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR/100f;
/* Sensitivity, adjusted according to screen size */
private final double mSensitivityFactor = (1.4 * (1080f/ Tools.getDisplayMetrics((Activity) getContext()).heightPixels));
@@ -76,7 +78,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
View mSurface;
private final InGameEventProcessor mIngameProcessor = new InGameEventProcessor(mSensitivityFactor);
private final InGUIEventProcessor mInGUIProcessor = new InGUIEventProcessor();
private final InGUIEventProcessor mInGUIProcessor = new InGUIEventProcessor(mScaleFactor);
private TouchEventProcessor mCurrentTouchProcessor = mInGUIProcessor;
private AndroidPointerCapture mPointerCapture;
private boolean mLastGrabState = false;
@@ -93,7 +95,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
@RequiresApi(api = Build.VERSION_CODES.O)
private void setUpPointerCapture(AbstractTouchpad touchpad) {
if(mPointerCapture != null) mPointerCapture.detach();
mPointerCapture = new AndroidPointerCapture(touchpad, this);
mPointerCapture = new AndroidPointerCapture(touchpad, this, mScaleFactor);
}
/** Initialize the view and all its settings
@@ -103,7 +105,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
* when the cursor is not grabbed
*/
public void start(boolean isAlreadyRunning, AbstractTouchpad touchpad){
if(Tools.isAndroid8OrHigher()) setUpPointerCapture(touchpad);
if(MainActivity.isAndroid8OrHigher()) setUpPointerCapture(touchpad);
mInGUIProcessor.setAbstractTouchpad(touchpad);
if(LauncherPreferences.PREF_USE_ALTERNATE_SURFACE){
SurfaceView surfaceView = new SurfaceView(getContext());
@@ -186,7 +188,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
for (int i = 0; i < e.getPointerCount(); i++) {
int toolType = e.getToolType(i);
if(toolType == MotionEvent.TOOL_TYPE_MOUSE) {
if(Tools.isAndroid8OrHigher() &&
if(MainActivity.isAndroid8OrHigher() &&
mPointerCapture != null) {
mPointerCapture.handleAutomaticCapture();
return true;
@@ -195,7 +197,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
// Mouse found
if(CallbackBridge.isGrabbing()) return false;
CallbackBridge.sendCursorPos( e.getX(i) * LauncherPreferences.PREF_SCALE_FACTOR, e.getY(i) * LauncherPreferences.PREF_SCALE_FACTOR);
CallbackBridge.sendCursorPos( e.getX(i) * mScaleFactor, e.getY(i) * mScaleFactor);
return true; //mouse event handled successfully
}
if (mIngameProcessor == null || mInGUIProcessor == null) return true;
@@ -234,8 +236,8 @@ public class MinecraftGLSurface extends View implements GrabListener {
switch(event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_MOVE:
CallbackBridge.mouseX = (event.getX(mouseCursorIndex) * LauncherPreferences.PREF_SCALE_FACTOR);
CallbackBridge.mouseY = (event.getY(mouseCursorIndex) * LauncherPreferences.PREF_SCALE_FACTOR);
CallbackBridge.mouseX = (event.getX(mouseCursorIndex) * mScaleFactor);
CallbackBridge.mouseY = (event.getY(mouseCursorIndex) * mScaleFactor);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
return true;
case MotionEvent.ACTION_SCROLL:
@@ -324,22 +326,14 @@ public class MinecraftGLSurface extends View implements GrabListener {
return true;
}
/** Called when the size need to be set at any point during the surface lifecycle **/
public void refreshSize(){
refreshSize(false);
}
/** Same as refreshSize, but allows you to force an immediate size update **/
public void refreshSize(boolean immediate) {
if(isInLayout() && !immediate) {
post(this::refreshSize);
return;
}
// Use the width and height of the View instead of display dimensions to avoid
// getting squiched/stretched due to inconsistencies between the layout and
// screen dimensions.
windowWidth = Tools.getDisplayFriendlyRes(getWidth(), LauncherPreferences.PREF_SCALE_FACTOR);
windowHeight = Tools.getDisplayFriendlyRes(getHeight(), LauncherPreferences.PREF_SCALE_FACTOR);
windowWidth = Tools.getDisplayFriendlyRes(Tools.currentDisplayMetrics.widthPixels, mScaleFactor);
windowHeight = Tools.getDisplayFriendlyRes(Tools.currentDisplayMetrics.heightPixels, mScaleFactor);
if(mSurface == null){
Log.w("MGLSurface", "Attempt to refresh size on null surface");
return;
@@ -361,9 +355,8 @@ public class MinecraftGLSurface extends View implements GrabListener {
}
private void realStart(Surface surface){
// Initial size set. Request immedate refresh, otherwise the initial width and height for the game
// may be broken/unknown.
refreshSize(true);
// Initial size set
refreshSize();
//Load Minecraft options:
MCOptionUtils.set("fullscreen", "off");
@@ -52,7 +52,7 @@ public class PojavApplication extends Application {
}
FatalErrorActivity.showError(PojavApplication.this, crashFile.getAbsolutePath(), storagePermAllowed, th);
Tools.fullyExit();
MainActivity.fullyExit();
});
try {
@@ -19,8 +19,6 @@ import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.Cursor;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -40,14 +38,9 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -79,7 +72,6 @@ import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.IOUtils;
import org.lwjgl.glfw.CallbackBridge;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -90,7 +82,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.ref.WeakReference;
import java.lang.reflect.Field;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.util.ArrayList;
@@ -513,14 +504,10 @@ public final class Tools {
return displayMetrics;
}
@SuppressWarnings("deprecation")
private static void setFullscreenLegacy(Activity activity, boolean fullscreen) {
public static void setFullscreen(Activity activity, boolean fullscreen) {
final View decorView = activity.getWindow().getDecorView();
View.OnSystemUiVisibilityChangeListener visibilityChangeListener = visibility -> {
boolean multiWindowMode = SDK_INT >= 24 && activity.isInMultiWindowMode();
// When in multi-window mode, asking for fullscreen makes no sense (cause the launcher runs in a window)
// So, ignore the fullscreen setting when activity is in multi window mode
if(fullscreen && !multiWindowMode){
if(fullscreen){
if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_FULLSCREEN
@@ -538,64 +525,11 @@ public final class Tools {
visibilityChangeListener.onSystemUiVisibilityChange(decorView.getSystemUiVisibility()); //call it once since the UI state may not change after the call, so the activity wont become fullscreen
}
@RequiresApi(Build.VERSION_CODES.R)
private static void setFullscreenSdk30(Activity activity, boolean fullscreen) {
WindowInsetsControllerCompat windowInsetsController =
WindowCompat.getInsetsController(activity.getWindow(), activity.getWindow().getDecorView());
if (windowInsetsController == null) {
Log.w(APP_NAME, "WindowInsetsController is null, cannot set fullscreen");
return;
}
// Configure the behavior of the hidden system bars.
windowInsetsController.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
);
ViewCompat.setOnApplyWindowInsetsListener(
activity.getWindow().getDecorView(),
(view, windowInsets) -> {
if (fullscreen && !activity.isInMultiWindowMode()) {
windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
activity.getWindow().setDecorFitsSystemWindows(false);
} else {
windowInsetsController.show(WindowInsetsCompat.Type.systemBars());
activity.getWindow().setDecorFitsSystemWindows(true);
}
return ViewCompat.onApplyWindowInsets(view, windowInsets);
});
}
public static void setFullscreen(Activity activity, boolean fullscreen) {
if (SDK_INT >= Build.VERSION_CODES.R) {
setFullscreenSdk30(activity, fullscreen);
}else {
setFullscreenLegacy(activity, fullscreen);
}
}
public static DisplayMetrics currentDisplayMetrics;
public static void updateWindowSize(Activity activity) {
currentDisplayMetrics = getDisplayMetrics(activity);
View dimensionView = activity.findViewById(R.id.dimension_tracker);
if(dimensionView != null) {
int width = dimensionView.getWidth();
int height = dimensionView.getHeight();
if(width != 0 && height != 0) {
Log.i("Tools", "Using dimension_tracker for display dimensions; W="+width+" H="+height);
CallbackBridge.physicalWidth = width;
CallbackBridge.physicalHeight = height;
return;
}else{
Log.e("Tools","Dimension tracker detected but dimensions out of date. Please check usage.", new Exception());
}
}
CallbackBridge.physicalWidth = currentDisplayMetrics.widthPixels;
CallbackBridge.physicalHeight = currentDisplayMetrics.heightPixels;
}
@@ -670,7 +604,7 @@ public final class Tools {
.setPositiveButton(android.R.string.ok, (p1, p2) -> {
if(exitIfOk) {
if (ctx instanceof MainActivity) {
fullyExit();
MainActivity.fullyExit();
} else if (ctx instanceof Activity) {
((Activity) ctx).finish();
}
@@ -682,7 +616,7 @@ public final class Tools {
mgr.setPrimaryClip(ClipData.newPlainText("error", printToString(e)));
if(exitIfOk) {
if (ctx instanceof MainActivity) {
fullyExit();
MainActivity.fullyExit();
} else {
((Activity) ctx).finish();
}
@@ -954,24 +888,6 @@ public final class Tools {
File file = new File(nameOutput);
DownloadUtils.downloadFile(urlInput, file);
}
public static boolean isAndroid8OrHigher() {
return SDK_INT >= 26;
}
public static void fullyExit() {
android.os.Process.killProcess(android.os.Process.myPid());
}
public static void printLauncherInfo(String gameVersion, String javaArguments) {
Logger.appendToLog("Info: Launcher version: " + BuildConfig.VERSION_NAME);
Logger.appendToLog("Info: Architecture: " + Architecture.archAsString(DEVICE_ARCHITECTURE));
Logger.appendToLog("Info: Device model: " + Build.MANUFACTURER + " " +Build.MODEL);
Logger.appendToLog("Info: API version: " + SDK_INT);
Logger.appendToLog("Info: Selected Minecraft version: " + gameVersion);
Logger.appendToLog("Info: Custom Java arguments: \"" + javaArguments + "\"");
}
public interface DownloaderFeedback {
void updateProgress(int curr, int max);
}
@@ -1192,55 +1108,17 @@ public final class Tools {
/** Triggers the share intent chooser, with the latestlog file attached to it */
public static void shareLog(Context context){
openPath(context, new File(Tools.DIR_GAME_HOME, "latestlog.txt"), true);
}
Uri contentUri = DocumentsContract.buildDocumentUri(context.getString(R.string.storageProviderAuthorities), Tools.DIR_GAME_HOME + "/latestlog.txt");
/**
* Determine the MIME type of a File.
* @param file The file to determine the type of
* @return the type, or the default value *slash* if cannot be determined
*/
public static String getMimeType(File file) {
if(file.isDirectory()) return DocumentsContract.Document.MIME_TYPE_DIR;
String mimeType = null;
try (FileInputStream fileInputStream = new FileInputStream(file)){
// Theoretically we don't even need the buffer since we don't care about the
// contents of the file after the guess, but mark-supported streams
// are a requirement of URLConnection.guessContentTypeFromStream()
try(BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream)) {
mimeType = URLConnection.guessContentTypeFromStream(bufferedInputStream);
}
}catch (IOException e) {
Log.w("FileMimeType", "Failed to determine MIME type by stream", e);
}
if(mimeType != null) return mimeType;
mimeType = URLConnection.guessContentTypeFromName(file.getName());
if(mimeType != null) return mimeType;
return "*/*";
}
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("text/plain");
/**
* Open the path specified by a File in a file explorer or in a relevant application.
* @param context the current Context
* @param file the File to open
* @param share whether to open a "Share" or an "Open" dialog.
*/
public static void openPath(Context context, File file, boolean share) {
Uri contentUri = DocumentsContract.buildDocumentUri(context.getString(R.string.storageProviderAuthorities), file.getAbsolutePath());
String mimeType = getMimeType(file);
Intent intent = new Intent();
if(share) {
intent.setAction(Intent.ACTION_SEND);
intent.setType(getMimeType(file));
intent.putExtra(Intent.EXTRA_STREAM, contentUri);
}else {
intent.setAction(Intent.ACTION_VIEW);
intent.setDataAndType(contentUri, mimeType);
}
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Intent chooserIntent = Intent.createChooser(intent, file.getName());
context.startActivity(chooserIntent);
Intent sendIntent = Intent.createChooser(shareIntent, "latestlog.txt");
context.startActivity(sendIntent);
}
/** Mesure the textview height, given its current parameters */
@@ -1325,22 +1203,4 @@ public final class Tools {
sCompatibleRenderers = null;
System.gc();
}
public static boolean deviceSupportsGyro(@NonNull Context context) {
return ((SensorManager)context.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null;
}
public static void dialogForceClose(Context ctx) {
new android.app.AlertDialog.Builder(ctx)
.setMessage(R.string.mcn_exit_confirm)
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, (p1, p2) -> {
try {
Tools.fullyExit();
} catch (Throwable th) {
Log.w(Tools.APP_NAME, "Could not enable System.exit() method!", th);
}
}).show();
}
}
@@ -5,79 +5,76 @@ import android.content.res.ColorStateList;
import android.graphics.Color;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import androidx.annotation.Nullable;
import com.kdt.SideDialogView;
import net.kdt.pojavlaunch.R;
public class ColorSelector extends SideDialogView implements HueSelectionListener, RectangleSelectionListener, AlphaSelectionListener, TextWatcher{
public class ColorSelector implements HueSelectionListener, RectangleSelectionListener, AlphaSelectionListener, TextWatcher{
private static final int ALPHA_MASK = ~(0xFF << 24);
private HueView mHueView;
private SVRectangleView mLuminosityIntensityView;
private AlphaView mAlphaView;
private ColorSideBySideView mColorView;
private EditText mTextView;
private final View mRootView;
private final HueView mHueView;
private final SVRectangleView mLuminosityIntensityView;
private final AlphaView mAlphaView;
private final ColorSideBySideView mColorView;
private final EditText mTextView;
private ColorSelectionListener mColorSelectionListener;
private final float[] mHueTemplate = new float[] {0,1,1};
private final float[] mHsvSelected = new float[] {360,1,1};
private int mAlphaSelected = 0xff;
private ColorStateList mTextColors;
private final ColorStateList mTextColors;
private boolean mWatch = true;
private boolean mAlphaEnabled = true;
/**
* Creates a color selector dialog for this Context.
* @param context Context used for this ColorSelector dialog
* @param colorSelectionListener Color selection listener to which the events will be sent to. Can be null.
*/
public ColorSelector(Context context, ViewGroup parent, @Nullable ColorSelectionListener colorSelectionListener) {
super(context, parent, R.layout.dialog_color_selector);
mColorSelectionListener = colorSelectionListener;
}
@Override
protected void onInflate() {
super.onInflate();
// Initialize the view contents
mHueView = mDialogContent.findViewById(R.id.color_selector_hue_view);
mLuminosityIntensityView = mDialogContent.findViewById(R.id.color_selector_rectangle_view);
mAlphaView = mDialogContent.findViewById(R.id.color_selector_alpha_view);
mColorView = mDialogContent.findViewById(R.id.color_selector_color_view);
mTextView = mDialogContent.findViewById(R.id.color_selector_hex_edit);
mRootView = LayoutInflater.from(context).inflate(R.layout.dialog_color_selector,parent, false);
mHueView = mRootView.findViewById(R.id.color_selector_hue_view);
mLuminosityIntensityView = mRootView.findViewById(R.id.color_selector_rectangle_view);
mAlphaView = mRootView.findViewById(R.id.color_selector_alpha_view);
mColorView = mRootView.findViewById(R.id.color_selector_color_view);
mTextView = mRootView.findViewById(R.id.color_selector_hex_edit);
runColor(Color.RED);
mHueView.setHueSelectionListener(this);
mLuminosityIntensityView.setRectSelectionListener(this);
mAlphaView.setAlphaSelectionListener(this);
mTextView.addTextChangedListener(this);
mTextColors = mTextView.getTextColors();
mAlphaView.setVisibility(mAlphaEnabled ? View.VISIBLE : View.GONE);
// Set elevation to show above other side dialogs.
// Jank, should be done better
View contentParent = mDialogContent.findViewById(R.id.side_dialog_scrollview);
if(contentParent != null) {
ViewGroup dialogLayout = (ViewGroup) mDialogContent.getParent();
dialogLayout.setElevation(11);
dialogLayout.setTranslationZ(11);
}
mColorSelectionListener = colorSelectionListener;
parent.addView(mRootView);
}
/** @return The root view, mainly for position manipulation purposes */
public View getRootView(){
return mRootView;
}
/**
* Shows the color selector with the default (red) color selected.
*/
public void show(boolean fromRight) {
show(fromRight, Color.RED);
public void show() {
show(Color.RED);
}
/**
* Shows the color selector with the desired ARGB color selected
* @param previousColor the desired ARGB color
*/
public void show(boolean fromRight, int previousColor) {
appear(fromRight);
public void show(int previousColor) {
runColor(previousColor); // initialize
dispatchColorChange(); // set the hex text
}
@@ -160,10 +157,8 @@ public class ColorSelector extends SideDialogView implements HueSelectionListene
public void setAlphaEnabled(boolean alphaEnabled){
mAlphaEnabled = alphaEnabled;
if(mAlphaView != null) {
mAlphaView.setVisibility(alphaEnabled ? View.VISIBLE : View.GONE);
mAlphaView.setAlpha(255);
}
mAlphaView.setVisibility(alphaEnabled ? View.VISIBLE : View.GONE);
mAlphaView.setAlpha(255);
}
private void notifyColorSelector(int color){
@@ -7,7 +7,6 @@ import android.util.ArrayMap;
import androidx.annotation.Keep;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.utils.JSONUtils;
import net.objecthunter.exp4j.ExpressionBuilder;
@@ -241,7 +240,7 @@ public class ControlData {
keyValueMap.put("height", "DUMMY_HEIGHT");
keyValueMap.put("screen_width", "DUMMY_DATA");
keyValueMap.put("screen_height", "DUMMY_DATA");
keyValueMap.put("margin", Integer.toString((int) ControlInterface.getMarginDistance()));
keyValueMap.put("margin", Integer.toString((int) Tools.dpToPx(2)));
keyValueMap.put("preferred_scale", "DUMMY_DATA");
conversionMap = new WeakReference<>(keyValueMap);
@@ -1,6 +1,7 @@
package net.kdt.pojavlaunch.customcontrols;
import static android.content.Context.INPUT_METHOD_SERVICE;
import static net.kdt.pojavlaunch.MainActivity.mControlLayout;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import static org.lwjgl.glfw.CallbackBridge.isGrabbing;
@@ -33,7 +34,7 @@ import net.kdt.pojavlaunch.customcontrols.buttons.ControlJoystick;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlSubButton;
import net.kdt.pojavlaunch.customcontrols.handleview.ActionRow;
import net.kdt.pojavlaunch.customcontrols.handleview.ControlHandleView;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlSideDialog;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import java.io.File;
@@ -53,7 +54,7 @@ public class ControlLayout extends FrameLayout {
private boolean mIsModified;
private boolean mControlVisible = false;
private EditControlSideDialog mControlDialog = null;
private EditControlPopup mControlPopup = null;
private ControlHandleView mHandleView;
private ControlButtonMenuListener mMenuListener;
public ActionRow mActionRow = null;
@@ -296,9 +297,9 @@ public class ControlLayout extends FrameLayout {
@Override
public void onViewRemoved(View child) {
super.onViewRemoved(child);
if(child instanceof ControlInterface && mControlDialog != null){
mControlDialog.disappearColor();
mControlDialog.disappear(false);
if(child instanceof ControlInterface && mControlPopup != null){
mControlPopup.disappearColor();
mControlPopup.disappear();
}
}
@@ -307,23 +308,22 @@ public class ControlLayout extends FrameLayout {
* to the button at hand.
*/
public void editControlButton(ControlInterface button){
if(mControlDialog == null){
if(mControlPopup == null){
// When the panel is null, it needs to inflate first.
// So inflate it, then process it on the next frame
mControlDialog = new EditControlSideDialog(getContext(), this);
mControlPopup = new EditControlPopup(getContext(), this);
post(() -> editControlButton(button));
return;
}
mControlDialog.internalChanges = true;
mControlDialog.setCurrentlyEditedButton(button);
mControlPopup.internalChanges = true;
mControlPopup.setCurrentlyEditedButton(button);
button.loadEditValues(mControlPopup);
mControlDialog.appear(button.getControlView().getX() + button.getControlView().getWidth()/2f < currentDisplayMetrics.widthPixels/2f);
button.loadEditValues(mControlDialog);
mControlPopup.internalChanges = false;
mControlDialog.internalChanges = false;
mControlDialog.disappearColor();
mControlPopup.appear(button.getControlView().getX() + button.getControlView().getWidth()/2f < currentDisplayMetrics.widthPixels/2f);
mControlPopup.disappearColor();
if(mHandleView == null){
mHandleView = new ControlHandleView(getContext());
@@ -336,7 +336,8 @@ public class ControlLayout extends FrameLayout {
/** Swap the panel if the button position requires it */
public void adaptPanelPosition(){
if(mControlDialog != null) mControlDialog.adaptPanelPosition();
if(mControlPopup != null)
mControlPopup.adaptPanelPosition();
}
@@ -400,14 +401,14 @@ public class ControlLayout extends FrameLayout {
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mModifiable && event.getActionMasked() != MotionEvent.ACTION_UP || mControlDialog == null)
if (mModifiable && event.getActionMasked() != MotionEvent.ACTION_UP || mControlPopup == null)
return true;
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE);
// When the input window cannot be hidden, it returns false
if(!imm.hideSoftInputFromWindow(getWindowToken(), 0)){
if(mControlDialog.disappearLayer()){
if(mControlPopup.disappearLayer()){
mActionRow.setFollowedButton(null);
mHandleView.hide();
}
@@ -420,9 +421,9 @@ public class ControlLayout extends FrameLayout {
// When the input window cannot be hidden, it returns false
imm.hideSoftInputFromWindow(getWindowToken(), 0);
if(mControlDialog != null) {
mControlDialog.disappearColor();
mControlDialog.disappear(true);
if(mControlPopup != null) {
mControlPopup.disappearColor();
mControlPopup.disappear();
}
if(mActionRow != null) mActionRow.setFollowedButton(null);
@@ -57,13 +57,13 @@ public class CustomControls {
this.mControlDataList.add(new ControlData(ctx, R.string.control_jump, new int[]{LwjglGlfwKeycode.GLFW_KEY_SPACE}, "${right} - ${margin} * 2 - ${width}", "${bottom} - ${margin} * 2 - ${height}", true));
//The default controls are conform to the V3
version = 8;
version = 7;
}
public void save(String path) throws IOException {
//Current version is the V3.2 so the version as to be marked as 8 !
version = 8;
//Current version is the V3.1 so the version as to be marked as 7 !
version = 7;
Tools.write(path, Tools.GLOBAL_GSON.toJson(this));
}
@@ -24,56 +24,27 @@ public class LayoutConverter {
CustomControls layout = LayoutConverter.convertV1Layout(layoutJobj);
layout.save(jsonPath);
return layout;
} else if (layoutJobj.getInt("version") == 2) {
CustomControls layout = LayoutConverter.convertV2Layout(layoutJobj);
layout.save(jsonPath);
return layout;
}else if (layoutJobj.getInt("version") >= 3 && layoutJobj.getInt("version") <= 5) {
return LayoutConverter.convertV3_4Layout(layoutJobj);
} else if (layoutJobj.getInt("version") == 6 || layoutJobj.getInt("version") == 7) {
return Tools.GLOBAL_GSON.fromJson(jsonLayoutData, CustomControls.class);
} else {
int version = layoutJobj.getInt("version");
if (version == 2) {
CustomControls layout = LayoutConverter.convertV2Layout(layoutJobj);
layout.save(jsonPath);
return layout;
}
if (version == 3 || version == 4 || version == 5) {
return LayoutConverter.convertV3_4Layout(layoutJobj);
}
if (version == 6 || version == 7) {
return convertV6_7Layout(layoutJobj);
}
else if (version == 8) {
return Tools.GLOBAL_GSON.fromJson(jsonLayoutData, CustomControls.class);
}
return null;
}
return null;
} catch (JSONException e) {
throw new JsonSyntaxException("Failed to load", e);
}
}
/**
* Normalize the layout to v8 from v6/7. An issue from the joystick height and position has to be fixed.
* @param oldLayoutJson The old layout
* @return The new layout with the fixed joystick height
*/
public static CustomControls convertV6_7Layout(JSONObject oldLayoutJson) {
CustomControls layout = Tools.GLOBAL_GSON.fromJson(oldLayoutJson.toString(), CustomControls.class);
for (ControlJoystickData data : layout.mJoystickDataList) {
if (data.getHeight() > data.getWidth()) {
// Make the size square, adjust the dynamic position related to height
float ratio = data.getHeight() / data.getWidth();
data.dynamicX = data.dynamicX.replace("${height}", "(" + ratio + " * ${height})");
data.dynamicY = data.dynamicY.replace("${height}", "(" + ratio + " * ${height})") + " + (" + (ratio-1) + " * ${height})";
data.setHeight(data.getWidth());
}
}
layout.version = 8;
return layout;
}
/**
* Normalize the layout to v6 from v3/4: The stroke width is no longer dependant on the button size
*/
private static CustomControls convertV3_4Layout(JSONObject oldLayoutJson) {
public static CustomControls convertV3_4Layout(JSONObject oldLayoutJson) {
CustomControls layout = Tools.GLOBAL_GSON.fromJson(oldLayoutJson.toString(), CustomControls.class);
convertStrokeWidth(layout);
layout.version = 6;
@@ -81,7 +52,7 @@ public class LayoutConverter {
}
private static CustomControls convertV2Layout(JSONObject oldLayoutJson) throws JSONException {
public static CustomControls convertV2Layout(JSONObject oldLayoutJson) throws JSONException {
CustomControls layout = Tools.GLOBAL_GSON.fromJson(oldLayoutJson.toString(), CustomControls.class);
JSONArray layoutMainArray = oldLayoutJson.getJSONArray("mControlDataList");
layout.mControlDataList = new ArrayList<>(layoutMainArray.length());
@@ -124,7 +95,7 @@ public class LayoutConverter {
return layout;
}
private static CustomControls convertV1Layout(JSONObject oldLayoutJson) throws JSONException {
public static CustomControls convertV1Layout(JSONObject oldLayoutJson) throws JSONException {
CustomControls empty = new CustomControls();
JSONArray layoutMainArray = oldLayoutJson.getJSONArray("mControlDataList");
for (int i = 0; i < layoutMainArray.length(); i++) {
@@ -20,7 +20,7 @@ import net.kdt.pojavlaunch.MainActivity;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlSideDialog;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import org.lwjgl.glfw.CallbackBridge;
@@ -89,7 +89,7 @@ public class ControlButton extends TextView implements ControlInterface {
}
public void loadEditValues(EditControlSideDialog editControlPopup){
public void loadEditValues(EditControlPopup editControlPopup){
editControlPopup.loadValues(getProperties());
}
@@ -207,7 +207,7 @@ public class ControlButton extends TextView implements ControlInterface {
break;
case ControlData.SPECIALBTN_TOGGLECTRL:
if(isDown)getControlLayoutParent().toggleControlVisible();
if(isDown)MainActivity.mControlLayout.toggleControlVisible();
break;
case ControlData.SPECIALBTN_VIRTUALMOUSE:
@@ -4,12 +4,13 @@ import android.annotation.SuppressLint;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlSideDialog;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
import java.util.ArrayList;
@@ -61,27 +62,26 @@ public class ControlDrawer extends ControlButton {
private void alignButtons(){
if(buttons == null) return;
if(drawerData.orientation == ControlDrawerData.Orientation.FREE) return;
int margin = (int) ControlInterface.getMarginDistance();
for(int i = 0; i < buttons.size(); ++i){
switch (drawerData.orientation){
case RIGHT:
buttons.get(i).setDynamicX(generateDynamicX(getX() + (drawerData.properties.getWidth() + margin)*(i+1) ));
buttons.get(i).setDynamicX(generateDynamicX(getX() + (drawerData.properties.getWidth() + Tools.dpToPx(2))*(i+1) ));
buttons.get(i).setDynamicY(generateDynamicY(getY()));
break;
case LEFT:
buttons.get(i).setDynamicX(generateDynamicX(getX() - (drawerData.properties.getWidth() + margin)*(i+1)));
buttons.get(i).setDynamicX(generateDynamicX(getX() - (drawerData.properties.getWidth() + Tools.dpToPx(2))*(i+1)));
buttons.get(i).setDynamicY(generateDynamicY(getY()));
break;
case UP:
buttons.get(i).setDynamicY(generateDynamicY(getY() - (drawerData.properties.getHeight() + margin)*(i+1)));
buttons.get(i).setDynamicY(generateDynamicY(getY() - (drawerData.properties.getHeight() + Tools.dpToPx(2))*(i+1)));
buttons.get(i).setDynamicX(generateDynamicX(getX()));
break;
case DOWN:
buttons.get(i).setDynamicY(generateDynamicY(getY() + (drawerData.properties.getHeight() + margin)*(i+1)));
buttons.get(i).setDynamicY(generateDynamicY(getY() + (drawerData.properties.getHeight() + Tools.dpToPx(2))*(i+1)));
buttons.get(i).setDynamicX(generateDynamicX(getX()));
break;
}
@@ -183,7 +183,7 @@ public class ControlDrawer extends ControlButton {
}
@Override
public void loadEditValues(EditControlSideDialog editControlPopup) {
public void loadEditValues(EditControlPopup editControlPopup) {
editControlPopup.loadValues(drawerData);
}
@@ -20,7 +20,7 @@ import net.kdt.pojavlaunch.GrabListener;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlSideDialog;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
import org.lwjgl.glfw.CallbackBridge;
@@ -30,6 +30,7 @@ import org.lwjgl.glfw.CallbackBridge;
* sending keys has to be implemented by sub classes.
*/
public interface ControlInterface extends View.OnLongClickListener, GrabListener {
View getControlView();
ControlData getProperties();
@@ -60,7 +61,7 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
/**
* Load the values and hide non useful forms
*/
void loadEditValues(EditControlSideDialog editControlDialog);
void loadEditValues(EditControlPopup editControlPopup);
@Override
default void onGrabState(boolean isGrabbing) {
@@ -213,7 +214,7 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
default boolean canSnap(ControlInterface button) {
float MIN_DISTANCE = getSnapDistance();
float MIN_DISTANCE = Tools.dpToPx(8);
if (button == this) return false;
return !(net.kdt.pojavlaunch.utils.MathUtils.dist(
@@ -236,7 +237,7 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
* @param y Coordinate on the y axis
*/
default void snapAndAlign(float x, float y) {
final float MIN_DISTANCE = getSnapDistance();
float MIN_DISTANCE = Tools.dpToPx(8);
String dynamicX = generateDynamicX(x);
String dynamicY = generateDynamicY(y);
@@ -403,12 +404,4 @@ public interface ControlInterface extends View.OnLongClickListener, GrabListener
return true;
}
static float getSnapDistance() {
return Tools.dpToPx(6);
}
static float getMarginDistance() {
return Tools.dpToPx(2);
}
}
@@ -19,7 +19,7 @@ import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import net.kdt.pojavlaunch.customcontrols.gamepad.GamepadJoystick;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlSideDialog;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
import org.lwjgl.glfw.CallbackBridge;
@@ -121,7 +121,7 @@ public class ControlJoystick extends JoystickView implements ControlInterface {
public void sendKeyPresses(boolean isDown) {/*STUB since non swipeable*/ }
@Override
public void loadEditValues(EditControlSideDialog editControlPopup) {
public void loadEditValues(EditControlPopup editControlPopup) {
editControlPopup.loadJoystickValues(mControlData);
}
@@ -2,12 +2,13 @@ package net.kdt.pojavlaunch.customcontrols.buttons;
import android.annotation.SuppressLint;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlSideDialog;
import net.kdt.pojavlaunch.customcontrols.handleview.EditControlPopup;
@SuppressLint("ViewConstructor")
public class ControlSubButton extends ControlButton {
@@ -90,7 +91,7 @@ public class ControlSubButton extends ControlButton {
}
@Override
public void loadEditValues(EditControlSideDialog editControlPopup) {
public void loadEditValues(EditControlPopup editControlPopup) {
editControlPopup.loadSubButtonValues(getProperties(), parentDrawer.drawerData.orientation);
}
}
@@ -10,8 +10,7 @@ public class GamepadButton extends GamepadEmulatedButton {
@Override
protected void onDownStateChanged(boolean isDown) {
if(isToggleable) {
if(!isDown) return;
if(isToggleable && isDown){
mIsToggled = !mIsToggled;
Gamepad.sendInput(keycodes, mIsToggled);
return;
@@ -1,5 +1,6 @@
package net.kdt.pojavlaunch.customcontrols.gamepad;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
@@ -7,12 +8,10 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.Spinner;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.SwitchCompat;
import androidx.recyclerview.widget.RecyclerView;
import net.kdt.pojavlaunch.EfficientAndroidLWJGLKeycode;
@@ -153,17 +152,15 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
}
}
public class ViewHolder extends RecyclerView.ViewHolder implements AdapterView.OnItemSelectedListener, View.OnClickListener, CompoundButton.OnCheckedChangeListener {
public class ViewHolder extends RecyclerView.ViewHolder implements AdapterView.OnItemSelectedListener, View.OnClickListener {
private static final int COLOR_ACTIVE_BUTTON = 0x2000FF00;
private final Context mContext;
private final ImageView mButtonIcon;
private final ImageView mExpansionIndicator;
private final Spinner[] mKeySpinners;
private final View mExpandedView;
private final SwitchCompat mToggleableSwitch;
private final TextView mKeycodeLabel;
private int mAttachedPosition = -1;
private GamepadEmulatedButton mAttachedButton;
private short[] mKeycodes;
public ViewHolder(@NonNull View itemView) {
@@ -173,8 +170,6 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
mExpandedView = itemView.findViewById(R.id.controller_mapper_expanded_view);
mExpansionIndicator = itemView.findViewById(R.id.controller_mapper_expand_button);
mKeycodeLabel = itemView.findViewById(R.id.controller_mapper_keycode_label);
mToggleableSwitch = itemView.findViewById(R.id.controller_mapper_toggleable_switch);
mToggleableSwitch.setOnCheckedChangeListener(this);
View defaultView = itemView.findViewById(R.id.controller_mapper_default_view);
defaultView.setOnClickListener(this);
mKeySpinners = new Spinner[4];
@@ -197,15 +192,6 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
GamepadEmulatedButton realButton = mRealButtons[index];
mAttachedButton = realButton;
if(realButton instanceof GamepadButton) {
mToggleableSwitch.setChecked(((GamepadButton)realButton).isToggleable);
mToggleableSwitch.setVisibility(View.VISIBLE);
}else {
mToggleableSwitch.setVisibility(View.GONE);
}
mKeycodes = realButton.keycodes;
int spinnerIndex;
@@ -231,7 +217,6 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
private void detach() {
mRebinderButtons[mAttachedPosition].changeViewHolder(null);
mAttachedPosition = -1;
mAttachedButton = null;
}
private void setPressed(boolean pressed) {
itemView.setBackgroundColor(pressed ? COLOR_ACTIVE_BUTTON : Color.TRANSPARENT);
@@ -291,17 +276,6 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
mExpandedView.setVisibility(View.GONE);
}
}
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
if(!(mAttachedButton instanceof GamepadButton)) return;
((GamepadButton)mAttachedButton).isToggleable = checked;
try {
GamepadMapStore.save();
}catch (Exception e) {
Tools.showError(compoundButton.getContext(), e);
}
}
}
@Override
@@ -325,13 +299,15 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
grabListener.onGrabState(mGrabState);
}
// Cannot do it another way
@SuppressLint("NotifyDataSetChanged")
public void setGrabState(boolean newState) {
mGrabState = newState;
if(mGamepadGrabListener != null) mGamepadGrabListener.onGrabState(newState);
if(mGrabState == mOldState) return;
updateRealButtons();
updateStickIcons();
notifyItemRangeChanged(0, mRebinderButtons.length);
notifyDataSetChanged();
mOldState = mGrabState;
}
}
@@ -16,22 +16,23 @@ public class DrawerPullButton extends View {
public DrawerPullButton(Context context) {super(context); init();}
public DrawerPullButton(Context context, @Nullable AttributeSet attrs) {super(context, attrs); init();}
private final Paint mBackgroundPaint = new Paint();
private final Paint mPaint = new Paint();
private VectorDrawableCompat mDrawable;
private void init(){
mDrawable = VectorDrawableCompat.create(getContext().getResources(), R.drawable.ic_sharp_settings_24, null);
setAlpha(0.33f);
mBackgroundPaint.setColor(Color.BLACK);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawArc(getPaddingLeft(),-getHeight() + getPaddingBottom(),getWidth() - getPaddingRight(), getHeight() - getPaddingBottom(), 0, 180, true, mBackgroundPaint);
mPaint.setColor(Color.BLACK);
canvas.drawArc(0,-getHeight(),getWidth(), getHeight(), 0, 180, true, mPaint);
mDrawable.setBounds(getPaddingLeft()/2, getPaddingTop()/2, getHeight() - getPaddingRight()/2, getHeight() - getPaddingBottom()/2);
mPaint.setColor(Color.WHITE);
mDrawable.setBounds(0, 0, getHeight(), getHeight());
canvas.save();
canvas.translate((getWidth()-getHeight())/2f, -getPaddingBottom()/2f);
canvas.translate((getWidth()-getHeight())/2f, 0);
mDrawable.draw(canvas);
canvas.restore();
}
@@ -0,0 +1,653 @@
package net.kdt.pojavlaunch.customcontrols.handleview;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Interpolator;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.kdt.DefocusableScrollView;
import net.kdt.pojavlaunch.EfficientAndroidLWJGLKeycode;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.colorselector.ColorSelector;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlDrawer;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface;
import java.util.List;
/**
* Class providing a sort of popup on top of a Layout, allowing to edit a given ControlButton
*/
public class EditControlPopup {
protected final Spinner[] mKeycodeSpinners = new Spinner[4];
private final DefocusableScrollView mScrollView;
private final ColorSelector mColorSelector;
private final ObjectAnimator mEditPopupAnimator;
private final ObjectAnimator mColorEditorAnimator;
private final int mMargin;
public boolean internalChanges = false; // True when we programmatically change stuff.
private final View.OnLayoutChangeListener mLayoutChangedListener = new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (internalChanges) return;
internalChanges = true;
int width = (int) (safeParseFloat(mWidthEditText.getText().toString()));
if (width >= 0 && Math.abs(right - width) > 1) {
mWidthEditText.setText(String.valueOf(right - left));
}
int height = (int) (safeParseFloat(mHeightEditText.getText().toString()));
if (height >= 0 && Math.abs(bottom - height) > 1) {
mHeightEditText.setText(String.valueOf(bottom - top));
}
internalChanges = false;
}
};
protected EditText mNameEditText, mWidthEditText, mHeightEditText;
@SuppressLint("UseSwitchCompatOrMaterialCode")
protected Switch mToggleSwitch, mPassthroughSwitch, mSwipeableSwitch, mForwardLockSwitch, mAbsoluteTrackingSwitch;
protected Spinner mOrientationSpinner;
protected TextView[] mKeycodeTextviews = new TextView[4];
protected SeekBar mStrokeWidthSeekbar, mCornerRadiusSeekbar, mAlphaSeekbar;
protected TextView mStrokePercentTextView, mCornerRadiusPercentTextView, mAlphaPercentTextView;
protected TextView mSelectBackgroundColor, mSelectStrokeColor;
protected ArrayAdapter<String> mAdapter;
protected List<String> mSpecialArray;
protected CheckBox mDisplayInGameCheckbox, mDisplayInMenuCheckbox;
private ConstraintLayout mRootView;
private boolean mDisplaying = false;
private boolean mDisplayingColor = false;
private ControlInterface mCurrentlyEditedButton;
// Decorative textviews
private TextView mOrientationTextView, mMappingTextView, mNameTextView,
mCornerRadiusTextView, mVisibilityTextView, mSizeTextview, mSizeXTextView;
public EditControlPopup(Context context, ViewGroup parent) {
mScrollView = (DefocusableScrollView) LayoutInflater.from(context).inflate(R.layout.dialog_control_button_setting, parent, false);
parent.addView(mScrollView);
mMargin = context.getResources().getDimensionPixelOffset(R.dimen._20sdp);
mColorSelector = new ColorSelector(context, parent, null);
mColorSelector.getRootView().setElevation(11);
mColorSelector.getRootView().setTranslationZ(11);
mColorSelector.getRootView().setX(-context.getResources().getDimensionPixelOffset(R.dimen._280sdp));
mEditPopupAnimator = ObjectAnimator.ofFloat(mScrollView, "x", 0).setDuration(600);
mColorEditorAnimator = ObjectAnimator.ofFloat(mColorSelector.getRootView(), "x", 0).setDuration(600);
Interpolator decelerate = new AccelerateDecelerateInterpolator();
mEditPopupAnimator.setInterpolator(decelerate);
mColorEditorAnimator.setInterpolator(decelerate);
mScrollView.setElevation(10);
mScrollView.setTranslationZ(10);
mScrollView.setX(-context.getResources().getDimensionPixelOffset(R.dimen._280sdp));
bindLayout();
loadAdapter();
setupRealTimeListeners();
}
public static void setPercentageText(TextView textView, int progress) {
textView.setText(textView.getContext().getString(R.string.percent_format, progress));
}
/**
* Slide the layout into the visible screen area
*/
public void appear(boolean fromRight) {
disappearColor(); // When someone jumps from a button to another
if (fromRight) {
if (!mDisplaying || !isAtRight()) {
mEditPopupAnimator.setFloatValues(currentDisplayMetrics.widthPixels, currentDisplayMetrics.widthPixels - mScrollView.getWidth() - mMargin);
mEditPopupAnimator.start();
}
} else {
if (!mDisplaying || isAtRight()) {
mEditPopupAnimator.setFloatValues(-mScrollView.getWidth(), mMargin);
mEditPopupAnimator.start();
}
}
mDisplaying = true;
}
/**
* Slide out the layout
*/
public void disappear() {
if (!mDisplaying) return;
mDisplaying = false;
if (isAtRight())
mEditPopupAnimator.setFloatValues(currentDisplayMetrics.widthPixels - mScrollView.getWidth() - mMargin, currentDisplayMetrics.widthPixels);
else
mEditPopupAnimator.setFloatValues(mMargin, -mScrollView.getWidth());
mEditPopupAnimator.start();
}
/**
* Slide the layout into the visible screen area
*/
public void appearColor(boolean fromRight, int color) {
if (fromRight) {
if (!mDisplayingColor || !isAtRight()) {
mColorEditorAnimator.setFloatValues(currentDisplayMetrics.widthPixels, currentDisplayMetrics.widthPixels - mScrollView.getWidth() - mMargin);
mColorEditorAnimator.start();
}
} else {
if (!mDisplayingColor || isAtRight()) {
mColorEditorAnimator.setFloatValues(-mScrollView.getWidth(), mMargin);
mColorEditorAnimator.start();
}
}
// Adjust the color selector to have the same size as the control settings
ViewGroup.LayoutParams params = mColorSelector.getRootView().getLayoutParams();
params.height = mScrollView.getHeight();
mColorSelector.getRootView().setLayoutParams(params);
mDisplayingColor = true;
mColorSelector.show(color == -1 ? Color.WHITE : color);
}
/**
* Slide out the layout
*/
public void disappearColor() {
if (!mDisplayingColor) return;
mDisplayingColor = false;
if (isAtRight())
mColorEditorAnimator.setFloatValues(currentDisplayMetrics.widthPixels - mScrollView.getWidth() - mMargin, currentDisplayMetrics.widthPixels);
else
mColorEditorAnimator.setFloatValues(mMargin, -mScrollView.getWidth());
mColorEditorAnimator.start();
}
/**
* Slide out the first visible layer.
*
* @return True if the last layer is disappearing
*/
public boolean disappearLayer() {
if (mDisplayingColor) {
disappearColor();
return false;
} else {
disappear();
return true;
}
}
/**
* Switch the panels position if needed
*/
public void adaptPanelPosition() {
if (mDisplaying) {
boolean isAtRight = mCurrentlyEditedButton.getControlView().getX() + mCurrentlyEditedButton.getControlView().getWidth() / 2f < currentDisplayMetrics.widthPixels / 2f;
appear(isAtRight);
}
}
public void destroy() {
((ViewGroup) mScrollView.getParent()).removeView(mColorSelector.getRootView());
((ViewGroup) mScrollView.getParent()).removeView(mScrollView);
}
private void loadAdapter() {
//Initialize adapter for keycodes
mAdapter = new ArrayAdapter<>(mRootView.getContext(), R.layout.item_centered_textview);
mSpecialArray = ControlData.buildSpecialButtonArray();
mAdapter.addAll(mSpecialArray);
mAdapter.addAll(EfficientAndroidLWJGLKeycode.generateKeyName());
mAdapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
for (Spinner spinner : mKeycodeSpinners) {
spinner.setAdapter(mAdapter);
}
// Orientation spinner
ArrayAdapter<ControlDrawerData.Orientation> adapter = new ArrayAdapter<>(mScrollView.getContext(), android.R.layout.simple_spinner_item);
adapter.addAll(ControlDrawerData.getOrientations());
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
mOrientationSpinner.setAdapter(adapter);
}
private void setDefaultVisibilitySetting() {
for (int i = 0; i < mRootView.getChildCount(); ++i) {
mRootView.getChildAt(i).setVisibility(VISIBLE);
}
for(Spinner s : mKeycodeSpinners) {
s.setVisibility(View.INVISIBLE);
}
}
private boolean isAtRight() {
return mScrollView.getX() > currentDisplayMetrics.widthPixels / 2f;
}
/* LOADING VALUES */
/**
* Load values for basic control data
*/
public void loadValues(ControlData data) {
setDefaultVisibilitySetting();
mOrientationTextView.setVisibility(GONE);
mOrientationSpinner.setVisibility(GONE);
mForwardLockSwitch.setVisibility(GONE);
mAbsoluteTrackingSwitch.setVisibility(GONE);
mNameEditText.setText(data.name);
mWidthEditText.setText(String.valueOf(data.getWidth()));
mHeightEditText.setText(String.valueOf(data.getHeight()));
mAlphaSeekbar.setProgress((int) (data.opacity * 100));
mStrokeWidthSeekbar.setProgress((int) data.strokeWidth * 10);
mCornerRadiusSeekbar.setProgress((int) data.cornerRadius);
setPercentageText(mAlphaPercentTextView, (int) (data.opacity * 100));
setPercentageText(mStrokePercentTextView, (int) data.strokeWidth * 10);
setPercentageText(mCornerRadiusPercentTextView, (int) data.cornerRadius);
mToggleSwitch.setChecked(data.isToggle);
mPassthroughSwitch.setChecked(data.passThruEnabled);
mSwipeableSwitch.setChecked(data.isSwipeable);
mDisplayInGameCheckbox.setChecked(data.displayInGame);
mDisplayInMenuCheckbox.setChecked(data.displayInMenu);
for (int i = 0; i < data.keycodes.length; i++) {
if (data.keycodes[i] < 0) {
mKeycodeSpinners[i].setSelection(data.keycodes[i] + mSpecialArray.size());
} else {
mKeycodeSpinners[i].setSelection(EfficientAndroidLWJGLKeycode.getIndexByValue(data.keycodes[i]) + mSpecialArray.size());
}
}
}
/**
* Load values for extended control data
*/
public void loadValues(ControlDrawerData data) {
loadValues(data.properties);
mOrientationSpinner.setSelection(
ControlDrawerData.orientationToInt(data.orientation));
mMappingTextView.setVisibility(GONE);
for (int i = 0; i < mKeycodeSpinners.length; i++) {
mKeycodeSpinners[i].setVisibility(GONE);
mKeycodeTextviews[i].setVisibility(GONE);
}
mOrientationTextView.setVisibility(VISIBLE);
mOrientationSpinner.setVisibility(VISIBLE);
mSwipeableSwitch.setVisibility(View.GONE);
mPassthroughSwitch.setVisibility(View.GONE);
mToggleSwitch.setVisibility(View.GONE);
}
/**
* Load values for the joystick
*/
public void loadJoystickValues(ControlJoystickData data) {
loadValues(data);
mMappingTextView.setVisibility(GONE);
for (int i = 0; i < mKeycodeSpinners.length; i++) {
mKeycodeSpinners[i].setVisibility(GONE);
mKeycodeTextviews[i].setVisibility(GONE);
}
mNameTextView.setVisibility(GONE);
mNameEditText.setVisibility(GONE);
mCornerRadiusTextView.setVisibility(GONE);
mCornerRadiusSeekbar.setVisibility(GONE);
mCornerRadiusPercentTextView.setVisibility(GONE);
mSwipeableSwitch.setVisibility(View.GONE);
mPassthroughSwitch.setVisibility(View.GONE);
mToggleSwitch.setVisibility(View.GONE);
mForwardLockSwitch.setVisibility(VISIBLE);
mForwardLockSwitch.setChecked(data.forwardLock);
mAbsoluteTrackingSwitch.setVisibility(VISIBLE);
mAbsoluteTrackingSwitch.setChecked(data.absolute);
}
/**
* Load values for sub buttons
*/
public void loadSubButtonValues(ControlData data, ControlDrawerData.Orientation drawerOrientation) {
loadValues(data);
// Size linked to the parent drawer depending on the drawer settings
if(drawerOrientation != ControlDrawerData.Orientation.FREE){
mSizeTextview.setVisibility(GONE);
mSizeXTextView.setVisibility(GONE);
mWidthEditText.setVisibility(GONE);
mHeightEditText.setVisibility(GONE);
}
// No conditional, already depends on the parent drawer visibility
mVisibilityTextView.setVisibility(GONE);
mDisplayInMenuCheckbox.setVisibility(GONE);
mDisplayInGameCheckbox.setVisibility(GONE);
}
private void bindLayout() {
mRootView = mScrollView.findViewById(R.id.edit_layout);
mNameEditText = mScrollView.findViewById(R.id.editName_editText);
mWidthEditText = mScrollView.findViewById(R.id.editSize_editTextX);
mHeightEditText = mScrollView.findViewById(R.id.editSize_editTextY);
mToggleSwitch = mScrollView.findViewById(R.id.checkboxToggle);
mPassthroughSwitch = mScrollView.findViewById(R.id.checkboxPassThrough);
mSwipeableSwitch = mScrollView.findViewById(R.id.checkboxSwipeable);
mForwardLockSwitch = mScrollView.findViewById(R.id.checkboxForwardLock);
mAbsoluteTrackingSwitch = mScrollView.findViewById(R.id.checkboxAbsoluteFingerTracking);
mKeycodeSpinners[0] = mScrollView.findViewById(R.id.editMapping_spinner_1);
mKeycodeSpinners[1] = mScrollView.findViewById(R.id.editMapping_spinner_2);
mKeycodeSpinners[2] = mScrollView.findViewById(R.id.editMapping_spinner_3);
mKeycodeSpinners[3] = mScrollView.findViewById(R.id.editMapping_spinner_4);
mKeycodeTextviews[0] = mScrollView.findViewById(R.id.mapping_1_textview);
mKeycodeTextviews[1] = mScrollView.findViewById(R.id.mapping_2_textview);
mKeycodeTextviews[2] = mScrollView.findViewById(R.id.mapping_3_textview);
mKeycodeTextviews[3] = mScrollView.findViewById(R.id.mapping_4_textview);
mOrientationSpinner = mScrollView.findViewById(R.id.editOrientation_spinner);
mStrokeWidthSeekbar = mScrollView.findViewById(R.id.editStrokeWidth_seekbar);
mCornerRadiusSeekbar = mScrollView.findViewById(R.id.editCornerRadius_seekbar);
mAlphaSeekbar = mScrollView.findViewById(R.id.editButtonOpacity_seekbar);
mSelectBackgroundColor = mScrollView.findViewById(R.id.editBackgroundColor_textView);
mSelectStrokeColor = mScrollView.findViewById(R.id.editStrokeColor_textView);
mStrokePercentTextView = mScrollView.findViewById(R.id.editStrokeWidth_textView_percent);
mAlphaPercentTextView = mScrollView.findViewById(R.id.editButtonOpacity_textView_percent);
mCornerRadiusPercentTextView = mScrollView.findViewById(R.id.editCornerRadius_textView_percent);
mDisplayInGameCheckbox = mScrollView.findViewById(R.id.visibility_game_checkbox);
mDisplayInMenuCheckbox = mScrollView.findViewById(R.id.visibility_menu_checkbox);
//Decorative stuff
mMappingTextView = mScrollView.findViewById(R.id.editMapping_textView);
mOrientationTextView = mScrollView.findViewById(R.id.editOrientation_textView);
mNameTextView = mScrollView.findViewById(R.id.editName_textView);
mCornerRadiusTextView = mScrollView.findViewById(R.id.editCornerRadius_textView);
mVisibilityTextView = mScrollView.findViewById(R.id.visibility_textview);
mSizeTextview = mScrollView.findViewById(R.id.editSize_textView);
mSizeXTextView = mScrollView.findViewById(R.id.editSize_x_textView);
}
/**
* A long function linking all the displayed data on the popup and,
* the currently edited mCurrentlyEditedButton
*/
public void setupRealTimeListeners() {
mNameEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().name = s.toString();
// Cheap and unoptimized, doesn't break the abstraction layer
mCurrentlyEditedButton.setProperties(mCurrentlyEditedButton.getProperties(), false);
}
});
mWidthEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (internalChanges) return;
float width = safeParseFloat(s.toString());
if (width >= 0) {
mCurrentlyEditedButton.getProperties().setWidth(width);
mCurrentlyEditedButton.updateProperties();
}
}
});
mHeightEditText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
if (internalChanges) return;
float height = safeParseFloat(s.toString());
if (height >= 0) {
mCurrentlyEditedButton.getProperties().setHeight(height);
mCurrentlyEditedButton.updateProperties();
}
}
});
mSwipeableSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().isSwipeable = isChecked;
});
mToggleSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().isToggle = isChecked;
});
mPassthroughSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().passThruEnabled = isChecked;
});
mForwardLockSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
if(mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData){
((ControlJoystickData) mCurrentlyEditedButton.getProperties()).forwardLock = isChecked;
}
});
mAbsoluteTrackingSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
if(mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData){
((ControlJoystickData) mCurrentlyEditedButton.getProperties()).absolute = isChecked;
}
});
mAlphaSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().opacity = mAlphaSeekbar.getProgress() / 100f;
mCurrentlyEditedButton.getControlView().setAlpha(mAlphaSeekbar.getProgress() / 100f);
setPercentageText(mAlphaPercentTextView, progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mStrokeWidthSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().strokeWidth = mStrokeWidthSeekbar.getProgress() / 10F;
mCurrentlyEditedButton.setBackground();
setPercentageText(mStrokePercentTextView, progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
mCornerRadiusSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().cornerRadius = mCornerRadiusSeekbar.getProgress();
mCurrentlyEditedButton.setBackground();
setPercentageText(mCornerRadiusPercentTextView, progress);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
});
for (int i = 0; i < mKeycodeSpinners.length; ++i) {
int finalI = i;
mKeycodeTextviews[i].setOnClickListener(v -> mKeycodeSpinners[finalI].performClick());
mKeycodeSpinners[i].setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// Side note, spinner listeners are fired later than all the other ones.
// Meaning the internalChanges bool is useless here.
if (position < mSpecialArray.size()) {
mCurrentlyEditedButton.getProperties().keycodes[finalI] = mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.size();
} else {
mCurrentlyEditedButton.getProperties().keycodes[finalI] = EfficientAndroidLWJGLKeycode.getValueByIndex(mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.size());
}
mKeycodeTextviews[finalI].setText((String) mKeycodeSpinners[finalI].getSelectedItem());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
mOrientationSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
// Side note, spinner listeners are fired later than all the other ones.
// Meaning the internalChanges bool is useless here.
if (mCurrentlyEditedButton instanceof ControlDrawer) {
((ControlDrawer) mCurrentlyEditedButton).drawerData.orientation = ControlDrawerData.intToOrientation(mOrientationSpinner.getSelectedItemPosition());
((ControlDrawer) mCurrentlyEditedButton).syncButtons();
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
mDisplayInGameCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().displayInGame = isChecked;
});
mDisplayInMenuCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().displayInMenu = isChecked;
});
mSelectStrokeColor.setOnClickListener(v -> {
mColorSelector.setAlphaEnabled(false);
mColorSelector.setColorSelectionListener(color -> {
mCurrentlyEditedButton.getProperties().strokeColor = color;
mCurrentlyEditedButton.setBackground();
});
appearColor(isAtRight(), mCurrentlyEditedButton.getProperties().strokeColor);
});
mSelectBackgroundColor.setOnClickListener(v -> {
mColorSelector.setAlphaEnabled(true);
mColorSelector.setColorSelectionListener(color -> {
mCurrentlyEditedButton.getProperties().bgColor = color;
mCurrentlyEditedButton.setBackground();
});
appearColor(isAtRight(), mCurrentlyEditedButton.getProperties().bgColor);
});
}
private float safeParseFloat(String string) {
float out = -1; // -1
try {
out = Float.parseFloat(string);
} catch (NumberFormatException e) {
Log.e("EditControlPopup", e.toString());
}
return out;
}
public void setCurrentlyEditedButton(ControlInterface button) {
if (mCurrentlyEditedButton != null)
mCurrentlyEditedButton.getControlView().removeOnLayoutChangeListener(mLayoutChangedListener);
mCurrentlyEditedButton = button;
mCurrentlyEditedButton.getControlView().addOnLayoutChangeListener(mLayoutChangedListener);
}
}
@@ -1,495 +0,0 @@
package net.kdt.pojavlaunch.customcontrols.handleview;
import static android.view.View.GONE;
import static android.view.View.VISIBLE;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import com.kdt.SideDialogView;
import net.kdt.pojavlaunch.EfficientAndroidLWJGLKeycode;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.colorselector.ColorSelector;
import net.kdt.pojavlaunch.customcontrols.ControlData;
import net.kdt.pojavlaunch.customcontrols.ControlDrawerData;
import net.kdt.pojavlaunch.customcontrols.ControlJoystickData;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlDrawer;
import net.kdt.pojavlaunch.customcontrols.buttons.ControlInterface;
import net.kdt.pojavlaunch.utils.interfaces.SimpleItemSelectedListener;
import net.kdt.pojavlaunch.utils.interfaces.SimpleSeekBarListener;
import net.kdt.pojavlaunch.utils.interfaces.SimpleTextWatcher;
import java.util.List;
public class EditControlSideDialog extends SideDialogView {
private final Spinner[] mKeycodeSpinners = new Spinner[4];
public boolean internalChanges = false; // True when we programmatically change stuff.
private final View.OnLayoutChangeListener mLayoutChangedListener = new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (internalChanges) return;
internalChanges = true;
int width = (int) (safeParseFloat(mWidthEditText.getText().toString()));
if (width >= 0 && Math.abs(right - width) > 1) {
mWidthEditText.setText(String.valueOf(right - left));
}
int height = (int) (safeParseFloat(mHeightEditText.getText().toString()));
if (height >= 0 && Math.abs(bottom - height) > 1) {
mHeightEditText.setText(String.valueOf(bottom - top));
}
internalChanges = false;
}
};
private EditText mNameEditText, mWidthEditText, mHeightEditText;
@SuppressLint("UseSwitchCompatOrMaterialCode")
private Switch mToggleSwitch, mPassthroughSwitch, mSwipeableSwitch, mForwardLockSwitch, mAbsoluteTrackingSwitch;
private Spinner mOrientationSpinner;
private final TextView[] mKeycodeTextviews = new TextView[4];
private SeekBar mStrokeWidthSeekbar, mCornerRadiusSeekbar, mAlphaSeekbar;
private TextView mStrokePercentTextView, mCornerRadiusPercentTextView, mAlphaPercentTextView;
private TextView mSelectBackgroundColor, mSelectStrokeColor;
private ArrayAdapter<String> mAdapter;
private List<String> mSpecialArray;
private CheckBox mDisplayInGameCheckbox, mDisplayInMenuCheckbox;
private ControlInterface mCurrentlyEditedButton;
// Decorative textviews
private TextView mOrientationTextView, mMappingTextView, mNameTextView,
mCornerRadiusTextView, mVisibilityTextView, mSizeTextview, mSizeXTextView;
// Color selector related stuff
private ColorSelector mColorSelector;
private final ViewGroup mParent;
public EditControlSideDialog(Context context, ViewGroup parent) {
super(context, parent, R.layout.dialog_control_button_setting);
mParent = parent;
}
@Override
protected void onInflate() {
bindLayout();
buildColorSelector();
loadAdapter();
setupRealTimeListeners();
}
@Override
protected void onDestroy() {
mColorSelector.disappear(true);
}
private void buildColorSelector() {
mColorSelector = new ColorSelector(mParent.getContext(), mParent, null);
}
/**
* Slide the layout into the visible screen area
*/
public void appearColor(boolean fromRight, int color) {
mColorSelector.show(fromRight, color == -1 ? Color.WHITE : color);
}
/**
* Slide out the layout
*/
public void disappearColor() {
mColorSelector.disappear(false);
}
/**
* Slide out the first visible layer.
*
* @return True if the last layer is disappearing
*/
public boolean disappearLayer() {
if (mColorSelector.isDisplaying()) {
disappearColor();
return false;
} else {
disappear(false);
return true;
}
}
/**
* Switch the panels position if needed
*/
public void adaptPanelPosition() {
if (mDisplaying) {
boolean isAtRight = mCurrentlyEditedButton.getControlView().getX() + mCurrentlyEditedButton.getControlView().getWidth() / 2f < currentDisplayMetrics.widthPixels / 2f;
appear(isAtRight);
if (mColorSelector.isDisplaying()) {
Tools.runOnUiThread(() -> appearColor(isAtRight, mCurrentlyEditedButton.getProperties().bgColor));
}
}
}
public static void setPercentageText(TextView textView, int progress) {
textView.setText(textView.getContext().getString(R.string.percent_format, progress));
}
/* LOADING VALUES */
/**
* Load values for basic control data
*/
public void loadValues(ControlData data) {
setDefaultVisibilitySetting();
mOrientationTextView.setVisibility(GONE);
mOrientationSpinner.setVisibility(GONE);
mForwardLockSwitch.setVisibility(GONE);
mAbsoluteTrackingSwitch.setVisibility(GONE);
mNameEditText.setText(data.name);
mWidthEditText.setText(String.valueOf(data.getWidth()));
mHeightEditText.setText(String.valueOf(data.getHeight()));
mAlphaSeekbar.setProgress((int) (data.opacity * 100));
mStrokeWidthSeekbar.setProgress((int) data.strokeWidth * 10);
mCornerRadiusSeekbar.setProgress((int) data.cornerRadius);
setPercentageText(mAlphaPercentTextView, (int) (data.opacity * 100));
setPercentageText(mStrokePercentTextView, (int) data.strokeWidth * 10);
setPercentageText(mCornerRadiusPercentTextView, (int) data.cornerRadius);
mToggleSwitch.setChecked(data.isToggle);
mPassthroughSwitch.setChecked(data.passThruEnabled);
mSwipeableSwitch.setChecked(data.isSwipeable);
mDisplayInGameCheckbox.setChecked(data.displayInGame);
mDisplayInMenuCheckbox.setChecked(data.displayInMenu);
for (int i = 0; i < data.keycodes.length; i++) {
if (data.keycodes[i] < 0) {
mKeycodeSpinners[i].setSelection(data.keycodes[i] + mSpecialArray.size());
} else {
mKeycodeSpinners[i].setSelection(EfficientAndroidLWJGLKeycode.getIndexByValue(data.keycodes[i]) + mSpecialArray.size());
}
}
}
/**
* Load values for extended control data
*/
public void loadValues(ControlDrawerData data) {
loadValues(data.properties);
mOrientationSpinner.setSelection(
ControlDrawerData.orientationToInt(data.orientation));
mMappingTextView.setVisibility(GONE);
for (int i = 0; i < mKeycodeSpinners.length; i++) {
mKeycodeSpinners[i].setVisibility(GONE);
mKeycodeTextviews[i].setVisibility(GONE);
}
mOrientationTextView.setVisibility(VISIBLE);
mOrientationSpinner.setVisibility(VISIBLE);
mSwipeableSwitch.setVisibility(View.GONE);
mPassthroughSwitch.setVisibility(View.GONE);
mToggleSwitch.setVisibility(View.GONE);
}
/**
* Load values for the joystick
*/
public void loadJoystickValues(ControlJoystickData data) {
loadValues(data);
mMappingTextView.setVisibility(GONE);
for (int i = 0; i < mKeycodeSpinners.length; i++) {
mKeycodeSpinners[i].setVisibility(GONE);
mKeycodeTextviews[i].setVisibility(GONE);
}
mNameTextView.setVisibility(GONE);
mNameEditText.setVisibility(GONE);
mCornerRadiusTextView.setVisibility(GONE);
mCornerRadiusSeekbar.setVisibility(GONE);
mCornerRadiusPercentTextView.setVisibility(GONE);
mSwipeableSwitch.setVisibility(View.GONE);
mPassthroughSwitch.setVisibility(View.GONE);
mToggleSwitch.setVisibility(View.GONE);
mForwardLockSwitch.setVisibility(VISIBLE);
mForwardLockSwitch.setChecked(data.forwardLock);
mAbsoluteTrackingSwitch.setVisibility(VISIBLE);
mAbsoluteTrackingSwitch.setChecked(data.absolute);
}
/**
* Load values for sub buttons
*/
public void loadSubButtonValues(ControlData data, ControlDrawerData.Orientation drawerOrientation) {
loadValues(data);
// Size linked to the parent drawer depending on the drawer settings
if(drawerOrientation != ControlDrawerData.Orientation.FREE){
mSizeTextview.setVisibility(GONE);
mSizeXTextView.setVisibility(GONE);
mWidthEditText.setVisibility(GONE);
mHeightEditText.setVisibility(GONE);
}
// No conditional, already depends on the parent drawer visibility
mVisibilityTextView.setVisibility(GONE);
mDisplayInMenuCheckbox.setVisibility(GONE);
mDisplayInGameCheckbox.setVisibility(GONE);
}
private void loadAdapter() {
//Initialize adapter for keycodes
mAdapter = new ArrayAdapter<>(mDialogContent.getContext(), R.layout.item_centered_textview);
mSpecialArray = ControlData.buildSpecialButtonArray();
mAdapter.addAll(mSpecialArray);
mAdapter.addAll(EfficientAndroidLWJGLKeycode.generateKeyName());
mAdapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
for (Spinner spinner : mKeycodeSpinners) {
spinner.setAdapter(mAdapter);
}
// Orientation spinner
ArrayAdapter<ControlDrawerData.Orientation> adapter = new ArrayAdapter<>(mDialogContent.getContext(), android.R.layout.simple_spinner_item);
adapter.addAll(ControlDrawerData.getOrientations());
adapter.setDropDownViewResource(android.R.layout.simple_list_item_single_choice);
mOrientationSpinner.setAdapter(adapter);
}
private void setDefaultVisibilitySetting() {
for (int i = 0; i < ((ViewGroup)mDialogContent).getChildCount(); ++i) {
((ViewGroup)mDialogContent).getChildAt(i).setVisibility(VISIBLE);
}
for(Spinner s : mKeycodeSpinners) {
s.setVisibility(View.INVISIBLE);
}
}
private void bindLayout() {
mNameEditText = mDialogContent.findViewById(R.id.editName_editText);
mWidthEditText = mDialogContent.findViewById(R.id.editSize_editTextX);
mHeightEditText = mDialogContent.findViewById(R.id.editSize_editTextY);
mToggleSwitch = mDialogContent.findViewById(R.id.checkboxToggle);
mPassthroughSwitch = mDialogContent.findViewById(R.id.checkboxPassThrough);
mSwipeableSwitch = mDialogContent.findViewById(R.id.checkboxSwipeable);
mForwardLockSwitch = mDialogContent.findViewById(R.id.checkboxForwardLock);
mAbsoluteTrackingSwitch = mDialogContent.findViewById(R.id.checkboxAbsoluteFingerTracking);
mKeycodeSpinners[0] = mDialogContent.findViewById(R.id.editMapping_spinner_1);
mKeycodeSpinners[1] = mDialogContent.findViewById(R.id.editMapping_spinner_2);
mKeycodeSpinners[2] = mDialogContent.findViewById(R.id.editMapping_spinner_3);
mKeycodeSpinners[3] = mDialogContent.findViewById(R.id.editMapping_spinner_4);
mKeycodeTextviews[0] = mDialogContent.findViewById(R.id.mapping_1_textview);
mKeycodeTextviews[1] = mDialogContent.findViewById(R.id.mapping_2_textview);
mKeycodeTextviews[2] = mDialogContent.findViewById(R.id.mapping_3_textview);
mKeycodeTextviews[3] = mDialogContent.findViewById(R.id.mapping_4_textview);
mOrientationSpinner = mDialogContent.findViewById(R.id.editOrientation_spinner);
mStrokeWidthSeekbar = mDialogContent.findViewById(R.id.editStrokeWidth_seekbar);
mCornerRadiusSeekbar = mDialogContent.findViewById(R.id.editCornerRadius_seekbar);
mAlphaSeekbar = mDialogContent.findViewById(R.id.editButtonOpacity_seekbar);
mSelectBackgroundColor = mDialogContent.findViewById(R.id.editBackgroundColor_textView);
mSelectStrokeColor = mDialogContent.findViewById(R.id.editStrokeColor_textView);
mStrokePercentTextView = mDialogContent.findViewById(R.id.editStrokeWidth_textView_percent);
mAlphaPercentTextView = mDialogContent.findViewById(R.id.editButtonOpacity_textView_percent);
mCornerRadiusPercentTextView = mDialogContent.findViewById(R.id.editCornerRadius_textView_percent);
mDisplayInGameCheckbox = mDialogContent.findViewById(R.id.visibility_game_checkbox);
mDisplayInMenuCheckbox = mDialogContent.findViewById(R.id.visibility_menu_checkbox);
//Decorative stuff
mMappingTextView = mDialogContent.findViewById(R.id.editMapping_textView);
mOrientationTextView = mDialogContent.findViewById(R.id.editOrientation_textView);
mNameTextView = mDialogContent.findViewById(R.id.editName_textView);
mCornerRadiusTextView = mDialogContent.findViewById(R.id.editCornerRadius_textView);
mVisibilityTextView = mDialogContent.findViewById(R.id.visibility_textview);
mSizeTextview = mDialogContent.findViewById(R.id.editSize_textView);
mSizeXTextView = mDialogContent.findViewById(R.id.editSize_x_textView);
}
/**
* A long function linking all the displayed data on the popup and,
* the currently edited mCurrentlyEditedButton
* @noinspection SuspiciousNameCombination
*/
private void setupRealTimeListeners() {
mNameEditText.addTextChangedListener((SimpleTextWatcher) s -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().name = s.toString();
// Cheap and unoptimized, doesn't break the abstraction layer
mCurrentlyEditedButton.setProperties(mCurrentlyEditedButton.getProperties(), false);
});
mWidthEditText.addTextChangedListener((SimpleTextWatcher) s -> {
if (internalChanges) return;
float width = safeParseFloat(s.toString());
if (width >= 0) {
mCurrentlyEditedButton.getProperties().setWidth(width);
if (mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData) {
// Joysticks are square
mCurrentlyEditedButton.getProperties().setHeight(width);
}
mCurrentlyEditedButton.updateProperties();
}
});
mHeightEditText.addTextChangedListener((SimpleTextWatcher) s -> {
if (internalChanges) return;
float height = safeParseFloat(s.toString());
if (height >= 0) {
mCurrentlyEditedButton.getProperties().setHeight(height);
if (mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData) {
// Joysticks are square
mCurrentlyEditedButton.getProperties().setWidth(height);
}
mCurrentlyEditedButton.updateProperties();
}
});
mSwipeableSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().isSwipeable = isChecked;
});
mToggleSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().isToggle = isChecked;
});
mPassthroughSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().passThruEnabled = isChecked;
});
mForwardLockSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
if(mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData){
((ControlJoystickData) mCurrentlyEditedButton.getProperties()).forwardLock = isChecked;
}
});
mAbsoluteTrackingSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
if(mCurrentlyEditedButton.getProperties() instanceof ControlJoystickData){
((ControlJoystickData) mCurrentlyEditedButton.getProperties()).absolute = isChecked;
}
});
mAlphaSeekbar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().opacity = mAlphaSeekbar.getProgress() / 100f;
mCurrentlyEditedButton.getControlView().setAlpha(mAlphaSeekbar.getProgress() / 100f);
setPercentageText(mAlphaPercentTextView, progress);
});
mStrokeWidthSeekbar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().strokeWidth = mStrokeWidthSeekbar.getProgress() / 10F;
mCurrentlyEditedButton.setBackground();
setPercentageText(mStrokePercentTextView, progress);
});
mCornerRadiusSeekbar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().cornerRadius = mCornerRadiusSeekbar.getProgress();
mCurrentlyEditedButton.setBackground();
setPercentageText(mCornerRadiusPercentTextView, progress);
});
for (int i = 0; i < mKeycodeSpinners.length; ++i) {
int finalI = i;
mKeycodeTextviews[i].setOnClickListener(v -> mKeycodeSpinners[finalI].performClick());
mKeycodeSpinners[i].setOnItemSelectedListener((SimpleItemSelectedListener) (parent, view, position, id) -> {
// Side note, spinner listeners are fired later than all the other ones.
// Meaning the internalChanges bool is useless here.
if (position < mSpecialArray.size()) {
mCurrentlyEditedButton.getProperties().keycodes[finalI] = mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.size();
} else {
mCurrentlyEditedButton.getProperties().keycodes[finalI] = EfficientAndroidLWJGLKeycode.getValueByIndex(mKeycodeSpinners[finalI].getSelectedItemPosition() - mSpecialArray.size());
}
mKeycodeTextviews[finalI].setText((String) mKeycodeSpinners[finalI].getSelectedItem());
});
}
mOrientationSpinner.setOnItemSelectedListener((SimpleItemSelectedListener) (parent, view, position, id) -> {
// Side note, spinner listeners are fired later than all the other ones.
// Meaning the internalChanges bool is useless here.
if (mCurrentlyEditedButton instanceof ControlDrawer) {
((ControlDrawer) mCurrentlyEditedButton).drawerData.orientation = ControlDrawerData.intToOrientation(mOrientationSpinner.getSelectedItemPosition());
((ControlDrawer) mCurrentlyEditedButton).syncButtons();
}
});
mDisplayInGameCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().displayInGame = isChecked;
});
mDisplayInMenuCheckbox.setOnCheckedChangeListener((buttonView, isChecked) -> {
if (internalChanges) return;
mCurrentlyEditedButton.getProperties().displayInMenu = isChecked;
});
mSelectStrokeColor.setOnClickListener(v -> {
mColorSelector.setAlphaEnabled(false);
mColorSelector.setColorSelectionListener(color -> {
mCurrentlyEditedButton.getProperties().strokeColor = color;
mCurrentlyEditedButton.setBackground();
});
appearColor(isAtRight(), mCurrentlyEditedButton.getProperties().strokeColor);
});
mSelectBackgroundColor.setOnClickListener(v -> {
mColorSelector.setAlphaEnabled(true);
mColorSelector.setColorSelectionListener(color -> {
mCurrentlyEditedButton.getProperties().bgColor = color;
mCurrentlyEditedButton.setBackground();
});
appearColor(isAtRight(), mCurrentlyEditedButton.getProperties().bgColor);
});
}
private float safeParseFloat(String string) {
float out = -1; // -1
try {
out = Float.parseFloat(string);
} catch (NumberFormatException e) {
Log.e("EditControlPopup", e.toString());
}
return out;
}
public void setCurrentlyEditedButton(ControlInterface button) {
if (mCurrentlyEditedButton != null)
mCurrentlyEditedButton.getControlView().removeOnLayoutChangeListener(mLayoutChangedListener);
mCurrentlyEditedButton = button;
mCurrentlyEditedButton.getControlView().addOnLayoutChangeListener(mLayoutChangedListener);
}
}
@@ -8,9 +8,9 @@ import android.view.ViewTreeObserver;
import androidx.annotation.RequiresApi;
import net.kdt.pojavlaunch.MainActivity;
import net.kdt.pojavlaunch.MinecraftGLSurface;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import org.lwjgl.glfw.CallbackBridge;
@@ -19,6 +19,7 @@ public class AndroidPointerCapture implements ViewTreeObserver.OnWindowFocusChan
private static final float TOUCHPAD_SCROLL_THRESHOLD = 1;
private final AbstractTouchpad mTouchpad;
private final View mHostView;
private final float mScaleFactor;
private final float mMousePrescale = Tools.dpToPx(1);
private final PointerTracker mPointerTracker = new PointerTracker();
private final Scroller mScroller = new Scroller(TOUCHPAD_SCROLL_THRESHOLD);
@@ -27,7 +28,8 @@ public class AndroidPointerCapture implements ViewTreeObserver.OnWindowFocusChan
private int mInputDeviceIdentifier;
private boolean mDeviceSupportsRelativeAxis;
public AndroidPointerCapture(AbstractTouchpad touchpad, View hostView) {
public AndroidPointerCapture(AbstractTouchpad touchpad, View hostView, float scaleFactor) {
this.mScaleFactor = scaleFactor;
this.mTouchpad = touchpad;
this.mHostView = hostView;
hostView.setOnCapturedPointerListener(this);
@@ -85,8 +87,8 @@ public class AndroidPointerCapture implements ViewTreeObserver.OnWindowFocusChan
}
} else {
// Position is updated by many events, hence it is send regardless of the event value
CallbackBridge.mouseX += (mVector[0] * LauncherPreferences.PREF_SCALE_FACTOR);
CallbackBridge.mouseY += (mVector[1] * LauncherPreferences.PREF_SCALE_FACTOR);
CallbackBridge.mouseX += (mVector[0] * mScaleFactor);
CallbackBridge.mouseY += (mVector[1] * mScaleFactor);
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
}
@@ -128,7 +130,7 @@ public class AndroidPointerCapture implements ViewTreeObserver.OnWindowFocusChan
@Override
public void onWindowFocusChanged(boolean hasFocus) {
if(hasFocus && Tools.isAndroid8OrHigher()) mHostView.requestPointerCapture();
if(hasFocus && MainActivity.isAndroid8OrHigher()) mHostView.requestPointerCapture();
}
public void detach() {
@@ -21,9 +21,6 @@ public class GyroControl implements SensorEventListener, GrabListener {
/* How much distance has to be moved before taking into account the gyro */
private static final float SINGLE_AXIS_LOW_PASS_THRESHOLD = 1.13F;
private static final float MULTI_AXIS_LOW_PASS_THRESHOLD = 1.3F;
// Warmup period of 2 since the first read from the sensor seems to produce a bogus value,
// which creates a far too large of a difference on the Y axis once actual sensor data comes in
private static final int ROTATION_VECTOR_WARMUP_PERIOD = 2;
private final WindowManager mWindowManager;
private int mSurfaceRotation;
@@ -31,7 +28,7 @@ public class GyroControl implements SensorEventListener, GrabListener {
private final Sensor mSensor;
private final OrientationCorrectionListener mCorrectionListener;
private boolean mShouldHandleEvents;
private int mWarmup;
private boolean mFirstPass;
private float xFactor; // -1 or 1 depending on device orientation
private float yFactor;
private boolean mSwapXY;
@@ -67,7 +64,7 @@ public class GyroControl implements SensorEventListener, GrabListener {
public void enable() {
if(mSensor == null) return;
mWarmup = ROTATION_VECTOR_WARMUP_PERIOD;
mFirstPass = true;
mSensorManager.registerListener(this, mSensor, 1000 * LauncherPreferences.PREF_GYRO_SAMPLE_RATE);
mCorrectionListener.enable();
mShouldHandleEvents = CallbackBridge.isGrabbing();
@@ -78,7 +75,6 @@ public class GyroControl implements SensorEventListener, GrabListener {
if(mSensor == null) return;
mSensorManager.unregisterListener(this);
mCorrectionListener.disable();
mStoredX = mStoredY = 0;
resetDamper();
CallbackBridge.removeGrabListener(this);
}
@@ -91,8 +87,8 @@ public class GyroControl implements SensorEventListener, GrabListener {
SensorManager.getRotationMatrixFromVector(mCurrentRotation, sensorEvent.values);
if(mWarmup > 0){ // Setup initial position
mWarmup--;
if(mFirstPass){ // Setup initial position
mFirstPass = false;
return;
}
SensorManager.getAngleChange(mAngleDifference, mCurrentRotation, mPreviousRotation);
@@ -165,7 +161,7 @@ public class GyroControl implements SensorEventListener, GrabListener {
@Override
public void onGrabState(boolean isGrabbing) {
mWarmup = ROTATION_VECTOR_WARMUP_PERIOD;
mFirstPass = true;
mShouldHandleEvents = isGrabbing;
}
@@ -11,7 +11,6 @@ import android.view.ViewParent;
import androidx.annotation.Nullable;
import net.kdt.pojavlaunch.GrabListener;
import net.kdt.pojavlaunch.LwjglGlfwKeycode;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.utils.MCOptionUtils;
@@ -27,16 +26,9 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
LwjglGlfwKeycode.GLFW_KEY_4, LwjglGlfwKeycode.GLFW_KEY_5, LwjglGlfwKeycode.GLFW_KEY_6,
LwjglGlfwKeycode.GLFW_KEY_7, LwjglGlfwKeycode.GLFW_KEY_8, LwjglGlfwKeycode.GLFW_KEY_9};
private final DropGesture mDropGesture = new DropGesture(new Handler(Looper.getMainLooper()));
private final GrabListener mGrabListener = new GrabListener() {
@Override
public void onGrabState(boolean isGrabbing) {
mLastIndex = -1;
mDropGesture.cancel();
}
};
private final float mScaleFactor = LauncherPreferences.PREF_SCALE_FACTOR/100f;
private int mWidth;
private int mLastIndex = -1;
private int mLastIndex;
private int mGuiScale;
public HotbarView(Context context) {
@@ -75,13 +67,6 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
}
mGuiScale = MCOptionUtils.getMcScale();
repositionView();
CallbackBridge.addGrabListener(mGrabListener);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallbackBridge.removeGrabListener(mGrabListener);
}
private void repositionView() {
@@ -109,8 +94,7 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
else mDropGesture.submit();
// Determine the hotbar slot
float x = event.getX();
// Ignore positions equal to mWidth because they would translate into an out-of-bounds hotbar index
if(x < 0 || x >= mWidth) {
if(x < 0 || x > mWidth) {
// If out of bounds, cancel the hotbar gesture to avoid dropping items on last hotbar slots
mDropGesture.cancel();
return true;
@@ -137,14 +121,7 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
}
private int mcScale(int input) {
return (int)((mGuiScale * input) / LauncherPreferences.PREF_SCALE_FACTOR);
}
/** Forces the view to reposition itself. */
public void onResolutionChanged() {
if(getParent() == null) return;
mGuiScale = MCOptionUtils.getMcScale();
post(this::repositionView);
return (int)((mGuiScale * input)/ mScaleFactor);
}
@Override
@@ -19,10 +19,12 @@ public class InGUIEventProcessor implements TouchEventProcessor {
private AbstractTouchpad mTouchpad;
private boolean mIsMouseDown = false;
private float mStartX, mStartY;
private final float mScaleFactor;
private final Scroller mScroller = new Scroller(FINGER_SCROLL_THRESHOLD);
public InGUIEventProcessor() {
public InGUIEventProcessor(float scaleFactor) {
mSingleTapDetector = new TapDetector(1, TapDetector.DETECTION_METHOD_BOTH);
mScaleFactor = scaleFactor;
}
@Override
@@ -89,7 +91,7 @@ public class InGUIEventProcessor implements TouchEventProcessor {
}
private void sendTouchCoordinates(float x, float y) {
CallbackBridge.sendCursorPos( x * LauncherPreferences.PREF_SCALE_FACTOR, y * LauncherPreferences.PREF_SCALE_FACTOR);
CallbackBridge.sendCursorPos( x * mScaleFactor, y * mScaleFactor);
}
private void enableMouse() {
@@ -103,8 +105,8 @@ public class InGUIEventProcessor implements TouchEventProcessor {
}
private void setGestureStart(MotionEvent event) {
mStartX = event.getX() * LauncherPreferences.PREF_SCALE_FACTOR;
mStartY = event.getY() * LauncherPreferences.PREF_SCALE_FACTOR;
mStartX = event.getX() * mScaleFactor;
mStartY = event.getY() * mScaleFactor;
}
private void resetGesture() {
@@ -2,7 +2,6 @@ package net.kdt.pojavlaunch.customcontrols.mouse;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.MotionEvent;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
@@ -33,12 +32,8 @@ public class InGameEventProcessor implements TouchEventProcessor {
case MotionEvent.ACTION_MOVE:
mTracker.trackEvent(motionEvent);
float[] motionVector = mTracker.getMotionVector();
float deltaX = (float) (motionVector[0] * mSensitivity);
float deltaY = (float) (motionVector[1] * mSensitivity);
mLeftClickGesture.setMotion(deltaX, deltaY);
mRightClickGesture.setMotion(deltaX, deltaY);
CallbackBridge.mouseX += deltaX;
CallbackBridge.mouseY += deltaY;
CallbackBridge.mouseX += motionVector[0] * mSensitivity;
CallbackBridge.mouseY += motionVector[1] * mSensitivity;
CallbackBridge.sendCursorPos(CallbackBridge.mouseX, CallbackBridge.mouseY);
if(LauncherPreferences.PREF_DISABLE_GESTURES) break;
checkGestures();
@@ -13,7 +13,7 @@ import org.lwjgl.glfw.CallbackBridge;
public class LeftClickGesture extends ValidatorGesture {
public static final int FINGER_STILL_THRESHOLD = (int) Tools.dpToPx(9);
private float mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY;
private float mGestureStartX, mGestureStartY;
private boolean mMouseActivated;
public LeftClickGesture(Handler handler) {
@@ -22,14 +22,14 @@ public class LeftClickGesture extends ValidatorGesture {
public final void inputEvent() {
if(submit()) {
mGestureStartX = mGestureEndX = CallbackBridge.mouseX;
mGestureStartY = mGestureEndY = CallbackBridge.mouseY;
mGestureStartX = CallbackBridge.mouseX;
mGestureStartY = CallbackBridge.mouseY;
}
}
@Override
public boolean checkAndTrigger() {
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY, FINGER_STILL_THRESHOLD);
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, FINGER_STILL_THRESHOLD);
// If the finger is still, fire the gesture.
if(fingerStill) {
sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_LEFT, true);
@@ -47,11 +47,6 @@ public class LeftClickGesture extends ValidatorGesture {
}
}
public void setMotion(float deltaX, float deltaY) {
mGestureEndX += deltaX;
mGestureEndY += deltaY;
}
/**
* Check if the finger is still when compared to mouseX/mouseY in CallbackBridge.
* @param startX the starting X of the gesture
@@ -66,13 +61,4 @@ public class LeftClickGesture extends ValidatorGesture {
startY
) <= threshold;
}
public static boolean isFingerStill(float startX, float startY, float endX, float endY, float threshold) {
return MathUtils.dist(
endX,
endY,
startX,
startY
) <= threshold;
}
}
@@ -9,7 +9,7 @@ import org.lwjgl.glfw.CallbackBridge;
public class RightClickGesture extends ValidatorGesture{
private boolean mGestureEnabled = true;
private boolean mGestureValid = true;
private float mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY;
private float mGestureStartX, mGestureStartY;
public RightClickGesture(Handler mHandler) {
super(mHandler, 150);
}
@@ -24,11 +24,6 @@ public class RightClickGesture extends ValidatorGesture{
}
}
public void setMotion(float deltaX, float deltaY) {
mGestureEndX += deltaX;
mGestureEndY += deltaY;
}
@Override
public boolean checkAndTrigger() {
// If the validate() method was called, it means that the user held on for too long. The cancellation should be ignored.
@@ -43,7 +38,7 @@ public class RightClickGesture extends ValidatorGesture{
public void onGestureCancelled(boolean isSwitching) {
mGestureEnabled = true;
if(!mGestureValid || isSwitching) return;
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, mGestureEndX, mGestureEndY, LeftClickGesture.FINGER_STILL_THRESHOLD);
boolean fingerStill = LeftClickGesture.isFingerStill(mGestureStartX, mGestureStartY, LeftClickGesture.FINGER_STILL_THRESHOLD);
if(!fingerStill) return;
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, true);
CallbackBridge.sendMouseButton(LwjglGlfwKeycode.GLFW_MOUSE_BUTTON_RIGHT, false);
@@ -1,6 +1,7 @@
package net.kdt.pojavlaunch.customcontrols.mouse;
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
import android.content.Context;
import android.graphics.Canvas;
@@ -28,6 +29,8 @@ public class Touchpad extends View implements GrabListener, AbstractTouchpad {
/* Mouse pointer icon used by the touchpad */
private Drawable mMousePointerDrawable;
private float mMouseX, mMouseY;
/* Resolution scaler option, allow downsizing a window */
private final float mScaleFactor = DEFAULT_PREF.getInt("resolutionRatio",100)/100f;
public Touchpad(@NonNull Context context) {
this(context, null);
}
@@ -65,7 +68,7 @@ public class Touchpad extends View implements GrabListener, AbstractTouchpad {
}
private void sendMousePosition() {
CallbackBridge.sendCursorPos((mMouseX * LauncherPreferences.PREF_SCALE_FACTOR), (mMouseY * LauncherPreferences.PREF_SCALE_FACTOR));
CallbackBridge.sendCursorPos((mMouseX * mScaleFactor), (mMouseY * mScaleFactor));
}
private void updateMousePosition() {
@@ -90,8 +93,8 @@ public class Touchpad extends View implements GrabListener, AbstractTouchpad {
assert mMousePointerDrawable != null;
mMousePointerDrawable.setBounds(
0, 0,
(int) (36 * LauncherPreferences.PREF_MOUSESCALE),
(int) (54 * LauncherPreferences.PREF_MOUSESCALE)
(int) (36 / 100f * LauncherPreferences.PREF_MOUSESCALE),
(int) (54 / 100f * LauncherPreferences.PREF_MOUSESCALE)
);
setFocusable(false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -1,6 +1,5 @@
package net.kdt.pojavlaunch.fragments;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
@@ -21,23 +20,17 @@ import java.util.regex.Pattern;
public class LocalLoginFragment extends Fragment {
public static final String TAG = "LOCAL_LOGIN_FRAGMENT";
private final Pattern mUsernameValidationPattern;
private EditText mUsernameEditText;
public LocalLoginFragment(){
super(R.layout.fragment_local_login);
mUsernameValidationPattern = Pattern.compile("^[a-zA-Z0-9_]*$");
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
mUsernameEditText = view.findViewById(R.id.login_edit_email);
view.findViewById(R.id.login_button).setOnClickListener(v -> {
if(!checkEditText()) {
Context context = v.getContext();
Tools.dialog(context, context.getString(R.string.local_login_bad_username_title), context.getString(R.string.local_login_bad_username_text));
return;
}
if(!checkEditText()) return;
ExtraCore.setValue(ExtraConstants.MOJANG_LOGIN_TODO, new String[]{
mUsernameEditText.getText().toString(), "" });
@@ -52,11 +45,13 @@ public class LocalLoginFragment extends Fragment {
String text = mUsernameEditText.getText().toString();
Matcher matcher = mUsernameValidationPattern.matcher(text);
Pattern pattern = Pattern.compile("[^a-zA-Z0-9_]");
Matcher matcher = pattern.matcher(text);
return !(text.isEmpty()
|| text.length() < 3
|| text.length() > 16
|| !matcher.find()
|| matcher.find()
|| new File(Tools.DIR_ACCOUNT_NEW + "/" + text + ".json").exists()
);
}
@@ -1,6 +1,5 @@
package net.kdt.pojavlaunch.fragments;
import static net.kdt.pojavlaunch.Tools.openPath;
import static net.kdt.pojavlaunch.Tools.shareLog;
import android.content.Intent;
@@ -21,12 +20,7 @@ import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.extra.ExtraConstants;
import net.kdt.pojavlaunch.extra.ExtraCore;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
import net.kdt.pojavlaunch.progresskeeper.ProgressKeeper;
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
import java.io.File;
public class MainMenuFragment extends Fragment {
public static final String TAG = "MainMenuFragment";
@@ -44,7 +38,6 @@ public class MainMenuFragment extends Fragment {
Button mCustomControlButton = view.findViewById(R.id.custom_control_button);
Button mInstallJarButton = view.findViewById(R.id.install_jar_button);
Button mShareLogsButton = view.findViewById(R.id.share_logs_button);
Button mOpenDirectoryButton = view.findViewById(R.id.open_files_button);
ImageButton mEditProfileButton = view.findViewById(R.id.edit_profile_button);
Button mPlayButton = view.findViewById(R.id.play_button);
@@ -64,24 +57,12 @@ public class MainMenuFragment extends Fragment {
mShareLogsButton.setOnClickListener((v) -> shareLog(requireContext()));
mOpenDirectoryButton.setOnClickListener((v)-> openPath(v.getContext(), getCurrentProfileDirectory(), false));
mNewsButton.setOnLongClickListener((v)->{
Tools.swapFragment(requireActivity(), GamepadMapperFragment.class, GamepadMapperFragment.TAG, null);
return true;
});
}
private File getCurrentProfileDirectory() {
String currentProfile = LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, null);
if(!Tools.isValidString(currentProfile)) return new File(Tools.DIR_GAME_NEW);
LauncherProfiles.load();
MinecraftProfile profileObject = LauncherProfiles.mainProfileJson.profiles.get(currentProfile);
if(profileObject == null) return new File(Tools.DIR_GAME_NEW);
return Tools.getGameDirPath(profileObject);
}
@Override
public void onResume() {
super.onResume();
@@ -107,28 +107,7 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
Tools.removeCurrentFragment(requireActivity());
});
View.OnClickListener gameDirListener = getGameDirListener();
mGameDirButton.setOnClickListener(gameDirListener);
mDefaultPath.setOnClickListener(gameDirListener);
View.OnClickListener controlSelectListener = getControlSelectListener();
mControlSelectButton.setOnClickListener(controlSelectListener);
mDefaultControl.setOnClickListener(controlSelectListener);
// Setup the expendable list behavior
View.OnClickListener versionSelectListener = getVersionSelectListener();
mVersionSelectButton.setOnClickListener(versionSelectListener);
mDefaultVersion.setOnClickListener(versionSelectListener);
// Set up the icon change click listener
mProfileIcon.setOnClickListener(v -> CropperUtils.startCropper(mCropperLauncher));
loadValues(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, ""), view.getContext());
}
private View.OnClickListener getGameDirListener() {
return v -> {
mGameDirButton.setOnClickListener(v -> {
Bundle bundle = new Bundle(2);
bundle.putBoolean(FileSelectorFragment.BUNDLE_SELECT_FOLDER, true);
bundle.putString(FileSelectorFragment.BUNDLE_ROOT_PATH, Tools.DIR_GAME_HOME);
@@ -137,11 +116,9 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
Tools.swapFragment(requireActivity(),
FileSelectorFragment.class, FileSelectorFragment.TAG, bundle);
};
}
});
private View.OnClickListener getControlSelectListener() {
return v -> {
mControlSelectButton.setOnClickListener(v -> {
Bundle bundle = new Bundle(3);
bundle.putBoolean(FileSelectorFragment.BUNDLE_SELECT_FOLDER, false);
bundle.putString(FileSelectorFragment.BUNDLE_ROOT_PATH, Tools.CTRLMAP_PATH);
@@ -149,14 +126,20 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
Tools.swapFragment(requireActivity(),
FileSelectorFragment.class, FileSelectorFragment.TAG, bundle);
};
}
});
private View.OnClickListener getVersionSelectListener() {
return v -> VersionSelectorDialog.open(v.getContext(), false, (id, snapshot)-> {
// Setup the expendable list behavior
mVersionSelectButton.setOnClickListener(v -> VersionSelectorDialog.open(v.getContext(), false, (id, snapshot)->{
mTempProfile.lastVersionId = id;
mDefaultVersion.setText(id);
});
}));
// Set up the icon change click listener
mProfileIcon.setOnClickListener(v -> CropperUtils.startCropper(mCropperLauncher));
loadValues(LauncherPreferences.DEFAULT_PREF.getString(LauncherPreferences.PREF_KEY_CURRENT_PROFILE, ""), view.getContext());
}
@@ -198,18 +181,7 @@ public class ProfileEditorFragment extends Fragment implements CropperUtils.Crop
private MinecraftProfile getProfile(@NonNull String profile){
MinecraftProfile minecraftProfile;
if(getArguments() == null) {
// EDGE CASE: User leaves Pojav in background. Pojav gets terminated in the background.
// Current selected fragment and its arguments are saved.
// User returns to Pojav. Android restarts process and reinitializes fragment without
// going to the main screen. mainProfileJson and profiles left uninitialized, which
// results in a crash.
// Reload the profiles to avoid this edge case.
LauncherProfiles.load();
MinecraftProfile originalProfile = LauncherProfiles.mainProfileJson.profiles.get(profile);
// EDGE CASE: User edits the JSON, so the profile that was edited no longer exists.
// Create a brand new profile as a fallback for this case.
if(originalProfile != null) minecraftProfile = new MinecraftProfile(originalProfile);
else minecraftProfile = MinecraftProfile.createTemplate();
minecraftProfile = new MinecraftProfile(LauncherProfiles.mainProfileJson.profiles.get(profile));
mProfileKey = profile;
}else{
minecraftProfile = MinecraftProfile.createTemplate();
@@ -36,7 +36,7 @@ public class LauncherPreferences {
public static boolean PREF_IGNORE_NOTCH = false;
public static int PREF_NOTCH_SIZE = 0;
public static float PREF_BUTTONSIZE = 100f;
public static float PREF_MOUSESCALE = 1f;
public static float PREF_MOUSESCALE = 100f;
public static int PREF_LONGPRESS_TRIGGER = 300;
public static String PREF_DEFAULTCTRL_PATH = Tools.CTRLDEF_FILE;
public static String PREF_CUSTOM_JAVA_ARGS;
@@ -53,7 +53,7 @@ public class LauncherPreferences {
public static boolean PREF_ARC_CAPES = false;
public static boolean PREF_USE_ALTERNATE_SURFACE = true;
public static boolean PREF_JAVA_SANDBOX = true;
public static float PREF_SCALE_FACTOR = 1f;
public static int PREF_SCALE_FACTOR = 100;
public static boolean PREF_ENABLE_GYRO = false;
public static float PREF_GYRO_SENSITIVITY = 1f;
public static int PREF_GYRO_SAMPLE_RATE = 16;
@@ -82,7 +82,7 @@ public class LauncherPreferences {
PREF_RENDERER = DEFAULT_PREF.getString("renderer", "opengles2");
PREF_BUTTONSIZE = DEFAULT_PREF.getInt("buttonscale", 100);
PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100)/100f;
PREF_MOUSESCALE = DEFAULT_PREF.getInt("mousescale", 100);
PREF_MOUSESPEED = ((float)DEFAULT_PREF.getInt("mousespeed",100))/100f;
PREF_HIDE_SIDEBAR = DEFAULT_PREF.getBoolean("hideSidebar", false);
PREF_IGNORE_NOTCH = DEFAULT_PREF.getBoolean("ignoreNotch", false);
@@ -103,7 +103,7 @@ public class LauncherPreferences {
PREF_ARC_CAPES = DEFAULT_PREF.getBoolean("arc_capes",false);
PREF_USE_ALTERNATE_SURFACE = DEFAULT_PREF.getBoolean("alternate_surface", false);
PREF_JAVA_SANDBOX = DEFAULT_PREF.getBoolean("java_sandbox", true);
PREF_SCALE_FACTOR = DEFAULT_PREF.getInt("resolutionRatio", 100)/100f;
PREF_SCALE_FACTOR = DEFAULT_PREF.getInt("resolutionRatio", 100);
PREF_ENABLE_GYRO = DEFAULT_PREF.getBoolean("enableGyro", false);
PREF_GYRO_SENSITIVITY = ((float)DEFAULT_PREF.getInt("gyroSensitivity", 100))/100f;
PREF_GYRO_SAMPLE_RATE = DEFAULT_PREF.getInt("gyroSampleRate", 16);
@@ -1,259 +0,0 @@
package net.kdt.pojavlaunch.prefs;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_DISABLE_GESTURES;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_ENABLE_GYRO;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GYRO_INVERT_X;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GYRO_INVERT_Y;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_GYRO_SENSITIVITY;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_LONGPRESS_TRIGGER;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_MOUSESPEED;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_SCALE_FACTOR;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
import android.widget.TextView;
import com.kdt.CustomSeekbar;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.utils.interfaces.SimpleSeekBarListener;
/**
* Side dialog for quick settings that you can change in game
* The implementation has to take action on some preference changes
*/
public abstract class QuickSettingSideDialog extends com.kdt.SideDialogView {
private SharedPreferences.Editor mEditor;
@SuppressLint("UseSwitchCompatOrMaterialCode")
private Switch mGyroSwitch, mGyroXSwitch, mGyroYSwitch, mGestureSwitch;
private CustomSeekbar mGyroSensitivityBar, mMouseSpeedBar, mGestureDelayBar, mResolutionBar;
private TextView mGyroSensitivityText, mGyroSensitivityDisplayText, mMouseSpeedText, mGestureDelayText, mGestureDelayDisplayText, mResolutionText;
private boolean mOriginalGyroEnabled, mOriginalGyroXEnabled, mOriginalGyroYEnabled, mOriginalGestureDisabled;
private float mOriginalGyroSensitivity, mOriginalMouseSpeed, mOriginalResolution;
private int mOriginalGestureDelay;
public QuickSettingSideDialog(Context context, ViewGroup parent) {
super(context, parent, R.layout.dialog_quick_setting);
setTitle(R.string.quick_setting_title);
setupCancelButton();
}
@Override
protected void onInflate() {
bindLayout();
Tools.runOnUiThread(() -> {
this.setupListeners();
this.updateGyroCompatibility();
});
}
@Override
protected void onDestroy() {
removeListeners();
}
private void bindLayout() {
// Bind layout elements
mGyroSwitch = mDialogContent.findViewById(R.id.checkboxGyro);
mGyroXSwitch = mDialogContent.findViewById(R.id.checkboxGyroX);
mGyroYSwitch = mDialogContent.findViewById(R.id.checkboxGyroY);
mGestureSwitch = mDialogContent.findViewById(R.id.checkboxGesture);
mGyroSensitivityBar = mDialogContent.findViewById(R.id.editGyro_seekbar);
mMouseSpeedBar = mDialogContent.findViewById(R.id.editMouseSpeed_seekbar);
mGestureDelayBar = mDialogContent.findViewById(R.id.editGestureDelay_seekbar);
mResolutionBar = mDialogContent.findViewById(R.id.editResolution_seekbar);
mGyroSensitivityText = mDialogContent.findViewById(R.id.editGyro_textView_percent);
mGyroSensitivityDisplayText = mDialogContent.findViewById(R.id.editGyro_textView);
mMouseSpeedText = mDialogContent.findViewById(R.id.editMouseSpeed_textView_percent);
mGestureDelayText = mDialogContent.findViewById(R.id.editGestureDelay_textView_percent);
mGestureDelayDisplayText = mDialogContent.findViewById(R.id.editGestureDelay_textView);
mResolutionText = mDialogContent.findViewById(R.id.editResolution_textView_percent);
}
private void setupListeners() {
mEditor = LauncherPreferences.DEFAULT_PREF.edit();
mOriginalGyroEnabled = PREF_ENABLE_GYRO;
mOriginalGyroXEnabled = PREF_GYRO_INVERT_X;
mOriginalGyroYEnabled = PREF_GYRO_INVERT_Y;
mOriginalGestureDisabled = PREF_DISABLE_GESTURES;
mOriginalGyroSensitivity = PREF_GYRO_SENSITIVITY;
mOriginalMouseSpeed = PREF_MOUSESPEED;
mOriginalGestureDelay = PREF_LONGPRESS_TRIGGER;
mOriginalResolution = PREF_SCALE_FACTOR;
mGyroSwitch.setChecked(mOriginalGyroEnabled);
mGyroXSwitch.setChecked(mOriginalGyroXEnabled);
mGyroYSwitch.setChecked(mOriginalGyroYEnabled);
mGestureSwitch.setChecked(mOriginalGestureDisabled);
mGyroSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
PREF_ENABLE_GYRO = isChecked;
onGyroStateChanged();
updateGyroVisibility(isChecked);
mEditor.putBoolean("enableGyro", isChecked);
});
mGyroXSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
PREF_GYRO_INVERT_X = isChecked;
onGyroStateChanged();
mEditor.putBoolean("gyroInvertX", isChecked);
});
mGyroYSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
PREF_GYRO_INVERT_Y = isChecked;
onGyroStateChanged();
mEditor.putBoolean("gyroInvertY", isChecked);
});
mGestureSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
PREF_DISABLE_GESTURES = isChecked;
updateGestureVisibility(isChecked);
mEditor.putBoolean("disableGestures", isChecked);
});
mGyroSensitivityBar.setRange(25, 300);
mGyroSensitivityBar.setIncrement(5);
mGyroSensitivityBar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
PREF_GYRO_SENSITIVITY = progress / 100f;
mEditor.putInt("gyroSensitivity", progress);
setSeekTextPercent(mGyroSensitivityText, progress);
});
mGyroSensitivityBar.setProgress((int) (mOriginalGyroSensitivity * 100f));
setSeekTextPercent(mGyroSensitivityText, mGyroSensitivityBar.getProgress());
mMouseSpeedBar.setRange(25, 300);
mMouseSpeedBar.setIncrement(5);
mMouseSpeedBar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
PREF_MOUSESPEED = progress / 100f;
mEditor.putInt("mousespeed", progress);
setSeekTextPercent(mMouseSpeedText, progress);
});
mMouseSpeedBar.setProgress((int) (mOriginalMouseSpeed * 100f));
setSeekTextPercent(mMouseSpeedText, mMouseSpeedBar.getProgress());
mGestureDelayBar.setRange(100, 1000);
mGestureDelayBar.setIncrement(10);
mGestureDelayBar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
PREF_LONGPRESS_TRIGGER = progress;
mEditor.putInt("timeLongPressTrigger", progress);
setSeekTextMillisecond(mGestureDelayText, progress);
});
mGestureDelayBar.setProgress(mOriginalGestureDelay);
setSeekTextMillisecond(mGestureDelayText, mGestureDelayBar.getProgress());
mResolutionBar.setRange(25, 100);
mResolutionBar.setIncrement(5);
mResolutionBar.setOnSeekBarChangeListener((SimpleSeekBarListener) (seekBar, progress, fromUser) -> {
PREF_SCALE_FACTOR = progress/100f;
mEditor.putInt("resolutionRatio", progress);
setSeekTextPercent(mResolutionText, progress);
onResolutionChanged();
});
mResolutionBar.setProgress((int) (mOriginalResolution * 100));
setSeekTextPercent(mResolutionText, mResolutionBar.getProgress());
updateGyroVisibility(mOriginalGyroEnabled);
updateGestureVisibility(mOriginalGestureDisabled);
}
private static void setSeekTextMillisecond(TextView target, int value) {
setSeekText(target, R.string.millisecond_format, value);
}
private static void setSeekTextPercent(TextView target, int value) {
setSeekText(target, R.string.percent_format, value);
}
private static void setSeekText(TextView target, int format, int value) {
target.setText(target.getContext().getString(format, value));
}
private void updateGyroVisibility(boolean isEnabled) {
int visibility = isEnabled ? View.VISIBLE : View.GONE;
mGyroXSwitch.setVisibility(visibility);
mGyroYSwitch.setVisibility(visibility);
mGyroSensitivityBar.setVisibility(visibility);
mGyroSensitivityText.setVisibility(visibility);
mGyroSensitivityDisplayText.setVisibility(visibility);
}
private void updateGyroCompatibility() {
boolean isGyroAvailable = Tools.deviceSupportsGyro(mDialogContent.getContext());
if (!isGyroAvailable) {
mGyroSwitch.setVisibility(View.GONE);
updateGestureVisibility(false);
}
}
private void updateGestureVisibility(boolean isDisabled) {
int visibility = isDisabled ? View.GONE : View.VISIBLE;
mGestureDelayBar.setVisibility(visibility);
mGestureDelayText.setVisibility(visibility);
mGestureDelayDisplayText.setVisibility(visibility);
}
private void removeListeners() {
mGyroSwitch.setOnCheckedChangeListener(null);
mGyroXSwitch.setOnCheckedChangeListener(null);
mGyroYSwitch.setOnCheckedChangeListener(null);
mGestureSwitch.setOnCheckedChangeListener(null);
mGyroSensitivityBar.setOnSeekBarChangeListener(null);
mMouseSpeedBar.setOnSeekBarChangeListener(null);
mGestureDelayBar.setOnSeekBarChangeListener(null);
mResolutionBar.setOnSeekBarChangeListener(null);
}
private void setupCancelButton() {
setStartButtonListener(android.R.string.cancel, v -> cancel());
setEndButtonListener(android.R.string.ok, v -> {
mEditor.apply();
disappear(true);
});
}
/** Resets all settings to their original values */
public void cancel() {
// Reset all settings if we were editing
if(isDisplaying()) {
PREF_ENABLE_GYRO = mOriginalGyroEnabled;
PREF_GYRO_INVERT_X = mOriginalGyroXEnabled;
PREF_GYRO_INVERT_Y = mOriginalGyroYEnabled;
PREF_DISABLE_GESTURES = mOriginalGestureDisabled;
PREF_GYRO_SENSITIVITY = mOriginalGyroSensitivity;
PREF_MOUSESPEED = mOriginalMouseSpeed;
PREF_LONGPRESS_TRIGGER = mOriginalGestureDelay;
PREF_SCALE_FACTOR = mOriginalResolution;
onGyroStateChanged();
onResolutionChanged();
}
disappear(true);
}
/** Called when the resolution is changed. Use {@link LauncherPreferences#PREF_SCALE_FACTOR} */
public abstract void onResolutionChanged();
/** Called when the gyro state is changed.
* Use {@link LauncherPreferences#PREF_ENABLE_GYRO}
* Use {@link LauncherPreferences#PREF_GYRO_INVERT_X}
* Use {@link LauncherPreferences#PREF_GYRO_INVERT_Y}
*/
public abstract void onGyroStateChanged();
}
@@ -9,7 +9,6 @@ import android.os.Bundle;
import androidx.preference.PreferenceCategory;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.prefs.CustomSeekBarPreference;
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
@@ -20,7 +19,7 @@ public class LauncherPreferenceControlFragment extends LauncherPreferenceFragmen
// Get values
int longPressTrigger = LauncherPreferences.PREF_LONGPRESS_TRIGGER;
int prefButtonSize = (int) LauncherPreferences.PREF_BUTTONSIZE;
int mouseScale = (int) (LauncherPreferences.PREF_MOUSESCALE * 100);
int mouseScale = (int) LauncherPreferences.PREF_MOUSESCALE;
int gyroSampleRate = LauncherPreferences.PREF_GYRO_SAMPLE_RATE;
float mouseSpeed = LauncherPreferences.PREF_MOUSESPEED;
float gyroSpeed = LauncherPreferences.PREF_GYRO_SENSITIVITY;
@@ -63,7 +62,7 @@ public class LauncherPreferenceControlFragment extends LauncherPreferenceFragmen
Context context = getContext();
if(context != null) {
mGyroAvailable = Tools.deviceSupportsGyro(context);
mGyroAvailable = ((SensorManager)context.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_GYROSCOPE) != null;
}
PreferenceCategory gyroCategory = requirePreference("gyroCategory",
PreferenceCategory.class);
@@ -13,7 +13,6 @@ import android.os.Process;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
import net.kdt.pojavlaunch.MainActivity;
import net.kdt.pojavlaunch.R;
import net.kdt.pojavlaunch.Tools;
import net.kdt.pojavlaunch.utils.NotificationUtils;
@@ -40,14 +39,9 @@ public class GameService extends Service {
killIntent.putExtra("kill", true);
PendingIntent pendingKillIntent = PendingIntent.getService(this, NotificationUtils.PENDINGINTENT_CODE_KILL_GAME_SERVICE
, killIntent, Build.VERSION.SDK_INT >=23 ? PendingIntent.FLAG_IMMUTABLE : 0);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT),
PendingIntent.FLAG_IMMUTABLE);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, "channel_id")
.setContentTitle(getString(R.string.lazy_service_default_title))
.setContentText(getString(R.string.notification_game_runs))
.setContentIntent(contentIntent)
.addAction(android.R.drawable.ic_menu_close_clear_cancel, getString(R.string.notification_terminate), pendingKillIntent)
.setSmallIcon(R.drawable.notif_icon)
.setNotificationSilent();
@@ -323,7 +323,7 @@ public class JREUtils {
LifecycleAwareAlertDialog.haltOnDialog(activity.getLifecycle(), activity, dialogCreator);
}
Tools.fullyExit();
MainActivity.fullyExit();
}
/**
@@ -355,8 +355,8 @@ public class JREUtils {
//"-Dorg.lwjgl.util.DebugFunctions=true",
//"-Dorg.lwjgl.util.DebugLoader=true",
// GLFW Stub width height
"-Dglfwstub.windowWidth=" + Tools.getDisplayFriendlyRes(currentDisplayMetrics.widthPixels, LauncherPreferences.PREF_SCALE_FACTOR),
"-Dglfwstub.windowHeight=" + Tools.getDisplayFriendlyRes(currentDisplayMetrics.heightPixels, LauncherPreferences.PREF_SCALE_FACTOR),
"-Dglfwstub.windowWidth=" + Tools.getDisplayFriendlyRes(currentDisplayMetrics.widthPixels, LauncherPreferences.PREF_SCALE_FACTOR/100F),
"-Dglfwstub.windowHeight=" + Tools.getDisplayFriendlyRes(currentDisplayMetrics.heightPixels, LauncherPreferences.PREF_SCALE_FACTOR/100F),
"-Dglfwstub.initEgl=false",
"-Dext.net.resolvPath=" +resolvFile,
"-Dlog4j2.formatMsgNoLookups=true", //Log4j RCE mitigation
@@ -572,5 +572,6 @@ public class JREUtils {
static {
System.loadLibrary("pojavexec");
System.loadLibrary("pojavexec_awt");
System.loadLibrary("istdio");
}
}
@@ -1,15 +0,0 @@
package net.kdt.pojavlaunch.utils.interfaces;
import android.view.View;
import android.widget.AdapterView;
/**
* Most interfaces implementations of {@link AdapterView.OnItemSelectedListener}
* only implement the {@link AdapterView.OnItemSelectedListener#onItemSelected(AdapterView, View, int, long)} onItemClick method.
* This class provides a default for other methods.
*/
public interface SimpleItemSelectedListener extends AdapterView.OnItemSelectedListener {
@Override
default void onNothingSelected(AdapterView<?> parent) {
}
}
@@ -1,17 +0,0 @@
package net.kdt.pojavlaunch.utils.interfaces;
import android.widget.SeekBar;
/**
* Most interfaces implementations of {@link SeekBar.OnSeekBarChangeListener}
* only implement the onProgressChanged method. This class provides a default for other methods.
*/
public interface SimpleSeekBarListener extends SeekBar.OnSeekBarChangeListener {
@Override
default void onStartTrackingTouch(android.widget.SeekBar seekBar) {
}
@Override
default void onStopTrackingTouch(android.widget.SeekBar seekBar) {
}
}
@@ -1,16 +0,0 @@
package net.kdt.pojavlaunch.utils.interfaces;
import android.text.Editable;
import android.text.TextWatcher;
/**
* Most interfaces implementations of {@link TextWatcher} only implement the afterTextChanged method.
* This class provides a default for other methods.
*/
public interface SimpleTextWatcher extends TextWatcher {
@Override
default void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
default void onTextChanged(CharSequence s, int start, int before, int count) {}
}
@@ -2,10 +2,8 @@ package org.lwjgl.glfw;
import net.kdt.pojavlaunch.*;
import android.content.*;
import android.util.Log;
import android.view.Choreographer;
import androidx.annotation.Keep;
import androidx.annotation.Nullable;
import java.util.ArrayList;
@@ -104,7 +102,6 @@ public class CallbackBridge {
// Called from JRE side
@SuppressWarnings("unused")
@Keep
public static @Nullable String accessAndroidClipboard(int type, String copy) {
switch (type) {
case CLIPBOARD_COPY:
@@ -167,7 +164,6 @@ public class CallbackBridge {
//Called from JRE side
@SuppressWarnings("unused")
@Keep
private static void onGrabStateChanged(final boolean grabbing) {
isGrabbing = grabbing;
sChoreographer.postFrameCallbackDelayed((time) -> {
@@ -194,17 +190,17 @@ public class CallbackBridge {
}
}
@Keep @CriticalNative public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
@CriticalNative public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
@Keep @CriticalNative private static native boolean nativeSendChar(char codepoint);
@CriticalNative private static native boolean nativeSendChar(char codepoint);
// GLFW: GLFWCharModsCallback deprecated, but is Minecraft still use?
@Keep @CriticalNative private static native boolean nativeSendCharMods(char codepoint, int mods);
@Keep @CriticalNative private static native void nativeSendKey(int key, int scancode, int action, int mods);
@CriticalNative private static native boolean nativeSendCharMods(char codepoint, int mods);
@CriticalNative private static native void nativeSendKey(int key, int scancode, int action, int mods);
// private static native void nativeSendCursorEnter(int entered);
@Keep @CriticalNative private static native void nativeSendCursorPos(float x, float y);
@Keep @CriticalNative private static native void nativeSendMouseButton(int button, int action, int mods);
@Keep @CriticalNative private static native void nativeSendScroll(double xoffset, double yoffset);
@Keep @CriticalNative private static native void nativeSendScreenSize(int width, int height);
@CriticalNative private static native void nativeSendCursorPos(float x, float y);
@CriticalNative private static native void nativeSendMouseButton(int button, int action, int mods);
@CriticalNative private static native void nativeSendScroll(double xoffset, double yoffset);
@CriticalNative private static native void nativeSendScreenSize(int width, int height);
public static native void nativeSetWindowAttrib(int attrib, int value);
static {
System.loadLibrary("pojavexec");
+10 -5
View File
@@ -20,21 +20,17 @@ LOCAL_SRC_FILES := tinywrapper/main.c tinywrapper/string_utils.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/tinywrapper
include $(BUILD_SHARED_LIBRARY)
$(call import-module,prefab/bytehook)
LOCAL_PATH := $(HERE_PATH)
include $(CLEAR_VARS)
# Link GLESv2 for test
LOCAL_LDLIBS := -ldl -llog -landroid
# -lGLESv2
LOCAL_MODULE := pojavexec
LOCAL_SHARED_LIBRARIES := bytehook
# LOCAL_CFLAGS += -DDEBUG
# -DGLES_TEST
LOCAL_SRC_FILES := \
bigcoreaffinity.c \
egl_bridge.c \
ctxbridges/loader_dlopen.c \
ctxbridges/gl_bridge.c \
ctxbridges/osm_bridge.c \
ctxbridges/egl_loader.c \
@@ -44,7 +40,6 @@ LOCAL_SRC_FILES := \
input_bridge_v3.c \
jre_launcher.c \
utils.c \
stdio_is.c \
driver_helper/nsbypass.c
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
@@ -61,6 +56,16 @@ LOCAL_LDFLAGS := -z global
include $(BUILD_SHARED_LIBRARY)
#endif
$(call import-module,prefab/bytehook)
LOCAL_PATH := $(HERE_PATH)
include $(CLEAR_VARS)
LOCAL_MODULE := istdio
LOCAL_SHARED_LIBRARIES := bytehook
LOCAL_SRC_FILES := \
stdio_is.c
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := pojavexec_awt
LOCAL_SRC_FILES := \
@@ -5,7 +5,6 @@
#include <stdlib.h>
#include <dlfcn.h>
#include "egl_loader.h"
#include "loader_dlopen.h"
EGLBoolean (*eglMakeCurrent_p) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
EGLBoolean (*eglDestroyContext_p) (EGLDisplay dpy, EGLContext ctx);
@@ -25,38 +24,28 @@ EGLint (*eglGetError_p) (void);
EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
EGLBoolean (*eglQuerySurface_p)( EGLDisplay display,
EGLSurface surface,
EGLint attribute,
EGLint * value);
__eglMustCastToProperFunctionPointerType (*eglGetProcAddress_p) (const char *procname);
bool dlsym_EGL() {
void* dl_handle = loader_dlopen(getenv("POJAVEXEC_EGL"),"libEGL.so", RTLD_LOCAL|RTLD_LAZY);
if(dl_handle == NULL) return false;
eglGetProcAddress_p = dlsym(dl_handle, "eglGetProcAddress");
if(eglGetProcAddress_p == NULL) {
printf("%s\n", dlerror());
return false;
}
eglBindAPI_p = (void*) eglGetProcAddress_p("eglBindAPI");
eglChooseConfig_p = (void*) eglGetProcAddress_p("eglChooseConfig");
eglCreateContext_p = (void*) eglGetProcAddress_p("eglCreateContext");
eglCreatePbufferSurface_p = (void*) eglGetProcAddress_p("eglCreatePbufferSurface");
eglCreateWindowSurface_p = (void*) eglGetProcAddress_p("eglCreateWindowSurface");
eglDestroyContext_p = (void*) eglGetProcAddress_p("eglDestroyContext");
eglDestroySurface_p = (void*) eglGetProcAddress_p("eglDestroySurface");
eglGetConfigAttrib_p = (void*) eglGetProcAddress_p("eglGetConfigAttrib");
eglGetCurrentContext_p = (void*) eglGetProcAddress_p("eglGetCurrentContext");
eglGetDisplay_p = (void*) eglGetProcAddress_p("eglGetDisplay");
eglGetError_p = (void*) eglGetProcAddress_p("eglGetError");
eglInitialize_p = (void*) eglGetProcAddress_p("eglInitialize");
eglMakeCurrent_p = (void*) eglGetProcAddress_p("eglMakeCurrent");
eglSwapBuffers_p = (void*) eglGetProcAddress_p("eglSwapBuffers");
eglReleaseThread_p = (void*) eglGetProcAddress_p("eglReleaseThread");
eglSwapInterval_p = (void*) eglGetProcAddress_p("eglSwapInterval");
eglTerminate_p = (void*) eglGetProcAddress_p("eglTerminate");
eglGetCurrentSurface_p = (void*) eglGetProcAddress_p("eglGetCurrentSurface");
eglQuerySurface_p = (void*) eglGetProcAddress_p("eglQuerySurface");
return true;
void dlsym_EGL() {
void* dl_handle = NULL;
if(getenv("POJAVEXEC_EGL")) dl_handle = dlopen(getenv("POJAVEXEC_EGL"), RTLD_LAZY);
if(dl_handle == NULL) dl_handle = dlopen("libEGL.so", RTLD_LAZY);
if(dl_handle == NULL) abort();
eglBindAPI_p = dlsym(dl_handle,"eglBindAPI");
eglChooseConfig_p = dlsym(dl_handle, "eglChooseConfig");
eglCreateContext_p = dlsym(dl_handle, "eglCreateContext");
eglCreatePbufferSurface_p = dlsym(dl_handle, "eglCreatePbufferSurface");
eglCreateWindowSurface_p = dlsym(dl_handle, "eglCreateWindowSurface");
eglDestroyContext_p = dlsym(dl_handle, "eglDestroyContext");
eglDestroySurface_p = dlsym(dl_handle, "eglDestroySurface");
eglGetConfigAttrib_p = dlsym(dl_handle, "eglGetConfigAttrib");
eglGetCurrentContext_p = dlsym(dl_handle, "eglGetCurrentContext");
eglGetDisplay_p = dlsym(dl_handle, "eglGetDisplay");
eglGetError_p = dlsym(dl_handle, "eglGetError");
eglInitialize_p = dlsym(dl_handle, "eglInitialize");
eglMakeCurrent_p = dlsym(dl_handle, "eglMakeCurrent");
eglSwapBuffers_p = dlsym(dl_handle, "eglSwapBuffers");
eglReleaseThread_p = dlsym(dl_handle, "eglReleaseThread");
eglSwapInterval_p = dlsym(dl_handle, "eglSwapInterval");
eglTerminate_p = dlsym(dl_handle, "eglTerminate");
eglGetCurrentSurface_p = dlsym(dl_handle,"eglGetCurrentSurface");
}
@@ -2,7 +2,6 @@
// Created by maks on 21.09.2022.
//
#include <EGL/egl.h>
#include <stdbool.h>
#ifndef POJAVLAUNCHER_EGL_LOADER_H
#define POJAVLAUNCHER_EGL_LOADER_H
@@ -24,12 +23,7 @@ extern EGLint (*eglGetError_p) (void);
extern EGLContext (*eglCreateContext_p) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
extern EGLBoolean (*eglSwapInterval_p) (EGLDisplay dpy, EGLint interval);
extern EGLSurface (*eglGetCurrentSurface_p) (EGLint readdraw);
extern EGLBoolean (*eglQuerySurface_p)( EGLDisplay display,
EGLSurface surface,
EGLint attribute,
EGLint * value);
extern __eglMustCastToProperFunctionPointerType (*eglGetProcAddress_p) (const char *procname);
bool dlsym_EGL();
void dlsym_EGL();
#endif //POJAVLAUNCHER_EGL_LOADER_H
@@ -20,7 +20,7 @@ static __thread gl_render_window_t* currentBundle;
static EGLDisplay g_EglDisplay;
bool gl_init() {
if(!dlsym_EGL()) return false;
dlsym_EGL();
g_EglDisplay = eglGetDisplay_p(EGL_DEFAULT_DISPLAY);
if (g_EglDisplay == EGL_NO_DISPLAY) {
__android_log_print(ANDROID_LOG_ERROR, g_LogTag, "%s",
@@ -39,41 +39,6 @@ gl_render_window_t* gl_get_current() {
return currentBundle;
}
static void gl4esi_get_display_dimensions(int* width, int* height) {
if(currentBundle == NULL) goto zero;
EGLSurface surface = currentBundle->surface;
// Fetch dimensions from the EGL surface - the most reliable way
EGLBoolean result_width = eglQuerySurface_p(g_EglDisplay, surface, EGL_WIDTH, width);
EGLBoolean result_height = eglQuerySurface_p(g_EglDisplay, surface, EGL_HEIGHT, height);
if(!result_width || !result_height) goto zero;
return;
zero:
// No idea what to do, but feeding gl4es incorrect or non-initialized dimensions may be
// a bad idea. Set to zero in case of errors.
*width = 0;
*height = 0;
}
static bool already_initialized = false;
static void gl_init_gl4es_internals() {
if(already_initialized) return;
already_initialized = true;
void* gl4es = dlopen("libgl4es_114.so", RTLD_NOLOAD);
if(gl4es == NULL) return;
void (*set_getmainfbsize)(void (*new_getMainFBSize)(int* width, int* height));
set_getmainfbsize = dlsym(gl4es, "set_getmainfbsize");
if(set_getmainfbsize == NULL) goto warn;
set_getmainfbsize(gl4esi_get_display_dimensions);
goto cleanup;
warn:
printf("gl4esinternals warning: gl4es was found but internals not initialized. expect rendering issues.\n");
cleanup:
// dlclose just decreases a ref counter, so this is fine
dlclose(gl4es);
}
gl_render_window_t* gl_init_context(gl_render_window_t *share) {
gl_render_window_t* bundle = malloc(sizeof(gl_render_window_t));
memset(bundle, 0, sizeof(gl_render_window_t));
@@ -145,11 +110,6 @@ void gl_swap_surface(gl_render_window_t* bundle) {
}
void gl_make_current(gl_render_window_t* bundle) {
// Perform initialization here as the renderer may not be loaded when gl_init or gl_init_context is called.
// Yes, even though it is dlopened on MC startup by Pojav, due to linker namespacing weirdness
// on API 29/MIUI it may not be loaded at the point of the gl_init call in the current namespace.
gl_init_gl4es_internals();
if(bundle == NULL) {
if(eglMakeCurrent_p(g_EglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT)) {
currentBundle = NULL;
@@ -1,24 +0,0 @@
//
// Created by maks on 26.10.2024.
//
#include <string.h>
#include <stdio.h>
#include <dlfcn.h>
#include <linux/limits.h>
void* loader_dlopen(char* primaryName, char* secondaryName, int flags) {
void* dl_handle;
if(primaryName == NULL) goto secondary;
dl_handle = dlopen(primaryName, flags);
if(dl_handle != NULL) return dl_handle;
if(secondaryName == NULL) goto dl_error;
secondary:
dl_handle = dlopen(secondaryName, flags);
if(dl_handle == NULL) goto dl_error;
return dl_handle;
dl_error:
printf("%s", dlerror());
return NULL;
}
@@ -1,10 +0,0 @@
//
// Created by maks on 26.10.2024.
//
#ifndef POJAVLAUNCHER_LOADER_DLOPEN_H
#define POJAVLAUNCHER_LOADER_DLOPEN_H
void* loader_dlopen(char* primaryName, char* secondaryName, int flags);
#endif //POJAVLAUNCHER_LOADER_DLOPEN_H
@@ -16,8 +16,8 @@ static char no_render_buffer[4];
void setNativeWindowSwapInterval(struct ANativeWindow* nativeWindow, int swapInterval);
bool osm_init() {
if(!dlsym_OSMesa()) return false;
return true;
dlsym_OSMesa();
return true; // no more specific initialization required
}
osm_render_window_t* osm_get_current() {
@@ -4,7 +4,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include "loader_dlopen.h"
#include "osmesa_loader.h"
GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
@@ -18,25 +17,26 @@ void (*glFinish_p) (void);
void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (*glClear_p) (GLbitfield mask);
void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);
void* (*OSMesaGetProcAddress_p)(const char* funcName);
bool dlsym_OSMesa() {
void* dl_handle = loader_dlopen("libOSMesa.so.8", "libOSMesa.so", RTLD_LOCAL | RTLD_LAZY);
if(dl_handle == NULL) return false;
OSMesaGetProcAddress_p = dlsym(dl_handle, "OSMesaGetProcAddress");
if(OSMesaGetProcAddress_p == NULL) {
printf("%s\n", dlerror());
return false;
void dlsym_OSMesa() {
char* main_path = NULL;
char* alt_path = NULL;
if(asprintf(&main_path, "%s/libOSMesa.so", getenv("POJAV_NATIVEDIR")) == -1 ||
asprintf(&alt_path, "%s/libOSMesa.so.8", getenv("POJAV_NATIVEDIR")) == -1) {
abort();
}
OSMesaMakeCurrent_p = OSMesaGetProcAddress_p("OSMesaMakeCurrent");
OSMesaGetCurrentContext_p = OSMesaGetProcAddress_p("OSMesaGetCurrentContext");
OSMesaCreateContext_p = OSMesaGetProcAddress_p("OSMesaCreateContext");
OSMesaDestroyContext_p = OSMesaGetProcAddress_p("OSMesaDestroyContext");
OSMesaPixelStore_p = OSMesaGetProcAddress_p("OSMesaPixelStore");
glGetString_p = OSMesaGetProcAddress_p("glGetString");
glClearColor_p = OSMesaGetProcAddress_p("glClearColor");
glClear_p = OSMesaGetProcAddress_p("glClear");
glFinish_p = OSMesaGetProcAddress_p("glFinish");
glReadPixels_p = OSMesaGetProcAddress_p("glReadPixels");
return true;
void* dl_handle = NULL;
dl_handle = dlopen(alt_path, RTLD_GLOBAL);
if(dl_handle == NULL) dl_handle = dlopen(main_path, RTLD_GLOBAL);
if(dl_handle == NULL) abort();
OSMesaMakeCurrent_p = dlsym(dl_handle, "OSMesaMakeCurrent");
OSMesaGetCurrentContext_p = dlsym(dl_handle,"OSMesaGetCurrentContext");
OSMesaCreateContext_p = dlsym(dl_handle, "OSMesaCreateContext");
OSMesaDestroyContext_p = dlsym(dl_handle, "OSMesaDestroyContext");
OSMesaPixelStore_p = dlsym(dl_handle,"OSMesaPixelStore");
glGetString_p = dlsym(dl_handle,"glGetString");
glClearColor_p = dlsym(dl_handle, "glClearColor");
glClear_p = dlsym(dl_handle,"glClear");
glFinish_p = dlsym(dl_handle,"glFinish");
glReadPixels_p = dlsym(dl_handle,"glReadPixels");
}
@@ -6,7 +6,6 @@
#define POJAVLAUNCHER_OSMESA_LOADER_H
#include <GL/osmesa.h>
#include <stdbool.h>
extern GLboolean (*OSMesaMakeCurrent_p) (OSMesaContext ctx, void *buffer, GLenum type,
GLsizei width, GLsizei height);
@@ -19,7 +18,5 @@ extern void (*glFinish_p) (void);
extern void (*glClearColor_p) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
extern void (*glClear_p) (GLbitfield mask);
extern void (*glReadPixels_p) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data);
extern void* (*OSMesaGetProcAddress_p)(const char* funcName);
bool dlsym_OSMesa();
void dlsym_OSMesa();
#endif //POJAVLAUNCHER_OSMESA_LOADER_H
@@ -212,14 +212,11 @@ int pojavInitOpenGL() {
return 0;
}
extern void updateMonitorSize(int width, int height);
EXTERNAL_API int pojavInit() {
ANativeWindow_acquire(pojav_environ->pojavWindow);
pojav_environ->savedWidth = ANativeWindow_getWidth(pojav_environ->pojavWindow);
pojav_environ->savedHeight = ANativeWindow_getHeight(pojav_environ->pojavWindow);
ANativeWindow_setBuffersGeometry(pojav_environ->pojavWindow,pojav_environ->savedWidth,pojav_environ->savedHeight,AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM);
updateMonitorSize(pojav_environ->savedWidth, pojav_environ->savedHeight);
pojavInitOpenGL();
return 1;
}
@@ -24,9 +24,11 @@ typedef void GLFW_invoke_Char_func(void* window, unsigned int codepoint);
typedef void GLFW_invoke_CharMods_func(void* window, unsigned int codepoint, int mods);
typedef void GLFW_invoke_CursorEnter_func(void* window, int entered);
typedef void GLFW_invoke_CursorPos_func(void* window, double xpos, double ypos);
typedef void GLFW_invoke_FramebufferSize_func(void* window, int width, int height);
typedef void GLFW_invoke_Key_func(void* window, int key, int scancode, int action, int mods);
typedef void GLFW_invoke_MouseButton_func(void* window, int button, int action, int mods);
typedef void GLFW_invoke_Scroll_func(void* window, double xoffset, double yoffset);
typedef void GLFW_invoke_WindowSize_func(void* window, int width, int height);
struct pojav_environ_s {
struct ANativeWindow* pojavWindow;
@@ -44,7 +46,6 @@ struct pojav_environ_s {
jmethodID method_onGrabStateChanged;
jmethodID method_glftSetWindowAttrib;
jmethodID method_internalWindowSizeChanged;
jmethodID method_internalChangeMonitorSize;
jclass bridgeClazz;
jclass vmGlfwClass;
jboolean isGrabbing;
@@ -55,8 +56,7 @@ struct pojav_environ_s {
JavaVM* dalvikJavaVMPtr;
JNIEnv* dalvikJNIEnvPtr_ANDROID;
long showingWindow;
bool isInputReady, isCursorEntered, isUseStackQueueCall, shouldUpdateMouse;
bool shouldUpdateMonitorSize, monitorSizeConsumed;
bool isInputReady, isCursorEntered, isUseStackQueueCall, isPumpingEvents;
int savedWidth, savedHeight;
#define ADD_CALLBACK_WWIN(NAME) \
GLFW_invoke_##NAME##_func* GLFW_invoke_##NAME;
@@ -64,9 +64,11 @@ struct pojav_environ_s {
ADD_CALLBACK_WWIN(CharMods);
ADD_CALLBACK_WWIN(CursorEnter);
ADD_CALLBACK_WWIN(CursorPos);
ADD_CALLBACK_WWIN(FramebufferSize);
ADD_CALLBACK_WWIN(Key);
ADD_CALLBACK_WWIN(MouseButton);
ADD_CALLBACK_WWIN(Scroll);
ADD_CALLBACK_WWIN(WindowSize);
#undef ADD_CALLBACK_WWIN
};
@@ -26,9 +26,11 @@
#define EVENT_TYPE_CHAR 1000
#define EVENT_TYPE_CHAR_MODS 1001
#define EVENT_TYPE_CURSOR_ENTER 1002
#define EVENT_TYPE_FRAMEBUFFER_SIZE 1004
#define EVENT_TYPE_KEY 1005
#define EVENT_TYPE_MOUSE_BUTTON 1006
#define EVENT_TYPE_SCROLL 1007
#define EVENT_TYPE_WINDOW_SIZE 1008
jint (*orig_ProcessImpl_forkAndExec)(JNIEnv *env, jobject process, jint mode, jbyteArray helperpath, jbyteArray prog, jbyteArray argBlock, jint argc, jbyteArray envBlock, jint envc, jbyteArray dir, jintArray std_fds, jboolean redirectErrorStream);
@@ -50,8 +52,7 @@ jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) {
(*vm)->GetEnv(vm, (void**) &pojav_environ->runtimeJNIEnvPtr_JRE, JNI_VERSION_1_4);
pojav_environ->vmGlfwClass = (*pojav_environ->runtimeJNIEnvPtr_JRE)->NewGlobalRef(pojav_environ->runtimeJNIEnvPtr_JRE, (*pojav_environ->runtimeJNIEnvPtr_JRE)->FindClass(pojav_environ->runtimeJNIEnvPtr_JRE, "org/lwjgl/glfw/GLFW"));
pojav_environ->method_glftSetWindowAttrib = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "glfwSetWindowAttrib", "(JII)V");
pojav_environ->method_internalWindowSizeChanged = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "internalWindowSizeChanged", "(J)V");
pojav_environ->method_internalChangeMonitorSize = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "internalChangeMonitorSize", "(II)V");
pojav_environ->method_internalWindowSizeChanged = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticMethodID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "internalWindowSizeChanged", "(JII)V");
jfieldID field_keyDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticFieldID(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, "keyDownBuffer", "Ljava/nio/ByteBuffer;");
jobject keyDownBufferJ = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetStaticObjectField(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, field_keyDownBuffer);
pojav_environ->keyDownBuffer = (*pojav_environ->runtimeJNIEnvPtr_JRE)->GetDirectBufferAddress(pojav_environ->runtimeJNIEnvPtr_JRE, keyDownBufferJ);
@@ -85,27 +86,30 @@ ADD_CALLBACK_WWIN(Char)
ADD_CALLBACK_WWIN(CharMods)
ADD_CALLBACK_WWIN(CursorEnter)
ADD_CALLBACK_WWIN(CursorPos)
ADD_CALLBACK_WWIN(FramebufferSize)
ADD_CALLBACK_WWIN(Key)
ADD_CALLBACK_WWIN(MouseButton)
ADD_CALLBACK_WWIN(Scroll)
ADD_CALLBACK_WWIN(WindowSize)
#undef ADD_CALLBACK_WWIN
void updateMonitorSize(int width, int height) {
(*pojav_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, pojav_environ->method_internalChangeMonitorSize, width, height);
}
void updateWindowSize(void* window) {
(*pojav_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, pojav_environ->method_internalWindowSizeChanged, (jlong)window);
void handleFramebufferSizeJava(long window, int w, int h) {
(*pojav_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(pojav_environ->runtimeJNIEnvPtr_JRE, pojav_environ->vmGlfwClass, pojav_environ->method_internalWindowSizeChanged, (long)window, w, h);
}
void pojavPumpEvents(void* window) {
if(pojav_environ->shouldUpdateMouse) {
if(pojav_environ->isPumpingEvents) return;
// prevent further calls until we exit the loop
// by spec, they will be called on the same thread so no synchronization here
pojav_environ->isPumpingEvents = true;
if((pojav_environ->cLastX != pojav_environ->cursorX || pojav_environ->cLastY != pojav_environ->cursorY) && pojav_environ->GLFW_invoke_CursorPos) {
pojav_environ->cLastX = pojav_environ->cursorX;
pojav_environ->cLastY = pojav_environ->cursorY;
pojav_environ->GLFW_invoke_CursorPos(window, floor(pojav_environ->cursorX),
floor(pojav_environ->cursorY));
}
if(pojav_environ->shouldUpdateMonitorSize) {
updateWindowSize(window);
}
size_t index = pojav_environ->outEventIndex;
size_t targetIndex = pojav_environ->outTargetIndex;
@@ -128,6 +132,14 @@ void pojavPumpEvents(void* window) {
case EVENT_TYPE_SCROLL:
if(pojav_environ->GLFW_invoke_Scroll) pojav_environ->GLFW_invoke_Scroll(window, event.i1, event.i2);
break;
case EVENT_TYPE_FRAMEBUFFER_SIZE:
handleFramebufferSizeJava(pojav_environ->showingWindow, event.i1, event.i2);
if(pojav_environ->GLFW_invoke_FramebufferSize) pojav_environ->GLFW_invoke_FramebufferSize(window, event.i1, event.i2);
break;
case EVENT_TYPE_WINDOW_SIZE:
handleFramebufferSizeJava(pojav_environ->showingWindow, event.i1, event.i2);
if(pojav_environ->GLFW_invoke_WindowSize) pojav_environ->GLFW_invoke_WindowSize(window, event.i1, event.i2);
break;
}
index++;
@@ -136,10 +148,11 @@ void pojavPumpEvents(void* window) {
}
// The out target index is updated by the rewinder
pojav_environ->isPumpingEvents = false;
}
/** Prepare the library for sending out callbacks to all windows */
void pojavStartPumping() {
/** Setup the amount of event that will get pumped into each window */
void pojavComputeEventTarget() {
size_t counter = atomic_load_explicit(&pojav_environ->eventCounter, memory_order_acquire);
size_t index = pojav_environ->outEventIndex;
@@ -150,37 +163,14 @@ void pojavStartPumping() {
// Only accessed by one unique thread, no need for atomic store
pojav_environ->inEventCount = counter;
pojav_environ->outTargetIndex = targetIndex;
//PumpEvents is called for every window, so this logic should be there in order to correctly distribute events to all windows.
if((pojav_environ->cLastX != pojav_environ->cursorX || pojav_environ->cLastY != pojav_environ->cursorY) && pojav_environ->GLFW_invoke_CursorPos) {
pojav_environ->cLastX = pojav_environ->cursorX;
pojav_environ->cLastY = pojav_environ->cursorY;
pojav_environ->shouldUpdateMouse = true;
}
if(pojav_environ->shouldUpdateMonitorSize) {
// Perform a monitor size update here to avoid doing it on every single window
updateMonitorSize(pojav_environ->savedWidth, pojav_environ->savedHeight);
// Mark the monitor size as consumed (since GLFW was made aware of it)
pojav_environ->monitorSizeConsumed = true;
}
}
/** Prepare the library for the next round of new events */
void pojavStopPumping() {
/** Apply index offsets after events have been pumped */
void pojavRewindEvents() {
pojav_environ->outEventIndex = pojav_environ->outTargetIndex;
// New events may have arrived while pumping, so remove only the difference before the start and end of execution
atomic_fetch_sub_explicit(&pojav_environ->eventCounter, pojav_environ->inEventCount, memory_order_acquire);
// Make sure the next frame won't send mouse or monitor updates if it's unnecessary
pojav_environ->shouldUpdateMouse = false;
// Only reset the update flag if the monitor size was consumed by pojavStartPumping. This
// will delay the update to next frame if it had occured between pojavStartPumping and pojavStopPumping,
// but it's better than not having it apply at all
if(pojav_environ->shouldUpdateMonitorSize && pojav_environ->monitorSizeConsumed) {
pojav_environ->shouldUpdateMonitorSize = false;
pojav_environ->monitorSizeConsumed = false;
}
}
JNIEXPORT void JNICALL
@@ -511,15 +501,23 @@ void noncritical_send_mouse_button(__attribute__((unused)) JNIEnv* env, __attrib
void critical_send_screen_size(jint width, jint height) {
pojav_environ->savedWidth = width;
pojav_environ->savedHeight = height;
// Even if there was call to pojavStartPumping that consumed the size, this call
// might happen right after it (or right before pojavStopPumping)
// So unmark the size as "consumed"
pojav_environ->monitorSizeConsumed = false;
pojav_environ->shouldUpdateMonitorSize = true;
// Don't use the direct updates for screen dimensions.
// This is done to ensure that we have predictable conditions to correctly call
// updateMonitorSize() and updateWindowSize() while on the render thread with an attached
// JNIEnv.
if (pojav_environ->isInputReady) {
if (pojav_environ->GLFW_invoke_FramebufferSize) {
if (pojav_environ->isUseStackQueueCall) {
sendData(EVENT_TYPE_FRAMEBUFFER_SIZE, width, height, 0, 0);
} else {
pojav_environ->GLFW_invoke_FramebufferSize((void*) pojav_environ->showingWindow, width, height);
}
}
if (pojav_environ->GLFW_invoke_WindowSize) {
if (pojav_environ->isUseStackQueueCall) {
sendData(EVENT_TYPE_WINDOW_SIZE, width, height, 0, 0);
} else {
pojav_environ->GLFW_invoke_WindowSize((void*) pojav_environ->showingWindow, width, height);
}
}
}
}
void noncritical_send_screen_size(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jint width, jint height) {
@@ -542,42 +540,21 @@ void noncritical_send_scroll(__attribute__((unused)) JNIEnv* env, __attribute__(
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_GLFW_nglfwSetShowingWindow(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jlong window) {
pojav_environ->showingWindow = (jlong) window;
pojav_environ->showingWindow = (long) window;
}
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetWindowAttrib(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jint attrib, jint value) {
// Check for stack queue no longer necessary here as the JVM crash's origin is resolved
if (!pojav_environ->showingWindow) {
if (!pojav_environ->showingWindow || !pojav_environ->isUseStackQueueCall) {
// If the window is not shown, there is nothing to do yet.
// For Minecraft < 1.13, calling to JNI functions here crashes the JVM for some reason, therefore it is skipped for now.
return;
}
// We cannot use pojav_environ->runtimeJNIEnvPtr_JRE here because that environment is attached
// on the thread that loaded pojavexec (which is the thread that first references the GLFW class)
// But this method is only called from the Android UI thread
// Technically the better solution would be to have a permanently attached env pointer stored
// in environ for the Android UI thread but this is the only place that uses it
// (very rarely, only in lifecycle callbacks) so i dont care
JavaVM* jvm = pojav_environ->runtimeJavaVMPtr;
JNIEnv *jvm_env = NULL;
jint env_result = (*jvm)->GetEnv(jvm, (void**)&jvm_env, JNI_VERSION_1_4);
if(env_result == JNI_EDETACHED) {
env_result = (*jvm)->AttachCurrentThread(jvm, &jvm_env, NULL);
}
if(env_result != JNI_OK) {
printf("input_bridge nativeSetWindowAttrib() JNI call failed: %i\n", env_result);
return;
}
(*jvm_env)->CallStaticVoidMethod(
jvm_env, pojav_environ->vmGlfwClass,
pojav_environ->method_glftSetWindowAttrib,
(jlong) pojav_environ->showingWindow, attrib, value
(*pojav_environ->runtimeJNIEnvPtr_JRE)->CallStaticVoidMethod(
pojav_environ->runtimeJNIEnvPtr_JRE,
pojav_environ->vmGlfwClass, pojav_environ->method_glftSetWindowAttrib,
(jlong) pojav_environ->showingWindow, attrib, value
);
// Attaching every time is annoying, so stick the attachment to the Android GUI thread around
}
const static JNINativeMethod critical_fcns[] = {
{"nativeSetUseInputStackQueue", "(Z)V", critical_set_stackqueue},
@@ -620,7 +597,6 @@ static bool tryCriticalNative(JNIEnv *env) {
};
jclass criticalNativeTest = (*env)->FindClass(env, "net/kdt/pojavlaunch/CriticalNativeTest");
if(criticalNativeTest == NULL) {
LOGD("No CriticalNativeTest class found !");
(*env)->ExceptionClear(env);
return false;
}
+46 -71
View File
@@ -51,6 +51,25 @@ static const char** const_appclasspath = NULL;
static const jboolean const_javaw = JNI_FALSE;
static const jboolean const_cpwildcard = JNI_TRUE;
static const jint const_ergo_class = 0; // DEFAULT_POLICY
static struct sigaction old_sa[NSIG];
void (*__old_sa)(int signal, siginfo_t *info, void *reserved);
int (*JVM_handle_linux_signal)(int signo, siginfo_t* siginfo, void* ucontext, int abort_if_unrecognized);
void android_sigaction(int signal, siginfo_t *info, void *reserved) {
printf("process killed with signal %d code %p addr %p\n", signal,info->si_code,info->si_addr);
if (JVM_handle_linux_signal == NULL) { // should not happen, but still
__old_sa = old_sa[signal].sa_sigaction;
__old_sa(signal,info,reserved);
exit(1);
} else {
// Based on https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u/blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/os/linux/vm/os_linux.cpp#L4688-4693
int orig_errno = errno; // Preserve errno value over signal handler.
JVM_handle_linux_signal(signal, info, reserved, true);
errno = orig_errno;
}
}
typedef jint JNI_CreateJavaVM_func(JavaVM **pvm, void **penv, void *args);
typedef jint JLI_Launch_func(int argc, char ** argv, /* main argc, argc */
int jargc, const char** jargv, /* java args */
@@ -65,80 +84,9 @@ typedef jint JLI_Launch_func(int argc, char ** argv, /* main argc, argc */
jint ergo /* ergonomics class policy */
);
struct {
sigset_t tracked_sigset;
int pipe[2];
} abort_waiter_data;
_Noreturn extern void nominal_exit(int code, bool is_signal);
_Noreturn static void* abort_waiter_thread(void* extraArg) {
// Don't allow this thread to receive signals this thread is tracking.
// We should only receive them externally.
pthread_sigmask(SIG_BLOCK, &abort_waiter_data.tracked_sigset, NULL);
int signal;
// Block for reading the signal ID until it arrives
read(abort_waiter_data.pipe[0], &signal, sizeof(int));
// Die
nominal_exit(signal, true);
}
_Noreturn static void abort_waiter_handler(int signal) {
// Write the final signal into the pipe and block forever.
write(abort_waiter_data.pipe[1], &signal, sizeof(int));
while(1) {}
}
static void abort_waiter_setup() {
// Only abort on SIGABRT as the JVM either emits SIGABRT or SIGKILL (which we can't catch)
// when a fatal crash occurs. Still, keep expandability if we would want to add more
// user-friendly fatal signals in the future.
const static int tracked_signals[] = {SIGABRT};
const static int ntracked = (sizeof(tracked_signals) / sizeof(tracked_signals[0]));
struct sigaction sigactions[ntracked];
sigemptyset(&abort_waiter_data.tracked_sigset);
for(size_t i = 0; i < ntracked; i++) {
sigaddset(&abort_waiter_data.tracked_sigset, tracked_signals[i]);
sigactions[i].sa_handler = abort_waiter_handler;
}
if(pipe(abort_waiter_data.pipe) != 0) {
printf("Failed to set up aborter pipe: %s\n", strerror(errno));
return;
}
pthread_t waiter_thread; int result;
if((result = pthread_create(&waiter_thread, NULL, abort_waiter_thread, NULL)) != 0) {
printf("Failed to start up waiter thread: %s", strerror(result));
for(int i = 0; i < 2; i++) close(abort_waiter_data.pipe[i]);
return;
}
// Only set the sigactions *after* we have already set up the pipe and the thread.
for(size_t i = 0; i < ntracked; i++) {
if(sigaction(tracked_signals[i], &sigactions[i], NULL) != 0) {
// Not returning here because we may have set some handlers successfully.
// Some handling is better than no handling.
printf("Failed to set signal hander for signal %i: %s", i, strerror(errno));
}
}
}
static jint launchJVM(int margc, char** margv) {
void* libjli = dlopen("libjli.so", RTLD_LAZY | RTLD_GLOBAL);
// Unset all signal handlers to create a good slate for JVM signal detection.
struct sigaction clean_sa;
memset(&clean_sa, 0, sizeof (struct sigaction));
for(int sigid = SIGHUP; sigid < NSIG; sigid++) {
// For some reason Android specifically checks if you set SIGSEGV to SIG_DFL.
// There's probably a good reason for that but the signal handler here is
// temporary and will be replaced by the Java VM's signal/crash handler.
// Work around the warning by using SIG_IGN for SIGSEGV
if(sigid == SIGSEGV) clean_sa.sa_handler = SIG_IGN;
else clean_sa.sa_handler = SIG_DFL;
sigaction(sigid, &clean_sa, NULL);
}
// Set up the thread that will abort the launcher with an user-facing dialog on a signal.
abort_waiter_setup();
// Boardwalk: silence
// LOGD("JLI lib = %x", (int)libjli);
if (NULL == libjli) {
@@ -182,8 +130,35 @@ static jint launchJVM(int margc, char** margv) {
* Signature: ([Ljava/lang/String;)I
*/
JNIEXPORT jint JNICALL Java_com_oracle_dalvik_VMLauncher_launchJVM(JNIEnv *env, jclass clazz, jobjectArray argsArray) {
#ifdef TRY_SIG2JVM
void* libjvm = dlopen("libjvm.so", RTLD_LAZY | RTLD_GLOBAL);
if (NULL == libjvm) {
LOGE("JVM lib = NULL: %s", dlerror());
return -1;
}
JVM_handle_linux_signal = dlsym(libjvm, "JVM_handle_linux_signal");
#endif
jint res = 0;
// int i;
//Prepare the signal trapper
struct sigaction catcher;
memset(&catcher,0,sizeof(sigaction));
catcher.sa_sigaction = android_sigaction;
catcher.sa_flags = SA_SIGINFO|SA_RESTART;
// SA_RESETHAND;
#define CATCHSIG(X) sigaction(X, &catcher, &old_sa[X])
CATCHSIG(SIGILL);
//CATCHSIG(SIGABRT);
CATCHSIG(SIGBUS);
CATCHSIG(SIGFPE);
#ifdef TRY_SIG2JVM
CATCHSIG(SIGSEGV);
#endif
CATCHSIG(SIGSTKFLT);
CATCHSIG(SIGPIPE);
CATCHSIG(SIGXFSZ);
//Signal trapper ready
// Save dalvik JNIEnv pointer for JVM launch thread
pojav_environ->dalvikJNIEnvPtr_ANDROID = env;
+17 -13
View File
@@ -9,7 +9,6 @@
#include <errno.h>
#include <stdlib.h>
#include <bytehook.h>
#include <environ/environ.h>
//
// Created by maks on 17.02.21.
@@ -20,6 +19,7 @@ static volatile jclass exitTrap_exitClass;
static volatile jmethodID exitTrap_staticMethod;
static JavaVM *exitTrap_jvm;
static JavaVM *stdiois_jvm;
static int pfd[2];
static pthread_t logger;
static jmethodID logger_onEventLogged;
@@ -37,11 +37,19 @@ static bool recordBuffer(char* buf, ssize_t len) {
return true;
}
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, __attribute((unused)) void* reserved) {
stdiois_jvm = vm;
JNIEnv *env;
(*vm)->GetEnv(vm, (void**)&env, JNI_VERSION_1_4);
jclass eventLogListener = (*env)->FindClass(env, "net/kdt/pojavlaunch/Logger$eventLogListener");
logger_onEventLogged = (*env)->GetMethodID(env, eventLogListener, "onEventLogged", "(Ljava/lang/String;)V");
return JNI_VERSION_1_4;
}
static void *logger_thread() {
JNIEnv *env;
jstring writeString;
JavaVM* dvm = pojav_environ->dalvikJavaVMPtr;
(*dvm)->AttachCurrentThread(dvm, &env, NULL);
(*stdiois_jvm)->AttachCurrentThread(stdiois_jvm, &env, NULL);
ssize_t rsize;
char buf[2050];
while((rsize = read(pfd[0], buf, sizeof(buf)-1)) > 0) {
@@ -56,7 +64,7 @@ static void *logger_thread() {
(*env)->DeleteLocalRef(env, writeString);
}
}
(*dvm)->DetachCurrentThread(dvm);
(*stdiois_jvm)->DetachCurrentThread(stdiois_jvm);
return NULL;
}
JNIEXPORT void JNICALL
@@ -66,10 +74,6 @@ Java_net_kdt_pojavlaunch_Logger_begin(JNIEnv *env, __attribute((unused)) jclass
latestlog_fd = -1;
close(localfd);
}
if(logger_onEventLogged == NULL) {
jclass eventLogListener = (*env)->FindClass(env, "net/kdt/pojavlaunch/Logger$eventLogListener");
logger_onEventLogged = (*env)->GetMethodID(env, eventLogListener, "onEventLogged", "(Ljava/lang/String;)V");
}
jclass ioeClass = (*env)->FindClass(env, "java/io/IOException");
@@ -105,7 +109,7 @@ Java_net_kdt_pojavlaunch_Logger_begin(JNIEnv *env, __attribute((unused)) jclass
typedef void (*exit_func)(int);
_Noreturn void nominal_exit(int code, bool is_signal) {
_Noreturn static void nominal_exit(int code) {
JNIEnv *env;
jint errorCode = (*exitTrap_jvm)->GetEnv(exitTrap_jvm, (void**)&env, JNI_VERSION_1_6);
if(errorCode == JNI_EDETACHED) {
@@ -120,7 +124,7 @@ _Noreturn void nominal_exit(int code, bool is_signal) {
if(code != 0) {
// Exit code 0 is pretty established as "eh it's fine"
// so only open the GUI if the code is != 0
(*env)->CallStaticVoidMethod(env, exitTrap_exitClass, exitTrap_staticMethod, exitTrap_ctx, code, is_signal);
(*env)->CallStaticVoidMethod(env, exitTrap_exitClass, exitTrap_staticMethod, exitTrap_ctx, code);
}
// Delete the reference, not gonna need 'em later anyway
(*env)->DeleteGlobalRef(env, exitTrap_ctx);
@@ -151,7 +155,7 @@ static void custom_exit(int code) {
}
exit_tripped = true;
// Perform a nominal exit, as we expect.
nominal_exit(code, false);
nominal_exit(code);
BYTEHOOK_POP_STACK();
}
@@ -161,14 +165,14 @@ static void custom_atexit() {
return;
}
exit_tripped = true;
nominal_exit(0, false);
nominal_exit(0);
}
JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupExitTrap(JNIEnv *env, __attribute((unused)) jclass clazz, jobject context) {
exitTrap_ctx = (*env)->NewGlobalRef(env,context);
(*env)->GetJavaVM(env,&exitTrap_jvm);
exitTrap_exitClass = (*env)->NewGlobalRef(env,(*env)->FindClass(env,"net/kdt/pojavlaunch/ExitActivity"));
exitTrap_staticMethod = (*env)->GetStaticMethodID(env,exitTrap_exitClass,"showExitMessage","(Landroid/content/Context;IZ)V");
exitTrap_staticMethod = (*env)->GetStaticMethodID(env,exitTrap_exitClass,"showExitMessage","(Landroid/content/Context;I)V");
if(bytehook_init(BYTEHOOK_MODE_AUTOMATIC, false) == BYTEHOOK_STATUS_CODE_OK) {
bytehook_hook_all(NULL,
@@ -14,7 +14,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@id/_background_display_view"
app:layout_constraintBottom_toTopOf="@id/mc_version_spinner"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
@@ -30,8 +30,11 @@
app:layout_constraintGuide_percent="0.5"/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/news_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/ic_menu_news"
android:text="@string/mcl_tab_wiki"
app:layout_constraintTop_toTopOf="parent"
@@ -39,7 +42,9 @@
app:layout_constraintEnd_toStartOf="@id/social_divider"/>
<View
android:id="@+id/social_divider"
style="@style/LauncherFragment_Divider"
android:layout_width="@dimen/padding_tiny"
android:layout_height="0dp"
android:background="@color/divider"
android:layout_marginVertical="@dimen/padding_heavy"
app:layout_constraintTop_toTopOf="@id/news_button"
app:layout_constraintStart_toStartOf="@id/center_guideline"
@@ -47,8 +52,11 @@
app:layout_constraintBottom_toBottomOf="@id/news_button"/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/discord_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/ic_discord"
android:text="@string/mcl_button_discord"
app:layout_constraintTop_toTopOf="parent"
@@ -57,37 +65,36 @@
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/custom_control_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/ic_menu_custom_controls"
android:text="@string/mcl_option_customcontrol"
app:layout_constraintTop_toBottomOf="@id/news_button"/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/install_jar_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/ic_menu_install_jar"
android:text="@string/main_install_jar_file"
app:layout_constraintTop_toBottomOf="@id/custom_control_button"
tools:layout_editor_absoluteX="0dp" />
app:layout_constraintTop_toBottomOf="@id/custom_control_button"/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/share_logs_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="@string/main_share_logs"
app:layout_constraintTop_toBottomOf="@id/install_jar_button" />
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/open_files_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:drawableStart="@drawable/ic_folder"
android:text="@string/mcl_button_open_directory"
app:layout_constraintTop_toBottomOf="@id/share_logs_button" />
app:layout_constraintTop_toBottomOf="@id/install_jar_button"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
@@ -20,8 +20,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<View style="@style/DimensionTracker"/>
<net.kdt.pojavlaunch.MinecraftGLSurface
android:id="@+id/main_game_render_view"
android:layout_width="fill_parent"
@@ -51,13 +49,11 @@
<net.kdt.pojavlaunch.customcontrols.handleview.DrawerPullButton
android:id="@+id/drawer_button"
android:layout_width="40dp"
android:layout_height="20dp"
android:padding="8dp"
android:layout_width="24dp"
android:layout_height="12dp"
android:elevation="10dp"
android:layout_gravity="center_horizontal"/>
<net.kdt.pojavlaunch.customcontrols.mouse.HotbarView
android:id="@+id/hotbar_view"
android:layout_width="0px"
android:layout_height="0px"/>
@@ -78,6 +74,7 @@
android:layout_gravity="right"
android:background="?attr/colorBackgroundFloating"
android:fitsSystemWindows="false"
app:menu="@menu/menu_runopt"
android:id="@+id/main_navigation_view"/>
</androidx.drawerlayout.widget.DrawerLayout>
@@ -15,9 +15,8 @@
<net.kdt.pojavlaunch.customcontrols.handleview.DrawerPullButton
android:id="@+id/drawer_button"
android:layout_width="40dp"
android:layout_height="20dp"
android:padding="6dp"
android:layout_width="32dp"
android:layout_height="16dp"
android:elevation="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
@@ -1,500 +1,507 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<com.kdt.DefocusableScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/edit_layout"
android:layout_width="match_parent"
android:layout_width="@dimen/_280sdp"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/padding_moderate"
android:paddingVertical="@dimen/padding_moderate"
app:layout_optimizationLevel="standard|dimensions|chains">
android:layout_marginVertical="@dimen/padding_heavy"
android:background="@drawable/background_control_editor"
android:layout_gravity="center_vertical"
>
<!-- EDIT NAME SECTION -->
<TextView
android:id="@+id/editName_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/global_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editName_editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Button Name"
android:imeOptions="flagNoExtractUi"
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editName_textView" />
<!-- SIZE SECTION -->
<TextView
android:id="@+id/editSize_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editName_editText"
tools:visibility="visible" />
<EditText
android:id="@+id/editSize_editTextX"
android:layout_width="@dimen/_134sdp"
android:layout_height="wrap_content"
android:gravity="center"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editSize_textView" />
<EditText
android:id="@+id/editSize_editTextY"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
app:layout_constraintBottom_toBottomOf="@+id/editSize_editTextX"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/editSize_editTextX"
app:layout_constraintTop_toTopOf="@+id/editSize_editTextX" />
<TextView
android:id="@+id/editSize_x_textView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:text="x"
app:layout_constraintBottom_toBottomOf="@+id/editSize_editTextX"
app:layout_constraintEnd_toStartOf="@id/editSize_editTextY"
app:layout_constraintStart_toEndOf="@id/editSize_editTextX"
app:layout_constraintTop_toTopOf="@+id/editSize_editTextX" />
<!-- MAPPING SECTION -->
<TextView
android:id="@+id/editMapping_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="5dp"
android:text="@string/customctrl_mapping"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editSize_editTextX" />
<!--
Spinners are hidden to handle to workaround the horizontal offset.
The horizontal offset was needed to display the spinner list at the same place.
Sadly it is broken since Android Jelly Bean and never scheduled to be fixed
-->
<Spinner
android:id="@+id/editMapping_spinner_1"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="30dp"
android:gravity="center"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editMapping_textView" />
<Spinner
android:id="@+id/editMapping_spinner_2"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownHorizontalOffset="30dp"
android:dropDownVerticalOffset="30dp"
android:gravity="center"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintTop_toBottomOf="@+id/editMapping_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="@+id/editMapping_spinner_3"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="30dp"
android:gravity="center"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintTop_toTopOf="@+id/mapping_3_textview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="@+id/editMapping_spinner_4"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="30dp"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintTop_toTopOf="@+id/mapping_3_textview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<!-- Clickable textview linked to the spinners
Spinners are hidden at the same place because the dropdown offset doesn't work
Do those textview acts as the spinner idle state
-->
<TextView
android:id="@+id/mapping_1_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toStartOf="@id/mapping_2_textview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editMapping_textView"
tools:text="HELLO" />
<TextView
android:id="@+id/editMapping_plus_1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:text="+"
app:layout_constraintBottom_toBottomOf="@+id/mapping_1_textview"
app:layout_constraintEnd_toEndOf="@+id/mapping_1_textview"
app:layout_constraintStart_toEndOf="@id/mapping_1_textview"
app:layout_constraintTop_toTopOf="@+id/mapping_1_textview" />
<TextView
android:id="@+id/mapping_2_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mapping_1_textview"
app:layout_constraintTop_toTopOf="@+id/mapping_1_textview"
tools:text="HELLO" />
<TextView
android:id="@+id/mapping_3_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toStartOf="@id/mapping_4_textview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mapping_1_textview"
tools:text="HELLO" />
<TextView
android:id="@+id/editMapping_plus_3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:text="+"
app:layout_constraintBottom_toBottomOf="@+id/mapping_3_textview"
app:layout_constraintEnd_toEndOf="@+id/mapping_3_textview"
app:layout_constraintStart_toEndOf="@id/mapping_3_textview"
app:layout_constraintTop_toBottomOf="@+id/mapping_1_textview" />
<TextView
android:id="@+id/mapping_4_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mapping_3_textview"
app:layout_constraintTop_toTopOf="@id/mapping_3_textview"
tools:text="HELLO" />
<!-- ORIENTATION SECTION -->
<TextView
android:id="@+id/editOrientation_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_2sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_orientation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mapping_3_textview" />
<Spinner
android:id="@+id/editOrientation_spinner"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editOrientation_textView" />
<!-- TOGGLE SECTION -->
<Switch
android:id="@+id/checkboxToggle"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_toggle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editOrientation_spinner"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- MOUSE PASS THROUGH SECTION -->
<Switch
android:id="@+id/checkboxPassThrough"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_passthru"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxToggle"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- SWIPEABLE BUTTON SECTION -->
<Switch
android:id="@+id/checkboxSwipeable"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_swipeable"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxPassThrough"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- FORWARD LOCK SECTION -->
<Switch
android:id="@+id/checkboxForwardLock"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_forward_lock"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxSwipeable"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<Switch
android:id="@+id/checkboxAbsoluteFingerTracking"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_absolute_tracking"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxForwardLock"
tools:ignore="UseSwitchCompatOrMaterialXml"/>
<!-- BACKGROUND COLOR SECTION -->
<fr.spse.extended_view.ExtendedTextView
android:id="@+id/editBackgroundColor_textView"
android:layout_width="0dp"
android:layout_height="@dimen/_35sdp"
android:background="?attr/selectableItemBackground"
android:drawableEnd="@drawable/spinner_arrow_right"
android:gravity="center_vertical"
android:paddingEnd="5dp"
android:text="@string/customctrl_background_color"
app:drawableEndIntegerScaling="true"
app:drawableEndSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxAbsoluteFingerTracking" />
<!-- STROKE WIDTH -->
<TextView
android:id="@+id/editStrokeWidth_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_stroke_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editStrokeColor_textView" />
<SeekBar
android:id="@+id/editStrokeWidth_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.538"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editStrokeWidth_textView" />
<TextView
android:id="@+id/editStrokeWidth_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editStrokeWidth_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editStrokeWidth_textView" />
<!-- STROKE COLOR VERSION -->
<fr.spse.extended_view.ExtendedTextView
android:id="@+id/editStrokeColor_textView"
android:layout_width="0dp"
android:layout_height="@dimen/_35sdp"
android:background="?attr/selectableItemBackground"
android:drawableEnd="@drawable/spinner_arrow_right"
android:gravity="center_vertical"
android:paddingEnd="5dp"
android:text="@string/customctrl_stroke_color"
app:drawableEndIntegerScaling="true"
app:drawableEndSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editBackgroundColor_textView" />
<!-- CORNER RADIUS SECTION -->
<TextView
android:id="@+id/editCornerRadius_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_corner_radius"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editStrokeWidth_seekbar" />
<SeekBar
android:id="@+id/editCornerRadius_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editCornerRadius_textView" />
<TextView
android:id="@+id/editCornerRadius_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editCornerRadius_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editCornerRadius_textView" />
<!-- BUTTON OPACITY SECTION -->
<TextView
android:id="@+id/editButtonOpacity_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_button_opacity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editCornerRadius_seekbar" />
<SeekBar
android:id="@+id/editButtonOpacity_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editButtonOpacity_textView" />
<TextView
android:id="@+id/editButtonOpacity_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editButtonOpacity_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editButtonOpacity_textView" />
<!-- Button visibility -->
<TextView
android:id="@+id/visibility_textview"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/edit_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_visibility_title"
app:layout_constraintTop_toBottomOf="@+id/editButtonOpacity_seekbar"
tools:layout_editor_absoluteX="6dp" />
<CheckBox
android:id="@+id/visibility_game_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_visibility_ingame"
app:layout_constraintTop_toBottomOf="@+id/visibility_textview" />
<CheckBox
android:id="@+id/visibility_menu_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_visibility_in_menus"
app:layout_constraintTop_toBottomOf="@+id/visibility_game_checkbox" />
android:paddingHorizontal="@dimen/padding_moderate"
android:paddingVertical="@dimen/padding_moderate"
app:layout_optimizationLevel="standard|dimensions|chains">
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- EDIT NAME SECTION -->
<TextView
android:id="@+id/editName_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/global_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editName_editText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="Button Name"
android:imeOptions="flagNoExtractUi"
android:maxLines="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editName_textView" />
<!-- SIZE SECTION -->
<TextView
android:id="@+id/editSize_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_size"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editName_editText"
tools:visibility="visible" />
<EditText
android:id="@+id/editSize_editTextX"
android:layout_width="@dimen/_134sdp"
android:layout_height="wrap_content"
android:gravity="center"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editSize_textView" />
<EditText
android:id="@+id/editSize_editTextY"
android:layout_width="0dp"
android:layout_height="0dp"
android:gravity="center"
android:imeOptions="flagNoExtractUi"
android:inputType="numberDecimal"
app:layout_constraintBottom_toBottomOf="@+id/editSize_editTextX"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/editSize_editTextX"
app:layout_constraintTop_toTopOf="@+id/editSize_editTextX" />
<TextView
android:id="@+id/editSize_x_textView"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:text="x"
app:layout_constraintBottom_toBottomOf="@+id/editSize_editTextX"
app:layout_constraintEnd_toStartOf="@id/editSize_editTextY"
app:layout_constraintStart_toEndOf="@id/editSize_editTextX"
app:layout_constraintTop_toTopOf="@+id/editSize_editTextX" />
<!-- MAPPING SECTION -->
<TextView
android:id="@+id/editMapping_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingEnd="5dp"
android:text="@string/customctrl_mapping"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editSize_editTextX" />
<!--
Spinners are hidden to handle to workaround the horizontal offset.
The horizontal offset was needed to display the spinner list at the same place.
Sadly it is broken since Android Jelly Bean and never scheduled to be fixed
-->
<Spinner
android:id="@+id/editMapping_spinner_1"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="30dp"
android:gravity="center"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editMapping_textView" />
<Spinner
android:id="@+id/editMapping_spinner_2"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownHorizontalOffset="30dp"
android:dropDownVerticalOffset="30dp"
android:gravity="center"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintTop_toBottomOf="@+id/editMapping_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="@+id/editMapping_spinner_3"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="30dp"
android:gravity="center"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintTop_toTopOf="@+id/mapping_3_textview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Spinner
android:id="@+id/editMapping_spinner_4"
android:layout_width="0dp"
android:layout_height="30dp"
android:dropDownWidth="match_parent"
android:dropDownVerticalOffset="30dp"
android:visibility="invisible"
android:background="@android:color/transparent"
app:layout_constraintTop_toTopOf="@+id/mapping_3_textview"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<!-- Clickable textview linked to the spinners
Spinners are hidden at the same place because the dropdown offset doesn't work
Do those textview acts as the spinner idle state
-->
<TextView
android:id="@+id/mapping_1_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toStartOf="@id/mapping_2_textview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editMapping_textView"
tools:text="HELLO" />
<TextView
android:id="@+id/editMapping_plus_1"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:text="+"
app:layout_constraintBottom_toBottomOf="@+id/mapping_1_textview"
app:layout_constraintEnd_toEndOf="@+id/mapping_1_textview"
app:layout_constraintStart_toEndOf="@id/mapping_1_textview"
app:layout_constraintTop_toTopOf="@+id/mapping_1_textview" />
<TextView
android:id="@+id/mapping_2_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mapping_1_textview"
app:layout_constraintTop_toTopOf="@+id/mapping_1_textview"
tools:text="HELLO" />
<TextView
android:id="@+id/mapping_3_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toStartOf="@id/mapping_4_textview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/mapping_1_textview"
tools:text="HELLO" />
<TextView
android:id="@+id/editMapping_plus_3"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:gravity="center"
android:text="+"
app:layout_constraintBottom_toBottomOf="@+id/mapping_3_textview"
app:layout_constraintEnd_toEndOf="@+id/mapping_3_textview"
app:layout_constraintStart_toEndOf="@id/mapping_3_textview"
app:layout_constraintTop_toBottomOf="@+id/mapping_1_textview" />
<TextView
android:id="@+id/mapping_4_textview"
style="?android:attr/spinnerItemStyle"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:ellipsize="marquee"
android:gravity="center"
android:singleLine="true"
android:textAlignment="inherit"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/mapping_3_textview"
app:layout_constraintTop_toTopOf="@id/mapping_3_textview"
tools:text="HELLO" />
<!-- ORIENTATION SECTION -->
<TextView
android:id="@+id/editOrientation_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_2sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_orientation"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/mapping_3_textview" />
<Spinner
android:id="@+id/editOrientation_spinner"
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:background="@android:color/transparent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editOrientation_textView" />
<!-- TOGGLE SECTION -->
<Switch
android:id="@+id/checkboxToggle"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_toggle"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editOrientation_spinner"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- MOUSE PASS THROUGH SECTION -->
<Switch
android:id="@+id/checkboxPassThrough"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_passthru"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxToggle"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- SWIPEABLE BUTTON SECTION -->
<Switch
android:id="@+id/checkboxSwipeable"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_swipeable"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxPassThrough"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- FORWARD LOCK SECTION -->
<Switch
android:id="@+id/checkboxForwardLock"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_forward_lock"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxSwipeable"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<Switch
android:id="@+id/checkboxAbsoluteFingerTracking"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/customctrl_absolute_tracking"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxForwardLock"
tools:ignore="UseSwitchCompatOrMaterialXml"/>
<!-- BACKGROUND COLOR SECTION -->
<fr.spse.extended_view.ExtendedTextView
android:id="@+id/editBackgroundColor_textView"
android:layout_width="0dp"
android:layout_height="@dimen/_35sdp"
android:background="?attr/selectableItemBackground"
android:drawableEnd="@drawable/spinner_arrow_right"
android:gravity="center_vertical"
android:paddingEnd="5dp"
android:text="@string/customctrl_background_color"
app:drawableEndIntegerScaling="true"
app:drawableEndSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxAbsoluteFingerTracking" />
<!-- STROKE WIDTH -->
<TextView
android:id="@+id/editStrokeWidth_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_stroke_width"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editStrokeColor_textView" />
<SeekBar
android:id="@+id/editStrokeWidth_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.538"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editStrokeWidth_textView" />
<TextView
android:id="@+id/editStrokeWidth_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editStrokeWidth_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editStrokeWidth_textView" />
<!-- STROKE COLOR VERSION -->
<fr.spse.extended_view.ExtendedTextView
android:id="@+id/editStrokeColor_textView"
android:layout_width="0dp"
android:layout_height="@dimen/_35sdp"
android:background="?attr/selectableItemBackground"
android:drawableEnd="@drawable/spinner_arrow_right"
android:gravity="center_vertical"
android:paddingEnd="5dp"
android:text="@string/customctrl_stroke_color"
app:drawableEndIntegerScaling="true"
app:drawableEndSize="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editBackgroundColor_textView" />
<!-- CORNER RADIUS SECTION -->
<TextView
android:id="@+id/editCornerRadius_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_corner_radius"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editStrokeWidth_seekbar" />
<SeekBar
android:id="@+id/editCornerRadius_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editCornerRadius_textView" />
<TextView
android:id="@+id/editCornerRadius_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editCornerRadius_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editCornerRadius_textView" />
<!-- BUTTON OPACITY SECTION -->
<TextView
android:id="@+id/editButtonOpacity_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/customctrl_button_opacity"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editCornerRadius_seekbar" />
<SeekBar
android:id="@+id/editButtonOpacity_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editButtonOpacity_textView" />
<TextView
android:id="@+id/editButtonOpacity_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
android:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editButtonOpacity_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editButtonOpacity_textView" />
<!-- Button visibility -->
<TextView
android:id="@+id/visibility_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_visibility_title"
app:layout_constraintTop_toBottomOf="@+id/editButtonOpacity_seekbar"
tools:layout_editor_absoluteX="6dp" />
<CheckBox
android:id="@+id/visibility_game_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_visibility_ingame"
app:layout_constraintTop_toBottomOf="@+id/visibility_textview" />
<CheckBox
android:id="@+id/visibility_menu_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/customctrl_visibility_in_menus"
app:layout_constraintTop_toBottomOf="@+id/visibility_game_checkbox" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.kdt.DefocusableScrollView>
@@ -1,191 +0,0 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/edit_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/padding_moderate"
android:paddingVertical="@dimen/padding_moderate"
app:layout_optimizationLevel="standard|dimensions|chains">
<!-- Resolution settings -->
<TextView
android:id="@+id/editResolution_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/mcl_setting_title_resolution_scaler"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.kdt.CustomSeekbar
android:id="@+id/editResolution_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.538"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editResolution_textView" />
<TextView
android:id="@+id/editResolution_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
tools:text="50%"
app:layout_constraintBottom_toBottomOf="@id/editResolution_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editResolution_textView" />
<!-- Gyroscope settings -->
<Switch
android:id="@+id/checkboxGyro"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/preference_enable_gyro_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editResolution_seekbar"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<Switch
android:id="@+id/checkboxGyroX"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/preference_gyro_invert_x_axis"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxGyro"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<Switch
android:id="@+id/checkboxGyroY"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/preference_gyro_invert_y_axis"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxGyroX"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- Gyroscope sensitivity -->
<TextView
android:id="@+id/editGyro_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/preference_gyro_sensitivity_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxGyroY" />
<com.kdt.CustomSeekbar
android:id="@+id/editGyro_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.538"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editGyro_textView" />
<TextView
android:id="@+id/editGyro_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
tools:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editGyro_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editGyro_textView" />
<!-- Mouse settings -->
<TextView
android:id="@+id/editMouseSpeed_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/mcl_setting_title_mousespeed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editGyro_seekbar" />
<com.kdt.CustomSeekbar
android:id="@+id/editMouseSpeed_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.538"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editMouseSpeed_textView" />
<TextView
android:id="@+id/editMouseSpeed_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
tools:text="100%"
app:layout_constraintBottom_toBottomOf="@id/editMouseSpeed_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editMouseSpeed_textView" />
<!-- Gesture toggle -->
<Switch
android:id="@+id/checkboxGesture"
android:layout_width="match_parent"
android:layout_height="@dimen/_36sdp"
android:text="@string/mcl_disable_gestures"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/editMouseSpeed_seekbar"
tools:ignore="UseSwitchCompatOrMaterialXml" />
<!-- gesture settings -->
<TextView
android:id="@+id/editGestureDelay_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_5sdp"
android:gravity="center"
android:paddingEnd="5dp"
android:text="@string/mcl_setting_title_longpresstrigger"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/checkboxGesture" />
<com.kdt.CustomSeekbar
android:id="@+id/editGestureDelay_seekbar"
android:layout_width="0dp"
android:layout_height="@dimen/_36sdp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.538"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editGestureDelay_textView" />
<TextView
android:id="@+id/editGestureDelay_textView_percent"
android:layout_width="50dp"
android:layout_height="0dp"
android:gravity="center"
tools:text="270ms"
app:layout_constraintBottom_toBottomOf="@id/editGestureDelay_textView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/editGestureDelay_textView" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -1,72 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/_280sdp"
android:layout_marginVertical="@dimen/padding_heavy"
android:orientation="vertical"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@drawable/background_control_editor">
<TextView
android:id="@+id/side_dialog_title_textview"
style="@style/TextAppearance.AppCompat.Large"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_moderate"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Quick settings"
tools:visibility="visible" />
<View
android:id="@+id/side_dialog_title_divider"
style="@style/ThickDivider"
android:layout_width="match_parent"
android:paddingHorizontal="@dimen/padding_moderate"
android:visibility="gone"
tools:visibility="visible"
/>
<com.kdt.DefocusableScrollView
android:id="@+id/side_dialog_scrollview"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:background="@color/background_status_bar">
<!-- The content is inflated here -->
</com.kdt.DefocusableScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/side_dialog_start_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:visibility="gone"
tools:visibility="visible"
tools:text="Cancel"
/>
<Button
android:id="@+id/side_dialog_end_button"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:visibility="gone"
tools:text="Confirm"
tools:visibility="visible"
tools:ignore="RelativeOverlap" />
<!-- Appears to be no way to properly fix this, and I'm not super fond of child ConstraintLayouts -->
</RelativeLayout>
</LinearLayout>
@@ -26,8 +26,10 @@
app:layout_constraintGuide_percent="0.5"/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/news_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="0dp"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:text="@string/mcl_tab_wiki"
android:drawableStart="@drawable/ic_menu_news"
app:layout_constraintTop_toTopOf="parent"
@@ -35,7 +37,9 @@
app:layout_constraintEnd_toStartOf="@id/social_divider" />
<View
android:id="@+id/social_divider"
style="@style/LauncherFragment_Divider"
android:layout_width="@dimen/padding_tiny"
android:layout_height="0dp"
android:background="@color/divider"
android:layout_marginVertical="@dimen/padding_large"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="@id/center_guideline"
@@ -43,8 +47,10 @@
app:layout_constraintBottom_toBottomOf="@id/news_button"/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/discord_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="0dp"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:text="@string/mcl_button_discord"
android:drawableStart="@drawable/ic_discord"
app:layout_constraintTop_toTopOf="parent"
@@ -54,35 +60,36 @@
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/custom_control_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/ic_menu_custom_controls"
android:text="@string/mcl_option_customcontrol"
app:layout_constraintTop_toBottomOf="@id/news_button" />
app:layout_constraintTop_toBottomOf="@id/news_button"
/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/install_jar_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@drawable/ic_menu_install_jar"
android:text="@string/main_install_jar_file"
app:layout_constraintTop_toBottomOf="@id/custom_control_button" />
app:layout_constraintTop_toBottomOf="@id/custom_control_button"
/>
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/share_logs_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:layout_height="@dimen/_66sdp"
android:background="?android:attr/selectableItemBackground"
android:drawableStart="@android:drawable/ic_menu_share"
android:text="@string/main_share_logs"
app:layout_constraintTop_toBottomOf="@id/install_jar_button" />
<com.kdt.mcgui.LauncherMenuButton
android:id="@+id/open_files_button"
style="@style/LauncherMenuButton.Universal"
android:layout_width="match_parent"
android:drawableStart="@drawable/ic_folder"
android:text="@string/mcl_button_open_directory"
app:layout_constraintTop_toBottomOf="@id/share_logs_button" />
app:layout_constraintTop_toBottomOf="@id/install_jar_button"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
@@ -136,18 +136,6 @@
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/controller_mapper_toggleable_switch"
android:layout_width="0dp"
android:layout_height="48dp"
android:text="@string/customctrl_toggle"
android:layout_marginTop="@dimen/padding_moderate"
android:layout_marginHorizontal="@dimen/padding_moderate"
android:paddingHorizontal="@dimen/padding_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/controller_mapper_key_spinner3" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/nav_forceclose"
android:title="@string/control_forceclose" />
<item
android:id="@+id/nav_viewlog"
android:title="@string/control_viewout" />
<item
android:id="@+id/nav_debug"
android:title="@string/control_adebug" />
<item
android:id="@+id/nav_customkey"
android:title="@string/control_customkey" />
<item
android:id="@+id/nav_mousespd"
android:title="@string/mcl_setting_title_mousespeed" />
<item
android:id="@+id/nav_customctrl"
android:title="@string/mcl_option_customcontrol" />
</menu>
@@ -12,11 +12,4 @@
<item name="android:textSize">@dimen/_14ssp</item>
</style>
<style name="LauncherMenuButton.Universal" parent="LauncherMenuButton">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginTop">8dp</item>
<item name="android:layout_marginBottom">8dp</item>
</style>
</resources>
@@ -27,9 +27,11 @@
</string-array>
<string-array name="menu_ingame">
<item>@string/control_forceclose</item>
<item>@string/control_viewout</item>
<item>@string/control_customkey</item>
<item>@string/quick_setting_title</item>
<item>@string/mcl_setting_title_mousespeed</item>
<item>@string/preference_gyro_sensitivity_title</item>
<item>@string/mcl_option_customcontrol</item>
</string-array>
@@ -13,7 +13,7 @@
<string name="login_online_login_label">Login</string>
<!-- Hint -->
<string name="hint_control_mapping">"Touch the top center cogwheel to open the context menu ⚙\nTap a button to customize: edit, resize, remove, or change its keybind."</string>
<string name="hint_control_mapping">"Tap the top center cog icon to open the context menu ⚙\nTap a button to customize: edit, resize, delete, or customize it's keybind."</string>
<!-- Warnings -->
<string name="warning_remove_account">This account will be removed!</string>
@@ -93,7 +93,6 @@
<!-- MainActivity: strings -->
<string name="mcn_exit_title">Application/Game exited with code %d, check latestlog.txt for more details.</string>
<string name="mcn_signal_title">Application/Game aborted by fatal signal %d, check latestlog.txt for more details.</string>
<string name="mcn_exit_confirm">Are you sure want to force close?</string>
<string name="mcn_check_fail_vulkan_support">Zink (Vulkan) renderer is not supported on this device!</string>
@@ -274,7 +273,6 @@
<string name="preference_shader_dump_title">Enable shader dumping</string>
<string name="preference_shader_dump_description">Log converted shaders into the log file.</string>
<string name="percent_format">%d%%</string>
<string name="millisecond_format">%d ms</string>
<string name="customctrl_editor_exit_title">Leaving?</string>
<string name="customctrl_editor_exit_msg">Are you sure you want to exit?</string>
<string name="customctrl_editor_exit">Leave editor</string>
@@ -416,9 +414,5 @@
<string name="preference_remap_controller_title">Change controller key bindings</string>
<string name="preference_remap_controller_description">Allows you to modify the keyboard keys bound to each controller button</string>
<string name="mcl_button_discord">Discord</string>
<string name="mcl_button_open_directory">Open game directory</string>
<string name="discord_invite" translatable="false">https://discord.com/invite/aenk3EUvER</string>
<string name="local_login_bad_username_title">Unsuitable username</string>
<string name="local_login_bad_username_text">The username must be between 3–16 characters long, and must only contain latin letters, arabic numerals and underscores.</string>
<string name="quick_setting_title">Quick settings</string>
<string name="discord_invite" translatable="false">https://discord.gg/pojavlauncher-724163890803638273</string>
</resources>
@@ -13,19 +13,6 @@
</style>
<style name="LauncherFragment_Divider">
<item name="android:layout_width">@dimen/padding_tiny</item>
<item name="android:layout_height">0dp</item>
<item name="android:background">@color/divider</item>
</style>
<style name="LauncherMenuButton" parent="Widget.AppCompat.Button">
<item name="android:background">?android:attr/selectableItemBackground</item>
</style>
<style name="LauncherMenuButton.Universal" parent="LauncherMenuButton">
<item name="android:layout_height">@dimen/_66sdp</item>
</style>
<style name="ThickDivider">
<item name="android:layout_width">match_parent</item>
@@ -33,10 +20,4 @@
<item name="android:background">?android:attr/listDivider</item>
</style>
<item name="dimension_tracker" type="id" />
<style name="DimensionTracker">
<item name="android:id">@id/dimension_tracker</item>
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
</style>
</resources>
-2
View File
@@ -5,5 +5,3 @@ android.useAndroidX=true
android.bundle.language.enableSplit=false
# Increase Gradle daemon RAM allocation
org.gradle.jvmargs=-Xmx4096M
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Binary file not shown.
+1 -3
View File
@@ -1,8 +1,6 @@
#Fri Dec 06 21:56:04 CET 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+12 -17
View File
@@ -83,8 +83,10 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -131,13 +133,10 @@ location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -145,7 +144,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -153,7 +152,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,15 +197,11 @@ if "$cygwin" || "$msys" ; then
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Binary file not shown.
@@ -6,6 +6,7 @@ package org.lwjgl.glfw;
import android.util.*;
import java.lang.annotation.Native;
import java.lang.reflect.*;
import java.nio.*;
@@ -22,6 +23,8 @@ import static org.lwjgl.system.MemoryStack.*;
import static org.lwjgl.system.MemoryUtil.*;
import java.util.*;
import sun.misc.Unsafe;
public class GLFW
{
static FloatBuffer joystickData = (FloatBuffer)FloatBuffer.allocate(8).flip();
@@ -478,6 +481,7 @@ public class GLFW
/* volatile */ public static GLFWCursorPosCallback mGLFWCursorPosCallback;
/* volatile */ public static GLFWDropCallback mGLFWDropCallback;
/* volatile */ public static GLFWErrorCallback mGLFWErrorCallback;
/* volatile */ public static GLFWFramebufferSizeCallback mGLFWFramebufferSizeCallback;
/* volatile */ public static GLFWJoystickCallback mGLFWJoystickCallback;
/* volatile */ public static GLFWKeyCallback mGLFWKeyCallback;
/* volatile */ public static GLFWMonitorCallback mGLFWMonitorCallback;
@@ -490,11 +494,7 @@ public class GLFW
/* volatile */ public static GLFWWindowMaximizeCallback mGLFWWindowMaximizeCallback;
/* volatile */ public static GLFWWindowPosCallback mGLFWWindowPosCallback;
/* volatile */ public static GLFWWindowRefreshCallback mGLFWWindowRefreshCallback;
// Store callback method references directly to avoid a roundtrip through
// JNI when calling the default LWJGL callbacks.
@Nullable public static GLFWFramebufferSizeCallbackI mGLFWFramebufferSizeCallbackI;
@Nullable public static GLFWWindowSizeCallbackI mGLFWWindowSizeCallbackI;
/* volatile */ public static GLFWWindowSizeCallback mGLFWWindowSizeCallback;
volatile public static int mGLFWWindowWidth, mGLFWWindowHeight;
@@ -507,8 +507,6 @@ public class GLFW
private static ArrayMap<Long, GLFWWindowProperties> mGLFWWindowMap;
public static boolean mGLFWIsInputReady;
private static boolean mGLFWInputPumping;
private static boolean mGLFWWindowVisibleOnCreation = true;
public static final ByteBuffer keyDownBuffer = ByteBuffer.allocateDirect(317);
public static final ByteBuffer mouseDownBuffer = ByteBuffer.allocateDirect(8);
@@ -517,6 +515,22 @@ public class GLFW
public static long mainContext = 0;
static {
String windowWidth = System.getProperty(PROP_WINDOW_WIDTH);
String windowHeight = System.getProperty(PROP_WINDOW_HEIGHT);
if (windowWidth == null || windowHeight == null) {
System.err.println("Warning: Property " + PROP_WINDOW_WIDTH + " or " + PROP_WINDOW_HEIGHT + " not set, defaulting to 1280 and 720");
mGLFWWindowWidth = 1280;
mGLFWWindowHeight = 720;
} else {
mGLFWWindowWidth = Integer.parseInt(windowWidth);
mGLFWWindowHeight = Integer.parseInt(windowHeight);
}
// Minecraft triggers a glfwPollEvents() on splash screen, so update window size there.
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_FRAMEBUFFER_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0);
// CallbackBridge.receiveCallback(CallbackBridge.EVENT_TYPE_WINDOW_SIZE, mGLFWWindowWidth, mGLFWWindowHeight, 0, 0);
try {
System.loadLibrary("pojavexec");
} catch (UnsatisfiedLinkError e) {
@@ -570,9 +584,11 @@ public class GLFW
private static native long nglfwSetCharModsCallback(long window, long ptr);
private static native long nglfwSetCursorEnterCallback(long window, long ptr);
private static native long nglfwSetCursorPosCallback(long window, long ptr);
private static native long nglfwSetFramebufferSizeCallback(long window, long ptr);
private static native long nglfwSetKeyCallback(long window, long ptr);
private static native long nglfwSetMouseButtonCallback(long window, long ptr);
private static native long nglfwSetScrollCallback(long window, long ptr);
private static native long nglfwSetWindowSizeCallback(long window, long ptr);
// private static native void nglfwSetInputReady();
private static native void nglfwSetShowingWindow(long window);
@@ -611,15 +627,14 @@ public class GLFW
SwapBuffers = apiGetFunctionAddress(GLFW, "pojavSwapBuffers"),
SwapInterval = apiGetFunctionAddress(GLFW, "pojavSwapInterval"),
PumpEvents = apiGetFunctionAddress(GLFW, "pojavPumpEvents"),
StopPumping = apiGetFunctionAddress(GLFW, "pojavStopPumping"),
StartPumping = apiGetFunctionAddress(GLFW, "pojavStartPumping");
RewindEvents = apiGetFunctionAddress(GLFW, "pojavRewindEvents"),
SetupEvents = apiGetFunctionAddress(GLFW, "pojavComputeEventTarget");
}
public static SharedLibrary getLibrary() {
return GLFW;
}
@SuppressWarnings("unused") // Used by pojavexec
public static void internalChangeMonitorSize(int width, int height) {
mGLFWWindowWidth = width;
mGLFWWindowHeight = height;
@@ -686,12 +701,11 @@ public class GLFW
}
public static GLFWFramebufferSizeCallback glfwSetFramebufferSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWframebuffersizefun") GLFWFramebufferSizeCallbackI cbfun) {
GLFWFramebufferSizeCallback previousCallback = null;
if(mGLFWFramebufferSizeCallbackI != null) {
previousCallback = GLFWFramebufferSizeCallback.create(mGLFWFramebufferSizeCallbackI);
}
mGLFWFramebufferSizeCallbackI = cbfun;
return previousCallback;
GLFWFramebufferSizeCallback lastCallback = mGLFWFramebufferSizeCallback;
if (cbfun == null) mGLFWFramebufferSizeCallback = null;
else mGLFWFramebufferSizeCallback = GLFWFramebufferSizeCallback.createSafe(nglfwSetFramebufferSizeCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
public static GLFWJoystickCallback glfwSetJoystickCallback(/* @NativeType("GLFWwindow *") long window, */ @Nullable @NativeType("GLFWjoystickfun") GLFWJoystickCallbackI cbfun) {
@@ -790,12 +804,11 @@ public class GLFW
}
public static GLFWWindowSizeCallback glfwSetWindowSizeCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWwindowsizefun") GLFWWindowSizeCallbackI cbfun) {
GLFWWindowSizeCallback previousCallback = null;
if(mGLFWWindowSizeCallbackI != null) {
previousCallback = GLFWWindowSizeCallback.create(mGLFWWindowSizeCallbackI);
}
mGLFWWindowSizeCallbackI = cbfun;
return previousCallback;
GLFWWindowSizeCallback lastCallback = mGLFWWindowSizeCallback;
if (cbfun == null) mGLFWWindowSizeCallback = null;
else mGLFWWindowSizeCallback = GLFWWindowSizeCallback.createSafe(nglfwSetWindowSizeCallback(window, memAddressSafe(cbfun)));
return lastCallback;
}
static boolean isGLFWReady;
@@ -989,15 +1002,11 @@ public class GLFW
win.height = mGLFWWindowHeight;
win.title = title;
win.windowAttribs.put(GLFW_HOVERED, 1);
win.windowAttribs.put(GLFW_VISIBLE, 1);
mGLFWWindowMap.put(ptr, win);
mainContext = ptr;
if(mGLFWWindowVisibleOnCreation || monitor != 0) {
// Show window by default if GLFW_VISIBLE hint is specified on creation or
// if the monitor is nonnull (fullscreen requested)
glfwShowWindow(ptr);
}
return ptr;
//Return our context
}
@@ -1014,9 +1023,7 @@ public class GLFW
nglfwSetShowingWindow(mGLFWWindowMap.size() == 0 ? 0 : mGLFWWindowMap.keyAt(mGLFWWindowMap.size() - 1));
}
public static void glfwDefaultWindowHints() {
mGLFWWindowVisibleOnCreation = true;
}
public static void glfwDefaultWindowHints() {}
public static void glfwGetWindowSize(long window, IntBuffer width, IntBuffer height) {
if (width != null) width.put(internalGetWindow(window).width);
@@ -1039,17 +1046,10 @@ public class GLFW
}
public static void glfwShowWindow(long window) {
GLFWWindowProperties win = internalGetWindow(window);
win.windowAttribs.put(GLFW_HOVERED, 1);
win.windowAttribs.put(GLFW_VISIBLE, 1);
nglfwSetShowingWindow(window);
}
public static void glfwWindowHint(int hint, int value) {
if (hint == GLFW_VISIBLE) {
mGLFWWindowVisibleOnCreation = value == GLFW_TRUE;
return;
}
long __functionAddress = Functions.SetWindowHint;
invokeV(hint, value, __functionAddress);
}
@@ -1080,22 +1080,15 @@ public class GLFW
mGLFWIsInputReady = true;
CallbackBridge.nativeSetInputReady(true);
}
// During interactions with UI elements, Minecraft likes to update the screen as events related to those inputs arrive.
// This leads to calls to glfwPollEvents within glfwPollEvents, which is not good for our queue system.
// Prevent these with this code.
if(mGLFWInputPumping) return;
mGLFWInputPumping = true;
callV(Functions.StartPumping);
callV(Functions.SetupEvents);
for (Long ptr : mGLFWWindowMap.keySet()) callJV(ptr, Functions.PumpEvents);
callV(Functions.StopPumping);
mGLFWInputPumping = false;
callV(Functions.RewindEvents);
}
@SuppressWarnings("unused") // Used by pojavexec
public static void internalWindowSizeChanged(long window) {
public static void internalWindowSizeChanged(long window, int w, int h) {
try {
internalChangeMonitorSize(w, h);
glfwSetWindowSize(window, mGLFWWindowWidth, mGLFWWindowHeight);
if(mGLFWFramebufferSizeCallbackI != null) mGLFWFramebufferSizeCallbackI.invoke(window, mGLFWWindowWidth, mGLFWWindowHeight);
if(mGLFWWindowSizeCallbackI != null) mGLFWWindowSizeCallbackI.invoke(window, mGLFWWindowWidth, mGLFWWindowHeight);
}catch (Exception e) {
e.printStackTrace();
}