/*
         * Moves the mouse cursor using a string command passed as a parameter
         * of format XaYb, where a and b are the relative movement of the joystick
         * in the X and Y direction, respectively.
         */
        private void MoveMouse(string command)
        {
            int i = command.IndexOf("Y"); // check where to split the command to get the X and Y movement values
            int x = Int32.Parse(command.Substring(1, i - 1));
            int y = Int32.Parse(command.Substring(i + 1));

            // values are divided based on the joystick sensitivity multiplier to control how reactive
            // the cursor is from the movement of the joystick
            OSController.MoveCursor(x / (221 - 15 * settings.JoystickSetting.SensitivityMultiplier), y / (221 - 15 * settings.JoystickSetting.SensitivityMultiplier));
        }
        /*
         * Executes the appropriate action from the passed ButtonSetting
         * instance.
         */
        private void PerformButtonAction(ButtonSetting button)
        {
            switch (button.Setting)
            {
            case ButtonSetting.ButtonSettingMode.LeftClick:
                OSController.SimulateLeftClick();
                break;

            case ButtonSetting.ButtonSettingMode.RightClick:
                OSController.SimulateRightClick();
                break;

            case ButtonSetting.ButtonSettingMode.OnScreenKeyboard:
                OSController.OpenOnScreenKeyboard();
                break;

            case ButtonSetting.ButtonSettingMode.TypePhrase:
                if (!String.IsNullOrEmpty(button.Phrase))
                {
                    OSController.TypePhrase(button.Phrase);
                }
                break;

            case ButtonSetting.ButtonSettingMode.OpenProgram:
                if (button.ProgramInfo != null && !String.IsNullOrEmpty(button.ProgramInfo.Path))
                {
                    OSController.OpenExecutable(button.ProgramInfo.Path);
                }
                break;

            case ButtonSetting.ButtonSettingMode.OpenWebsite:
                if (!String.IsNullOrEmpty(button.WebsiteURL))
                {
                    OSController.OpenWebsite(button.WebsiteURL);
                }
                break;

            case ButtonSetting.ButtonSettingMode.KeyboardShortcut:
                if (button.KeyCombination != null)
                {
                    OSController.PerformKeyboardShortcut(button.KeyCombination);
                }
                break;
            }
        }