private static JoystickSetup ParseJoystickSetup(XmlNode joystickSetupNode)
        {
            var setup = new JoystickSetup();
            setup.Name = joystickSetupNode.GetAttribute("Name");
            XmlNodeList deviceNodes = joystickSetupNode.SelectNodes("JoystickDevice");

            foreach (XmlNode deviceNode in deviceNodes)
                setup.Devices.Add(ParseDevice(deviceNode));

            return setup;
        }
Example #2
0
        private void Init(JoystickSetup setup)
        {
            string[] connectedJoystickDeviceNames = Joystick.FindJoysticks();

            foreach (JoystickDevice device in setup.Devices)
            {
                if (!connectedJoystickDeviceNames.Contains(device.Name))
                {
                    throw new Exception("Joystick " + device.Name + " was not connected!");
                }

                var js = new Joystick(_windowHandle);
                js.AcquireJoystick(device.Name);
                _joysticks.Add(js);

                foreach (Axis axis in device.Axes)
                {
                    _actionToAxis[axis.Action]     = axis;
                    _actionToJoystick[axis.Action] = js;
                }
            }
        }
        private void Init(JoystickSetup setup)
        {
            string[] connectedJoystickDeviceNames = Joystick.FindJoysticks();

            foreach (JoystickDevice device in setup.Devices)
            {
                if (!connectedJoystickDeviceNames.Contains(device.Name))
                    throw new Exception("Joystick " + device.Name + " was not connected!");

                var js = new Joystick(_windowHandle);
                js.AcquireJoystick(device.Name);
                _joysticks.Add(js);

                foreach (Axis axis in device.Axes)
                {
                    _actionToAxis[axis.Action] = axis;
                    _actionToJoystick[axis.Action] = js;
                }
            }
        }