Add warm reset menu option. (Open Apple-Control-Reset)

This commit is contained in:
James Sanford 2012-10-12 17:25:04 -07:00
parent c0ecd8da18
commit 4b03473214
4 changed files with 18 additions and 0 deletions

View File

@ -8,4 +8,6 @@
android:title="@string/input_controls_hide" />
<item android:id="@+id/emulation_speed"
android:title="@string/emulation_speed" />
<item android:id="@+id/warm_reset"
android:title="@string/warm_reset" />
</menu>

View File

@ -28,4 +28,5 @@
<string name="input_controls_hide">Hide Controls</string>
<string name="input_controls_show">Show Controls</string>
<string name="emulation_speed">Emulation Speed</string>
<string name="warm_reset">Warm Reset</string>
</resources>

View File

@ -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();

View File

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