MCPcopy Create free account
hub / github.com/Svxy/The-Simpsons-Hit-and-Run / DispatchOnButton

Method DispatchOnButton

game/code/input/mappable.cpp:29–67  ·  view source on GitHub ↗

Route the Button changes through the Active Mapper.

Source from the content-addressed store, hash-verified

27// Route the Button changes through the Active Mapper.
28//
29void 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*)

Callers 3

UpdateMethod · 0.80
ButtonCallbackFunction · 0.80
usercontroller.cppFile · 0.80

Calls 3

GetLogicalIndexMethod · 0.80
TimeSinceChangeMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected