Esempio n. 1
0
        static void MonitorCallback(Glfw.Monitor monitor, Glfw.ConnectionEvent evt)
        {
            if (evt == Glfw.ConnectionEvent.Connected)
            {
                int x, y, widthMM, heightMM;
                var mode = Glfw.GetVideoMode(monitor);

                Glfw.GetMonitorPos(monitor, out x, out y);
                Glfw.GetMonitorPhysicalSize(monitor, out widthMM, out heightMM);

                Log("{0} at {1}: Monitor {2} ({3}x{4} at {5}x{6}, {7}x{8} mm) was connected",
                    m_Counter++,
                    Glfw.GetTime(),
                    Glfw.GetMonitorName(monitor),
                    mode.Width, mode.Height,
                    x, y,
                    widthMM, heightMM);
            }
            else if (evt == Glfw.ConnectionEvent.Disconnected)
            {
                Log("{0} at {1}: Monitor {2} was disconnected",
                    m_Counter++,
                    Glfw.GetTime(),
                    Glfw.GetMonitorName(monitor));
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
            }
        }