示例#1
0
        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);
            }
        }
示例#2
0
        static void JoystickCallback(Glfw.Joystick joy, Glfw.ConnectionEvent evt)
        {
            if (evt == Glfw.ConnectionEvent.Connected)
            {
                var axes    = Glfw.GetJoystickAxes(joy);
                var buttons = Glfw.GetJoystickButtons(joy);

                Log("{0} at {1}: Joystick {2} ({3}) was connected with {4} axes and {5} buttons",
                    m_Counter++, Glfw.GetTime(),
                    joy,
                    Glfw.GetJoystickName(joy),
                    axes.Length,
                    buttons.Length);
            }
            else
            {
                Log("{0} at {1}: Joystick {2} was disconnected",
                    m_Counter++, Glfw.GetTime(), joy);
            }
        }
示例#3
0
        static void JoystickCallback(Glfw.Joystick joy, Glfw.ConnectionEvent evt)
        {
            if (evt == Glfw.ConnectionEvent.Connected)
            {
                var axisCount   = Glfw.GetJoystickAxes(joy).Length;
                var buttonCount = Glfw.GetJoystickButtons(joy).Length;

                Log("Found joystick {0} named \'{1}\' with {2} axes, {3} buttons\n",
                    (int)joy + 1,
                    Glfw.GetJoystickName(joy),
                    axisCount,
                    buttonCount);

                m_Joysticks.Add(joy);
            }
            else if (evt == Glfw.ConnectionEvent.Disconnected)
            {
                m_Joysticks.Remove(joy);
                Log("Lost joystick {0}", (int)joy + 1);
            }
        }