Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

A should fire main lazors now

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