Ejemplo n.º 1
0
        private void LoadJoystickConfiguration()
        {
            // Loads the joysick configuration from the sharedpreferences
            ISharedPreferences sharedPreferences = Activity.GetSharedPreferences(typeof(JoystickConfiguration).FullName, 0);

            string leftJoystickJson  = sharedPreferences.GetString(LeftJoystickPreferenceKey, string.Empty);
            string rightJoystickJson = sharedPreferences.GetString(RightJoystickPreferenceKey, string.Empty);


            if (!string.IsNullOrEmpty(leftJoystickJson))
            {
                try
                {
                    // Only if we have stored a string we deserialize its data
                    _leftJoystickConfiguration = JsonConvert.DeserializeObject <JoystickConfiguration>(leftJoystickJson);
                }
                catch (JsonException) { }
            }
            if (!string.IsNullOrEmpty(rightJoystickJson))
            {
                try
                {
                    // Only if we have stored a string we deserialize its data
                    _rightJoystickConfiguration = JsonConvert.DeserializeObject <JoystickConfiguration>(rightJoystickJson);
                }
                catch (JsonException) { }
            }
        }
Ejemplo n.º 2
0
        private void ApplyJoystickConfiguration(JoystickConfiguration configuration, int joystickId)
        {
            // Apply the joystick configuration depending on the given id
            switch (joystickId)
            {
            case LeftJoystickIndex:
                _leftJoystickConfiguration = configuration;
                break;

            case RightJoystickIndex:
                _rightJoystickConfiguration = configuration;
                break;
            }
        }
Ejemplo n.º 3
0
        public JoystickFragment()
        {
            FtInterfaceInstanceProvider.InstanceChanged += FtInterfaceInstanceProviderOnInstanceChanged;

            _leftJoystickConfiguration = new JoystickConfiguration
            {
                JoystickMode = JoystickConfiguration.JoystickModes.Syncron,
                MotorIndexes = new[] { 0, 1 }
            };
            _rightJoystickConfiguration = new JoystickConfiguration
            {
                JoystickMode = JoystickConfiguration.JoystickModes.Single,
                MotorIndexes = new[] { 2, 3 }
            };
        }