Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 17, 2016, 10:29:21 PM (9 years ago)
Author:
landauf
Message:

merged branch cpp11_v3 back to trunk

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/input/KeyBinder.cc

    r11052 r11071  
    5353        : deriveTime_(0.0f)
    5454        , filename_(filename)
    55         , configFile_(NULL)
    56         , fallbackConfigFile_(NULL)
     55        , configFile_(nullptr)
     56        , fallbackConfigFile_(nullptr)
    5757    {
    5858        mouseRelative_[0] = 0;
     
    153153    void KeyBinder::buttonThresholdChanged()
    154154    {
    155         for (unsigned int i = 0; i < allHalfAxes_.size(); i++)
    156             if (!allHalfAxes_[i]->bButtonThresholdUser_)
    157                 allHalfAxes_[i]->buttonThreshold_ = this->buttonThreshold_;
     155        for (HalfAxis* halfAxis : allHalfAxes_)
     156            if (!halfAxis->bButtonThresholdUser_)
     157                halfAxis->buttonThreshold_ = this->buttonThreshold_;
    158158    }
    159159
     
    170170
    171171        // load the bindings if required
    172         if (configFile_ != NULL)
     172        if (configFile_ != nullptr)
    173173        {
    174174            for (unsigned int iDev = oldValue; iDev < joySticks_.size(); ++iDev)
     
    188188    {
    189189        while (joyStickAxes_.size() < joySticks_.size())
    190             joyStickAxes_.push_back(shared_ptr<JoyStickAxisVector>(new JoyStickAxisVector()));
     190            joyStickAxes_.push_back(std::make_shared<JoyStickAxisVector>());
    191191        while (joyStickButtons_.size() < joySticks_.size())
    192             joyStickButtons_.push_back(shared_ptr<JoyStickButtonVector>(new JoyStickButtonVector()));
     192            joyStickButtons_.push_back(std::make_shared<JoyStickButtonVector>());
    193193        // For the case the new size is smaller
    194194        this->joyStickAxes_.resize(joySticks_.size());
     
    274274
    275275        // Parse bindings and create the ConfigValueContainers if necessary
    276         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    277         {
    278             it->second->readBinding(this->configFile_, this->fallbackConfigFile_);
    279             addButtonToCommand(it->second->bindingString_, it->second);
     276        for (const auto& mapEntry : allButtons_)
     277        {
     278            mapEntry.second->readBinding(this->configFile_, this->fallbackConfigFile_);
     279            addButtonToCommand(mapEntry.second->bindingString_, mapEntry.second);
    280280        }
    281281
     
    420420    void KeyBinder::clearBindings()
    421421    {
    422         for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    423             it->second->clear();
    424 
    425         for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
    426             delete paramCommandBuffer_[i];
     422        for (const auto& mapEntry : allButtons_)
     423            mapEntry.second->clear();
     424
     425        for (BufferedParamCommand* command : paramCommandBuffer_)
     426            delete command;
    427427        paramCommandBuffer_.clear();
    428428    }
     
    434434    {
    435435        // iterate over all buttons
    436         for (std::map<std::string, Button*>::iterator it = this->allButtons_.begin(); it != this->allButtons_.end(); ++it)
    437         {
    438             Button* button = it->second;
     436        for (const auto& mapEntry : this->allButtons_)
     437        {
     438            Button* button = mapEntry.second;
    439439
    440440            // iterate over all modes
     
    479479                        {
    480480                            delete[] button->commands_[mode_index];
    481                             button->commands_[mode_index] = 0;
     481                            button->commands_[mode_index] = nullptr;
    482482                        }
    483483
     
    505505        this->mousePosition_[1] = 0.0f;
    506506
    507         for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
    508             mouseAxes_[i].reset();
     507        for (HalfAxis& axis : mouseAxes_)
     508            axis.reset();
    509509    }
    510510
     
    545545        }
    546546
    547         for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
     547        for (HalfAxis& axis : mouseAxes_)
    548548        {
    549549            // Why dividing relative value by dt? The reason lies in the simple fact, that when you
     
    555555            {
    556556                // just ignore if dt == 0.0 because we have multiplied by 0.0 anyway..
    557                 mouseAxes_[i].relVal_ /= dt;
    558             }
    559 
    560             tickHalfAxis(mouseAxes_[i]);
     557                axis.relVal_ /= dt;
     558            }
     559
     560            tickHalfAxis(axis);
    561561        }
    562562    }
Note: See TracChangeset for help on using the changeset viewer.