项目作者: nahueltaibo

项目描述 :
.Net Core Gamepad library
高级语言: C#
项目地址: git://github.com/nahueltaibo/gamepad.git
创建时间: 2019-11-11T03:11:53Z
项目社区:https://github.com/nahueltaibo/gamepad

开源协议:MIT License

下载


Gamepad

Gamepad

.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:

  1. // You should provide the gamepad file you want to connect to. /dev/input/js0 is the default
  2. using (var gamepad = new GamepadController("/dev/input/js0"))
  3. {
  4. // Configure this if you want to get events when the state of a button changes
  5. gamepad.ButtonChanged += (object sender, ButtonEventArgs e) =>
  6. {
  7. Console.WriteLine($"Button {e.Button} Pressed: {e.Pressed}");
  8. };
  9. // Configure this if you want to get events when the state of an axis changes
  10. gamepad.AxisChanged += (object sender, AxisEventArgs e) =>
  11. {
  12. Console.WriteLine($"Axis {e.Axis} Pressed: {e.Value}");
  13. };
  14. Console.ReadLine();
  15. }
  16. // 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.

paypal

Not to much please, I don’t want to get drunk either!