Changeset 9876 for code/branches/wiimote/src
- Timestamp:
- Dec 9, 2013, 1:04:09 PM (11 years ago)
- Location:
- code/branches/wiimote/src/libraries/core/input
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/wiimote/src/libraries/core/input/InputManager.cc
r9856 r9876 255 255 wiimote.SetLEDs(LED_MAP[index]); 256 256 try 257 258 259 260 261 262 263 264 265 266 267 268 257 { 258 orxout()<< "Size of devices vector before wiimote insertion:" << devices_.size() << std::endl; 259 devices_.push_back(new WiiMote((unsigned int)devices_.size(), *i, wii)); 260 //devices_[2] = new WiiMote(devices_.size(), *(new CWiimote())); 261 orxout()<< "Size of devices vector after wiimote insertion:" << devices_.size() << std::endl; 262 wiimote.SetMotionSensingMode(CWiimote::ON); 263 264 } 265 catch(std::exception& e) //gotta catch em all 266 { 267 orxout()<<"Exception loading WiiMote!!!1!11!"; 268 } 269 269 270 270 … … 432 432 } 433 433 } 434 434 435 if (bUpdateRequired) 435 436 updateActiveStates(); … … 437 438 // Capture all the input and collect the function calls 438 439 // No event gets triggered here yet! 440 439 441 BOOST_FOREACH(InputDevice* device, devices_) 440 if (device != NULL )442 if (device != NULL || device->getDeviceID()!=2) 441 443 device->update(time); 444 devices_[2]->update(time); 445 442 446 443 447 // Collect function calls for the update -
code/branches/wiimote/src/libraries/core/input/WiiMote.cc
r9863 r9876 17 17 //else 18 18 //orxout(user_warning) << "pointer is not null, yay" << std::endl; 19 PWii->Poll(); 19 PWii->RefreshWiimotes(); 20 if(PWii->Poll()) 21 { 22 orxout()<<"test11"<<endl; 23 switch (p->GetEvent()) 24 { 25 case CWiimote::EVENT_EVENT: 26 { 27 if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily 28 { 29 orxout()<<"fak u dolan"<<endl; 30 CommandExecutor::execute("fire 0", 0, 0); 31 } 32 Orientation o; 33 p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw); 34 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 35 int y = (int)((o.pitch-lastOrientation.pitch)/time.getDeltaTime()); 36 orxout()<<time.getDeltaTime()<<std::endl; 37 IntVector2 abs(0, 0); 38 IntVector2 rel(x, y); 39 IntVector2 clippingSize(1920, 1080); 40 lastOrientation.pitch = o.pitch; 41 lastOrientation.yaw = o.yaw; 42 orxout()<<x<<std::endl<<y<<std::endl; 43 if(x!=0 || y!=0) 44 { 45 for (unsigned int i = 0; i < inputStates_.size(); ++i) 46 inputStates_[i]->mouseMoved(abs, rel, clippingSize); //pass random mouse movements to all input states 47 } 48 break; 49 } 50 case CWiimote::EVENT_STATUS: 51 { 20 52 21 p->UpdateStatus(); //perhaps this will help against the lag? 22 if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily 23 { 24 CommandExecutor::execute("fire 0", 0, 0); 53 break; 25 54 } 26 Orientation o; 55 default: 56 break; 27 57 28 p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);29 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 change30 int y = (int)((o.pitch-lastOrientation.pitch)/time.getDeltaTime());31 orxout()<<time.getDeltaTime()<<std::endl;32 IntVector2 abs(0, 0);33 IntVector2 rel(x, y);34 IntVector2 clippingSize(1920, 1080);35 lastOrientation.pitch = o.pitch;36 lastOrientation.yaw = o.yaw;37 orxout()<<x<<std::endl<<y<<std::endl;38 if(x!=0 || y!=0)39 {40 for (unsigned int i = 0; i < inputStates_.size(); ++i)41 inputStates_[i]->mouseMoved(abs, rel, clippingSize); //pass random mouse movements to all input states42 58 } 59 } 43 60 44 61 }
Note: See TracChangeset
for help on using the changeset viewer.