Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 13, 2009, 10:43:59 PM (15 years ago)
Author:
rgrieder
Message:

Finally found a satisfying way to deal with interfaces that deliver information, but only upon virtual call.
The solution involves a static variable but any other (and uglier/hackier) solution will do so too.
I applied the method the the JoyStickQuantityListener so that the KeyBinder is now independent on the InputManager.

File:
1 edited

Legend:

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

    r3286 r3288  
    260260
    261261        // inform all JoyStick Device Number Listeners
    262         for (ObjectList<JoyStickQuantityListener>::iterator it = ObjectList<JoyStickQuantityListener>::begin(); it; ++it)
    263             it->JoyStickQuantityChanged(devices_.size() - InputDeviceEnumerator::FirstJoyStick);
     262        std::vector<JoyStick*> joyStickList;
     263        for (unsigned int i = InputDeviceEnumerator::FirstJoyStick; i < devices_.size(); ++i)
     264            joyStickList.push_back(static_cast<JoyStick*>(devices_[i]));
     265        JoyStickQuantityListener::changeJoyStickQuantity(joyStickList);
    264266    }
    265267
     
    572574        if (statesByName_.find(name) == statesByName_.end())
    573575        {
    574             InputState* state = new InputState;
    575576            if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
    576577            {
     
    583584                        COUT(2) << "Warning: Could not add an InputState with the same priority '"
    584585                            << static_cast<int>(priority) << "' != 0." << std::endl;
    585                         return false;
     586                        return 0;
    586587                    }
    587588                }
    588589            }
     590            InputState* state = new InputState(name, bAlwaysGetsInput, bTransparent, priority);
    589591            statesByName_[name] = state;
    590             state->JoyStickQuantityChanged(devices_.size() - InputDeviceEnumerator::FirstJoyStick);
    591             state->setName(name);
    592             state->bAlwaysGetsInput_ = bAlwaysGetsInput;
    593             state->bTransparent_ = bTransparent;
    594             if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
    595                 state->setPriority(priority);
    596592
    597593            return state;
Note: See TracChangeset for help on using the changeset viewer.