| 1 | #include "WiiMote.h" |
|---|
| 2 | #include "core/CoreIncludes.h" |
|---|
| 3 | //#include "core/command/ConsoleCommand.h" |
|---|
| 4 | #include <wiicpp/wiicpp/wiicpp.h> |
|---|
| 5 | #include <command/CommandExecutor.h> |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | namespace orxonox |
|---|
| 9 | { |
|---|
| 10 | |
|---|
| 11 | const std::string WiiMote::deviceName = "WiiMote"; |
|---|
| 12 | void WiiMote::update(const Clock& time) |
|---|
| 13 | { |
|---|
| 14 | orxout(user_warning) << this->inputStates_.size() << std::endl; |
|---|
| 15 | if(p == NULL) |
|---|
| 16 | exit(0); |
|---|
| 17 | //else |
|---|
| 18 | //orxout(user_warning) << "pointer is not null, yay" << std::endl; |
|---|
| 19 | if (PWii->Poll()) |
|---|
| 20 | { |
|---|
| 21 | CWiimote::EventTypes e = p->GetEvent(); |
|---|
| 22 | if(p->Buttons.isPressed(CButtons::BUTTON_A)) |
|---|
| 23 | { |
|---|
| 24 | CE->execute("fire 0", 0, 0); |
|---|
| 25 | } |
|---|
| 26 | Orientation o; |
|---|
| 27 | p->SetMotionSensingMode(CWiimote::ON); |
|---|
| 28 | p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw); |
|---|
| 29 | int x = (int)(500*(o.yaw-lastOrientation.yaw)/time.getDeltaTime()); |
|---|
| 30 | int y = (int)((o.pitch-lastOrientation.pitch)/time.getDeltaTime()); |
|---|
| 31 | IntVector2 abs(0, 0); |
|---|
| 32 | IntVector2 rel(x, y); |
|---|
| 33 | IntVector2 clippingSize(1920, 1080); |
|---|
| 34 | lastOrientation.pitch = o.pitch; |
|---|
| 35 | lastOrientation.yaw = o.yaw; |
|---|
| 36 | orxout()<<x<<std::endl<<y<<std::endl; |
|---|
| 37 | if(x!=0 || y!=0) |
|---|
| 38 | { |
|---|
| 39 | for (unsigned int i = 0; i < inputStates_.size(); ++i) |
|---|
| 40 | inputStates_[i]->mouseMoved(abs, rel, clippingSize); |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | } |
|---|
| 46 | void WiiMote::clearBuffers() |
|---|
| 47 | { |
|---|
| 48 | |
|---|
| 49 | } |
|---|
| 50 | void WiiMote::test(int x, int y) |
|---|
| 51 | { |
|---|
| 52 | |
|---|
| 53 | } |
|---|
| 54 | WiiMote::WiiMote(unsigned int id, CWiimote & parent, CWii & parentWii) : InputDevice(id) |
|---|
| 55 | { |
|---|
| 56 | p = &parent; |
|---|
| 57 | PWii = &parentWii; |
|---|
| 58 | lastOrientation.yaw = 0; |
|---|
| 59 | lastOrientation.roll = 0; |
|---|
| 60 | lastOrientation.pitch = 0; |
|---|
| 61 | CE = &(CommandExecutor::getInstance()); |
|---|
| 62 | |
|---|
| 63 | } |
|---|
| 64 | } |
|---|