Route the Button changes through the Active Mapper.
| 27 | // Route the Button changes through the Active Mapper. |
| 28 | // |
| 29 | void Mappable::DispatchOnButton( int controllerId, int id, const Button* pButton ) |
| 30 | { |
| 31 | if(!mActive) |
| 32 | { |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | // perform a lookup on this physical id and set state of the appropriate logical button |
| 37 | int destButtonID = GetActiveMapper( )->GetLogicalIndex(id); |
| 38 | |
| 39 | if ( destButtonID != Input::INVALID_CONTROLLERID && IsActive()) |
| 40 | { |
| 41 | // Grab the state of the button before we update the state. |
| 42 | bool bWasButtonDown = IsButtonDown( destButtonID ); |
| 43 | bool duplicate = mButton[ destButtonID ].TimeSinceChange() == 0; |
| 44 | |
| 45 | if(!duplicate || (duplicate && ( pButton->GetValue( ) >= mButton[ destButtonID].GetValue( ) ))) |
| 46 | { |
| 47 | UpdateButtonState( controllerId, destButtonID, pButton ); |
| 48 | |
| 49 | OnButton( controllerId, destButtonID, pButton ); |
| 50 | |
| 51 | if ( 0.0f == pButton->GetValue( ) ) |
| 52 | { |
| 53 | if ( bWasButtonDown ) |
| 54 | { |
| 55 | OnButtonUp( controllerId, destButtonID, pButton ); |
| 56 | } |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | if ( !bWasButtonDown ) |
| 61 | { |
| 62 | OnButtonDown( controllerId, destButtonID, pButton ); |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // load in a complete button state |
| 70 | // we only update the state, no edge-trigerred stuff (OnButton*) |
no test coverage detected