summaryrefslogtreecommitdiff
path: root/Cydia.mm
diff options
context:
space:
mode:
authorRyan Petrich <rpetrich@gmail.com>2010-09-23 02:43:54 -0600
committerJay Freeman <saurik@Jay-Freemans-MacBook-Pro.local>2010-10-04 00:12:19 -0700
commit10d657527d5385b540988f50c79936f5e0b563b4 (patch)
tree2d98b7ad31ccc7324e04c2c6a115b0e5c6a873b6 /Cydia.mm
parent904e4273c51ff61a884ce6c04855c4a6335bf2d6 (diff)
Use system keyboard sounds setting
Kind of a hack, but the setting is buried in UIKit as a static Doesn't track system notifications, but I don't think that's a big deal
Diffstat (limited to 'Cydia.mm')
-rw-r--r--Cydia.mm27
1 files changed, 27 insertions, 0 deletions
diff --git a/Cydia.mm b/Cydia.mm
index 38ba04e..b546ec9 100644
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -8518,6 +8518,26 @@ MSHook(void, UIWebDocumentView$_setUIKitDelegate$, UIWebDocumentView *self, SEL
return _UIWebDocumentView$_setUIKitDelegate$(self, _cmd, delegate);
}
+static NSNumber *shouldPlayKeyboardSounds;
+
+Class $UIHardware;
+
+MSHook(void, UIHardware$_playSystemSound$, Class self, SEL _cmd, int soundIndex) {
+ switch (soundIndex) {
+ case 1104: // Keyboard Button Clicked
+ case 1105: // Keyboard Delete Repeated
+ if (!shouldPlayKeyboardSounds) {
+ NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:@"/var/mobile/Library/Preferences/com.apple.preferences.sounds.plist"];
+ shouldPlayKeyboardSounds = [[dict objectForKey:@"keyboard"] ?: (id)kCFBooleanTrue retain];
+ [dict release];
+ }
+ if (![shouldPlayKeyboardSounds boolValue])
+ break;
+ default:
+ _UIHardware$_playSystemSound$(self, _cmd, soundIndex);
+ }
+}
+
int main(int argc, char *argv[]) { _pooled
_trace();
@@ -8539,6 +8559,13 @@ int main(int argc, char *argv[]) { _pooled
_UIWebDocumentView$_setUIKitDelegate$ = reinterpret_cast<void (*)(UIWebDocumentView *, SEL, id)>(method_getImplementation(UIWebDocumentView$_setUIKitDelegate$));
method_setImplementation(UIWebDocumentView$_setUIKitDelegate$, reinterpret_cast<IMP>(&$UIWebDocumentView$_setUIKitDelegate$));
}
+
+ $UIHardware = objc_getClass("UIHardware");
+ Method UIHardware$_playSystemSound$(class_getClassMethod($UIHardware, @selector(_playSystemSound:)));
+ if (UIHardware$_playSystemSound$ != NULL) {
+ _UIHardware$_playSystemSound$ = reinterpret_cast<void (*)(Class, SEL, int)>(method_getImplementation(UIHardware$_playSystemSound$));
+ method_setImplementation(UIHardware$_playSystemSound$, reinterpret_cast<IMP>(&$UIHardware$_playSystemSound$));
+ }
/* }}} */
/* Set Locale {{{ */
Locale_ = CFLocaleCopyCurrent();