Skip to content

Commit

Permalink
Add stacked screen landscape mode
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-dressler committed Jan 10, 2013
1 parent 81fe0b1 commit 4003e67
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
<!-- Release m17 -->
<string name="Pause">Pause</string>
<string name="Resume">Resume</string>
<string name="NdsLikeLandscape">NDS like landscape</string>
<string name="NdsLikeLandscapeDesc">In landscape orientation stack the top screen above the bottom screen.
The controls will be alongside the screens.</string>



Expand Down
5 changes: 2 additions & 3 deletions res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<CheckBoxPreference android:title="@string/fps" android:summary="@string/fpsdesc" android:key="DisplayFps"/>
<CheckBoxPreference android:title="@string/LCDSwap" android:key="LCDsSwap" android:summary="@string/LCDSwapDesc"/>
<CheckBoxPreference android:title="@string/DontRotateLCDs" android:key="WindowRotate" android:summary="@string/DontRotateLCDsDesc"/>
<CheckBoxPreference android:title="@string/NdsLikeLandscape" android:key="LandscapeStackScreens" android:summary="@string/NdsLikeLandscapeDesc"/>
</PreferenceCategory>

<PreferenceCategory android:title="@string/Sound">
Expand All @@ -36,6 +37,4 @@

</PreferenceCategory>



</PreferenceScreen>
</PreferenceScreen>
14 changes: 11 additions & 3 deletions src/com/danieru/miraie/nds/EmulateActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void loadJavaSettings(String key)
view.haptic = prefs.getBoolean(Settings.HAPTIC, false);
view.dontRotate = prefs.getBoolean(Settings.DONT_ROTATE_LCDS, false);
view.alwaysTouch = prefs.getBoolean(Settings.ALWAYS_TOUCH, false);
view.landscapeStackScreens = prefs.getBoolean(Settings.LANDSCAPE_STACK_SCREENS, false);

controls.loadMappings(this);

Expand Down Expand Up @@ -374,6 +375,7 @@ public boolean onTouchEvent(MotionEvent event) {
boolean sized = false;
boolean landscape = false;
boolean dontRotate = false;
boolean landscapeStackScreens = false;
int sourceWidth;
int sourceHeight;
Rect srcMain, destMain, srcTouch, destTouch;
Expand Down Expand Up @@ -419,8 +421,14 @@ void resize(int newWidth, int newHeight, int newPixelFormat) {

forceTouchScreen = !prefs.getBoolean("Controls." + (landscape ? "Landscape." : "Portrait.") + "Draw", false);


if(landscape) {
if (landscape && landscapeStackScreens) {
double ndsAspectRatio = 256.0 / (192 * 2);
int adjustedWidth = (int) Math.floor(newHeight * ndsAspectRatio);
int offset = (newWidth - adjustedWidth) / 2;
destMain = new Rect(offset, 0, newWidth - offset, newHeight / 2);
destTouch = new Rect(offset, newHeight / 2, newWidth - offset, newHeight);

} else if(landscape) {
destMain = new Rect(0, 0, newWidth / 2, newHeight);
destTouch = new Rect(newWidth / 2, 0, newWidth, newHeight);
}
Expand All @@ -429,7 +437,7 @@ void resize(int newWidth, int newHeight, int newPixelFormat) {
destTouch = new Rect(0, newHeight / 2, newWidth, newHeight);
}

if(landscape && dontRotate) {
if(landscape && dontRotate && !landscapeStackScreens) {
emuBitmapMain = Bitmap.createBitmap(sourceHeight / 2, sourceWidth, is565 ? Config.RGB_565 : Config.ARGB_8888);
emuBitmapTouch = Bitmap.createBitmap(sourceHeight / 2, sourceWidth, is565 ? Config.RGB_565 : Config.ARGB_8888);
srcMain = new Rect(0, 0, sourceHeight / 2, sourceWidth);
Expand Down
3 changes: 3 additions & 0 deletions src/com/danieru/miraie/nds/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ static void applyLayoutDefaults(SharedPreferences prefs, boolean overwrite) {
public static final String MAPPING_R = "Controls.KeyMap.R";
public static final String MAPPING_TOUCH = "Controls.KeyMap.Touch";
public static final String DONT_ROTATE_LCDS = "WindowRotate";
public static final String LANDSCAPE_STACK_SCREENS = "LandscapeStackScreens";
public static final String LANGUAGE = "Language";
public static final String ENABLE_MICROPHONE = "EnableMicrophone";
public static final String ALWAYS_TOUCH = "Controls.AlwaysTouch";
Expand Down Expand Up @@ -215,6 +216,8 @@ public static void applyDefaults(Context context) {
editor.putBoolean(LCD_SWAP, false);
if(!prefs.contains(DONT_ROTATE_LCDS))
editor.putBoolean(DONT_ROTATE_LCDS, false);
if(!prefs.contains(LANDSCAPE_STACK_SCREENS))
editor.putBoolean(LANDSCAPE_STACK_SCREENS, false);
if(!prefs.contains(ENABLE_MICROPHONE))
editor.putBoolean(ENABLE_MICROPHONE, true);
if(!prefs.contains(LANGUAGE)) {
Expand Down

0 comments on commit 4003e67

Please sign in to comment.