Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

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