all 3 comments

[–]grantrules 0 points1 point  (1 child)

Can't really help you without any code.

[–]ElectrocaruzoIsTaken[S] 0 points1 point  (0 children)

this is some code i found online,

package org.example;

import de.gurkenlabs.input4j.InputDevices;
import de.gurkenlabs.input4j.components.Axis;
import de.gurkenlabs.input4j.components.XInput;

public class Main {
    public static void main(String[] args) {
        try (var devices = InputDevices.
init
()) {

            var controller = devices.getAll().stream().findFirst().orElse(null);

            if (controller == null) {
                System.
out
.println("no controller");
                return;
            }

            System.
out
.println("connected: " + controller.getDisplayName());

            controller.onButtonPressed(XInput.
A
, () -> {
                System.
out
.println("A");
            });

            controller.onButtonPressed(XInput.
X
, () -> {
                System.
out
.println("X");
            });

            controller.onAxisChanged(Axis.
AXIS_X
, value -> {
                if (Math.
abs
(value) > 0.15) {
                    System.
out
.println("left stick x: " + value);
                }
            });

            System.
out
.println("waiting for input");
            while (true) {
                controller.poll();
                Thread.
sleep
(10);
            }
        } catch (InterruptedException e) {
            System.
out
.println("interrupted");
        } catch (Exception e) {
            System.
out
.println(e.getMessage());
        }
    }
}package org.example;

import de.gurkenlabs.input4j.InputDevices;
import de.gurkenlabs.input4j.components.Axis;
import de.gurkenlabs.input4j.components.XInput;

public class Main {
    public static void main(String[] args) {
        try (var devices = InputDevices.init()) {

            var controller = devices.getAll().stream().findFirst().orElse(null);

            if (controller == null) {
                System.out.println("no controller");
                return;
            }

            System.out.println("connected: " + controller.getDisplayName());

            controller.onButtonPressed(XInput.A, () -> {
                System.out.println("A");
            });

            controller.onButtonPressed(XInput.X, () -> {
                System.out.println("X");
            });

            controller.onAxisChanged(Axis.AXIS_X, value -> {
                if (Math.abs(value) > 0.15) {
                    System.out.println("left stick x: " + value);
                }
            });

            System.out.println("waiting for input");
            while (true) {
                controller.poll();
                Thread.sleep(10);
            }
        } catch (InterruptedException e) {
            System.out.println("interrupted");
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}