Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added debug output with deltatime

File size: 1.8 KB
Line 
1#include "WiiMote.h"
2#include "core/CoreIncludes.h"
3//#include "core/command/ConsoleCommand.h"
4#include <wiicpp/wiicpp/wiicpp.h>
5#include "core/command/CommandExecutor.h"
6
7
8namespace 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                PWii->Poll();
20
21                        p->UpdateStatus(); //perhaps this will help against the lag?
22                        if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily
23                                {
24                                        CommandExecutor::execute("fire 0", 0, 0);
25                                }
26                        Orientation o;
27
28                        p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
29                        int x = (int)(500*(o.yaw-lastOrientation.yaw)/time.getDeltaTime()); //get difference in orientation, divide by time to make faster movements result in faster orientation change
30                        int y = (int)((o.pitch-lastOrientation.pitch)/time.getDeltaTime());
31                        orxout()<<time.getDeltaTime()<<std::endl;
32                        IntVector2 abs(0, 0);
33                        IntVector2 rel(x, y);
34                        IntVector2 clippingSize(1920, 1080);
35                        lastOrientation.pitch = o.pitch;
36                        lastOrientation.yaw = o.yaw;
37                        orxout()<<x<<std::endl<<y<<std::endl;
38                        if(x!=0 || y!=0)
39                        {
40                                for (unsigned int i = 0; i < inputStates_.size(); ++i)
41                                                                inputStates_[i]->mouseMoved(abs, rel, clippingSize);    //pass random mouse movements to all input states
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
61        }
62}
Note: See TracBrowser for help on using the repository browser.