void JoypadConnectionCallback(Glfw.Joystick x, Glfw.ConnectionEvent state) { if (state == Glfw.ConnectionEvent.Connected) { var pad = new GlfwJoypad(handler, (int)x); pad.Initialize(); devices.Add(pad); JoypadConnectionEvent(pad, true); } if (state == Glfw.ConnectionEvent.Disconnected) { var toRemove = devices.Where(g => (g is GlfwJoypad pad) ? pad.Index == (int)x : false); foreach (GlfwJoypad j in toRemove) { JoypadConnectionEvent(j, false); } devices.RemoveAll(g => (g is GlfwJoypad pad) ? pad.Index == (int)x : false); } }
protected override IJoypad[] GetConnectedJoypads() { List <GlfwJoypad> pads = new List <GlfwJoypad>(); for (int i = 0; i <= (int)Glfw.Joystick.JoystickLast; ++i) { if (Glfw.JoystickPresent((Glfw.Joystick)i)) { var pad = new GlfwJoypad(handler, i); pad.Initialize(); pads.Add(pad); } } return(pads.ToArray()); }