Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

trying to get a reaction out of the wiiMote

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->Accelerometer.
24                        p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
25                        int x = (int)(1000*(o.yaw-lastOrientation.yaw)/time.getDeltaTime());
26                        int y = (int)(1000*(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                        if(x!=0 && y!=0)
33                        {
34                                for (unsigned int i = 0; i < inputStates_.size(); ++i)
35                                                                inputStates_[i]->mouseMoved(abs, rel, clippingSize);
36                        }
37                }
38
39
40        }
41        void WiiMote::clearBuffers()
42        {
43
44        }
45        void WiiMote::test(int x, int y)
46        {
47
48        }
49        WiiMote::WiiMote(unsigned int id, CWiimote & parent, CWii & parentWii)  : InputDevice(id)
50        {
51                p = &parent;
52                PWii = &parentWii;
53                lastOrientation.yaw = 0;
54                lastOrientation.roll = 0;
55                lastOrientation.pitch = 0;
56
57        }
58}
Note: See TracBrowser for help on using the repository browser.