[Orxonox-commit 5213] r9876 - in code/branches/wiimote: cmake/tools src/libraries/core/input

georgr at orxonox.net georgr at orxonox.net
Mon Dec 9 13:04:09 CET 2013


Author: georgr
Date: 2013-12-09 13:04:09 +0100 (Mon, 09 Dec 2013)
New Revision: 9876

Modified:
   code/branches/wiimote/cmake/tools/FindBluetooth.cmake
   code/branches/wiimote/src/libraries/core/input/InputManager.cc
   code/branches/wiimote/src/libraries/core/input/WiiMote.cc
Log:
lag sorta fixed - it disappears after ~40s, but will reappear for unknown reasons

Modified: code/branches/wiimote/cmake/tools/FindBluetooth.cmake
===================================================================
--- code/branches/wiimote/cmake/tools/FindBluetooth.cmake	2013-12-06 14:10:06 UTC (rev 9875)
+++ code/branches/wiimote/cmake/tools/FindBluetooth.cmake	2013-12-09 12:04:09 UTC (rev 9876)
@@ -1,8 +1,8 @@
 IF(LINUX)
 	#FIND_PATH(BLUETOOTH_INCLUDE_DIR NAMES bluetooth PATHS /usr/include/bluetooth/ /usr/local/include/bluetooth /home/georgr/libbluetooth-dev/libbluetooth-dev/usr/include/bluetooth)
 	#FIND_LIBRARY(BLUETOOTH_LIBRARY NAMES bluetooth PATHS  /usr/lib/ /usr/lib/x86_64-linux-gnu /home/georgr/libbluetooth-dev/libbluetooth-dev/usr/lib/x86_64-linux-gnu) 
-	FIND_PATH(BLUETOOTH_INCLUDE_DIR bluetooth /home/georgr/libbluetooth-dev/libbluetooth-dev/usr/include/)
-	FIND_LIBRARY(BLUETOOTH_LIBRARY NAMES bluetooth PATHS  /home/georgr/libbluetooth-dev/libbluetooth-dev/usr/lib/x86_64-linux-gnu/) 
+	FIND_PATH(BLUETOOTH_INCLUDE_DIR bluetooth /usr/include/)
+	FIND_LIBRARY(BLUETOOTH_LIBRARY NAMES bluetooth PATHS  /usr/lib/x86_64-linux-gnu/) 
         MESSAGE(STATUS "Bluetooth library test: ${BLUETOOTH_LIBRARY}")
         MESSAGE(STATUS "Bluetooth header test: ${BLUETOOTH_INCLUDE_DIR}")
 	IF(BLUETOOTH_INCLUDE_DIR AND BLUETOOTH_LIBRARY)

Modified: code/branches/wiimote/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/wiimote/src/libraries/core/input/InputManager.cc	2013-12-06 14:10:06 UTC (rev 9875)
+++ code/branches/wiimote/src/libraries/core/input/InputManager.cc	2013-12-09 12:04:09 UTC (rev 9876)
@@ -254,18 +254,18 @@
     	       CWiimote::LED_3, CWiimote::LED_4};
     	    wiimote.SetLEDs(LED_MAP[index]);
     	    try
-    	               {
-    	                 orxout()<< "Size of devices vector before wiimote insertion:" << devices_.size() << std::endl;
-    	                 devices_.push_back(new WiiMote((unsigned int)devices_.size(), *i, wii));
-    	                 //devices_[2] = new WiiMote(devices_.size(), *(new CWiimote()));
-    	                 orxout()<< "Size of devices vector after wiimote insertion:" << devices_.size() << std::endl;
-    	                 wiimote.SetMotionSensingMode(CWiimote::ON);
+		   {
+			 orxout()<< "Size of devices vector before wiimote insertion:" << devices_.size() << std::endl;
+			 devices_.push_back(new WiiMote((unsigned int)devices_.size(), *i, wii));
+			 //devices_[2] = new WiiMote(devices_.size(), *(new CWiimote()));
+			 orxout()<< "Size of devices vector after wiimote insertion:" << devices_.size() << std::endl;
+			 wiimote.SetMotionSensingMode(CWiimote::ON);
 
-    	               }
-    	               catch(std::exception& e)  //gotta catch em all
-    	               {
-    	                 orxout()<<"Exception loading WiiMote!!!1!11!";
-    	               }
+		   }
+		   catch(std::exception& e)  //gotta catch em all
+		   {
+			 orxout()<<"Exception loading WiiMote!!!1!11!";
+		   }
 
 
 
@@ -431,15 +431,19 @@
                 bUpdateRequired = true;
             }
         }
+
         if (bUpdateRequired)
             updateActiveStates();
 
         // Capture all the input and collect the function calls
         // No event gets triggered here yet!
+
         BOOST_FOREACH(InputDevice* device, devices_)
-            if (device != NULL)
+            if (device != NULL || device->getDeviceID()!=2)
                 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-06 14:10:06 UTC (rev 9875)
+++ code/branches/wiimote/src/libraries/core/input/WiiMote.cc	2013-12-09 12:04:09 UTC (rev 9876)
@@ -16,30 +16,47 @@
 	      exit(0);
 		//else
 		  //orxout(user_warning) << "pointer is not null, yay" << std::endl;
-		PWii->Poll();
-
-			p->UpdateStatus(); //perhaps this will help against the lag?
-			if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily
+		PWii->RefreshWiimotes();
+		if(PWii->Poll())
+		{
+			orxout()<<"test11"<<endl;
+			switch (p->GetEvent())
+			{
+				case CWiimote::EVENT_EVENT:
 				{
-					CommandExecutor::execute("fire 0", 0, 0);
+					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)
+					{
+						for (unsigned int i = 0; i < inputStates_.size(); ++i)
+						inputStates_[i]->mouseMoved(abs, rel, clippingSize); 	//pass random mouse movements to all input states
+					}
+					break;
 				}
-			Orientation o;
+				case CWiimote::EVENT_STATUS:
+				{
 
-			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)
-			{
-				for (unsigned int i = 0; i < inputStates_.size(); ++i)
-								inputStates_[i]->mouseMoved(abs, rel, clippingSize); 	//pass random mouse movements to all input states
+					break;
+				}
+				default:
+					break;
+
 			}
+		}
 
 	}
 	void WiiMote::clearBuffers()




More information about the Orxonox-commit mailing list