Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

3s of lag are still here…next try

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                        IntVector2 abs(0, 0);
32                        IntVector2 rel(x, y);
33                        IntVector2 clippingSize(1920, 1080);
34                        lastOrientation.pitch = o.pitch;
35                        lastOrientation.yaw = o.yaw;
36                        orxout()<<x<<std::endl<<y<<std::endl;
37                        if(x!=0 || y!=0)
38                        {
39                                for (unsigned int i = 0; i < inputStates_.size(); ++i)
40                                                                inputStates_[i]->mouseMoved(abs, rel, clippingSize);    //pass random mouse movements to all input states
41                        }
42                //}
43
44
45        }
46        void WiiMote::clearBuffers()
47        {
48
49        }
50        void WiiMote::test(int x, int y)
51        {
52
53        }
54        WiiMote::WiiMote(unsigned int id, CWiimote & parent, CWii & parentWii)  : InputDevice(id)
55        {
56                p = &parent;
57                PWii = &parentWii;
58                lastOrientation.yaw = 0;
59                lastOrientation.roll = 0;
60                lastOrientation.pitch = 0;
61
62
63        }
64}
Note: See TracBrowser for help on using the repository browser.