.Net Core based library, that allows getting the button presses and axis value changes of a gamepad or a Joystick.
The library was developed with Raspberry Pi in mind (but probably runs on any linux based device)
This is all you need to do to use it:
// You should provide the gamepad file you want to connect to. /dev/input/js0 is the default
using (var gamepad = new GamepadController("/dev/input/js0"))
{
// Configure this if you want to get events when the state of a button changes
gamepad.ButtonChanged += (object sender, ButtonEventArgs e) =>
{
Console.WriteLine($"Button {e.Button} Pressed: {e.Pressed}");
};
// Configure this if you want to get events when the state of an axis changes
gamepad.AxisChanged += (object sender, AxisEventArgs e) =>
{
Console.WriteLine($"Axis {e.Axis} Pressed: {e.Value}");
};
Console.ReadLine();
}
// Remember to Dispose the GamepadController, so it can finish the Task that listens for changes in the gamepad
If you are feeling generous and want to support this project, you could buy me a beer to energyze my programming nights using the button below.
Not to much please, I don't want to get drunk either!