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; } }
/// <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; } } }