Ejemplo n.º 1
0
        void SwizzleNSApplicationAccessibilitySetter()
        {
            // Swizzle accessibilitySetValue:forAttribute: so that we can detect when VoiceOver gets enabled
            var nsApplicationClassHandle = Class.GetHandle("NSApplication");

            // This happens if GtkMac is loaded before XamMac
            if (nsApplicationClassHandle == IntPtr.Zero)
            {
                return;
            }

            var accessibilitySetValueForAttributeSelector = Selector.GetHandle("accessibilitySetValue:forAttribute:");

            var accessibilitySetValueForAttributeMethod = class_getInstanceMethod(nsApplicationClassHandle, accessibilitySetValueForAttributeSelector);

            originalAccessibilitySetValueForAttributeMethod = method_getImplementation(accessibilitySetValueForAttributeMethod);

            var block = new BlockLiteral();

            SwizzledAccessibilitySetValueForAttributeDelegate d = accessibilitySetValueForAttribute;

            block.SetupBlock(d, null);
            var imp = imp_implementationWithBlock(ref block);

            method_setImplementation(accessibilitySetValueForAttributeMethod, imp);

            accessibilityInUse    = CFPreferences.GetAppBooleanValue("voiceOverOnOffKey", "com.apple.universalaccess");
            a11yHelperInitialized = true;
        }
Ejemplo n.º 2
0
        public void PlaySoundEffect(SoundEffect effect, EffectMode mode)
        {
            if (mode == EffectMode.Off || effect == SoundEffect.None)
            {
                return;
            }
            if (mode == EffectMode.Default && Forms9Patch.Settings.SoundEffectMode != EffectMode.On)
            {
                if (Forms9Patch.Settings.SoundEffectMode == EffectMode.Default)
                {
                    // this no longer works and there doesn't appear to be a way to detect if keyclicks is on
                    //var type = CFPreferences.CurrentApplication;
                    CFPreferences.AppSynchronize("/var/mobile/Library/Preferences/com.apple.preferences.sounds");
                    if (!CFPreferences.GetAppBooleanValue("keyboard", "/var/mobile/Library/Preferences/com.apple.preferences.sounds"))
                    {
                        return;
                    }
                }
                else // Forms9Patch.Settings.SoundEffectMode == EffectMode.Off
                {
                    return;
                }
            }
            switch (effect)
            {
            case SoundEffect.KeyClick:
                click.PlaySystemSound();
                break;

            case SoundEffect.Return:
                modifier.PlaySystemSound();
                break;

            case SoundEffect.Delete:
                delete.PlaySystemSound();
                break;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Feedback the specified effect and mode.
        /// </summary>
        /// <param name="effect">Effect.</param>
        /// <param name="mode">Mode.</param>
        public void Feedback(HapticEffect effect, KeyClicks mode = KeyClicks.Default)
        {
            var soundEnabled = (mode & KeyClicks.On) > 0;

            if (mode == KeyClicks.Default)
            {
                soundEnabled = (Forms9Patch.Settings.KeyClicks & KeyClicks.On) > 0;
                if (Forms9Patch.Settings.KeyClicks == KeyClicks.Default)
                {
                    // this no longer works and there doesn't appear to be a way to detect if keyclicks is on
                    //var type = CFPreferences.CurrentApplication;
                    CFPreferences.AppSynchronize("/var/mobile/Library/Preferences/com.apple.preferences.sounds");
                    soundEnabled = CFPreferences.GetAppBooleanValue("keyboard", "/var/mobile/Library/Preferences/com.apple.preferences.sounds");
                }
            }

            if (soundEnabled)
            {
                switch (effect)
                {
                case HapticEffect.None:
                    break;

                case HapticEffect.KeyClick:
                    click.PlaySystemSoundAsync();
                    break;

                case HapticEffect.Return:
                    modifier.PlaySystemSoundAsync();
                    break;

                case HapticEffect.Delete:
                    delete.PlaySystemSoundAsync();
                    break;
                }
            }
        }