Hot-download relevant Netty lib #24

Closed
opened 2023-07-21 18:16:58 +03:00 by Madis0 · 3 comments
Contributor

Would it be possible to download and use only the system-specific Netty Quic library, instead of bundling all of them? That could be done on the first time the user clicks "Open to LAN" and has internet access.

image

As a related example, Controlify prompts the user on whether they'd like to install the vibration support library, maybe something like that can be done for e4mc as well (without a prompt). I'm not fully sure how exactly it works nor where the relevant code excerpt is, so I've asked him to clarify.

Would it be possible to download and use only the system-specific Netty Quic library, instead of bundling all of them? That could be done on the first time the user clicks "Open to LAN" and has internet access. ![image](/attachments/8973a74d-f360-4ece-ae02-ca9311ba0409) As a related example, [Controlify](https://github.com/isXander/Controlify) prompts the user on whether they'd like to install the vibration support library, maybe something like that can be done for e4mc as well (without a prompt). I'm not fully sure how exactly it works nor where the relevant code excerpt is, so I've asked him to clarify.
5.4 KiB
Owner

yeah the current method is suboptimal to say the least
but I'm not sure if there's any good way to download them on-the-fly and still have them loaded properly by netty

yeah the current method is suboptimal to say the least but I'm not sure if there's any good way to download them on-the-fly and still have them loaded properly by netty
Author
Contributor

First, the library I download is SDL2: a very common library that is present on most systems in some form on Windows, macOS, Linux and even used on stuff such as the Playstation, and Nintendo Switch.
I still need to download it though as JNI requires actual cpp code, named "glue" code to be able to interface between the two languages.
It does more than just handle vibration, such as backup controller identification when hid4java doesn't work (namely macOS arm) and any other advanced stuff such as gyro control.

I download SDL2 directly from my own maven repository that I host (and build) myself.
https://github.com/isxander/sdl2-jni
Look at the github workflow to see how it is built and published to maven. The comments in SDL.java found inside the src folder of that repo are the glue code I mentioned earlier, the C++ code. I then use a custom library called gdx-jni-gen which automatically generates the CPP and headers that are used for JNI (java native access).

On first boot, the library is not downloaded until after the user says yes on the popup, then a property is set to true in the config for future.
From then on, with the property set to true, any updates for this library in a Controlify update is then downloaded automatically on boot, without any user input.

Once downloaded, I load the library like all others are using System.loadLibrary(), which loads the DLL (or whatever other format) into java, ready for use with JNI.

The handling of SDL2 on the Controlify side is all done inside of the following class.
https://github.com/isXander/Controlify/blob/1.20.x/dev/src/main/java/dev/isxander/controlify/controller/sdl2/SDL2NativesManager.java

I hope that answers all your questions!

https://discord.com/channels/780023008668287017/1131966865552449627 via https://discord.gg/B8khcbvAQz

> First, the library I download is SDL2: a very common library that is present on most systems in some form on Windows, macOS, Linux and even used on stuff such as the Playstation, and Nintendo Switch. I still need to download it though as JNI requires actual cpp code, named "glue" code to be able to interface between the two languages. It does more than just handle vibration, such as backup controller identification when hid4java doesn't work (namely macOS arm) and any other advanced stuff such as gyro control. > > I download SDL2 directly from my own maven repository that I host (and build) myself. <https://github.com/isxander/sdl2-jni> Look at the github workflow to see how it is built and published to maven. The comments in `SDL.java` found inside the `src` folder of that repo are the glue code I mentioned earlier, the C++ code. I then use a custom library called `gdx-jni-gen` which automatically generates the CPP and headers that are used for JNI (java native access). > > On first boot, the library is not downloaded until after the user says yes on the popup, then a property is set to true in the config for future. > From then on, with the property set to true, any updates for this library in a Controlify update is then downloaded automatically on boot, without any user input. > > Once downloaded, I load the library like all others are using `System.loadLibrary()`, which loads the DLL (or whatever other format) into java, ready for use with JNI. > > The handling of SDL2 on the Controlify side is all done inside of the following class. <https://github.com/isXander/Controlify/blob/1.20.x/dev/src/main/java/dev/isxander/controlify/controller/sdl2/SDL2NativesManager.java> > > I hope that answers all your questions! https://discord.com/channels/780023008668287017/1131966865552449627 via https://discord.gg/B8khcbvAQz
Owner

completed

completed
me closed this issue 2023-08-21 17:04:45 +03:00
Sign in to join this conversation.
No description provided.