Compare commits
25
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b12ad04815 | ||
|
|
6eb830ba7a | ||
|
|
42c1c98c21 | ||
|
|
3b4364bca2 | ||
|
|
093c810e9f | ||
|
|
dcc2b95f54 | ||
|
|
7c9c076105 | ||
|
|
a6f3fc0606 | ||
|
|
2387817f4f | ||
|
|
98947f23d3 | ||
|
|
b239d06745 | ||
|
|
3733f9cdd4 | ||
|
|
e49222380f | ||
|
|
92bde837fd | ||
|
|
1e060d1aa8 | ||
|
|
fab0186cbe | ||
|
|
988d3bbcb6 | ||
|
|
9e53552a8c | ||
|
|
740568fafa | ||
|
|
4903cfc8d3 | ||
|
|
21cfcdb15e | ||
|
|
ffc74c502a | ||
|
|
4e1bdd8675 | ||
|
|
0ee0dfecc2 | ||
|
|
5a98a43d21 |
No files matched your search
@@ -18,28 +18,24 @@ jobs:
|
||||
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: "recursive"
|
||||
|
||||
- name: Set up JDK 8
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '8'
|
||||
java-version: '21'
|
||||
|
||||
- name: Get LTW
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
continue-on-error: true
|
||||
with:
|
||||
github_token: ${{secrets.LTW_CLONER_SECRET}}
|
||||
repo: PojavLauncherTeam/BigTinyWrapper
|
||||
workflow: android.yml
|
||||
workflow_conclusion: success
|
||||
name: output-aar
|
||||
path: app_pojavlauncher/libs
|
||||
allow_forks: false
|
||||
run: |
|
||||
apt update && apt install wget
|
||||
cd app_pojavlauncher/libs
|
||||
wget https://github.com/PojavLauncherTeam/LTW/releases/latest/download/ltw-release.aar
|
||||
|
||||
- name: Get JRE 8
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
uses: dawidd6/action-download-artifact@v9
|
||||
with:
|
||||
workflow: build.yml
|
||||
path: app_pojavlauncher/src/main/assets/components/jre
|
||||
@@ -49,7 +45,7 @@ jobs:
|
||||
name: jre8-pojav
|
||||
|
||||
- name: Get JRE17
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
uses: dawidd6/action-download-artifact@v9
|
||||
with:
|
||||
workflow: build.yml
|
||||
path: app_pojavlauncher/src/main/assets/components/jre-new
|
||||
@@ -59,7 +55,7 @@ jobs:
|
||||
name: jre17-pojav
|
||||
|
||||
- name: Get JRE21
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
uses: dawidd6/action-download-artifact@v9
|
||||
with:
|
||||
workflow: build.yml
|
||||
path: app_pojavlauncher/src/main/assets/components/jre-21
|
||||
|
||||
@@ -1,135 +1,151 @@
|
||||
<H1 align="center">PojavLauncher</H1>
|
||||
<h1 align="center">PojavLauncher</h1>
|
||||
|
||||
<img src="https://github.com/PojavLauncherTeam/PojavLauncher/blob/v3_openjdk/app_pojavlauncher/src/main/assets/pojavlauncher.png" align="left" width="130" height="150" alt="PojavLauncher logo">
|
||||
|
||||
[](https://github.com/PojavLauncherTeam/PojavLauncher/actions)
|
||||
[](https://github.com/PojavLauncherTeam/PojavLauncher/actions)
|
||||
[](https://crowdin.com/project/pojavlauncher)
|
||||
[](https://discord.com/invite/aenk3EUvER)
|
||||
[](https://discord.com/invite/aenk3EUvER)
|
||||
[](https://twitter.com/PLaunchTeam)
|
||||
|
||||
* From [Boardwalk](https://github.com/zhuowei/Boardwalk)'s ashes here comes PojavLauncher!
|
||||
*From [Boardwalk](https://github.com/zhuowei/Boardwalk)'s ashes here comes PojavLauncher!*
|
||||
|
||||
* PojavLauncher is a launcher that allows you to play Minecraft: Java Edition on your Android device!
|
||||
PojavLauncher is a launcher that allows you to play Minecraft: Java Edition on your Android and [iOS](https://github.com/PojavLauncherTeam/PojavLauncher_iOS) devices.
|
||||
|
||||
* 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://pojavlauncher.app/)!
|
||||
|
||||
* For more details [check out our wiki](https://pojavlauncherteam.github.io/)
|
||||
## 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.
|
||||
## Important Notes
|
||||
|
||||
## Navigation
|
||||
- [Introduction](#introduction)
|
||||
- [Getting PojavLauncher](#getting-pojavlauncher)
|
||||
- [Building](#building)
|
||||
- [Current status](#current-status)
|
||||
- [License](#license)
|
||||
- [Contributing](#contributing)
|
||||
- [Credits & Third party components and their licenses](#credits--third-party-components-and-their-licenses-if-available)
|
||||
**PojavLauncher has been discontinued** and is no longer supported. Its successor is available [here](https://github.com/AngelAuraMC/Amethyst-Android).
|
||||
|
||||
## Introduction
|
||||
* PojavLauncher is a Minecraft: Java Edition launcher for Android and iOS based on [Boardwalk](https://github.com/zhuowei/Boardwalk).
|
||||
* This launcher can launch almost all available Minecraft versions ranging from rd-132211 to 1.21 snapshots (including Combat Test versions).
|
||||
* Modding via Forge and Fabric are also supported.
|
||||
* This repository contains source code for Android.
|
||||
* For iOS/iPadOS, check out [PojavLauncher_iOS](https://github.com/PojavLauncherTeam/PojavLauncher_iOS).
|
||||
## Table of Contents
|
||||
|
||||
* [Introduction](#introduction)
|
||||
* [Getting PojavLauncher](#getting-pojavlauncher)
|
||||
* [Building](#building)
|
||||
* [Quick Build (Recommended)](#quick-build-recommended)
|
||||
* [Detailed Build](#detailed-build)
|
||||
* [Current Status](#current-status)
|
||||
* [Known Issues](#known-issues)
|
||||
* [FAQ](#faq)
|
||||
* [Contributing](#contributing)
|
||||
* [Support](#support)
|
||||
* [License](#license)
|
||||
* [Credits & Dependencies](#credits--dependencies)
|
||||
* [Roadmap](#roadmap)
|
||||
|
||||
## Introduction
|
||||
|
||||
* PojavLauncher is a Minecraft: Java Edition launcher for Android and iOS based on [Boardwalk](https://github.com/zhuowei/Boardwalk)
|
||||
* This launcher can launch almost all available Minecraft versions ranging from rd-132211 to 1.21 snapshots (including Combat Test versions)
|
||||
* Modding via Forge and Fabric are also supported.
|
||||
* This repository contains source code for Android. For iOS/iPadOS, check out [PojavLauncher_iOS](https://github.com/PojavLauncherTeam/PojavLauncher_iOS).
|
||||
|
||||
## Getting PojavLauncher
|
||||
|
||||
You can get PojavLauncher via three methods:
|
||||
|
||||
1. You can get the prebuilt app from [stable releases](https://github.com/PojavLauncherTeam/PojavLauncher/releases) or [automatic builds](https://github.com/PojavLauncherTeam/PojavLauncher/actions).
|
||||
1. **Releases:** Download the prebuilt app from our [stable releases](https://github.com/PojavLauncherTeam/PojavLauncher/releases) or [automatic builds](https://github.com/PojavLauncherTeam/PojavLauncher/actions).
|
||||
2. **Google Play:** Get it from Google Play by clicking on this badge: [](https://play.google.com/store/apps/details?id=net.kdt.pojavlaunch)
|
||||
3. **Build from Source:** Follow the [building instructions](#building) below.
|
||||
|
||||
2. You can get it from Google Play by clicking on this badge:
|
||||
[](https://play.google.com/store/apps/details?id=net.kdt.pojavlaunch)
|
||||
|
||||
3. You can [build](#building) from source.
|
||||
## Building
|
||||
If you want to build from source code, follow the steps below.
|
||||
### Java Runtime Environment (JRE)
|
||||
- JRE for Android is [here](https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u), and the build script is [here](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch).
|
||||
- Follow build instruction on build script [README.md](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch/blob/buildjre8/README.md).
|
||||
- You can also get [CI auto builds](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch/actions) if you are lazy or are failing to build it for some reason.
|
||||
* Either get the `jre8-pojav` artifact from auto builds, or split all artifacts by yourself:</br>
|
||||
- Get JREs for all of 4 supported architectures (arm, arm64, x86, x86_64) </br>
|
||||
- Split JRE into parts:</br>
|
||||
Platform-independent: .jar files, libraries, configs, etc...</br>
|
||||
Platform-dependent: .so files, etc...</br>
|
||||
- Create:</br>
|
||||
A file named `universal.tar.xz` with all platform-independent files</br>
|
||||
4 files named `bin-<arch>.tar.xz` with all platform-dependent files per-architecture</br>
|
||||
- Put these in the `assets/components/jre/` folder</br>
|
||||
- (If needed) update the Version file with the current date</br>
|
||||
|
||||
### LWJGL
|
||||
The build instructions for the custom LWJGL are available over the [LWJGL repository](https://github.com/PojavLauncherTeam/lwjgl3)
|
||||
### Quick Build (Recommended)
|
||||
|
||||
### The Launcher
|
||||
- Because languages are auto-added by Crowdin, you need to run the language list generator before building. In the project directory, run:
|
||||
The easiest way to build PojavLauncher is to use the pre-built JREs provided by our CI.
|
||||
|
||||
* On Linux, Mac OS:
|
||||
```
|
||||
chmod +x scripts/languagelist_updater.sh
|
||||
bash scripts/languagelist_updater.sh
|
||||
```
|
||||
* On Windows:
|
||||
```
|
||||
scripts\languagelist_updater.bat
|
||||
```
|
||||
Then, run these commands ~~or build using Android Studio~~.
|
||||
1. Clone the repository: `git clone https://github.com/PojavLauncherTeam/PojavLauncher.git`
|
||||
2. Build the launcher: `./gradlew :app_pojavlauncher:assembleDebug` (Use `gradlew.bat` on Windows)
|
||||
|
||||
* Build GLFW stub:
|
||||
```
|
||||
./gradlew :jre_lwjgl3glfw:build
|
||||
```
|
||||
* Build the launcher
|
||||
```
|
||||
./gradlew :app_pojavlauncher:assembleDebug
|
||||
```
|
||||
(Replace `gradlew` with `gradlew.bat` if you are building on Windows).
|
||||
The built APK will be located in `app_pojavlauncher/build/outputs/apk/debug/`.
|
||||
|
||||
## Current status
|
||||
- [x] ~~OpenJDK 9 Mobile port: ARM32, ARM64, x86, x86_64.~~ Replaced by JRE8.
|
||||
- [x] OpenJDK 8 Mobile port: ARM32, ARM64, x86, x86_64
|
||||
- [x] OpenJDK 17 Mobile port: ARM32, ARM64, x86, x86_64
|
||||
- [x] Headless mod installer
|
||||
- [x] Mod installer with GUI. Used `Caciocavallo` project for AWT without X11.
|
||||
- [x] OpenGL in OpenJDK environment
|
||||
- [x] OpenAL (works on most devices)
|
||||
- [x] Support for Minecraft 1.12.2 and below. Used [lwjglx](https://github.com/PojavLauncherTeam/lwjglx), a LWJGL2 compatibility layer for LWJGL3.
|
||||
- [x] Support for Minecraft 1.13 and above. Used [GLFW stub](https://github.com/PojavLauncherTeam/lwjgl3-glfw-java).
|
||||
- [x] Support for Minecraft 1.17 (22w13a to be exact) and above. Used [Holy GL4ES](https://github.com/PojavLauncherTeam/gl4es-114-extra)
|
||||
- [x] Game surface zooming.
|
||||
- [x] New input pipe rewritten to native code to boost performance.
|
||||
- [x] Rewritten entire controls system (thanks to @Mathias-Boulay)
|
||||
- [ ] More to come!
|
||||
### Detailed Build
|
||||
|
||||
If you need more control over the build process, follow these steps:
|
||||
|
||||
1. **Java Runtime Environment (JRE):** Download the `jre8-pojav` artifact from our [CI auto builds](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch/actions). This package contains pre-built JREs for all supported architectures. If you need to build the JRE yourself, follow the instructions in the [android-openjdk-build-multiarch](https://github.com/PojavLauncherTeam/android-openjdk-build-multiarch) repository.
|
||||
|
||||
2. **LWJGL:** The build instructions for the custom LWJGL are available over the [LWJGL repository](https://github.com/PojavLauncherTeam/lwjgl3).
|
||||
|
||||
3. **Language List:** Because languages are auto-added by Crowdin, you need to run the language list generator before building. In the project directory, run:
|
||||
* Linux/macOS:
|
||||
```bash
|
||||
chmod +x scripts/languagelist_updater.sh
|
||||
bash scripts/languagelist_updater.sh
|
||||
```
|
||||
* Windows:
|
||||
```batch
|
||||
scripts\languagelist_updater.bat
|
||||
```
|
||||
|
||||
4. **Build GLFW stub:** `./gradlew :jre_lwjgl3glfw:build`
|
||||
|
||||
5. **Build the launcher:** `./gradlew :app_pojavlauncher:assembleDebug` (Replace `gradlew` with `gradlew.bat` on Windows).
|
||||
|
||||
## Current Status
|
||||
|
||||
* [x] OpenJDK 8 Mobile port: ARM32, ARM64, x86, x86_64
|
||||
* [x] OpenJDK 17 Mobile port: ARM32, ARM64, x86, x86_64
|
||||
* [x] OpenJDK 21 Mobile port: ARM32, ARM64, x86, x86_64
|
||||
* [x] Headless mod installer
|
||||
* [x] Mod installer with GUI
|
||||
* [x] OpenGL in OpenJDK environment
|
||||
* [x] OpenAL (works on most devices)
|
||||
* [x] Support for Minecraft 1.12.2 and below
|
||||
* [x] Support for Minecraft 1.13 and above
|
||||
* [x] Support for Minecraft 1.17 (22w13a) and above
|
||||
* [x] Game surface zooming
|
||||
* [x] New input pipe rewritten to native code
|
||||
* [x] Rewritten entire controls system
|
||||
* [ ] More to come!
|
||||
|
||||
## Known Issues
|
||||
- Controller mods aren't working.
|
||||
- Random crashes could happen very often on Android 5.x when loading the game or joining a world.
|
||||
- With big modpacks textures could be messed up
|
||||
- Probably more, that's why we have a bug tracker ;)
|
||||
|
||||
## License
|
||||
- PojavLauncher is licensed under [GNU LGPLv3](https://github.com/PojavLauncherTeam/PojavLauncher/blob/v3_openjdk/LICENSE).
|
||||
See our [issue tracker](https://github.com/PojavLauncherTeam/PojavLauncher/issues) for a list of known issues and their current status.
|
||||
|
||||
## FAQ
|
||||
|
||||
See our [wiki](https://pojavlauncherteam.github.io/) for more information.
|
||||
|
||||
## Contributing
|
||||
Contributions are welcome! We welcome any type of contribution, not only code. For example, you can help the wiki shape up. You can help the [translation](https://crowdin.com/project/pojavlauncher) too!
|
||||
|
||||
Contributions are welcome! We welcome any type of contribution, not only code. For example, you can help improve the [wiki](https://pojavlauncherteam.github.io/), contribute to the [translations](https://crowdin.com/project/pojavlauncher), or submit bug reports and feature requests.
|
||||
|
||||
Any code change to this repository (or iOS) should be submitted as a pull request. The description should explain what the code does and give steps to execute it.
|
||||
Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it.
|
||||
|
||||
## Credits & Third party components and their licenses (if available)
|
||||
- [Boardwalk](https://github.com/zhuowei/Boardwalk) (JVM Launcher): Unknown License/[Apache License 2.0](https://github.com/zhuowei/Boardwalk/blob/master/LICENSE) or GNU GPLv2.
|
||||
- Android Support Libraries: [Apache License 2.0](https://android.googlesource.com/platform/prebuilts/maven_repo/android/+/master/NOTICE.txt).
|
||||
- [GL4ES](https://github.com/PojavLauncherTeam/gl4es): [MIT License](https://github.com/ptitSeb/gl4es/blob/master/LICENSE).<br>
|
||||
- [OpenJDK](https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u): [GNU GPLv2 License](https://openjdk.java.net/legal/gplv2+ce.html).<br>
|
||||
- [LWJGL3](https://github.com/PojavLauncherTeam/lwjgl3): [BSD-3 License](https://github.com/LWJGL/lwjgl3/blob/master/LICENSE.md).
|
||||
- [LWJGLX](https://github.com/PojavLauncherTeam/lwjglx) (LWJGL2 API compatibility layer for LWJGL3): unknown license.<br>
|
||||
- [Mesa 3D Graphics Library](https://gitlab.freedesktop.org/mesa/mesa): [MIT License](https://docs.mesa3d.org/license.html).
|
||||
- [pro-grade](https://github.com/pro-grade/pro-grade) (Java sandboxing security manager): [Apache License 2.0](https://github.com/pro-grade/pro-grade/blob/master/LICENSE.txt).
|
||||
- [bhook](https://github.com/bytedance/bhook) (Used for exit code trapping): [MIT license](https://github.com/bytedance/bhook/blob/main/LICENSE).
|
||||
- [libepoxy](https://github.com/anholt/libepoxy): [MIT License](https://github.com/anholt/libepoxy/blob/master/COPYING).
|
||||
- [virglrenderer](https://github.com/PojavLauncherTeam/virglrenderer): [MIT License](https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/COPYING).
|
||||
- Thanks to [MCHeads](https://mc-heads.net) for providing Minecraft avatars.
|
||||
## Support
|
||||
|
||||
For support, please join our [Discord server](https://discord.com/invite/aenk3EUvER).
|
||||
|
||||
## License
|
||||
|
||||
PojavLauncher is licensed under [GNU LGPLv3](https://github.com/PojavLauncherTeam/PojavLauncher/blob/v3_openjdk/LICENSE).
|
||||
|
||||
## Credits & Dependencies
|
||||
|
||||
* [Boardwalk](https://github.com/zhuowei/Boardwalk) (JVM Launcher): Unknown License/[Apache License 2.0](https://github.com/zhuowei/Boardwalk/blob/master/LICENSE) or GNU GPLv2.
|
||||
* Android Support Libraries: [Apache License 2.0](https://android.googlesource.com/platform/prebuilts/maven_repo/android/+/master/NOTICE.txt).
|
||||
* [GL4ES](https://github.com/PojavLauncherTeam/gl4es): [MIT License](https://github.com/ptitSeb/gl4es/blob/master/LICENSE).
|
||||
* [OpenJDK](https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u): [GNU GPLv2 License](https://openjdk.java.net/legal/gplv2+ce.html).
|
||||
* [LWJGL3](https://github.com/PojavLauncherTeam/lwjgl3): [BSD-3 License](https://github.com/LWJGL/lwjgl3/blob/master/LICENSE.md).
|
||||
* [LWJGLX](https://github.com/PojavLauncherTeam/lwjglx) (LWJGL2 API compatibility layer for LWJGL3): unknown license.
|
||||
* [Mesa 3D Graphics Library](https://gitlab.freedesktop.org/mesa/mesa): [MIT License](https://docs.mesa3d.org/license.html).
|
||||
* [pro-grade](https://github.com/pro-grade/pro-grade) (Java sandboxing security manager): [Apache License 2.0](https://github.com/pro-grade/pro-grade/blob/master/LICENSE.txt).
|
||||
* [bhook](https://github.com/bytedance/bhook) (Used for exit code trapping): [MIT license](https://github.com/bytedance/bhook/blob/main/LICENSE).
|
||||
* [libepoxy](https://github.com/anholt/libepoxy): [MIT License](https://github.com/anholt/libepoxy/blob/master/COPYING).
|
||||
* [virglrenderer](https://github.com/PojavLauncherTeam/virglrenderer): [MIT License](https://gitlab.freedesktop.org/virgl/virglrenderer/-/blob/master/COPYING).
|
||||
* Thanks to [MCHeads](https://mc-heads.net) for providing Minecraft avatars.
|
||||
|
||||
## Roadmap
|
||||
|
||||
We are currently focusing on:
|
||||
|
||||
* Exploring new rendering technologies.
|
||||
|
||||
Future plans include:
|
||||
|
||||
* Improving stability and performance.
|
||||
* Enhancing the mod installation experience.
|
||||
|
||||
We welcome community feedback and suggestions for our roadmap. Please feel free to open a feature request in our [issue tracker](https://github.com/PojavLauncherTeam/PojavLauncher/issues).
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
1687691695196
|
||||
98947f23d338012c5869dc13de31cb39dadba333
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
1692525087345
|
||||
98947f23d338012c5869dc13de31cb39dadba333
|
||||
Binary file not shown.
@@ -1 +1 @@
|
||||
1732218529630
|
||||
98947f23d338012c5869dc13de31cb39dadba333
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
</Console>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<OnStartupTriggeringPolicy />
|
||||
</Policies>
|
||||
</RollingRandomAccessFile>
|
||||
<Listener name="Tracy">
|
||||
<PatternLayout pattern="(%F:%L): %msg{nolookups}%n"/>
|
||||
</Listener>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL" />
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
<AppenderRef ref="Tracy"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
@@ -1 +1 @@
|
||||
1
|
||||
2
|
||||
@@ -43,11 +43,13 @@ import net.kdt.pojavlaunch.services.ProgressServiceKeeper;
|
||||
import net.kdt.pojavlaunch.tasks.AsyncMinecraftDownloader;
|
||||
import net.kdt.pojavlaunch.tasks.AsyncVersionList;
|
||||
import net.kdt.pojavlaunch.tasks.MinecraftDownloader;
|
||||
import net.kdt.pojavlaunch.utils.DateUtils;
|
||||
import net.kdt.pojavlaunch.utils.NotificationUtils;
|
||||
import net.kdt.pojavlaunch.value.launcherprofiles.LauncherProfiles;
|
||||
import net.kdt.pojavlaunch.value.launcherprofiles.MinecraftProfile;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.text.ParseException;
|
||||
|
||||
public class LauncherActivity extends BaseActivity {
|
||||
public static final String SETTING_FRAGMENT_TAG = "SETTINGS_FRAGMENT";
|
||||
@@ -125,6 +127,23 @@ public class LauncherActivity extends BaseActivity {
|
||||
}
|
||||
String normalizedVersionId = AsyncMinecraftDownloader.normalizeVersionId(prof.lastVersionId);
|
||||
JMinecraftVersionList.Version mcVersion = AsyncMinecraftDownloader.getListedVersion(normalizedVersionId);
|
||||
|
||||
// Do not load when is a modded version or older than minecraft 1.3 on demo account
|
||||
if (mAccountSpinner.getSelectedAccount().isDemo()) {
|
||||
boolean isOlderThan13 = true;
|
||||
|
||||
if (mcVersion != null) {
|
||||
try {
|
||||
isOlderThan13 = DateUtils.dateBefore(DateUtils.parseReleaseDate(mcVersion.releaseTime), 2012, 6, 22);
|
||||
} catch (ParseException ignored) {}
|
||||
}
|
||||
|
||||
if (isOlderThan13) {
|
||||
Toast.makeText(this, R.string.toast_not_available_demo, Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
new MinecraftDownloader().start(
|
||||
this,
|
||||
mcVersion,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.kdt.pojavlaunch;
|
||||
|
||||
import static net.kdt.pojavlaunch.Tools.currentDisplayMetrics;
|
||||
import static net.kdt.pojavlaunch.Tools.dialogForceClose;
|
||||
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;
|
||||
@@ -190,10 +191,11 @@ 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: openQuickSettings(); break;
|
||||
case 4: openCustomControls(); break;
|
||||
}
|
||||
drawerLayout.closeDrawers();
|
||||
};
|
||||
|
||||
@@ -29,6 +29,8 @@ import androidx.annotation.RequiresApi;
|
||||
import net.kdt.pojavlaunch.customcontrols.ControlLayout;
|
||||
import net.kdt.pojavlaunch.customcontrols.gamepad.DefaultDataProvider;
|
||||
import net.kdt.pojavlaunch.customcontrols.gamepad.Gamepad;
|
||||
import net.kdt.pojavlaunch.customcontrols.gamepad.direct.DirectGamepad;
|
||||
import net.kdt.pojavlaunch.customcontrols.gamepad.direct.DirectGamepadEnableHandler;
|
||||
import net.kdt.pojavlaunch.customcontrols.mouse.AbstractTouchpad;
|
||||
import net.kdt.pojavlaunch.customcontrols.mouse.AndroidPointerCapture;
|
||||
import net.kdt.pojavlaunch.customcontrols.mouse.InGUIEventProcessor;
|
||||
@@ -40,15 +42,16 @@ import net.kdt.pojavlaunch.utils.MCOptionUtils;
|
||||
|
||||
import org.lwjgl.glfw.CallbackBridge;
|
||||
|
||||
import fr.spse.gamepad_remapper.GamepadHandler;
|
||||
import fr.spse.gamepad_remapper.RemapperManager;
|
||||
import fr.spse.gamepad_remapper.RemapperView;
|
||||
|
||||
/**
|
||||
* Class dealing with showing minecraft surface and taking inputs to dispatch them to minecraft
|
||||
*/
|
||||
public class MinecraftGLSurface extends View implements GrabListener {
|
||||
public class MinecraftGLSurface extends View implements GrabListener, DirectGamepadEnableHandler {
|
||||
/* Gamepad object for gamepad inputs, instantiated on need */
|
||||
private Gamepad mGamepad = null;
|
||||
private GamepadHandler mGamepadHandler;
|
||||
/* The RemapperView.Builder object allows you to set which buttons to remap */
|
||||
private final RemapperManager mInputManager = new RemapperManager(getContext(), new RemapperView.Builder(null)
|
||||
.remapA(true)
|
||||
@@ -88,6 +91,7 @@ public class MinecraftGLSurface extends View implements GrabListener {
|
||||
public MinecraftGLSurface(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
setFocusable(true);
|
||||
CallbackBridge.setDirectGamepadEnableHandler(this);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
@@ -203,7 +207,11 @@ public class MinecraftGLSurface extends View implements GrabListener {
|
||||
}
|
||||
|
||||
private void createGamepad(View contextView, InputDevice inputDevice) {
|
||||
mGamepad = new Gamepad(contextView, inputDevice, DefaultDataProvider.INSTANCE, true);
|
||||
if(CallbackBridge.sGamepadDirectInput) {
|
||||
mGamepadHandler = new DirectGamepad();
|
||||
}else {
|
||||
mGamepadHandler = new Gamepad(contextView, inputDevice, DefaultDataProvider.INSTANCE, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,9 +223,9 @@ public class MinecraftGLSurface extends View implements GrabListener {
|
||||
int mouseCursorIndex = -1;
|
||||
|
||||
if(Gamepad.isGamepadEvent(event)){
|
||||
if(mGamepad == null) createGamepad(this, event.getDevice());
|
||||
if(mGamepadHandler == null) createGamepad(this, event.getDevice());
|
||||
|
||||
mInputManager.handleMotionEventInput(getContext(), event, mGamepad);
|
||||
mInputManager.handleMotionEventInput(getContext(), event, mGamepadHandler);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -287,9 +295,9 @@ public class MinecraftGLSurface extends View implements GrabListener {
|
||||
}
|
||||
|
||||
if(Gamepad.isGamepadEvent(event)){
|
||||
if(mGamepad == null) createGamepad(this, event.getDevice());
|
||||
if(mGamepadHandler == null) createGamepad(this, event.getDevice());
|
||||
|
||||
mInputManager.handleKeyEventInput(getContext(), event, mGamepad);
|
||||
mInputManager.handleKeyEventInput(getContext(), event, mGamepadHandler);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -411,6 +419,17 @@ public class MinecraftGLSurface extends View implements GrabListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDirectGamepadEnabled() {
|
||||
post(()->{
|
||||
if(mGamepadHandler != null && mGamepadHandler instanceof Gamepad) {
|
||||
((Gamepad)mGamepadHandler).removeSelf();
|
||||
}
|
||||
// Force gamepad recreation on next event
|
||||
mGamepadHandler = null;
|
||||
});
|
||||
}
|
||||
|
||||
/** A small interface called when the listener is ready for the first time */
|
||||
public interface SurfaceReadyListener {
|
||||
void isReady();
|
||||
|
||||
@@ -118,6 +118,7 @@ public final class Tools {
|
||||
public static String DIR_ACCOUNT_NEW;
|
||||
public static String DIR_GAME_HOME = Environment.getExternalStorageDirectory().getAbsolutePath() + "/games/PojavLauncher";
|
||||
public static String DIR_GAME_NEW;
|
||||
public static String GAME_PROFILES_FILE;
|
||||
|
||||
// New since 3.0.0
|
||||
public static String DIRNAME_HOME_JRE = "lib";
|
||||
@@ -200,6 +201,8 @@ public final class Tools {
|
||||
OBSOLETE_RESOURCES_PATH = DIR_GAME_NEW + "/resources";
|
||||
CTRLMAP_PATH = DIR_GAME_HOME + "/controlmap";
|
||||
CTRLDEF_FILE = DIR_GAME_HOME + "/controlmap/default.json";
|
||||
GAME_PROFILES_FILE = Tools.DIR_GAME_NEW + "/launcher_profiles.json";
|
||||
switchDemo(isDemoProfile(ctx));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -325,6 +328,14 @@ public final class Tools {
|
||||
}
|
||||
javaArgList.add("-Dlog4j.configurationFile=" + configFile);
|
||||
}
|
||||
|
||||
File versionSpecificNativesDir = new File(Tools.DIR_CACHE, "natives/"+versionId);
|
||||
if(versionSpecificNativesDir.exists()) {
|
||||
String dirPath = versionSpecificNativesDir.getAbsolutePath();
|
||||
javaArgList.add("-Djava.library.path="+dirPath+":"+Tools.NATIVE_LIB_DIR);
|
||||
javaArgList.add("-Djna.boot.library.path="+dirPath);
|
||||
}
|
||||
|
||||
javaArgList.addAll(Arrays.asList(getMinecraftJVMArgs(versionId, gamedir)));
|
||||
javaArgList.add("-cp");
|
||||
javaArgList.add(launchClassPath + ":" + getLWJGL3ClassPath());
|
||||
@@ -453,7 +464,7 @@ public final class Tools {
|
||||
}
|
||||
|
||||
public static String[] getMinecraftClientArgs(MinecraftAccount profile, JMinecraftVersionList.Version versionInfo, File gameDir) {
|
||||
String username = profile.username;
|
||||
String username = profile.username.replace("Demo.", "");
|
||||
String versionName = versionInfo.id;
|
||||
if (versionInfo.inheritsFrom != null) {
|
||||
versionName = versionInfo.inheritsFrom;
|
||||
@@ -498,13 +509,13 @@ public final class Tools {
|
||||
}
|
||||
}
|
||||
|
||||
return JSONUtils.insertJSONValueList(
|
||||
splitAndFilterEmpty(
|
||||
versionInfo.minecraftArguments == null ?
|
||||
fromStringArray(minecraftArgs.toArray(new String[0])):
|
||||
versionInfo.minecraftArguments
|
||||
), varArgMap
|
||||
);
|
||||
String mcArguments = versionInfo.minecraftArguments == null ?
|
||||
fromStringArray(minecraftArgs.toArray(new String[0])):
|
||||
versionInfo.minecraftArguments;
|
||||
|
||||
if(profile.isDemo()) mcArguments += " --demo";
|
||||
|
||||
return JSONUtils.insertJSONValueList(splitAndFilterEmpty(mcArguments), varArgMap);
|
||||
}
|
||||
|
||||
public static String fromStringArray(String[] strArr) {
|
||||
@@ -1405,4 +1416,26 @@ public final class Tools {
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
|
||||
public static void switchDemo(boolean isDemo){
|
||||
if(isDemo) {
|
||||
DIR_GAME_NEW = DIR_DATA + "/demo/.minecraft";
|
||||
} else {
|
||||
DIR_GAME_NEW = DIR_GAME_HOME + "/.minecraft";
|
||||
}
|
||||
DIR_HOME_VERSION = DIR_GAME_NEW + "/versions";
|
||||
DIR_HOME_LIBRARY = DIR_GAME_NEW + "/libraries";
|
||||
ASSETS_PATH = DIR_GAME_NEW + "/assets";
|
||||
OBSOLETE_RESOURCES_PATH = DIR_GAME_NEW + "/resources";
|
||||
}
|
||||
|
||||
public static boolean isDemoProfile(Context ctx){
|
||||
MinecraftAccount currentProfile = PojavProfile.getCurrentProfileContent(ctx, null);
|
||||
return currentProfile != null && currentProfile.isDemo();
|
||||
}
|
||||
|
||||
public static boolean isLocalProfile(Context ctx){
|
||||
MinecraftAccount currentProfile = PojavProfile.getCurrentProfileContent(ctx, null);
|
||||
return currentProfile == null || currentProfile.isLocal();
|
||||
}
|
||||
}
|
||||
+12
-12
@@ -87,17 +87,15 @@ public class MicrosoftBackgroundLogin {
|
||||
|
||||
MinecraftAccount acc = MinecraftAccount.load(mcName);
|
||||
if(acc == null) acc = new MinecraftAccount();
|
||||
if (doesOwnGame) {
|
||||
acc.xuid = xsts[0];
|
||||
acc.clientToken = "0"; /* FIXME */
|
||||
acc.accessToken = mcToken;
|
||||
acc.username = mcName;
|
||||
acc.profileId = mcUuid;
|
||||
acc.isMicrosoft = true;
|
||||
acc.msaRefreshToken = msRefreshToken;
|
||||
acc.expiresAt = expiresAt;
|
||||
acc.updateSkinFace();
|
||||
}
|
||||
acc.xuid = xsts[0];
|
||||
acc.clientToken = "0"; /* FIXME */
|
||||
acc.accessToken = mcToken;
|
||||
acc.username = mcName;
|
||||
acc.profileId = mcUuid;
|
||||
acc.isMicrosoft = true;
|
||||
acc.msaRefreshToken = msRefreshToken;
|
||||
acc.expiresAt = expiresAt;
|
||||
acc.updateSkinFace();
|
||||
acc.save();
|
||||
|
||||
if(doneListener != null) {
|
||||
@@ -298,7 +296,9 @@ public class MicrosoftBackgroundLogin {
|
||||
}else{
|
||||
Log.i("MicrosoftLogin","It seems that this Microsoft Account does not own the game.");
|
||||
doesOwnGame = false;
|
||||
throw new PresentedException(new RuntimeException(conn.getResponseMessage()), R.string.minecraft_not_owned);
|
||||
mcName = "Demo.Player";
|
||||
mcUuid = "00000000-0000-0000-0000-000000000000";
|
||||
//throw new PresentedException(new RuntimeException(conn.getResponseMessage()), R.string.minecraft_not_owned);
|
||||
//throwResponseError(conn);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -30,4 +30,9 @@ public class DefaultDataProvider implements GamepadDataProvider {
|
||||
public void attachGrabListener(GrabListener grabListener) {
|
||||
CallbackBridge.addGrabListener(grabListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachGrabListener(GrabListener grabListener) {
|
||||
CallbackBridge.removeGrabListener(grabListener);
|
||||
}
|
||||
}
|
||||
+14
-2
@@ -26,7 +26,6 @@ import androidx.core.math.MathUtils;
|
||||
import net.kdt.pojavlaunch.GrabListener;
|
||||
import net.kdt.pojavlaunch.LwjglGlfwKeycode;
|
||||
import net.kdt.pojavlaunch.R;
|
||||
import net.kdt.pojavlaunch.prefs.LauncherPreferences;
|
||||
import net.kdt.pojavlaunch.utils.MCOptionUtils;
|
||||
|
||||
import org.lwjgl.glfw.CallbackBridge;
|
||||
@@ -88,6 +87,8 @@ public class Gamepad implements GrabListener, GamepadHandler {
|
||||
|
||||
private final GamepadDataProvider mMapProvider;
|
||||
|
||||
private boolean mRemoved = false;
|
||||
|
||||
public Gamepad(View contextView, InputDevice inputDevice, GamepadDataProvider mapProvider, boolean showCursor){
|
||||
Settings.setDeadzoneScale(PREF_DEADZONE_SCALE);
|
||||
|
||||
@@ -96,7 +97,7 @@ public class Gamepad implements GrabListener, GamepadHandler {
|
||||
@Override
|
||||
public void doFrame(long frameTimeNanos) {
|
||||
tick(frameTimeNanos);
|
||||
mScreenChoreographer.postFrameCallback(this);
|
||||
if(!mRemoved) mScreenChoreographer.postFrameCallback(this);
|
||||
}
|
||||
};
|
||||
mScreenChoreographer.postFrameCallback(frameCallback);
|
||||
@@ -453,4 +454,15 @@ public class Gamepad implements GrabListener, GamepadHandler {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops the Gamepad and removes all traces of the Gamepad from the view hierarchy.
|
||||
* After this call, the Gamepad is not recoverable and a new one must be made.
|
||||
*/
|
||||
public void removeSelf() {
|
||||
mRemoved = true;
|
||||
mMapProvider.detachGrabListener(this);
|
||||
ViewGroup viewGroup = (ViewGroup) mPointerImageView.getParent();
|
||||
if(viewGroup != null) viewGroup.removeView(mPointerImageView);
|
||||
}
|
||||
}
|
||||
+1
@@ -7,4 +7,5 @@ public interface GamepadDataProvider {
|
||||
GamepadMap getGameMap();
|
||||
boolean isGrabbing();
|
||||
void attachGrabListener(GrabListener grabListener);
|
||||
void detachGrabListener(GrabListener grabListener);
|
||||
}
|
||||
+2
-51
@@ -2,61 +2,12 @@ package net.kdt.pojavlaunch.customcontrols.gamepad;
|
||||
|
||||
import static android.view.InputDevice.KEYBOARD_TYPE_ALPHABETIC;
|
||||
import static android.view.InputDevice.SOURCE_GAMEPAD;
|
||||
import static android.view.KeyEvent.KEYCODE_DPAD_CENTER;
|
||||
import static android.view.KeyEvent.KEYCODE_DPAD_DOWN;
|
||||
import static android.view.KeyEvent.KEYCODE_DPAD_LEFT;
|
||||
import static android.view.KeyEvent.KEYCODE_DPAD_RIGHT;
|
||||
import static android.view.KeyEvent.KEYCODE_DPAD_UP;
|
||||
|
||||
import android.view.InputDevice;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
|
||||
public class GamepadDpad {
|
||||
private int mLastKeycode = KEYCODE_DPAD_CENTER;
|
||||
|
||||
/**
|
||||
* Convert the event to a 2 int array: keycode and keyAction, similar to a keyEvent
|
||||
* @param event The motion to convert
|
||||
* @return int[0] keycode, int[1] keyAction
|
||||
*/
|
||||
public int[] convertEvent(MotionEvent event){
|
||||
// Use the hat axis value to find the D-pad direction
|
||||
float xaxis = event.getAxisValue(MotionEvent.AXIS_HAT_X);
|
||||
float yaxis = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
|
||||
int action = KeyEvent.ACTION_DOWN;
|
||||
|
||||
// Check if the AXIS_HAT_X value is -1 or 1, and set the D-pad
|
||||
// LEFT and RIGHT direction accordingly.
|
||||
if (Float.compare(xaxis, -1.0f) == 0) {
|
||||
mLastKeycode = KEYCODE_DPAD_LEFT;
|
||||
} else if (Float.compare(xaxis, 1.0f) == 0) {
|
||||
mLastKeycode = KEYCODE_DPAD_RIGHT;
|
||||
}
|
||||
// Check if the AXIS_HAT_Y value is -1 or 1, and set the D-pad
|
||||
// UP and DOWN direction accordingly.
|
||||
else if (Float.compare(yaxis, -1.0f) == 0) {
|
||||
mLastKeycode = KEYCODE_DPAD_UP;
|
||||
} else if (Float.compare(yaxis, 1.0f) == 0) {
|
||||
mLastKeycode = KEYCODE_DPAD_DOWN;
|
||||
}else {
|
||||
//No keycode change
|
||||
action = KeyEvent.ACTION_UP;
|
||||
}
|
||||
|
||||
return new int[]{mLastKeycode, action};
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused") public static boolean isDpadEvent(MotionEvent event) {
|
||||
// Check that input comes from a device with directional pads.
|
||||
// And... also the joystick since it declares sometimes as a joystick.
|
||||
return (event.getSource() & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK;
|
||||
}
|
||||
|
||||
public static boolean isDpadEvent(KeyEvent event){
|
||||
//return ((event.getSource() & InputDevice.SOURCE_DPAD) == InputDevice.SOURCE_DPAD) && (event.getDevice().getKeyboardType() == KEYBOARD_TYPE_NON_ALPHABETIC);
|
||||
return event.isFromSource(SOURCE_GAMEPAD) && event.getDevice().getKeyboardType() != KEYBOARD_TYPE_ALPHABETIC;
|
||||
public static boolean isDpadEvent(KeyEvent event) {
|
||||
return event.isFromSource(SOURCE_GAMEPAD) && (event.getDevice() == null || event.getDevice().getKeyboardType() != KEYBOARD_TYPE_ALPHABETIC);
|
||||
}
|
||||
}
|
||||
+5
@@ -325,6 +325,11 @@ public class GamepadMapperAdapter extends RecyclerView.Adapter<GamepadMapperAdap
|
||||
grabListener.onGrabState(mGrabState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detachGrabListener(GrabListener grabListener) {
|
||||
mGamepadGrabListener = null;
|
||||
}
|
||||
|
||||
public void setGrabState(boolean newState) {
|
||||
mGrabState = newState;
|
||||
if(mGamepadGrabListener != null) mGamepadGrabListener.onGrabState(newState);
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
||||
|
||||
import static org.lwjgl.glfw.CallbackBridge.sGamepadAxisBuffer;
|
||||
import static org.lwjgl.glfw.CallbackBridge.sGamepadButtonBuffer;
|
||||
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import fr.spse.gamepad_remapper.GamepadHandler;
|
||||
|
||||
public class DirectGamepad implements GamepadHandler {
|
||||
@Override
|
||||
public void handleGamepadInput(int keycode, float value) {
|
||||
int gKeycode = -1, gAxis = -1;
|
||||
switch (keycode) {
|
||||
case KeyEvent.KEYCODE_BUTTON_A: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_A; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_B: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_B; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_X: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_X; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_Y: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_Y; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_L1: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_LEFT_BUMPER; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_R1: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_L2:
|
||||
case MotionEvent.AXIS_LTRIGGER:
|
||||
gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_TRIGGER;
|
||||
break;
|
||||
case KeyEvent.KEYCODE_BUTTON_R2:
|
||||
case MotionEvent.AXIS_RTRIGGER:
|
||||
gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER;
|
||||
break;
|
||||
case KeyEvent.KEYCODE_BUTTON_THUMBL: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_LEFT_THUMB; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_THUMBR: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_RIGHT_THUMB; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_START: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_START; break;
|
||||
case KeyEvent.KEYCODE_BUTTON_SELECT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_BACK; break;
|
||||
case KeyEvent.KEYCODE_DPAD_UP: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP; break;
|
||||
case KeyEvent.KEYCODE_DPAD_DOWN: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN; break;
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT; break;
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT: gKeycode = GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT; break;
|
||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
||||
// Behave the same way as the Gamepad here, as GLFW doesn't have a keycode
|
||||
// for the dpad center.
|
||||
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP, GamepadKeycodes.GLFW_RELEASE);
|
||||
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN, GamepadKeycodes.GLFW_RELEASE);
|
||||
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT, GamepadKeycodes.GLFW_RELEASE);
|
||||
sGamepadButtonBuffer.put(GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT, GamepadKeycodes.GLFW_RELEASE);
|
||||
return;
|
||||
case MotionEvent.AXIS_X: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_X; break;
|
||||
case MotionEvent.AXIS_Y: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_LEFT_Y; break;
|
||||
case MotionEvent.AXIS_Z: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_X; break;
|
||||
case MotionEvent.AXIS_RZ: gAxis = GamepadKeycodes.GLFW_GAMEPAD_AXIS_RIGHT_Y; break;
|
||||
case MotionEvent.AXIS_HAT_X:
|
||||
sGamepadButtonBuffer.put(
|
||||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||
);
|
||||
sGamepadButtonBuffer.put(
|
||||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||
);
|
||||
return;
|
||||
case MotionEvent.AXIS_HAT_Y:
|
||||
sGamepadButtonBuffer.put(
|
||||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_UP,
|
||||
value < -0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||
);
|
||||
sGamepadButtonBuffer.put(
|
||||
GamepadKeycodes.GLFW_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE
|
||||
);
|
||||
return;
|
||||
}
|
||||
if(gKeycode != -1) {
|
||||
sGamepadButtonBuffer.put(gKeycode, value > 0.85 ? GamepadKeycodes.GLFW_PRESS : GamepadKeycodes.GLFW_RELEASE);
|
||||
}
|
||||
if(gAxis != -1) {
|
||||
sGamepadAxisBuffer.put(gAxis, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
||||
|
||||
/**
|
||||
* Interface that is called once when the GLFW implementation requests to switch from
|
||||
* the default gamepad implementation to the direct one. The implementor of this interface
|
||||
* must take the necessary steps to disable the default gamepad implementation and replace
|
||||
* it with an instance of DirectGamepad.
|
||||
|
||||
* This is useful for switching from default to direct input after the user has already
|
||||
* interacted with the gamepad.
|
||||
*/
|
||||
public interface DirectGamepadEnableHandler {
|
||||
/**
|
||||
* Called once when GLFW requests switching the gamepad mode from default to direct.
|
||||
*/
|
||||
void onDirectGamepadEnabled();
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package net.kdt.pojavlaunch.customcontrols.gamepad.direct;
|
||||
|
||||
public class GamepadKeycodes {
|
||||
public static final byte GLFW_RELEASE = 0;
|
||||
public static final byte GLFW_PRESS = 1;
|
||||
|
||||
public static final short GLFW_GAMEPAD_BUTTON_A = 0;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_B = 1;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_X = 2;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_Y = 3;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_LEFT_BUMPER = 4;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_RIGHT_BUMPER = 5;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_BACK = 6;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_START = 7;
|
||||
// Home button, unused because Android takes the home button events
|
||||
// for itself
|
||||
public static final short GLFW_GAMEPAD_BUTTON_GUIDE = 8;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_LEFT_THUMB = 9;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_RIGHT_THUMB = 10;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_UP = 11;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_RIGHT = 12;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_DOWN = 13;
|
||||
public static final short GLFW_GAMEPAD_BUTTON_DPAD_LEFT = 14;
|
||||
|
||||
public static final short GLFW_GAMEPAD_AXIS_LEFT_X = 0;
|
||||
public static final short GLFW_GAMEPAD_AXIS_LEFT_Y = 1;
|
||||
public static final short GLFW_GAMEPAD_AXIS_RIGHT_X = 2;
|
||||
public static final short GLFW_GAMEPAD_AXIS_RIGHT_Y = 3;
|
||||
public static final short GLFW_GAMEPAD_AXIS_LEFT_TRIGGER = 4;
|
||||
public static final short GLFW_GAMEPAD_AXIS_RIGHT_TRIGGER = 5;
|
||||
}
|
||||
+15
-1
@@ -64,7 +64,15 @@ public class MainMenuFragment extends Fragment {
|
||||
|
||||
mShareLogsButton.setOnClickListener((v) -> shareLog(requireContext()));
|
||||
|
||||
mOpenDirectoryButton.setOnClickListener((v)-> openPath(v.getContext(), getCurrentProfileDirectory(), false));
|
||||
mOpenDirectoryButton.setOnClickListener((v)-> {
|
||||
Tools.switchDemo(Tools.isDemoProfile(v.getContext())); // avoid switching accounts being able to access
|
||||
if(Tools.isDemoProfile(v.getContext())){
|
||||
Toast.makeText(v.getContext(), R.string.toast_not_available_demo, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
openPath(v.getContext(), getCurrentProfileDirectory(), false);
|
||||
});
|
||||
|
||||
|
||||
mNewsButton.setOnLongClickListener((v)->{
|
||||
@@ -89,6 +97,12 @@ public class MainMenuFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void runInstallerWithConfirmation(boolean isCustomArgs) {
|
||||
// avoid using custom installers to install a version
|
||||
if(Tools.isLocalProfile(requireContext()) || Tools.isDemoProfile(requireContext())){
|
||||
Toast.makeText(requireContext(), R.string.toast_not_available_demo, Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if (ProgressKeeper.getTaskCount() == 0)
|
||||
Tools.installMod(requireActivity(), isCustomArgs);
|
||||
else
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class OptiFineInstallFragment extends ModVersionListFragment<OptiFineUtil
|
||||
|
||||
@Override
|
||||
public Runnable createDownloadTask(Object selectedVersion, ModloaderListenerProxy listenerProxy) {
|
||||
return new OptiFineDownloadTask((OptiFineUtils.OptiFineVersion) selectedVersion, listenerProxy);
|
||||
return new OptiFineDownloadTask((OptiFineUtils.OptiFineVersion) selectedVersion, listenerProxy, requireActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+17
-7
@@ -2,11 +2,13 @@ package net.kdt.pojavlaunch.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import net.kdt.pojavlaunch.PojavProfile;
|
||||
import net.kdt.pojavlaunch.R;
|
||||
import net.kdt.pojavlaunch.Tools;
|
||||
|
||||
@@ -25,17 +27,25 @@ public class ProfileTypeSelectFragment extends Fragment {
|
||||
// NOTE: Special care needed! If you wll decide to add these to the back stack, please read
|
||||
// the comment in FabricInstallFragment.onDownloadFinished() and amend the code
|
||||
// in FabricInstallFragment.onDownloadFinished() and ModVersionListFragment.onDownloadFinished()
|
||||
view.findViewById(R.id.optifine_profile).setOnClickListener(v -> Tools.swapFragment(requireActivity(), OptiFineInstallFragment.class,
|
||||
OptiFineInstallFragment.TAG, null));
|
||||
view.findViewById(R.id.optifine_profile).setOnClickListener(v ->
|
||||
tryInstall(OptiFineInstallFragment.class, OptiFineInstallFragment.TAG));
|
||||
view.findViewById(R.id.modded_profile_fabric).setOnClickListener((v)->
|
||||
Tools.swapFragment(requireActivity(), FabricInstallFragment.class, FabricInstallFragment.TAG, null));
|
||||
tryInstall(FabricInstallFragment.class, FabricInstallFragment.TAG));
|
||||
view.findViewById(R.id.modded_profile_forge).setOnClickListener((v)->
|
||||
Tools.swapFragment(requireActivity(), ForgeInstallFragment.class, ForgeInstallFragment.TAG, null));
|
||||
tryInstall(ForgeInstallFragment.class, ForgeInstallFragment.TAG));
|
||||
view.findViewById(R.id.modded_profile_modpack).setOnClickListener((v)->
|
||||
Tools.swapFragment(requireActivity(), SearchModFragment.class, SearchModFragment.TAG, null));
|
||||
tryInstall(SearchModFragment.class, SearchModFragment.TAG));
|
||||
view.findViewById(R.id.modded_profile_quilt).setOnClickListener((v)->
|
||||
Tools.swapFragment(requireActivity(), QuiltInstallFragment.class, QuiltInstallFragment.TAG, null));
|
||||
tryInstall(QuiltInstallFragment.class, QuiltInstallFragment.TAG));
|
||||
view.findViewById(R.id.modded_profile_bta).setOnClickListener((v)->
|
||||
Tools.swapFragment(requireActivity(), BTAInstallFragment.class, BTAInstallFragment.TAG, null));
|
||||
tryInstall(BTAInstallFragment.class, BTAInstallFragment.TAG));
|
||||
}
|
||||
|
||||
private void tryInstall(Class<? extends Fragment> fragmentClass, String tag){
|
||||
if(Tools.isLocalProfile(requireContext()) || Tools.isDemoProfile(requireContext())){
|
||||
Toast.makeText(requireContext(), R.string.toast_not_available_demo, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
Tools.swapFragment(requireActivity(), fragmentClass, tag, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -1,5 +1,7 @@
|
||||
package net.kdt.pojavlaunch.modloaders;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.kdt.mcgui.ProgressLayout;
|
||||
|
||||
import net.kdt.pojavlaunch.JMinecraftVersionList;
|
||||
@@ -22,11 +24,13 @@ public class OptiFineDownloadTask implements Runnable, Tools.DownloaderFeedback,
|
||||
private final ModloaderDownloadListener mListener;
|
||||
private final Object mMinecraftDownloadLock = new Object();
|
||||
private Throwable mDownloaderThrowable;
|
||||
private final Activity activity;
|
||||
|
||||
public OptiFineDownloadTask(OptiFineUtils.OptiFineVersion mOptiFineVersion, ModloaderDownloadListener mListener) {
|
||||
public OptiFineDownloadTask(OptiFineUtils.OptiFineVersion mOptiFineVersion, ModloaderDownloadListener mListener, Activity activity) {
|
||||
this.mOptiFineVersion = mOptiFineVersion;
|
||||
this.mDestinationFile = new File(Tools.DIR_CACHE, "optifine-installer.jar");
|
||||
this.mListener = mListener;
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +93,7 @@ public class OptiFineDownloadTask implements Runnable, Tools.DownloaderFeedback,
|
||||
if(minecraftJsonVersion == null) return false;
|
||||
try {
|
||||
synchronized (mMinecraftDownloadLock) {
|
||||
new MinecraftDownloader().start(null, minecraftJsonVersion, minecraftVersion, this);
|
||||
new MinecraftDownloader().start(activity, minecraftJsonVersion, minecraftVersion, this);
|
||||
mMinecraftDownloadLock.wait();
|
||||
}
|
||||
}catch (InterruptedException e) {
|
||||
|
||||
-2
@@ -2,8 +2,6 @@ package net.kdt.pojavlaunch.prefs.screens;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.preference.PreferenceCategory;
|
||||
|
||||
@@ -39,8 +39,10 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
public class MinecraftDownloader {
|
||||
private static final double ONE_MEGABYTE = (1024d * 1024d);
|
||||
public static final String MINECRAFT_RES = "https://resources.download.minecraft.net/";
|
||||
private static final String MAVEN_CENTRAL_REPO1 = "https://repo1.maven.org/maven2/";
|
||||
private AtomicReference<Exception> mDownloaderThreadException;
|
||||
private ArrayList<DownloaderTask> mScheduledDownloadTasks;
|
||||
private ArrayList<File> mDeclaredNatives;
|
||||
private AtomicLong mProcessedFileCounter;
|
||||
private AtomicLong mProcessedSizeCounter; // Total bytes of processed files (passed SHA1 or downloaded)
|
||||
private AtomicLong mInternetUsageCounter; // How many bytes downloaded over Internet
|
||||
@@ -52,6 +54,8 @@ public class MinecraftDownloader {
|
||||
|
||||
private static final ThreadLocal<byte[]> sThreadLocalDownloadBuffer = new ThreadLocal<>();
|
||||
|
||||
private boolean isLocalProfile = false;
|
||||
|
||||
/**
|
||||
* Start the game version download process on the global executor service.
|
||||
* @param activity Activity, used for automatic installation of JRE 17 if needed
|
||||
@@ -62,6 +66,14 @@ public class MinecraftDownloader {
|
||||
public void start(@Nullable Activity activity, @Nullable JMinecraftVersionList.Version version,
|
||||
@NonNull String realVersion, // this was there for a reason
|
||||
@NonNull AsyncMinecraftDownloader.DoneListener listener) {
|
||||
if(activity != null){
|
||||
isLocalProfile = Tools.isLocalProfile(activity);
|
||||
Tools.switchDemo(Tools.isDemoProfile(activity));
|
||||
} else {
|
||||
isLocalProfile = true;
|
||||
Tools.switchDemo(true);
|
||||
}
|
||||
|
||||
sExecutorService.execute(() -> {
|
||||
try {
|
||||
downloadGame(activity, version, realVersion);
|
||||
@@ -88,6 +100,7 @@ public class MinecraftDownloader {
|
||||
|
||||
mTargetJarFile = createGameJarPath(versionName);
|
||||
mScheduledDownloadTasks = new ArrayList<>();
|
||||
mDeclaredNatives = new ArrayList<>();
|
||||
mProcessedFileCounter = new AtomicLong(0);
|
||||
mProcessedSizeCounter = new AtomicLong(0);
|
||||
mInternetUsageCounter = new AtomicLong(0);
|
||||
@@ -120,6 +133,7 @@ public class MinecraftDownloader {
|
||||
throw thrownException;
|
||||
} else {
|
||||
ensureJarFileCopy();
|
||||
extractNatives(versionName);
|
||||
}
|
||||
}catch (InterruptedException e) {
|
||||
// Interrupted while waiting, which means that the download was cancelled.
|
||||
@@ -167,6 +181,25 @@ public class MinecraftDownloader {
|
||||
org.apache.commons.io.FileUtils.copyFile(mSourceJarFile, mTargetJarFile, false);
|
||||
}
|
||||
|
||||
private void extractNatives(String versionName) throws IOException {
|
||||
if(mDeclaredNatives.isEmpty()) return;
|
||||
int totalCount = mDeclaredNatives.size();
|
||||
|
||||
ProgressLayout.setProgress(ProgressLayout.DOWNLOAD_MINECRAFT, 0,
|
||||
R.string.newdl_extracting_native_libraries, 0, totalCount);
|
||||
|
||||
File targetDirectory = new File(Tools.DIR_CACHE, "natives/"+versionName);
|
||||
FileUtils.ensureDirectory(targetDirectory);
|
||||
NativesExtractor nativesExtractor = new NativesExtractor(targetDirectory);
|
||||
int extractedCount = 0;
|
||||
for(File source : mDeclaredNatives) {
|
||||
nativesExtractor.extractFromAar(source);
|
||||
extractedCount++;
|
||||
ProgressLayout.setProgress(ProgressLayout.DOWNLOAD_MINECRAFT, extractedCount * 100 / totalCount,
|
||||
R.string.newdl_extracting_native_libraries, extractedCount, totalCount);
|
||||
}
|
||||
}
|
||||
|
||||
private File downloadGameJson(JMinecraftVersionList.Version verInfo) throws IOException, MirrorTamperedException {
|
||||
File targetFile = createGameJsonPath(verInfo.id);
|
||||
if(verInfo.sha1 == null && targetFile.canRead() && targetFile.isFile())
|
||||
@@ -256,7 +289,8 @@ public class MinecraftDownloader {
|
||||
long size, boolean skipIfFailed) throws IOException {
|
||||
FileUtils.ensureParentDirectory(targetFile);
|
||||
mTotalFileCount++;
|
||||
if(size < 0) {
|
||||
// Only attempt to check size if we still use the size counter and didn't switch to file counter.
|
||||
if(size <= 0 && !mUseFileCounter) {
|
||||
size = DownloadMirror.getContentLengthMirrored(downloadClass, url);
|
||||
}
|
||||
if(size < 0) {
|
||||
@@ -273,13 +307,31 @@ public class MinecraftDownloader {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the download of an AAR library containing the required natives, for later extraction
|
||||
* and adding to the library path.
|
||||
* @param baseRepository the source Maven repository to download from.
|
||||
* @param dependentLibrary the DependentLibrary to get the path from
|
||||
* @throws IOException in case if download scheduling fails.
|
||||
*/
|
||||
private void scheduleNativeLibraryDownload(String baseRepository, DependentLibrary dependentLibrary) throws IOException {
|
||||
String path = FileUtils.removeExtension(Tools.artifactToPath(dependentLibrary)) + ".aar";
|
||||
String downloadUrl = baseRepository + path;
|
||||
File targetPath = new File(Tools.DIR_HOME_LIBRARY, path);
|
||||
mDeclaredNatives.add(targetPath);
|
||||
scheduleDownload(targetPath, DownloadMirror.DOWNLOAD_CLASS_LIBRARIES, downloadUrl, null, 0, true);
|
||||
}
|
||||
|
||||
private void scheduleLibraryDownloads(DependentLibrary[] dependentLibraries) throws IOException {
|
||||
Tools.preProcessLibraries(dependentLibraries);
|
||||
growDownloadList(dependentLibraries.length);
|
||||
for(DependentLibrary dependentLibrary : dependentLibraries) {
|
||||
// Don't download lwjgl, we have our own bundled in.
|
||||
if(dependentLibrary.name.startsWith("org.lwjgl")) continue;
|
||||
|
||||
// Special handling for JNA Android natives
|
||||
if(dependentLibrary.name.startsWith("net.java.dev.jna:jna:")) {
|
||||
scheduleNativeLibraryDownload(MAVEN_CENTRAL_REPO1, dependentLibrary);
|
||||
}
|
||||
String libArtifactPath = Tools.artifactToPath(dependentLibrary);
|
||||
String sha1 = null, url = null;
|
||||
long size = 0;
|
||||
@@ -464,6 +516,10 @@ public class MinecraftDownloader {
|
||||
}
|
||||
|
||||
private void downloadFile() throws Exception {
|
||||
if(isLocalProfile){
|
||||
throw new RuntimeException("Download failed. Please make sure you are logged in with a Microsoft Account.");
|
||||
}
|
||||
|
||||
try {
|
||||
DownloadUtils.ensureSha1(mTargetPath, mTargetSha1, () -> {
|
||||
DownloadMirror.downloadFileMirrored(mDownloadClass, mTargetUrl, mTargetPath,
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
package net.kdt.pojavlaunch.tasks;
|
||||
|
||||
import net.kdt.pojavlaunch.Architecture;
|
||||
import net.kdt.pojavlaunch.Tools;
|
||||
import net.kdt.pojavlaunch.utils.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.zip.CRC32;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public class NativesExtractor {
|
||||
private static final ArrayList<String> LIBRARY_BLACKLIST = createLibraryBlacklist();
|
||||
private final File mDestinationDir;
|
||||
private final String mLibraryLocation;
|
||||
|
||||
public NativesExtractor(File mDestinationDir) {
|
||||
this.mDestinationDir = mDestinationDir;
|
||||
this.mLibraryLocation = "jni/"+getAarArchitectureName()+"/";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a library blacklist so that downloaded natives are not able to
|
||||
* override built-in libraries.
|
||||
* @return the resulting blacklist of library file names
|
||||
*/
|
||||
private static ArrayList<String> createLibraryBlacklist() {
|
||||
String[] includedLibraryNames = new File(Tools.NATIVE_LIB_DIR).list();
|
||||
ArrayList<String> blacklist = new ArrayList<>(includedLibraryNames.length);
|
||||
for(String libraryName : includedLibraryNames) {
|
||||
// allow overriding jnidispatch (as the integrated version may be too old)
|
||||
if(libraryName.equals("libjnidispatch.so")) continue;
|
||||
blacklist.add(libraryName);
|
||||
}
|
||||
blacklist.trimToSize();
|
||||
return blacklist;
|
||||
}
|
||||
|
||||
private static String getAarArchitectureName() {
|
||||
int architecture = Architecture.getDeviceArchitecture();
|
||||
switch (architecture) {
|
||||
case Architecture.ARCH_ARM:
|
||||
return "armeabi-v7a";
|
||||
case Architecture.ARCH_ARM64:
|
||||
return "arm64-v8a";
|
||||
case Architecture.ARCH_X86:
|
||||
return "x86";
|
||||
case Architecture.ARCH_X86_64:
|
||||
return "x86_64";
|
||||
}
|
||||
throw new RuntimeException("Unknown CPU architecture: "+architecture);
|
||||
}
|
||||
|
||||
public void extractFromAar(File source) throws IOException {
|
||||
byte[] buffer = new byte[8192];
|
||||
try (FileInputStream fileInputStream = new FileInputStream(source);
|
||||
ZipInputStream zipInputStream = new ZipInputStream(fileInputStream)) {
|
||||
// Wrap the ZIP input stream into a non-closeable stream to
|
||||
// avoid it being closed by processEntry()
|
||||
NonCloseableInputStream entryCopyStream = new NonCloseableInputStream(zipInputStream);
|
||||
ZipEntry entry;
|
||||
while((entry = zipInputStream.getNextEntry()) != null) {
|
||||
String entryName = entry.getName();
|
||||
if(!entryName.startsWith(mLibraryLocation) || entry.isDirectory()) continue;
|
||||
// Entry name is actually the full path, so we need to strip the path before extraction
|
||||
entryName = FileUtils.getFileName(entryName);
|
||||
// getFileName may make the file name null, avoid that case.
|
||||
if(entryName == null || LIBRARY_BLACKLIST.contains(entryName)) continue;
|
||||
|
||||
processEntry(entryCopyStream, entry, new File(mDestinationDir, entryName), buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static long fileCrc32(File target, byte[] buffer) throws IOException {
|
||||
try(FileInputStream fileInputStream = new FileInputStream(target)) {
|
||||
CRC32 crc32 = new CRC32();
|
||||
int len;
|
||||
while((len = fileInputStream.read(buffer)) != -1) {
|
||||
crc32.update(buffer, 0, len);
|
||||
}
|
||||
return crc32.getValue();
|
||||
}
|
||||
}
|
||||
|
||||
private void processEntry(InputStream sourceStream, ZipEntry zipEntry, File entryDestination, byte[] buffer) throws IOException {
|
||||
if(entryDestination.exists()) {
|
||||
long expectedSize = zipEntry.getSize();
|
||||
long expectedCrc32 = zipEntry.getCrc();
|
||||
long realSize = entryDestination.length();
|
||||
long realCrc32 = fileCrc32(entryDestination, buffer);
|
||||
// File in archive is the same as the local one, don't extract
|
||||
if(realSize == expectedSize && realCrc32 == expectedCrc32) return;
|
||||
}
|
||||
// copyInputStreamToFile copies the stream to a file and then closes it.
|
||||
org.apache.commons.io.FileUtils.copyInputStreamToFile(sourceStream, entryDestination);
|
||||
}
|
||||
|
||||
|
||||
private static class NonCloseableInputStream extends FilterInputStream {
|
||||
|
||||
protected NonCloseableInputStream(InputStream in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// Do nothing (the point of this class)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.apache.commons.io.*;
|
||||
@SuppressWarnings("IOStreamConstructor")
|
||||
public class DownloadUtils {
|
||||
public static final String USER_AGENT = Tools.APP_NAME;
|
||||
private static final int TIME_OUT = 10000;
|
||||
|
||||
public static void download(String url, OutputStream os) throws IOException {
|
||||
download(new URL(url), os);
|
||||
@@ -26,7 +27,8 @@ public class DownloadUtils {
|
||||
// System.out.println("Connecting: " + url.toString());
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestProperty("User-Agent", USER_AGENT);
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setConnectTimeout(TIME_OUT);
|
||||
conn.setReadTimeout(TIME_OUT);
|
||||
conn.setDoInput(true);
|
||||
conn.connect();
|
||||
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
|
||||
@@ -67,6 +69,8 @@ public class DownloadUtils {
|
||||
FileUtils.ensureParentDirectory(outputFile);
|
||||
|
||||
HttpURLConnection conn = (HttpURLConnection) new URL(urlInput).openConnection();
|
||||
conn.setConnectTimeout(TIME_OUT);
|
||||
conn.setReadTimeout(TIME_OUT);
|
||||
InputStream readStr = conn.getInputStream();
|
||||
try (FileOutputStream fos = new FileOutputStream(outputFile)) {
|
||||
int current;
|
||||
@@ -81,8 +85,9 @@ public class DownloadUtils {
|
||||
monitor.updateProgress(overall, length);
|
||||
}
|
||||
conn.disconnect();
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Unable to download from " + urlInput, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static <T> T downloadStringCached(String url, String cacheName, ParseCallback<T> parseCallback) throws IOException, ParseException{
|
||||
|
||||
@@ -24,6 +24,17 @@ public class FileUtils {
|
||||
return pathOrUrl.substring(lastSlashIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the extension (all text after the last dot) from a path/URL string.
|
||||
* @param pathOrUrl the path or the URL of the file
|
||||
* @return the input with the extension removed
|
||||
*/
|
||||
public static String removeExtension(String pathOrUrl) {
|
||||
int lastDotIndex = pathOrUrl.lastIndexOf('.');
|
||||
if(lastDotIndex == -1) return pathOrUrl;
|
||||
return pathOrUrl.substring(0, lastDotIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that a directory exists, is a directory and is writable.
|
||||
* @param targetFile the directory to check
|
||||
|
||||
@@ -223,18 +223,6 @@ public class JREUtils {
|
||||
envMap.put("AWTSTUB_WIDTH", Integer.toString(CallbackBridge.windowWidth > 0 ? CallbackBridge.windowWidth : CallbackBridge.physicalWidth));
|
||||
envMap.put("AWTSTUB_HEIGHT", Integer.toString(CallbackBridge.windowHeight > 0 ? CallbackBridge.windowHeight : CallbackBridge.physicalHeight));
|
||||
|
||||
File customEnvFile = new File(Tools.DIR_GAME_HOME, "custom_env.txt");
|
||||
if (customEnvFile.exists() && customEnvFile.isFile()) {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(customEnvFile));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
// Not use split() as only split first one
|
||||
int index = line.indexOf("=");
|
||||
envMap.put(line.substring(0, index), line.substring(index + 1));
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
|
||||
GLInfoUtils.GLInfo info = GLInfoUtils.getGlInfo();
|
||||
if(!envMap.containsKey("LIBGL_ES") && LOCAL_RENDERER != null) {
|
||||
int glesMajor = info.glesMajorVersion;
|
||||
@@ -256,6 +244,8 @@ public class JREUtils {
|
||||
envMap.put("POJAV_LOAD_TURNIP", "1");
|
||||
}
|
||||
|
||||
readCustomEnv(envMap); // Must be last so it overrides anything the user sets for obvious reasons.
|
||||
|
||||
for (Map.Entry<String, String> env : envMap.entrySet()) {
|
||||
Logger.appendToLog("Added custom env: " + env.getKey() + "=" + env.getValue());
|
||||
try {
|
||||
@@ -274,6 +264,19 @@ public class JREUtils {
|
||||
// return ldLibraryPath;
|
||||
}
|
||||
|
||||
private static void readCustomEnv(Map<String, String> envMap) throws IOException {
|
||||
File customEnvFile = new File(Tools.DIR_GAME_HOME, "custom_env.txt");
|
||||
if (customEnvFile.exists() && customEnvFile.isFile()) {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(customEnvFile));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
// Not use split() as only split first one
|
||||
int index = line.indexOf("=");
|
||||
envMap.put(line.substring(0, index), line.substring(index + 1));
|
||||
}
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
public static void launchJavaVM(final AppCompatActivity activity, final Runtime runtime, File gameDirectory, final List<String> JVMArgs, final String userArgsString) throws Throwable {
|
||||
String runtimeHome = MultiRTUtils.getRuntimeHome(runtime.name).getAbsolutePath();
|
||||
|
||||
|
||||
@@ -45,7 +45,11 @@ public class MinecraftAccount {
|
||||
}
|
||||
|
||||
public boolean isLocal(){
|
||||
return accessToken.equals("0");
|
||||
return accessToken.equals("0") && !username.startsWith("Demo.");
|
||||
}
|
||||
|
||||
public boolean isDemo(){
|
||||
return username.startsWith("Demo.");
|
||||
}
|
||||
|
||||
public void updateSkinFace() {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import java.util.UUID;
|
||||
|
||||
public class LauncherProfiles {
|
||||
public static MinecraftLauncherProfiles mainProfileJson;
|
||||
private static final File launcherProfilesFile = new File(Tools.DIR_GAME_NEW, "launcher_profiles.json");
|
||||
private static final File launcherProfilesFile = new File(Tools.GAME_PROFILES_FILE);
|
||||
|
||||
/** Reload the profile from the file, creating a default one if necessary */
|
||||
public static void load(){
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.lwjgl.glfw;
|
||||
|
||||
import net.kdt.pojavlaunch.*;
|
||||
import net.kdt.pojavlaunch.customcontrols.gamepad.direct.DirectGamepadEnableHandler;
|
||||
|
||||
import android.content.*;
|
||||
import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
@@ -8,6 +10,10 @@ import android.view.Choreographer;
|
||||
import androidx.annotation.Keep;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import dalvik.annotation.optimization.CriticalNative;
|
||||
@@ -16,6 +22,8 @@ public class CallbackBridge {
|
||||
public static final Choreographer sChoreographer = Choreographer.getInstance();
|
||||
private static boolean isGrabbing = false;
|
||||
private static final ArrayList<GrabListener> grabListeners = new ArrayList<>();
|
||||
// Use a weak reference here to avoid possibly statically referencing a Context.
|
||||
private static @Nullable WeakReference<DirectGamepadEnableHandler> sDirectGamepadEnableHandler;
|
||||
|
||||
public static final int CLIPBOARD_COPY = 2000;
|
||||
public static final int CLIPBOARD_PASTE = 2001;
|
||||
@@ -27,6 +35,10 @@ public class CallbackBridge {
|
||||
public volatile static boolean holdingAlt, holdingCapslock, holdingCtrl,
|
||||
holdingNumlock, holdingShift;
|
||||
|
||||
public static final ByteBuffer sGamepadButtonBuffer;
|
||||
public static final FloatBuffer sGamepadAxisBuffer;
|
||||
public static boolean sGamepadDirectInput = false;
|
||||
|
||||
public static void putMouseEventWithCoords(int button, float x, float y) {
|
||||
putMouseEventWithCoords(button, true, x, y);
|
||||
sChoreographer.postFrameCallbackDelayed(l -> putMouseEventWithCoords(button, false, x, y), 33);
|
||||
@@ -165,6 +177,16 @@ public class CallbackBridge {
|
||||
}
|
||||
}
|
||||
|
||||
//Called from JRE side
|
||||
@SuppressWarnings("unused")
|
||||
@Keep
|
||||
private static void onDirectInputEnable() {
|
||||
Log.i("CallbackBridge", "onDirectInputEnable()");
|
||||
DirectGamepadEnableHandler enableHandler = Tools.getWeakReference(sDirectGamepadEnableHandler);
|
||||
if(enableHandler != null) enableHandler.onDirectGamepadEnabled();
|
||||
sGamepadDirectInput = true;
|
||||
}
|
||||
|
||||
//Called from JRE side
|
||||
@SuppressWarnings("unused")
|
||||
@Keep
|
||||
@@ -194,6 +216,16 @@ public class CallbackBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static FloatBuffer createGamepadAxisBuffer() {
|
||||
ByteBuffer axisByteBuffer = nativeCreateGamepadAxisBuffer();
|
||||
// NOTE: hardcoded order (also in jre_lwjgl3glfw CallbackBridge)
|
||||
return axisByteBuffer.order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer();
|
||||
}
|
||||
|
||||
public static void setDirectGamepadEnableHandler(DirectGamepadEnableHandler h) {
|
||||
sDirectGamepadEnableHandler = new WeakReference<>(h);
|
||||
}
|
||||
|
||||
@Keep @CriticalNative public static native void nativeSetUseInputStackQueue(boolean useInputStackQueue);
|
||||
|
||||
@Keep @CriticalNative private static native boolean nativeSendChar(char codepoint);
|
||||
@@ -206,8 +238,12 @@ public class CallbackBridge {
|
||||
@Keep @CriticalNative private static native void nativeSendScroll(double xoffset, double yoffset);
|
||||
@Keep @CriticalNative private static native void nativeSendScreenSize(int width, int height);
|
||||
public static native void nativeSetWindowAttrib(int attrib, int value);
|
||||
private static native ByteBuffer nativeCreateGamepadButtonBuffer();
|
||||
private static native ByteBuffer nativeCreateGamepadAxisBuffer();
|
||||
static {
|
||||
System.loadLibrary("pojavexec");
|
||||
sGamepadButtonBuffer = nativeCreateGamepadButtonBuffer();
|
||||
sGamepadAxisBuffer = createGamepadAxisBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,11 @@ typedef void GLFW_invoke_Key_func(void* window, int key, int scancode, int actio
|
||||
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 struct {
|
||||
unsigned char buttons [15];
|
||||
float axes[6];
|
||||
} GLFWgamepadstate;
|
||||
|
||||
struct pojav_environ_s {
|
||||
struct ANativeWindow* pojavWindow;
|
||||
basic_render_window_t* mainWindowBundle;
|
||||
@@ -42,6 +47,7 @@ struct pojav_environ_s {
|
||||
double cursorX, cursorY, cLastX, cLastY;
|
||||
jmethodID method_accessAndroidClipboard;
|
||||
jmethodID method_onGrabStateChanged;
|
||||
jmethodID method_onDirectInputEnable;
|
||||
jmethodID method_glftSetWindowAttrib;
|
||||
jmethodID method_internalWindowSizeChanged;
|
||||
jmethodID method_internalChangeMonitorSize;
|
||||
@@ -57,6 +63,7 @@ struct pojav_environ_s {
|
||||
bool isInputReady, isCursorEntered, isUseStackQueueCall, shouldUpdateMouse;
|
||||
bool shouldUpdateMonitorSize, monitorSizeConsumed;
|
||||
int savedWidth, savedHeight;
|
||||
GLFWgamepadstate gamepadState;
|
||||
#define ADD_CALLBACK_WWIN(NAME) \
|
||||
GLFW_invoke_##NAME##_func* GLFW_invoke_##NAME;
|
||||
ADD_CALLBACK_WWIN(Char);
|
||||
|
||||
@@ -32,6 +32,15 @@
|
||||
#define EVENT_TYPE_MOUSE_BUTTON 1006
|
||||
#define EVENT_TYPE_SCROLL 1007
|
||||
|
||||
#define TRY_ATTACH_ENV(env_name, vm, error_message, then) JNIEnv* env_name;\
|
||||
do { \
|
||||
env_name = get_attached_env(vm); \
|
||||
if(env_name == NULL) { \
|
||||
printf(error_message); \
|
||||
then \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
static void registerFunctions(JNIEnv *env);
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) {
|
||||
@@ -44,6 +53,7 @@ jint JNI_OnLoad(JavaVM* vm, __attribute__((unused)) void* reserved) {
|
||||
pojav_environ->bridgeClazz = (*dvEnv)->NewGlobalRef(dvEnv,(*dvEnv) ->FindClass(dvEnv,"org/lwjgl/glfw/CallbackBridge"));
|
||||
pojav_environ->method_accessAndroidClipboard = (*dvEnv)->GetStaticMethodID(dvEnv, pojav_environ->bridgeClazz, "accessAndroidClipboard", "(ILjava/lang/String;)Ljava/lang/String;");
|
||||
pojav_environ->method_onGrabStateChanged = (*dvEnv)->GetStaticMethodID(dvEnv, pojav_environ->bridgeClazz, "onGrabStateChanged", "(Z)V");
|
||||
pojav_environ->method_onDirectInputEnable = (*dvEnv)->GetStaticMethodID(dvEnv, pojav_environ->bridgeClazz, "onDirectInputEnable", "()V");
|
||||
pojav_environ->isUseStackQueueCall = JNI_FALSE;
|
||||
} else if (pojav_environ->dalvikJavaVMPtr != vm) {
|
||||
LOGI("Saving JVM environ...");
|
||||
@@ -249,7 +259,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNI
|
||||
(*pojav_environ->dalvikJavaVMPtr)->AttachCurrentThread(pojav_environ->dalvikJavaVMPtr, &dalvikEnv, NULL);
|
||||
assert(dalvikEnv != NULL);
|
||||
assert(pojav_environ->bridgeClazz != NULL);
|
||||
|
||||
|
||||
LOGD("Clipboard: Converting string\n");
|
||||
char *copySrcC;
|
||||
jstring copyDst = NULL;
|
||||
@@ -262,7 +272,7 @@ JNIEXPORT jstring JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeClipboard(JNI
|
||||
jstring pasteDst = convertStringJVM(dalvikEnv, env, (jstring) (*dalvikEnv)->CallStaticObjectMethod(dalvikEnv, pojav_environ->bridgeClazz, pojav_environ->method_accessAndroidClipboard, action, copyDst));
|
||||
|
||||
if (copySrc) {
|
||||
(*dalvikEnv)->DeleteLocalRef(dalvikEnv, copyDst);
|
||||
(*dalvikEnv)->DeleteLocalRef(dalvikEnv, copyDst);
|
||||
(*env)->ReleaseByteArrayElements(env, copySrc, (jbyte *)copySrcC, 0);
|
||||
}
|
||||
(*pojav_environ->dalvikJavaVMPtr)->DetachCurrentThread(pojav_environ->dalvikJavaVMPtr);
|
||||
@@ -283,13 +293,18 @@ JNIEXPORT jboolean JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetInputRead
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetGrabbing(__attribute__((unused)) JNIEnv* env, __attribute__((unused)) jclass clazz, jboolean grabbing) {
|
||||
JNIEnv *dalvikEnv;
|
||||
(*pojav_environ->dalvikJavaVMPtr)->AttachCurrentThread(pojav_environ->dalvikJavaVMPtr, &dalvikEnv, NULL);
|
||||
(*dalvikEnv)->CallStaticVoidMethod(dalvikEnv, pojav_environ->bridgeClazz, pojav_environ->method_onGrabStateChanged, grabbing);
|
||||
(*pojav_environ->dalvikJavaVMPtr)->DetachCurrentThread(pojav_environ->dalvikJavaVMPtr);
|
||||
TRY_ATTACH_ENV(dvm_env, pojav_environ->dalvikJavaVMPtr, "nativeSetGrabbing failed!\n", return;);
|
||||
(*dvm_env)->CallStaticVoidMethod(dvm_env, pojav_environ->bridgeClazz, pojav_environ->method_onGrabStateChanged, grabbing);
|
||||
pojav_environ->isGrabbing = grabbing;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_lwjgl_glfw_CallbackBridge_nativeEnableGamepadDirectInput(__attribute__((unused)) JNIEnv *env, __attribute__((unused)) jclass clazz) {
|
||||
TRY_ATTACH_ENV(dvm_env, pojav_environ->dalvikJavaVMPtr, "nativeEnableGamepadDirectInput failed!\n", return JNI_FALSE;);
|
||||
(*dvm_env)->CallStaticVoidMethod(dvm_env, pojav_environ->bridgeClazz, pojav_environ->method_onDirectInputEnable);
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
jboolean critical_send_char(jchar codepoint) {
|
||||
if (pojav_environ->GLFW_invoke_Char && pojav_environ->isInputReady) {
|
||||
if (pojav_environ->isUseStackQueueCall) {
|
||||
@@ -449,7 +464,7 @@ JNIEXPORT void JNICALL Java_org_lwjgl_glfw_CallbackBridge_nativeSetWindowAttrib(
|
||||
// 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
|
||||
|
||||
JNIEnv *jvm_env = get_attached_env(pojav_environ->runtimeJavaVMPtr);
|
||||
TRY_ATTACH_ENV(jvm_env, pojav_environ->runtimeJavaVMPtr, "nativeSetWindowAttrib failed: %i", return;);
|
||||
|
||||
(*jvm_env)->CallStaticVoidMethod(
|
||||
jvm_env, pojav_environ->vmGlfwClass,
|
||||
@@ -524,3 +539,18 @@ static void registerFunctions(JNIEnv *env) {
|
||||
use_critical_cc ? critical_fcns : noncritical_fcns,
|
||||
sizeof(critical_fcns)/sizeof(critical_fcns[0]));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_org_lwjgl_glfw_GLFW_internalGetGamepadDataPointer(JNIEnv *env, jclass clazz) {
|
||||
return (jlong) &pojav_environ->gamepadState;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_lwjgl_glfw_CallbackBridge_nativeCreateGamepadButtonBuffer(JNIEnv *env, jclass clazz) {
|
||||
return (*env)->NewDirectByteBuffer(env, &pojav_environ->gamepadState.buttons, sizeof(pojav_environ->gamepadState.buttons));
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL
|
||||
Java_org_lwjgl_glfw_CallbackBridge_nativeCreateGamepadAxisBuffer(JNIEnv *env, jclass clazz) {
|
||||
return (*env)->NewDirectByteBuffer(env, &pojav_environ->gamepadState.axes, sizeof(pojav_environ->gamepadState.axes));
|
||||
}
|
||||
@@ -164,7 +164,7 @@ JNIEnv* get_attached_env(JavaVM* jvm) {
|
||||
env_result = (*jvm)->AttachCurrentThread(jvm, &jvm_env, NULL);
|
||||
}
|
||||
if(env_result != JNI_OK) {
|
||||
printf("get_attached_env failed: %i", env_result);
|
||||
printf("get_attached_env failed: %i\n", env_result);
|
||||
return NULL;
|
||||
}
|
||||
return jvm_env;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -27,6 +27,7 @@
|
||||
</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>
|
||||
|
||||
@@ -252,7 +252,7 @@
|
||||
<string name="main_add_account">Add account</string>
|
||||
<string name="tasks_ongoing">Tasks are in progress, please wait</string>
|
||||
<string name="no_saved_accounts">No saved accounts</string>
|
||||
<string name="mc_download_failed">Failed to download Minecraft! This could be due to bad network connection, incorrectly placed files, etc..</string>
|
||||
<string name="mc_download_failed">Failed to download Minecraft! This could be due to bad network connection, incorrectly placed files, trying to download Minecraft from a Local account, etc..</string>
|
||||
<string name="xerr_unknown">Unknown Xbox Live API error %d</string>
|
||||
<string name="xerr_no_account">You don\'t seem to have an Xbox Live account. Please log in once on https://minecraft.net/ and try again.</string>
|
||||
<string name="xerr_adult_verification">An adult needs to verify your account.</string>
|
||||
@@ -429,4 +429,6 @@
|
||||
<string name="bta_installer_available_versions">Supported BTA versions</string>
|
||||
<string name="bta_installer_untested_versions">Untested BTA versions</string>
|
||||
<string name="bta_installer_nightly_versions">Nightly BTA versions</string>
|
||||
<string name="newdl_extracting_native_libraries">Extracting native libraries (%d/%d)</string>
|
||||
<string name="toast_not_available_demo">This is not available in demo mode</string>
|
||||
</resources>
|
||||
@@ -6,12 +6,15 @@ java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes("Manifest-Version": "1.0",
|
||||
"PreMain-Class": "git.artdeell.arcdns.ArcDNSInjectorAgent")
|
||||
}
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/arc_dns_injector/version")
|
||||
versionFile.write(String.valueOf(new Date().getTime()))
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/arc_dns_injector/version")
|
||||
versionFile.write(getGitHash(project.name))
|
||||
}
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/arc_dns_injector/"))
|
||||
}
|
||||
@@ -1 +1,33 @@
|
||||
import java.io.IOException
|
||||
plugins{
|
||||
id 'com.android.application' version '8.7.2' apply false
|
||||
id 'com.android.library' version '8.7.2' apply false
|
||||
}
|
||||
|
||||
String getGitHash(String project) {
|
||||
def command = Runtime.getRuntime().exec("git rev-list -1 HEAD " + project)
|
||||
def returnCode = command.waitFor()
|
||||
if (returnCode != 0) {
|
||||
throw new IOException("Command 'getGitHash()' exited with " + returnCode)
|
||||
}
|
||||
String gitCommitHash = command.inputStream.text.trim()
|
||||
return gitCommitHash
|
||||
}
|
||||
|
||||
Boolean gitUsed() {
|
||||
def returnCode = Runtime.getRuntime().exec("git rev-parse --is-inside-work-tree").waitFor()
|
||||
switch(returnCode){
|
||||
case 127:
|
||||
println("git not found");
|
||||
return false;
|
||||
break;
|
||||
case 128:
|
||||
println("not inside a git repository");
|
||||
return false;
|
||||
break;
|
||||
case 0:
|
||||
return true;
|
||||
default:
|
||||
throw new IOException("Command 'gitUsed()' exited with " + returnCode)
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,13 @@ jar {
|
||||
from {
|
||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||
}
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/forge_installer/version")
|
||||
versionFile.write(String.valueOf(new Date().getTime()))
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/forge_installer/version")
|
||||
versionFile.write(getGitHash(project.name))
|
||||
}
|
||||
manifest {
|
||||
attributes("Manifest-Version": "1.0",
|
||||
"PreMain-Class": "git.artdeell.installer_agent.Agent")
|
||||
}
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/forge_installer/"))
|
||||
}
|
||||
}
|
||||
-1
Submodule gl4es deleted from b9c0c79dd9.
+1
-1
@@ -1,7 +1,7 @@
|
||||
#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-8.13-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -10,9 +10,10 @@ jar {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
archiveBaseName = "lwjgl-glfw-classes"
|
||||
destinationDirectory.set(file("../app_pojavlauncher/src/main/assets/components/lwjgl3/"))
|
||||
// Auto update the version with a timestamp so the project jar gets updated by Pojav
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/lwjgl3/version")
|
||||
versionFile.write(String.valueOf(new Date().getTime()))
|
||||
if (gitUsed()){
|
||||
File versionFile = file("../app_pojavlauncher/src/main/assets/components/lwjgl3/version")
|
||||
versionFile.write(getGitHash(project.name))
|
||||
}
|
||||
from {
|
||||
configurations.default.collect {
|
||||
println(it.getName())
|
||||
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
package org.lwjgl.glfw;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.*;
|
||||
|
||||
public class CallbackBridge {
|
||||
@@ -18,6 +19,8 @@ public class CallbackBridge {
|
||||
public static final int ANDROID_TYPE_GRAB_STATE = 0;
|
||||
|
||||
public static final boolean INPUT_DEBUG_ENABLED;
|
||||
|
||||
public static boolean sGamepadDirectEnabled;
|
||||
|
||||
// TODO send grab state event to Android
|
||||
|
||||
@@ -40,6 +43,11 @@ public class CallbackBridge {
|
||||
}
|
||||
|
||||
|
||||
public static void enableGamepadDirectInput() {
|
||||
if(sGamepadDirectEnabled) return;
|
||||
sGamepadDirectEnabled = nativeEnableGamepadDirectInput();
|
||||
}
|
||||
|
||||
public static void sendData(int type, String data) {
|
||||
nativeSendData(false, type, data);
|
||||
}
|
||||
@@ -47,5 +55,8 @@ public class CallbackBridge {
|
||||
public static native boolean nativeSetInputReady(boolean ready);
|
||||
public static native String nativeClipboard(int action, byte[] copy);
|
||||
public static native void nativeSetGrabbing(boolean grab);
|
||||
public static native ByteBuffer nativeCreateGamepadButtonBuffer();
|
||||
public static native ByteBuffer nativeCreateGamepadAxisBuffer();
|
||||
private static native boolean nativeEnableGamepadDirectInput();
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import javax.annotation.*;
|
||||
|
||||
import org.lwjgl.*;
|
||||
import org.lwjgl.system.*;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import static org.lwjgl.opengl.GL20.*;
|
||||
import static org.lwjgl.system.APIUtil.*;
|
||||
@@ -24,8 +25,9 @@ import java.util.*;
|
||||
|
||||
public class GLFW
|
||||
{
|
||||
static FloatBuffer joystickData = (FloatBuffer)FloatBuffer.allocate(8).flip();
|
||||
static ByteBuffer buttonData = (ByteBuffer)ByteBuffer.allocate(8).flip();
|
||||
static FloatBuffer joystickAxisData;
|
||||
static ByteBuffer joystickButtonData;
|
||||
static ByteBuffer empty = (ByteBuffer)ByteBuffer.allocate(0);
|
||||
/** The major version number of the GLFW library. This is incremented when the API is changed in non-compatible ways. */
|
||||
public static final int GLFW_VERSION_MAJOR = 3;
|
||||
|
||||
@@ -515,6 +517,7 @@ public class GLFW
|
||||
private static final String PROP_WINDOW_WIDTH = "glfwstub.windowWidth";
|
||||
private static final String PROP_WINDOW_HEIGHT= "glfwstub.windowHeight";
|
||||
public static long mainContext = 0;
|
||||
private static long gamepadDataPointer;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -636,6 +639,8 @@ public class GLFW
|
||||
return win;
|
||||
}
|
||||
|
||||
private static native long internalGetGamepadDataPointer();
|
||||
|
||||
// Generated stub callback methods
|
||||
public static GLFWCharCallback glfwSetCharCallback(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("GLFWcharfun") GLFWCharCallbackI cbfun) {
|
||||
GLFWCharCallback lastCallback = mGLFWCharCallback;
|
||||
@@ -805,6 +810,10 @@ public class GLFW
|
||||
mGLFWInitialTime = (double) System.nanoTime();
|
||||
long __functionAddress = Functions.Init;
|
||||
isGLFWReady = invokeI(__functionAddress) != 0;
|
||||
gamepadDataPointer = internalGetGamepadDataPointer();
|
||||
// NOTE: hardcoded order (also in android CallbackBridge)
|
||||
joystickAxisData = CallbackBridge.nativeCreateGamepadAxisBuffer().order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer();
|
||||
joystickButtonData = CallbackBridge.nativeCreateGamepadButtonBuffer();
|
||||
}
|
||||
return isGLFWReady;
|
||||
}
|
||||
@@ -1207,50 +1216,60 @@ public class GLFW
|
||||
}
|
||||
|
||||
public static boolean glfwJoystickPresent(int jid) {
|
||||
if(jid == 0) {
|
||||
if(jid == GLFW_JOYSTICK_1) {
|
||||
CallbackBridge.enableGamepadDirectInput();
|
||||
return true;
|
||||
}else return false;
|
||||
}
|
||||
public static String glfwGetJoystickName(int jid) {
|
||||
if(jid == 0) {
|
||||
return "AIC event bus controller";
|
||||
if(jid == GLFW_JOYSTICK_1) {
|
||||
return "Pojav XBOX 360 compatible gamepad";
|
||||
}else return null;
|
||||
}
|
||||
public static FloatBuffer glfwGetJoystickAxes(int jid) {
|
||||
if(jid == 0) {
|
||||
return joystickData;
|
||||
if(jid == GLFW_JOYSTICK_1) {
|
||||
return joystickAxisData;
|
||||
}else return null;
|
||||
}
|
||||
public static ByteBuffer glfwGetJoystickButtons(int jid) {
|
||||
if(jid == 0) {
|
||||
return buttonData;
|
||||
if(jid == GLFW_JOYSTICK_1) {
|
||||
return joystickButtonData;
|
||||
}else return null;
|
||||
}
|
||||
public static ByteBuffer glfwGetjoystickHats(int jid) {
|
||||
return null;
|
||||
public static ByteBuffer glfwGetJoystickHats(int jid) {
|
||||
if(jid == GLFW_JOYSTICK_1) {
|
||||
return empty; // Maybe implement this later?
|
||||
}else return null;
|
||||
}
|
||||
public static boolean glfwJoystickIsGamepad(int jid) {
|
||||
if(jid == 0) return true;
|
||||
if(jid == GLFW_JOYSTICK_1) return true;
|
||||
else return false;
|
||||
}
|
||||
public static String glfwGetJoystickGUID(int jid) {
|
||||
if(jid == 0) return "aio0";
|
||||
// Return Xbox 360 controller GUID
|
||||
if(jid == GLFW_JOYSTICK_1) return "030000005e0400008e02000056210000";
|
||||
else return null;
|
||||
}
|
||||
|
||||
private static long mUserPointer;
|
||||
|
||||
public static long glfwGetJoystickUserPointer(int jid) {
|
||||
return 0;
|
||||
return mUserPointer;
|
||||
}
|
||||
public static void glfwSetJoystickUserPointer(int jid, long pointer) {
|
||||
|
||||
mUserPointer = pointer;
|
||||
}
|
||||
public static boolean glfwUpdateGamepadMappings(ByteBuffer string) {
|
||||
return false;
|
||||
}
|
||||
public static String glfwGetGamepadName(int jid) {
|
||||
return null;
|
||||
if(jid == GLFW_JOYSTICK_1) return "Pojav XBOX 360 compatible gamepad";
|
||||
else return null;
|
||||
}
|
||||
public static boolean glfwGetGamepadState(int jid, GLFWGamepadState state) {
|
||||
return false;
|
||||
if(jid != 0) return false;
|
||||
MemoryUtil.memCopy(gamepadDataPointer, state.address(), state.sizeof());
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Array version of: {@link #glfwGetVersion GetVersion} */
|
||||
@@ -1306,17 +1325,26 @@ public class GLFW
|
||||
*/
|
||||
|
||||
/** Array version of: {@link #glfwGetMonitorContentScale GetMonitorContentScale} */
|
||||
/*
|
||||
|
||||
public static void glfwGetMonitorContentScale(@NativeType("GLFWmonitor *") long monitor, @Nullable @NativeType("float *") float[] xscale, @Nullable @NativeType("float *") float[] yscale) {
|
||||
long __functionAddress = Functions.GetMonitorContentScale;
|
||||
if (CHECKS) {
|
||||
// check(monitor);
|
||||
checkSafe(xscale, 1);
|
||||
checkSafe(yscale, 1);
|
||||
}
|
||||
invokePPPV(monitor, xscale, yscale, __functionAddress);
|
||||
xscale[0] = 1;
|
||||
yscale[0] = 1;
|
||||
}
|
||||
|
||||
public static void glfwGetMonitorContentScale(@NativeType("GLFWmonitor *") long monitor, @NativeType("float *") @Nullable FloatBuffer xscale, @NativeType("float *") @Nullable FloatBuffer yscale) {
|
||||
if (CHECKS) {
|
||||
// check(monitor);
|
||||
checkSafe(xscale, 1);
|
||||
checkSafe(yscale, 1);
|
||||
}
|
||||
xscale.put(0, 1);
|
||||
yscale.put(0, 1);
|
||||
}
|
||||
*/
|
||||
|
||||
/** Array version of: {@link #glfwGetWindowPos GetWindowPos} */
|
||||
public static void glfwGetWindowPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("int *") int[] xpos, @Nullable @NativeType("int *") int[] ypos) {
|
||||
@@ -1376,7 +1404,7 @@ public class GLFW
|
||||
}
|
||||
invokePPPV(window, xscale, yscale, __functionAddress);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/** Array version of: {@link #glfwGetCursorPos GetCursorPos} */
|
||||
public static void glfwGetCursorPos(@NativeType("GLFWwindow *") long window, @Nullable @NativeType("double *") double[] xpos, @Nullable @NativeType("double *") double[] ypos) {
|
||||
|
||||
Reference in new issue
Block a user