+/* We need this to respond to "shake" gestures
+ */
+- (BOOL)canBecomeFirstResponder
+{
+ return YES;
+}
+
+- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
+{
+}
+
+- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
+{
+}
+
+
+/* Shake means load a random screen saver.
+ */
+- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
+{
+ if (motion != UIEventSubtypeMotionShake)
+ return;
+ NSMutableArray *a = [NSMutableArray arrayWithCapacity: 200];
+ for (NSArray *sec in letter_sections)
+ for (NSString *s in sec)
+ [a addObject: s];
+ int n = [a count];
+ if (! n) return;
+ NSString *which = [a objectAtIndex: (random() % n)];
+
+ SaverRunner *s =
+ (SaverRunner *) [[UIApplication sharedApplication] delegate];
+ if (! s) return;
+ NSAssert ([s isKindOfClass:[SaverRunner class]], @"not a SaverRunner");
+ [self scrollTo: which];
+ [s loadSaver: which];
+}
+
+