Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9890


Ignore:
Timestamp:
Dec 9, 2013, 5:05:44 PM (10 years ago)
Author:
georgr
Message:

hardly any spazzing around from the accelerometer now - there is some lag, but it's negligible. no lag when shooting.

Location:
code/branches/wiimote/src/libraries/core/input
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/wiimote/src/libraries/core/input/InputManager.cc

    r9876 r9890  
    440440
    441441        BOOST_FOREACH(InputDevice* device, devices_)
    442             if (device != NULL || device->getDeviceID()!=2)
     442            if (device != NULL)
    443443                device->update(time);
    444         devices_[2]->update(time);
     444
    445445
    446446
  • code/branches/wiimote/src/libraries/core/input/WiiMote.cc

    r9876 r9890  
    1212        void WiiMote::update(const Clock& time)
    1313        {
    14                 //orxout(user_warning) << this->inputStates_.size() << std::endl;
    1514                if(p == NULL)
    1615              exit(0);
    17                 //else
    18                   //orxout(user_warning) << "pointer is not null, yay" << std::endl;
    1916                PWii->RefreshWiimotes();
    20                 if(PWii->Poll())
     17                Orientation o;
     18                Orientation toMove;
     19                for (int i=0; i<4; i++)
    2120                {
    22                         orxout()<<"test11"<<endl;
    23                         switch (p->GetEvent())
     21                        if(PWii->Poll())
     22                                {
     23                                        //orxout()<<"test11"<<endl;
     24                                        switch (p->GetEvent())
     25                                        {
     26                                                case CWiimote::EVENT_EVENT:
     27                                                {
     28                                                        if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily
     29                                                                {
     30                                                                        orxout()<<"fak u dolan"<<endl;
     31                                                                        CommandExecutor::execute("fire 0", 0, 0);
     32                                                                }
     33                                                        if (i==0)
     34                                                                p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
     35                                                        //orxout()<<time.getDeltaTime()<<std::endl;
     36
     37                                                        break;
     38                                                }
     39                                                case CWiimote::EVENT_STATUS:
     40                                                {
     41
     42                                                        break;
     43                                                }
     44                                                default:
     45                                                        break;
     46
     47                                        }
     48                                }
     49                }
     50                //orxout() << time.getDeltaTime()<<endl;
     51                orxout() << o.pitch << endl;
     52        //      int x = (int)(-10*(o.yaw-lastOrientation.yaw)); //get difference in orientation, divide by time to make faster movements result in faster orientation change
     53                int y = (int)(4*(o.pitch-lastOrientation.pitch));//-lastOrientation.pitch)/time.getDeltaTime());
     54                int x=0;
     55                //orxout() << x<< endl << y << endl;
     56                IntVector2 abs(0,0);
     57                IntVector2 rel(x,y);
     58                IntVector2 clippingSize(1920, 1080);
     59
     60
     61                if((x!=0 || y!=0)&&(o.pitch!=0))
    2462                        {
    25                                 case CWiimote::EVENT_EVENT:
    26                                 {
    27                                         if(p->Buttons.isPressed(CButtons::BUTTON_A)||p->Buttons.isJustPressed(CButtons::BUTTON_A)) //ugly hack to just do something on button press easily
    28                                                                                 {
    29                                                                                         orxout()<<"fak u dolan"<<endl;
    30                                                                                         CommandExecutor::execute("fire 0", 0, 0);
    31                                                                                 }
    32                                         Orientation o;
    33                                         p->Accelerometer.GetOrientation(o.pitch, o.roll, o.yaw);
    34                                         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
    35                                         int y = (int)((o.pitch-lastOrientation.pitch)/time.getDeltaTime());
    36                                         orxout()<<time.getDeltaTime()<<std::endl;
    37                                         IntVector2 abs(0, 0);
    38                                         IntVector2 rel(x, y);
    39                                         IntVector2 clippingSize(1920, 1080);
    40                                         lastOrientation.pitch = o.pitch;
    41                                         lastOrientation.yaw = o.yaw;
    42                                         orxout()<<x<<std::endl<<y<<std::endl;
    43                                         if(x!=0 || y!=0)
    44                                         {
    45                                                 for (unsigned int i = 0; i < inputStates_.size(); ++i)
    46                                                 inputStates_[i]->mouseMoved(abs, rel, clippingSize);    //pass random mouse movements to all input states
    47                                         }
    48                                         break;
    49                                 }
    50                                 case CWiimote::EVENT_STATUS:
    51                                 {
    52 
    53                                         break;
    54                                 }
    55                                 default:
    56                                         break;
    57 
     63                                for (unsigned int i = 0; i < inputStates_.size(); ++i)
     64                                        inputStates_[i]->mouseMoved(abs, rel, clippingSize);    //pass random mouse movements to all input states
    5865                        }
    59                 }
    60 
     66                lastOrientation = o;
    6167        }
    6268        void WiiMote::clearBuffers()
  • code/branches/wiimote/src/libraries/core/input/WiiMote.h

    r9853 r9890  
    2929
    3030         protected:
    31                  void calibrationStarted() { }
    32                  void calibrationStopped() { }
    33                  Orientation lastOrientation;
    34                  //! List of all input states that receive events from this device
    35                  //std::vector<InputState*> inputStates_;
     31                void calibrationStarted() { }
     32                void calibrationStopped() { }
     33                Orientation lastOrientation;
     34                Orientation averageOrientation(Orientation o[], int l);
    3635
    3736         private:
Note: See TracChangeset for help on using the changeset viewer.