From 4b034732142e74c4450adbd02bf71e96f0f1a03e Mon Sep 17 00:00:00 2001 From: James Sanford Date: Fri, 12 Oct 2012 17:25:04 -0700 Subject: [PATCH] Add warm reset menu option. (Open Apple-Control-Reset) --- res/menu/options.xml | 2 ++ res/values/strings.xml | 1 + src/com/froop/app/kegs/KegsMain.java | 4 ++++ src/com/froop/app/kegs/KegsView.java | 11 +++++++++++ 4 files changed, 18 insertions(+) diff --git a/res/menu/options.xml b/res/menu/options.xml index 7a913d1..a201c8c 100644 --- a/res/menu/options.xml +++ b/res/menu/options.xml @@ -8,4 +8,6 @@ android:title="@string/input_controls_hide" /> + diff --git a/res/values/strings.xml b/res/values/strings.xml index c0847a4..8b6f8df 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -28,4 +28,5 @@ Hide Controls Show Controls Emulation Speed + Warm Reset diff --git a/src/com/froop/app/kegs/KegsMain.java b/src/com/froop/app/kegs/KegsMain.java index 8664a99..7115bde 100644 --- a/src/com/froop/app/kegs/KegsMain.java +++ b/src/com/froop/app/kegs/KegsMain.java @@ -105,6 +105,9 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset { } else if (item_id == R.id.emulation_speed) { new SpeedFragment().show(getFragmentManager(), FRAGMENT_SPEED); return true; + } else if (item_id == R.id.warm_reset) { + mKegsView.doWarmReset(); + return true; } return false; } @@ -222,6 +225,7 @@ public class KegsMain extends Activity implements KegsKeyboard.StickyReset { } } else { Rect displaySize = new Rect(); + // We use the mKegsView object here, but we could ask any view. mKegsView.getWindowVisibleDisplayFrame(displaySize); width = displaySize.width(); height = displaySize.height(); diff --git a/src/com/froop/app/kegs/KegsView.java b/src/com/froop/app/kegs/KegsView.java index 85676bf..b43a445 100644 --- a/src/com/froop/app/kegs/KegsView.java +++ b/src/com/froop/app/kegs/KegsView.java @@ -147,6 +147,17 @@ class KegsView extends SurfaceView implements SurfaceHolder.Callback { mEventQueue.add(new Event.KeyKegsEvent(speed + 0x80, true)); } + public void doWarmReset() { + // Press keys down. + mEventQueue.add(new Event.KeyKegsEvent(KegsKeyboard.KEY_OPEN_APPLE, false)); + mEventQueue.add(new Event.KeyKegsEvent(KegsKeyboard.KEY_CONTROL, false)); + mEventQueue.add(new Event.KeyKegsEvent(KegsKeyboard.KEY_RESET, false)); + // Release reset key first, then the others. + mEventQueue.add(new Event.KeyKegsEvent(KegsKeyboard.KEY_RESET, true)); + mEventQueue.add(new Event.KeyKegsEvent(KegsKeyboard.KEY_CONTROL, true)); + mEventQueue.add(new Event.KeyKegsEvent(KegsKeyboard.KEY_OPEN_APPLE, true)); + } + public KegsThread getThread() { return thread; }