[Orxonox-commit 5248] r9911 - code/branches/wiimote/src/libraries/core/input

georgr at orxonox.net georgr at orxonox.net
Mon Dec 16 15:06:08 CET 2013


Author: georgr
Date: 2013-12-16 15:06:08 +0100 (Mon, 16 Dec 2013)
New Revision: 9911

Modified:
   code/branches/wiimote/src/libraries/core/input/InputManager.cc
   code/branches/wiimote/src/libraries/core/input/Mouse.cc
   code/branches/wiimote/src/libraries/core/input/WiiMote.cc
   code/branches/wiimote/src/libraries/core/input/WiiMote.h
Log:
watch out for sensitivity! IR input now working, still trying to fix roll

Modified: code/branches/wiimote/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputManager.cc	2013-12-16 14:03:17 UTC (rev 9910)
+++ code/branches/wiimote/src/libraries/core/input/InputManager.cc	2013-12-16 14:06:08 UTC (rev 9911)
@@ -253,6 +253,10 @@
     	      {CWiimote::LED_1, CWiimote::LED_2,
     	       CWiimote::LED_3, CWiimote::LED_4};
     	    wiimote.SetLEDs(LED_MAP[index]);
+    	    wiimote.IR.SetMode(CIR::ON);
+    	    wiimote.IR.SetAspectRatio(CIR::ASPECT_16_9);
+    	    wiimote.IR.SetBarPosition(CIR::BAR_ABOVE);
+    	    wiimote.IR.SetVres(1920,1080);
     	    try
 		   {
 			 orxout()<< "Size of devices vector before wiimote insertion:" << devices_.size() << std::endl;
@@ -266,12 +270,9 @@
 		   {
 			 orxout()<<"Exception loading WiiMote!!!1!11!";
 		   }
+   	    }
 
 
-
-    	}
-
-
     }
     //! Creates a new orxonox::Mouse
     void InputManager::loadMouse()

Modified: code/branches/wiimote/src/libraries/core/input/Mouse.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/Mouse.cc	2013-12-16 14:03:17 UTC (rev 9910)
+++ code/branches/wiimote/src/libraries/core/input/Mouse.cc	2013-12-16 14:06:08 UTC (rev 9911)
@@ -78,6 +78,8 @@
         {
             IntVector2 abs(e.state.X.abs, e.state.Y.abs);
             IntVector2 rel(e.state.X.rel, e.state.Y.rel);
+            orxout()<<"absolute x,y: " << abs.x<< ", " << abs.y << endl;
+            orxout()<<"relative x,y: " << rel.x<< ", " << rel.y << endl;
             IntVector2 clippingSize(e.state.width, e.state.height);
             for (unsigned int i = 0; i < inputStates_.size(); ++i)
                 inputStates_[i]->mouseMoved(abs, rel, clippingSize);

Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.cc	2013-12-16 14:03:17 UTC (rev 9910)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.cc	2013-12-16 14:06:08 UTC (rev 9911)
@@ -13,27 +13,31 @@
 	{
 		if(p == NULL)
 	      exit(0);
-		PWii->RefreshWiimotes();
-		Orientation o;
-		Orientation toMove;
+		IntVector2 o(0,0);
+		float r = 0; //roll variable
 		for (int i=0; i<4; i++)
 		{
 			if(PWii->Poll())
 				{
-					//orxout()<<"test11"<<endl;
 					switch (p->GetEvent())
 					{
 						case CWiimote::EVENT_EVENT:
 						{
 							if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily
-								{
-									orxout()<<"fak u dolan"<<endl;
-									CommandExecutor::execute("fire 0", 0, 0);
-								}
-							if (i==0)
-								p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
-							//orxout()<<time.getDeltaTime()<<std::endl;
-
+							{
+								//orxout()<<"fak u dolan"<<endl;
+								CommandExecutor::execute("fire 0", 0, 0);
+							}
+//							if(p->ExpansionDevice.GetType()==CExpansionDevice::TYPE_NUNCHUK)
+//							{
+//								if(p->ExpansionDevice.Nunchuk.Buttons.isPressed(CNunchukButtons::BUTTON_C))
+//									CommandExecutor::execute("NewHumanController accelerate");
+//								if(p->ExpansionDevice.Nunchuk.Buttons.isPressed(CNunchukButtons::BUTTON_Z))
+//									CommandExecutor::execute("NewHumanController decelerate");
+//							}
+//							float dummyPitch, dummyYaw, dummyRoll;
+//							p->Accelerometer.GetOrientation(dummyPitch, dummyRoll, dummyYaw);
+//							r += dummyRoll;
 							break;
 						}
 						case CWiimote::EVENT_STATUS:
@@ -47,23 +51,34 @@
 					}
 				}
 		}
-		//orxout() << time.getDeltaTime()<<endl;
-		orxout() << o.pitch << endl;
-	//	int x = (int)(-10*(o.yaw-lastOrientation.yaw)); //get difference in orientation, divide by time to make faster movements result in faster orientation change
-		int y = (int)(4*(o.pitch-lastOrientation.pitch));//-lastOrientation.pitch)/time.getDeltaTime());
-		int x=0;
-		//orxout() << x<< endl << y << endl;
+//		r/=4;
+//		std::stringstream temp;
+//		temp << "scale ";
+//		temp << (r-lastOrientation.roll);
+//		temp << " rotateRoll";
+//		string com = temp.str();
+//		orxout()<<com<<endl;
+//		//CommandExecutor::execute(com, 0, 0);
+
 		IntVector2 abs(0,0);
-		IntVector2 rel(x,y);
+		IntVector2 rel(0,0);
 		IntVector2 clippingSize(1920, 1080);
+		p->IR.GetCursorPosition(o.x, o.y);
+//		orxout() << "y: " << o.y << " x: " << o.x << endl;
+//		orxout() << p->IR.GetNumDots() << endl;
+		rel.x = (o.x-lastCursor.x);
+		rel.y = (o.y-lastCursor.y);
+		abs.x = o.x;
+		abs.y = o.y;
+		if((rel.x!=0 || rel.y!=0))
+					{
+						for (unsigned int i = 0; i < inputStates_.size(); ++i)
+							inputStates_[i]->mouseMoved(abs, rel, clippingSize); 	//pass random mouse movements to all input states
+					}
+		lastCursor.x = o.x;
+		lastCursor.y = o.y;
+		lastOrientation.roll = r;
 
-
-		if((x!=0 || y!=0)&&(o.pitch!=0))
-			{
-				for (unsigned int i = 0; i < inputStates_.size(); ++i)
-					inputStates_[i]->mouseMoved(abs, rel, clippingSize); 	//pass random mouse movements to all input states
-			}
-		lastOrientation = o;
 	}
 	void WiiMote::clearBuffers()
 	{
@@ -80,6 +95,7 @@
 		lastOrientation.yaw = 0;
 		lastOrientation.roll = 0;
 		lastOrientation.pitch = 0;
-
+		lastCursor.x = 0;
+		lastCursor.y = 0;
 	}
 }

Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.h
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.h	2013-12-16 14:03:17 UTC (rev 9910)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.h	2013-12-16 14:06:08 UTC (rev 9911)
@@ -38,5 +38,6 @@
 	         void test(int x, int y);
 	         CWiimote * p;
 	         CWii * PWii; //parent "wii" the wiimote is registered to
+	         IntVector2 lastCursor;
 	};
 };




More information about the Orxonox-commit mailing list