Last active
January 3, 2020 00:31
-
-
Save W4RH4WK/966a4872d6bdf0dde2153b5846cce10d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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