Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/wiimote/src/libraries/core/input/WiiMote.cc @ 9846

Last change on this file since 9846 was 9846, checked in by georgr, 10 years ago

trying to get a reaction out of the wiiMote, 5th try

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