Skip to content

Instantly share code, notes, and snippets.

@W4RH4WK
Last active January 3, 2020 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save W4RH4WK/966a4872d6bdf0dde2153b5846cce10d to your computer and use it in GitHub Desktop.
Save W4RH4WK/966a4872d6bdf0dde2153b5846cce10d to your computer and use it in GitHub Desktop.
// Instructions:
// 1) Add NuGet: glfw-net
// 2) Download official GLFW DLL (pre-compiled): https://www.glfw.org/download.html
// 3) Copy DLL to $(TargetDir) so it can be loaded
// 4) Rename DLL to glfw.dll
using GLFW;
using System;
using System.Threading;
namespace GlfwTest
{
class Program
{
static void Main(string[] args)
{
while (true)
{
for (int id = 0; id < 16; id++)
{
if (Glfw.GetGamepadState(id, out var state))
{
if (state.GetButtonState(GamePadButton.DpadUp) == InputState.Press)
Console.WriteLine("Up");
if (state.GetButtonState(GamePadButton.DpadDown) == InputState.Press)
Console.WriteLine("Down");
if (state.GetButtonState(GamePadButton.DpadLeft) == InputState.Press)
Console.WriteLine("Left");
if (state.GetButtonState(GamePadButton.DpadRight) == InputState.Press)
Console.WriteLine("Right");
if (state.GetButtonState(GamePadButton.A) == InputState.Press)
Console.WriteLine("Ok");
if (state.GetButtonState(GamePadButton.B) == InputState.Press)
Console.WriteLine("Cancel");
}
}
Thread.Sleep(100);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment