[Orxonox-commit 5227] r9890 - code/branches/wiimote/src/libraries/core/input

georgr at orxonox.net georgr at orxonox.net
Mon Dec 9 17:05:44 CET 2013


Author: georgr
Date: 2013-12-09 17:05:44 +0100 (Mon, 09 Dec 2013)
New Revision: 9890

Modified:
   code/branches/wiimote/src/libraries/core/input/InputManager.cc
   code/branches/wiimote/src/libraries/core/input/WiiMote.cc
   code/branches/wiimote/src/libraries/core/input/WiiMote.h
Log:
hardly any spazzing around from the accelerometer now - there is some lag, but it's negligible. no lag when shooting.

Modified: code/branches/wiimote/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputManager.cc	2013-12-09 15:06:38 UTC (rev 9889)
+++ code/branches/wiimote/src/libraries/core/input/InputManager.cc	2013-12-09 16:05:44 UTC (rev 9890)
@@ -439,11 +439,11 @@
         // No event gets triggered here yet!
 
         BOOST_FOREACH(InputDevice* device, devices_)
-            if (device != NULL || device->getDeviceID()!=2)
+            if (device != NULL)
                 device->update(time);
-        devices_[2]->update(time);
 
 
+
         // Collect function calls for the update
         for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
             activeStatesTicked_[i]->update(time.getDeltaTime());

Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.cc	2013-12-09 15:06:38 UTC (rev 9889)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.cc	2013-12-09 16:05:44 UTC (rev 9890)
@@ -11,53 +11,59 @@
 	const std::string WiiMote::deviceName = "WiiMote";
 	void WiiMote::update(const Clock& time)
 	{
-		//orxout(user_warning) << this->inputStates_.size() << std::endl;
 		if(p == NULL)
 	      exit(0);
-		//else
-		  //orxout(user_warning) << "pointer is not null, yay" << std::endl;
 		PWii->RefreshWiimotes();
-		if(PWii->Poll())
+		Orientation o;
+		Orientation toMove;
+		for (int i=0; i<4; i++)
 		{
-			orxout()<<"test11"<<endl;
-			switch (p->GetEvent())
-			{
-				case CWiimote::EVENT_EVENT:
+			if(PWii->Poll())
 				{
-					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);
-										}
-					Orientation o;
-					p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
-					int x = (int)(500*(o.yaw-lastOrientation.yaw)/time.getDeltaTime()); //get difference in orientation, divide by time to make faster movements result in faster orientation change
-					int y = (int)((o.pitch-lastOrientation.pitch)/time.getDeltaTime());
-					orxout()<<time.getDeltaTime()<<std::endl;
-					IntVector2 abs(0, 0);
-					IntVector2 rel(x, y);
-					IntVector2 clippingSize(1920, 1080);
-					lastOrientation.pitch = o.pitch;
-					lastOrientation.yaw = o.yaw;
-					orxout()<<x<<std::endl<<y<<std::endl;
-					if(x!=0 || y!=0)
+					//orxout()<<"test11"<<endl;
+					switch (p->GetEvent())
 					{
-						for (unsigned int i = 0; i < inputStates_.size(); ++i)
-						inputStates_[i]->mouseMoved(abs, rel, clippingSize); 	//pass random mouse movements to all input states
+						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;
+
+							break;
+						}
+						case CWiimote::EVENT_STATUS:
+						{
+
+							break;
+						}
+						default:
+							break;
+
 					}
-					break;
 				}
-				case CWiimote::EVENT_STATUS:
-				{
+		}
+		//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;
+		IntVector2 abs(0,0);
+		IntVector2 rel(x,y);
+		IntVector2 clippingSize(1920, 1080);
 
-					break;
-				}
-				default:
-					break;
 
+		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()
 	{

Modified: code/branches/wiimote/src/libraries/core/input/WiiMote.h
===================================================================
--- code/branches/wiimote/src/libraries/core/input/WiiMote.h	2013-12-09 15:06:38 UTC (rev 9889)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.h	2013-12-09 16:05:44 UTC (rev 9890)
@@ -28,11 +28,10 @@
 	        void clearBuffers();
 
 	 protected:
-	         void calibrationStarted() { }
-	         void calibrationStopped() { }
-	         Orientation lastOrientation;
-	         //! List of all input states that receive events from this device
-		 //std::vector<InputState*> inputStates_;
+	        void calibrationStarted() { }
+	        void calibrationStopped() { }
+	        Orientation lastOrientation;
+	        Orientation averageOrientation(Orientation o[], int l);
 
 	 private:
 	         static const std::string deviceName;




More information about the Orxonox-commit mailing list