#include "WiiMote.h" #include "core/CoreIncludes.h" //#include "core/command/ConsoleCommand.h" #include #include "core/command/CommandExecutor.h" namespace orxonox { const std::string WiiMote::deviceName = "WiiMote"; void WiiMote::update(const Clock& time) { if(p == NULL) exit(0); IntVector2 o(0,0); float r = 0; //roll variable for (int i=0; i<4; i++) { if(PWii->Poll()) { 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"<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: { break; } default: break; } } } r/=4; std::stringstream temp; // temp << "scale "; if (r>0) temp << "HumanController rotateRoll 1,1"; if (r<0) temp << "HumanController rotateRoll -1,-1"; if (r==0) temp << ""; // temp << " rotateRoll"; string com = temp.str(); //orxout()<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; } void WiiMote::clearBuffers() { } void WiiMote::test(int x, int y) { } WiiMote::WiiMote(unsigned int id, CWiimote & parent, CWii & parentWii) : InputDevice(id) { p = &parent; PWii = &parentWii; lastOrientation.yaw = 0; lastOrientation.roll = 0; lastOrientation.pitch = 0; lastCursor.x = 0; lastCursor.y = 0; } }