Acceleration and orientation sensors support
authorEugene Ostroukhov <eugeneo@symbian.org>
Tue, 29 Jun 2010 17:21:51 -0700
changeset 403 ba20dd5983c7
parent 402 f943a50b6689 (current diff)
parent 401 72386743b723 (diff)
child 404 5aff54f94943
Acceleration and orientation sensors support
org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js
org.symbian.tools.wrttools.previewer/preview/script/emulator.js
org.symbian.tools.wrttools.previewer/preview/script/helper.js
org.symbian.tools.wrttools.previewer/preview/script/nokia.js
org.symbian.tools.wrttools.previewer/preview/wrt_preview.html
--- a/org.symbian.tools.wrttools.debug.core/plugin.xml	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.debug.core/plugin.xml	Tue Jun 29 17:21:51 2010 -0700
@@ -28,7 +28,7 @@
             delegate="org.symbian.tools.wrttools.debug.internal.launch.WidgetLaunchDelegate"
             id="org.symbian.tools.wrttools.debug.widget"
             modes="debug,run"
-            name="TMW Application"
+            name="Mobile Web Application"
             public="true">
       </launchConfigurationType>
    </extension>
@@ -36,7 +36,7 @@
          point="org.eclipse.debug.ui.launchConfigurationTabGroups">
       <launchConfigurationTabGroup
             class="org.symbian.tools.wrttools.debug.ui.launch.WidgetLaunchConfigurationTabGroup"
-            description="TMW Application"
+            description="Mobile Web Application"
             id="org.symbian.tools.wrttools.debug.wrtTabGroup"
             type="org.symbian.tools.wrttools.debug.widget">
       </launchConfigurationTabGroup>
@@ -55,7 +55,7 @@
             class="org.symbian.tools.wrttools.debug.ui.launch.WidgetLaunchShortcut"
             icon="icons/main16.gif"
             id="org.symbian.tools.wrttools.debug.wrtshortcut"
-            label="TMW Application"
+            label="Mobile Web Application"
             modes="run, debug">
          <configurationType
                id="org.symbian.tools.wrttools.debug.widget">
@@ -79,11 +79,11 @@
             </with>
          </enablement>
             <contextLabel
-                  label="TMW Application"
+                  label="Mobile Web Application"
                   mode="run">
             </contextLabel>
             <contextLabel
-                  label="TMW Application"
+                  label="Mobile Web Application"
                   mode="debug">
             </contextLabel></contextualLaunch>
       </shortcut>
@@ -295,9 +295,9 @@
     <extension
           point="org.eclipse.ui.actionSets">
        <actionSet
-             description="Actions for TMW debugging"
+             description="Actions for Mobile Web debugging"
              id="org.symbian.tools.wrttools.debug.core.mainActions"
-             label="TMW Debug">
+             label="Mobile Web Debug">
           <action
                 class="org.symbian.tools.wrttools.debug.ui.actions.DebugAction"
                 helpContextId="debug_last_action_context"
--- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/ResourcesChangeListener.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/ResourcesChangeListener.java	Tue Jun 29 17:21:51 2010 -0700
@@ -48,7 +48,7 @@
                     public void run() {
                         String message = "Debug browser is not updated when the files are updated. You may notice discrepancies between your workspace contents and debug session. You should either refresh the browser or restart debugging session to see the latest changes made to the workspace.";
                         MessageDialogWithToggle.openWarning(PlatformUI.getWorkbench().getActiveWorkbenchWindow()
-                                .getShell(), "TMW Debugger", message,
+                                .getShell(), "Mobile Web Debugger", message,
                                 "Do not show this warning on code changes", false, Activator.getDefault()
                                         .getPreferenceStore(), IConstants.PREF_SHOW_RESOURCE_CHANGE_ERROR);
                         ResourcesPlugin.getWorkspace().removeResourceChangeListener(ResourcesChangeListener.this);
--- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WidgetLaunchDelegate.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WidgetLaunchDelegate.java	Tue Jun 29 17:21:51 2010 -0700
@@ -40,7 +40,7 @@
 
 	public void launch(ILaunchConfiguration configuration, String mode, final ILaunch launch, IProgressMonitor monitor)
 			throws CoreException {
-		monitor.beginTask("Preparing TMW Debugger", IProgressMonitor.UNKNOWN);
+		monitor.beginTask("Preparing Mobile Web Debugger", IProgressMonitor.UNKNOWN);
 		ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
         final IWorkbench workbench = PlatformUI.getWorkbench();
         final IWorkbenchWindow window = workbench.getWorkbenchWindows()[0];
--- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/ui/DebugPreferencePage.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/ui/DebugPreferencePage.java	Tue Jun 29 17:21:51 2010 -0700
@@ -37,7 +37,7 @@
     public DebugPreferencePage() {
 		super(GRID);
 		setPreferenceStore(Activator.getDefault().getPreferenceStore());
-		setDescription("TMW debugger settings");
+		setDescription("Mobile Web debugger settings");
 	}
 
 	@Override
--- a/org.symbian.tools.wrttools.feature/feature.xml	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.feature/feature.xml	Tue Jun 29 17:21:51 2010 -0700
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <feature
       id="org.symbian.tools.wrttools"
-      label="TMW Tools Feature"
+      label="Mobile Web Tools Feature"
       version="1.0.0.qualifier"
       provider-name="Symbian Foundation">
 
--- a/org.symbian.tools.wrttools.previewer/plugin.xml	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/plugin.xml	Tue Jun 29 17:21:51 2010 -0700
@@ -10,7 +10,7 @@
             class="org.symbian.tools.wrttools.previewer.preview.PreviewView"
             icon="icons/obj16/preview_view.gif"
             id="org.symbian.tools.wrttools.editing.wrtpreview"
-            name="TMW Preview"
+            name="Preview"
             restorable="true">
       </view>
    </extension>
@@ -19,7 +19,7 @@
       <page
             class="org.symbian.tools.wrttools.previewer.preferences.WrtEditingPreferencePage"
             id="org.symbian.tools.wrttools.editing.preferences.WrtEditingPreferencePage"
-            name="TMW">
+            name="Tools for Mobile Web">
          <keywordReference
                id="org.symbian.tools.wrttools.wrtwords">
          </keywordReference>
--- a/org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/accelerometer.js	Tue Jun 29 17:21:51 2010 -0700
@@ -3,88 +3,99 @@
 }
 
 function RotationControls(accelCallback) {
-	var width = 50, height = 100, depth = 10;
-	var margin = 5, bottomMargin = 15;
-	var angleX = 180;
-	var angleY = 180;
-	var angleZ = 180;
-	var accelerationCallback = accelCallback;
+	this.angleX = 180;
+	this.angleY = 180;
+	this.angleZ = 180;
+	var control = this;
+	this.accelerationCallback = accelCallback;
 
 	$("#sliderX").slider( {
 		slide : updateAngleX,
 		animate : true,
 		max : 360,
 		min : 0,
-		value : angleX
+		value : this.angleX
 	});
 	$("#sliderY").slider( {
 		slide : updateAngleY,
 		animate : true,
 		max : 360,
 		min : 0,
-		value : angleY
+		value : this.angleY
 	});
 	$("#sliderZ").slider( {
 		slide : updateAngleZ,
 		animate : true,
 		max : 360,
 		min : 0,
-		value : angleZ
+		value : this.angleZ
 	});
-	renderUI();
+	this.paint();
+
+	function updateAngleX(event, ui) {
+		control.angleX = ui.value;
+		control.paint();
+	}
+
+	function updateAngleY(event, ui) {
+		control.angleY = ui.value;
+		control.paint();
+	}
+
+	function updateAngleZ(event, ui) {
+		control.angleZ = ui.value;
+		control.paint();
+	}
+}
+
+RotationControls.prototype.paint = function(ignoreListeners) {
+	var width = 50, height = 100, depth = 10;
+	var margin = 5, bottomMargin = 15;
+
+	var canvas = document.getElementById("phoneposition");
+	var ctx = canvas.getContext("2d");
+	ctx.clearRect(0, 0, canvas.width, canvas.height);
+
+	var r = 62;
 
+	var xy = (180 - this.angleX) * Math.PI / 180;
+	var yz = (this.angleY - 180) * Math.PI / 180;
+	var xz = (180 - this.angleZ) * Math.PI / 180 + Math.PI / 2;
+
+	var back = translateBack(xy, xz, yz);
+	if ((back[0].z + back[2].z) / 2 < 0) {
+		paint(canvas, ctx, back);
+	} else {
+		paint(canvas, ctx, translateFace(xy, xz, yz));
+		paintScreen(canvas, ctx, translateScreen(xy, xz, yz));
+	}
+
+	var dz = 0;
+	if (back[0].z > back[3].z) {
+		var bottom = translateBottom(xy, xz, yz);
+		paint(canvas, ctx, bottom);
+		dz = bottom[1].y - bottom[0].y;
+	} else if (back[0].z != back[3].z) {
+		var top = translateTop(xy, xz, yz);
+		paint(canvas, ctx, top);
+		dz = top[1].y - top[0].y;
+	}
+
+	if (back[1].z > back[0].z) {
+		paint(canvas, ctx, translateLeft(xy, xz, yz));
+	} else if (back[1].z != back[0].z) {
+		paint(canvas, ctx, translateRight(xy, xz, yz));
+	}
+	if (!ignoreListeners) {
+		var accelX = (back[1].y - back[0].y) / width;
+		var accelY = (back[0].y - back[3].y) / height;
+		var accelZ = dz / depth;
+		notifyAcceleration(accelX, accelY, accelZ);
+	}
 	function translateFace(xy, xz, yz) {
 		var px = width / 2;
 		var py = height / 2;
-		var pz = depth/2;
-		var points = [ {
-			x : px,
-			y : py,
-			z : pz
-		}, {
-			x : px,
-			y : -py,
-			z : pz
-		}, {
-			x : -px,
-			y : -py,
-			z : pz
-		}, {
-			x : -px,
-			y : py,
-			z : pz
-		} ];
-		return rotate(points, xy, xz, yz);
-	}
-	
-	function translateScreen(xy, xz, yz) {
-		var px = width / 2;
-		var py = height / 2;
-		var pz = depth/2;
-		var points = [ {
-			x : px - margin,
-			y : py - bottomMargin,
-			z : pz
-		}, {
-			x : px - margin,
-			y : -py + bottomMargin,
-			z : pz
-		}, {
-			x : -px + margin,
-			y : -py + margin,
-			z : pz
-		}, {
-			x : -px + margin,
-			y : py - margin,
-			z : pz
-		} ];
-		return rotate(points, xy, xz, yz);
-	}
-	
-	function translateBack(xy, xz, yz) {
-		var px = width / 2;
-		var py = height / 2;
-		var pz = -depth/2;
+		var pz = depth / 2;
 		var points = [ {
 			x : px,
 			y : py,
@@ -104,35 +115,59 @@
 		} ];
 		return rotate(points, xy, xz, yz);
 	}
-	
-	function translateTop(xy, xz, yz) {
+
+	function translateScreen(xy, xz, yz) {
 		var px = width / 2;
 		var py = height / 2;
-		var pz = depth/2;
+		var pz = depth / 2;
 		var points = [ {
+			x : px - margin,
+			y : py - bottomMargin,
+			z : pz
+		}, {
+			x : px - margin,
+			y : -py + bottomMargin,
+			z : pz
+		}, {
+			x : -px + margin,
+			y : -py + margin,
+			z : pz
+		}, {
+			x : -px + margin,
+			y : py - margin,
+			z : pz
+		} ];
+		return rotate(points, xy, xz, yz);
+	}
+
+	function translateBack(xy, xz, yz) {
+		var px = width / 2;
+		var py = height / 2;
+		var pz = -depth / 2;
+		var points = [ {
+			x : px,
+			y : py,
+			z : pz
+		}, {
 			x : px,
 			y : -py,
 			z : pz
 		}, {
-			x : px,
+			x : -px,
 			y : -py,
-			z : -pz
+			z : pz
 		}, {
-			x : px,
-			y : py,
-			z : -pz
-		}, {
-			x : px,
+			x : -px,
 			y : py,
 			z : pz
 		} ];
 		return rotate(points, xy, xz, yz);
 	}
-	
-	function translateBottom(xy, xz, yz) {
-		var px = -width / 2;
+
+	function translateTop(xy, xz, yz) {
+		var px = width / 2;
 		var py = height / 2;
-		var pz = depth/2;
+		var pz = depth / 2;
 		var points = [ {
 			x : px,
 			y : -py,
@@ -152,11 +187,35 @@
 		} ];
 		return rotate(points, xy, xz, yz);
 	}
-	
+
+	function translateBottom(xy, xz, yz) {
+		var px = -width / 2;
+		var py = height / 2;
+		var pz = depth / 2;
+		var points = [ {
+			x : px,
+			y : -py,
+			z : pz
+		}, {
+			x : px,
+			y : -py,
+			z : -pz
+		}, {
+			x : px,
+			y : py,
+			z : -pz
+		}, {
+			x : px,
+			y : py,
+			z : pz
+		} ];
+		return rotate(points, xy, xz, yz);
+	}
+
 	function translateLeft(xy, xz, yz) {
 		var px = width / 2;
 		var py = height / 2;
-		var pz = depth/2;
+		var pz = depth / 2;
 		var points = [ {
 			x : px,
 			y : py,
@@ -176,11 +235,11 @@
 		} ];
 		return rotate(points, xy, xz, yz);
 	}
-	
+
 	function translateRight(xy, xz, yz) {
 		var px = width / 2;
 		var py = -height / 2;
-		var pz = depth/2;
+		var pz = depth / 2;
 		var points = [ {
 			x : px,
 			y : py,
@@ -200,49 +259,6 @@
 		} ];
 		return rotate(points, xy, xz, yz);
 	}
-	
-	
-	function renderUI() {
-		var canvas = document.getElementById("phoneposition");
-		var ctx = canvas.getContext("2d");
-		ctx.clearRect(0, 0, canvas.width, canvas.height);
-
-		var r = 62;
-
-		var xy = (180 - angleX) * Math.PI / 180;
-		var yz = (angleY - 180) * Math.PI / 180;
-		var xz = (180 - angleZ) * Math.PI / 180 + Math.PI / 2;
-
-		var back = translateBack(xy, xz, yz);
-		if ((back[0].z + back[2].z)/2 < 0) {
-			paint(canvas, ctx, back);
-		} else {
-			paint(canvas, ctx, translateFace(xy, xz, yz));
-			paintScreen(canvas, ctx, translateScreen(xy, xz, yz));
-		}
-
-		var dz = 0;
-		if (back[0].z > back[3].z) {
-			var bottom = translateBottom(xy, xz, yz);
-			paint(canvas, ctx, bottom);
-			dz = bottom[1].y - bottom[0].y;
-		} else if (back[0].z != back[3].z) {
-			var top = translateTop(xy, xz, yz);
-			paint(canvas, ctx, top);
-			dz = top[1].y - top[0].y;
-		}
-		
-		if (back[1].z > back[0].z) {
-			paint(canvas, ctx, translateLeft(xy, xz, yz));
-		} else if (back[1].z != back[0].z) {
-			paint(canvas, ctx, translateRight(xy, xz, yz));
-		}
-		var accelX = (back[1].y - back[0].y) / width;
-		var accelY = (back[0].y - back[3].y) / height;
-		var accelZ = dz / depth;
-		
-		notifyAcceleration(accelX, accelY, accelZ);	
-	}
 
 	function rotate(points, xy, xz, yz) {
 		var res = new Array();
@@ -280,21 +296,6 @@
 		return res;
 	}
 
-	function updateAngleX(event, ui) {
-		angleX = ui.value;
-		renderUI();
-	}
-
-	function updateAngleY(event, ui) {
-		angleY = ui.value;
-		renderUI();
-	}
-
-	function updateAngleZ(event, ui) {
-		angleZ = ui.value;
-		renderUI();
-	}
-
 	function paint(canvas, ctx, points) {
 		var xcoord = canvas.width / 2;
 		var ycoord = canvas.height / 2;
@@ -327,8 +328,24 @@
 		}
 		ctx.fill();
 	}
-	
+
 	function notifyAcceleration(x, y, z) {
 		accelerationCallback(x, y, z);
 	}
-}
+};
+
+RotationSupport.prototype.setAngles = function(x, y, z) {
+	this.controls.angleX = x;
+	this.controls.angleY = z; // It is extremly messy - this UI was developed separately from the rest and follows 
+	this.controls.angleZ = y; // different conventions
+	$("#sliderX").slider( {
+		value : x
+	});
+	$("#sliderY").slider( {
+		value : z
+	});
+	$("#sliderZ").slider( {
+		value : y
+	});
+	this.controls.paint(true);
+};
--- a/org.symbian.tools.wrttools.previewer/preview/script/emulator.js	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/emulator.js	Tue Jun 29 17:21:51 2010 -0700
@@ -12,6 +12,15 @@
  * Description:
  * 
  */
+var ORIENTATIONS = {
+	DisplayRightUp : "DisplayRightUp",
+	DisplayLeftUp : "DisplayLeftUp",
+	DisplayUp : "DisplayUp",
+	DisplayDown : "DisplayDown",
+	DisplayUpwards : "DisplayUpwards",
+	DisplayDownwards : "DisplayDownwards"
+};
+
 function Emulator() {
 	this.child = false;
 	this.accelerationCallback = false;
@@ -19,7 +28,8 @@
 	this.loaded = false;
 	this.FORCE = 62;
 	this.state = new EmulatorState(0, this.FORCE, 0, true);
-	this.orientation = "DisplayUp";
+	this.orientation = ORIENTATIONS.DisplayUp;
+	this.modeForced = false;
 
 	this.plist = {
 		DisplayName : '',
@@ -34,7 +44,8 @@
 
 Emulator.prototype.setAccelerationCallback = function(acceleration) {
 	this.accelerationCallback = acceleration;
-	this.accelerationCallback(this.state.XAxis, this.state.YAxis, this.state.ZAxis, this.orientation);
+	this.accelerationCallback(this.state.XAxis, this.state.YAxis,
+			this.state.ZAxis, this.orientation);
 };
 
 function orientationFromAcceleration(x, y, z) {
@@ -42,44 +53,53 @@
 
 	var xangle = Math.asin(x) * 180 / Math.PI;
 	if (xangle > 55) {
-		orientation = "DisplayRightUp";
+		orientation = ORIENTATIONS.DisplayRightUp;
 	} else if (xangle < -55) {
-		orientation = "DisplayLeftUp";
+		orientation = ORIENTATIONS.DisplayLeftUp;
 	}
 
 	var yangle = Math.asin(y) * 180 / Math.PI;
 	if (yangle > 55) {
-		orientation = "DisplayUp";
+		orientation = ORIENTATIONS.DisplayUp;
 	} else if (yangle < -55) {
-		orientation = "DisplayDown";
+		orientation = ORIENTATIONS.DisplayDown;
 	}
 
 	var zangle = Math.asin(z) * 180 / Math.PI;
 	if (zangle > 75) {
-		orientation = "DisplayUpwards";
+		orientation = ORIENTATIONS.DisplayUpwards;
 	} else if (zangle < -75) {
-		orientation = "DisplayDownwards";
+		orientation = ORIENTATIONS.DisplayDownwards;
 	}
 
 	return orientation;
 }
 
-
 Emulator.prototype.accelerationChanged = function(x, y, z) {
 	this.state.XAxis = x * this.FORCE;
 	this.state.YAxis = y * this.FORCE;
 	this.state.ZAxis = z * this.FORCE;
-	
+
 	var orientation = orientationFromAcceleration(x, y, z);
-	
+
 	if (orientation != this.orientation) {
 		this.orientation = orientation;
-		NOKIA.layout.render();
+		NOKIA.helper.setPreference("__SYM_DEVICE_ORIENTATION", orientation);
+		NOKIA.emulator.render();
+	}
+
+	if (this.accelerationCallback) {
+		this.accelerationCallback(this.state.XAxis, this.state.YAxis,
+				this.state.ZAxis, this.orientation);
 	}
-	
-	if (this.accelerationCallback) {
-		this.accelerationCallback(this.state.XAxis, this.state.YAxis, this.state.ZAxis, this.orientation);
-	}
+};
+
+Emulator.prototype.setAccelerationValues = function(x, y, z) {
+	window.setTimeout(function() {
+		NOKIA.emulator.accelerationChanged(x, y, z);
+		NOKIA.rotationSupport.setAngles(180 - x * 90, y * 90 + 180,
+				180 + z * 90);
+	}, 5);
 };
 
 Emulator.prototype.load = function() {
@@ -91,26 +111,42 @@
 	var device = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE');
 	NOKIA.currentDevice = device || NOKIA.currentDevice;
 
+	var orientation = NOKIA.helper.getPreference("__SYM_DEVICE_ORIENTATION");
+	if (orientation != null) {
+		this.orientation = orientation;
+		switch (orientation) {
+		case ORIENTATIONS.DisplayUp:
+			this.setAccelerationValues(0, 0, 0);
+			break;
+		case ORIENTATIONS.DisplayDown:
+			this.setAccelerationValues(2, 0, 0);
+			break;
+		case ORIENTATIONS.DisplayRightUp:
+			this.setAccelerationValues(1, 0, 0);
+			break;
+		case ORIENTATIONS.DisplayLeftUp:
+			this.setAccelerationValues(-1, 0, 0);
+			break;
+		case ORIENTATIONS.DisplayUpwards:
+			this.setAccelerationValues(0, 0, 1);
+			break;
+		case ORIENTATIONS.DisplayDownwards:
+			this.setAccelerationValues(0, 0, -1);
+			break;
+		}
+	}
+
 	// load the saved device mode
 	var mode = NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE');
 	if (mode != null)
 		NOKIA.mode = mode;
 
-	var orientation = Number(NOKIA.helper
-			.getPreference('__SYM_NOKIA_EMULATOR_ORIENTATION'));
-	if (typeof orientation == "number" && orientation >= -90
-			&& orientation <= 180)
-		NOKIA.orientation = orientation;
-
 	// SAVE the device DATA
 	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE',
 			NOKIA.currentDevice);
 	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode);
-	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION',
-			NOKIA.orientation);
 
 	this.loaded = true;
-
 };
 
 Emulator.prototype.render = function() {
@@ -124,20 +160,42 @@
 		}
 	}
 
+	var deg = 0;
+	switch (NOKIA.emulator.orientation) {
+	case ORIENTATIONS.DisplayUp:
+		deg = 0;
+		break;
+	case ORIENTATIONS.DisplayDown:
+		deg = 180;
+		break;
+	case ORIENTATIONS.DisplayRightUp:
+		deg = -90;
+		break;
+	case ORIENTATIONS.DisplayLeftUp:
+		deg = 90;
+		break;
+	default:
+		if (NOKIA.mode == 'portrait') {
+			deg = 0;
+		} else {
+			deg = -90;
+		}
+		break;
+	}
+	if (this.orientationSupports() && !this.modeForced) {
+		if (deg == 0) {
+			NOKIA.mode = 'portrait';
+		} else if (deg == -90) {
+			NOKIA.mode = 'landscape';
+		}
+	}
+
 	if (!NOKIA.emulator.orientationSupports())
 		NOKIA.mode = NOKIA.deviceList[NOKIA.currentDevice]['default'];
 
-	if (typeof NOKIA.deviceList == 'undefined'
-			|| typeof NOKIA.deviceList[NOKIA.currentDevice] == 'undefined'
-			|| typeof NOKIA.deviceList[NOKIA.currentDevice][NOKIA.mode] == 'undefined') {
-		alert('Deive resolution: ' + NOKIA.currentDevice + ' or the mode: '
-				+ NOKIA.mode + ' not found');
-		return false;
-	}
+	this.setStyle();
 
-	this.setStyle();
-	var or = (NOKIA.mode == 'portrait') ? NOKIA.orientation
-			: (NOKIA.orientation + 90);
+	var or = (NOKIA.mode == 'portrait') ? deg : (deg + 90);
 	var val = "rotate(" + or + "deg)";
 	$("#DeviceDisplayLayout").css("-moz-transform", val);
 	$("#DeviceDisplayLayout").css("-webkit-transform", val);
@@ -152,18 +210,6 @@
 	NOKIA.emulator.render();
 };
 
-Emulator.prototype.toggle = function(o) {
-	NOKIA.orientation = o;
-	NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION',
-			NOKIA.orientation);
-	NOKIA.emulator.child.device.implementation.setOrientation(o, 0);
-	if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) {
-		NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape');
-	} else {
-		NOKIA.emulator.render();
-	}
-};
-
 Emulator.prototype.orientationSupports = function() {
 	return NOKIA.deviceList[NOKIA.currentDevice]['orientation'];
 };
--- a/org.symbian.tools.wrttools.previewer/preview/script/helper.js	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/helper.js	Tue Jun 29 17:21:51 2010 -0700
@@ -241,16 +241,6 @@
 	return NOKIA.emulator.prefs[name];
 };
 
-EmulatorHelper.prototype.rotateCW = function() {
-	var newOrient = NOKIA.orientation + 90;
-	NOKIA.emulator.toggle(newOrient - (newOrient > 180 ? 360 : 0));
-};
-
-EmulatorHelper.prototype.rotateCCW = function() {
-	var newOrient = NOKIA.orientation - 90;
-	NOKIA.emulator.toggle(newOrient + (newOrient <= -180 ? 360 : 0));
-};
-
 EmulatorHelper.prototype.version = function(ele) {
 	if (confirm('Would you like to reload the widget to apply the changes on the Version settings?')) {
 		NOKIA.helper.setPreference('__SYM_WRT_VERSION', ele.value);
@@ -304,13 +294,6 @@
 			});
 		}
 	});
-
-	$('#rotateCW').click(function() {
-		NOKIA.helper.rotateCW();
-	});
-	$('#rotateCCW').click(function() {
-		NOKIA.helper.rotateCCW();
-	});
 	$('#resOptions').change(
 			function(ele) {
 				ele = ele.target || this;
@@ -341,12 +324,6 @@
 		NOKIA.helper.version(this);
 	});
 
-	$("#orientationIcon").click(function() {
-		var mode = (NOKIA.mode == 'portrait') ? 'landscape' : 'portrait';
-		NOKIA.emulator.setMode(mode);
-		$("#WidgetArea")[0].className = 'hs_' + NOKIA.mode;
-	});
-
 	$("#iframeMask").click(function() {
 		$("#orientationIcon").hide();
 		$("#iframeMask").hide();
@@ -358,7 +335,6 @@
 
 		NOKIA.menu.softkeys_visibility = true;
 		NOKIA.menu.showSoftKeys();
-
 	});
 
 	// MenuItems DIV events
--- a/org.symbian.tools.wrttools.previewer/preview/script/nokia.js	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/script/nokia.js	Tue Jun 29 17:21:51 2010 -0700
@@ -25,8 +25,8 @@
 		version : 'WRT 1.1',
 		currentDevice : '240x320',
 		mode : 'portrait',
-		orientation : 0,
 		resolution : ['240x320', '320x240', '360x640', '800x352'],
+		rotationSupport : false,
 		scriptsLoaded : {
 			loader : false,
 			widget : false,
@@ -50,6 +50,8 @@
 	
 	NOKIA.init = function()
 	{
+		this.rotationSupport = new RotationSupport(accelerationCallback);
+
 		// Not-Supported Browser check
 		NOKIA.emulator.is_browserReady = (/MSIE/i.test(navigator.userAgent));
 		if(NOKIA.emulator.is_browserReady)
@@ -128,8 +130,6 @@
 
 		//	For getting Icon.png
 		this.helper.getInfo('Icon.png', NOKIA.helper.getIconCallback);
-		
-		new RotationSupport(accelerationCallback);
 	};
 
 	/*
--- a/org.symbian.tools.wrttools.previewer/preview/wrt_preview.html	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/preview/wrt_preview.html	Tue Jun 29 17:21:51 2010 -0700
@@ -16,7 +16,7 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-	<title>TMW Debugger</title>
+	<title>Mobile Web Debugger</title>
 	<!-- jQuery-ui Begins -->
 	<link type="text/css" rel="stylesheet"  href="preview/script/jquery-ui/css/ui-darkness/jquery-ui-1.8.2.custom.css"/>	
 	<script type="text/javascript" src="preview/script/jquery-ui/js/jquery-1.4.2.min.js"></script>
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java	Tue Jun 29 17:21:51 2010 -0700
@@ -134,7 +134,7 @@
 
     public MessageConsole getConsole() {
         if (console == null) {
-            console = new MessageConsole("TMW Console", null);
+            console = new MessageConsole("Console", null);
             ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[] { console });
         }
         return console;
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/BrowserConnectionJob.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/BrowserConnectionJob.java	Tue Jun 29 17:21:51 2010 -0700
@@ -18,7 +18,7 @@
     private String sId = null;
 
 	public BrowserConnectionJob(IPreviewStartupListener listener, URI uri) {
-		super("Connecting to TMW debugger browser");
+		super("Connecting to Mobile Web debugger browser");
 		this.listener = listener;
 		this.uri = uri;
 		setUser(false);
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preferences/WrtEditingPreferencePage.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preferences/WrtEditingPreferencePage.java	Tue Jun 29 17:21:51 2010 -0700
@@ -53,7 +53,7 @@
 				{ "Prompt", MessageDialogWithToggle.PROMPT } };
 		enableAutorefresh = new RadioGroupFieldEditor(
 				IWrtEditingPreferences.PREF_AUTO_REFRESH,
-				"Initial auto-refresh setting for TMW Preview window",
+				"Initial auto-refresh setting for Mobile Web Preview window",
 				namesAndValues.length, namesAndValues, projectComposite, true);
 		enableAutorefresh.setPreferenceStore(getPreferenceStore());
 		enableAutorefresh.setPage(this);
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java	Tue Jun 29 17:21:51 2010 -0700
@@ -38,7 +38,7 @@
         public ClearPreferencesAction() {
             setText("Clear");
             setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.CLEAR_PREFS));
-            setDescription("Forget all TMW application preference values");
+            setDescription("Forget all Mobile Web application preference values");
             setToolTipText(getDescription());
         }
 
--- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java	Tue Jun 29 17:21:51 2010 -0700
@@ -53,7 +53,7 @@
 	@Override
 	protected IPage createDefaultPage(PageBook book) {
 		MessagePage messagePage = new MessagePage();
-		messagePage.setMessage("Open an editor to preview TMW widget");
+		messagePage.setMessage("Open an editor to preview Mobile Web App");
 		initPage(messagePage);
 		messagePage.createControl(book);
 		return messagePage;
@@ -243,7 +243,7 @@
 							.open(
 									MessageDialogWithToggle.QUESTION,
 									getSite().getShell(),
-									"TMW Preview",
+									"Preview",
 									"The preview window can refresh (reinitialize and restart) whenever a project file is saved.\n" +
 									"This setting for each project can be toggled from the preview toolbar.\n\n" +
 									"Do you want to enable automatic refresh for this project?",
--- a/org.symbian.tools.wrttools.product/plugin.properties	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.product/plugin.properties	Tue Jun 29 17:21:51 2010 -0700
@@ -1,4 +1,4 @@
-pluginName=WebRuntime Toolkit IDE
+pluginName=Mobile Web IDE
 providerName=Symbian Foundation
 productName=Web Runtime Toolkit IDE 
 productBlurb=Symbian Foundation's Open Source Web Runtime Toolkit IDE based on Eclipse Platform for developing and deploying Web applications\n\
--- a/org.symbian.tools.wrttools.product/plugin.xml	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.product/plugin.xml	Tue Jun 29 17:21:51 2010 -0700
@@ -14,7 +14,7 @@
          point="org.eclipse.ui.actionSets">
       <actionSet
             id="org.symbian.tools.wrttools.product.creationActionSet"
-            label="TMW Element Creation">
+            label="Mobile Web Element Creation">
          <action
                class="org.symbian.tools.wrttools.product.actions.NewCSSFileAction"
                icon="icons/newcss_wiz.gif"
@@ -43,7 +43,7 @@
                class="org.symbian.tools.wrttools.product.actions.NewWRTProjectAction"
                icon="icons/newWRT_app_icon_16px.png"
                id="org.symbian.tools.wrttools.product.newWRTProjectAction"
-               label="New TMW Application..."
+               label="New Mobile Web Application..."
                style="push"
                toolbarPath="wrtwizards">
          </action>
@@ -71,7 +71,7 @@
    <extension
          point="org.eclipse.ui.activities">
       <activity
-            description="WTP functionality not used in TMW IDE"
+            description="WTP functionality not used in Mobile Web IDE"
             id="org.symbian.tools.wrttools.product.wtp"
             name="Web Tools Platform (WTP)">
       </activity>
@@ -152,7 +152,7 @@
             pattern="org\.eclipse\.debug\.ui/org\.eclipse\.debug\.ui\.contextualLaunch\.debug\.submenu">
       </activityPatternBinding>
       <category
-            description="WTP UI elements that are not compatible with TMW app development"
+            description="WTP UI elements that are not compatible with Mobile Web app development"
             id="org.symbian.tools.wrttools.product.wtp"
             name="Web Tools Platform (WTP)">
       </category>
@@ -192,7 +192,7 @@
          point="org.eclipse.core.runtime.products">
       <product
             application="org.eclipse.ui.ide.workbench"
-            name="WebRuntime Toolkit IDE">
+            name="Mobile Web IDE">
          <property
                name="windowImages"
                value="icons/ico/WRT_main-icon_16px.png,icons/ico/WRT_main-icon_32px.png,icons/ico/WRT_main-icon_48px.png,icons/ico/WRT_main-icon_64px.png,icons/ico/WRT_main-icon_128px.png">
@@ -219,7 +219,7 @@
          </property>
          <property
                name="appName"
-               value="WebRuntime Toolkit IDE">
+               value="Mobile Web IDE">
          </property>
          <property
                name="preferenceCustomization"
--- a/org.symbian.tools.wrttools.product/wrt-ide.product	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools.product/wrt-ide.product	Tue Jun 29 17:21:51 2010 -0700
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?pde version="3.5"?>
 
-<product name="WebRuntime Toolkit IDE" uid="org.symbian.wrtide" id="org.symbian.tools.wrttools.product.product" application="org.eclipse.ui.ide.workbench" version="0.9.1.qualifier" useFeatures="false" includeLaunchers="true">
+<product name="Mobile Web IDE" uid="org.symbian.wrtide" id="org.symbian.tools.wrttools.product.product" application="org.eclipse.ui.ide.workbench" version="0.9.1.qualifier" useFeatures="false" includeLaunchers="true">
 
    <aboutInfo>
       <image path="icons/WRT_blurb_image.png"/>
--- a/org.symbian.tools.wrttools/plugin.xml	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools/plugin.xml	Tue Jun 29 17:21:51 2010 -0700
@@ -246,10 +246,10 @@
 	<extension point="org.eclipse.ui.views">
 		<view allowMultiple="false" category="org.symbian.tools.wrttools.views"
 			class="org.eclipse.ui.navigator.CommonNavigator" icon="icons/main16.gif"
-			id="org.symbian.tools.wrttools.wrtnavigator" name="TMW Navigator"
+			id="org.symbian.tools.wrttools.wrtnavigator" name="Projects"
 			restorable="true">
 		</view>
-		<category id="org.symbian.tools.wrttools.views" name="TMW Tools">
+		<category id="org.symbian.tools.wrttools.views" name="Tools for Mobile Web">
 		</category>
 	</extension>
 	<extension point="org.eclipse.ui.navigator.viewer">
@@ -598,7 +598,7 @@
        point="org.eclipse.ui.commands">
     <category
           id="org.symbian.tools.wrttools.commands.maincategory"
-          name="TMW Tools">
+          name="Tools for Mobile Web">
     </category>
     <command
           categoryId="org.symbian.tools.wrttools.commands.maincategory"
@@ -615,7 +615,7 @@
     <command
           categoryId="org.symbian.tools.wrttools.commands.maincategory"
           defaultHandler="org.symbian.tools.wrttools.handlers.AddJSLibrary"
-          description="Adds JavaScript libraries to TMW projects"
+          description="Adds JavaScript libraries to Mobile Web projects"
           id="org.symbian.tools.wrttools.addlibrary"
           name="Add JavaScript Libraries...">
     </command>
@@ -823,7 +823,7 @@
  </extension>
  <extension
        id="org.symbian.tools.wrttools.excluded"
-       name="Excluded from TMW packaging marker"
+       name="Excluded from Mobile Web packaging marker"
        point="org.eclipse.core.resources.markers">
     <persistent
           value="true">
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/ConsoleFactory.java	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/ConsoleFactory.java	Tue Jun 29 17:21:51 2010 -0700
@@ -46,7 +46,7 @@
 	
 	private synchronized static MessageConsole getConsole() {
 		if (console == null) {
-			console = new MessageConsole("TMW Console", null, true);
+			console = new MessageConsole("Mobile Web Console", null, true);
 			IConsoleManager consoleManager = ConsolePlugin.getDefault().getConsoleManager();
 			consoleManager.addConsoles(new IConsole[]{console});
 		}
--- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/packageMessages.properties	Tue Jun 29 13:44:16 2010 -0700
+++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/packager/packageMessages.properties	Tue Jun 29 17:21:51 2010 -0700
@@ -10,7 +10,7 @@
 WRTPackagerConstants.directoryCreateErr=Can not create output directory
 WRTPackagerConstants.checkPermission=Can not create specified directory at the destination.
 WRTPackagerConstants.unSupportedInput=Any input other then a folder is not supported
-WRTPackagerConstants.InputNotSupported=Input type not supported by TMW Packager
+WRTPackagerConstants.InputNotSupported=Input type not supported by Mobile Web Packager
 WRTPackagerConstants.renameFailed=Packager failed while renaming a .zip file
 WRTPackagerConstants.failureGenerate=Packager failed while generating package files
 WRTPackagerConstants.srcNotFound=Source folder not found