|
|
|
@ -79,6 +79,60 @@ bool Input::Pressed(){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Input::PressedDAS(){ |
|
|
|
|
if(!game->IsFocused())return false; |
|
|
|
|
bool inputPressed=false; |
|
|
|
|
|
|
|
|
|
auto HandleDAS=[&](const HWButton&button){ |
|
|
|
|
if(button.bPressed){ |
|
|
|
|
if(initialHoldDownTime==0.f){ |
|
|
|
|
initialHoldDownTime="Interface.InitialScrollDelay"_F; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}else |
|
|
|
|
if(button.bHeld&&initialHoldDownTime>0.f){ |
|
|
|
|
initialHoldDownTime-=game->GetElapsedTime(); |
|
|
|
|
if(initialHoldDownTime<=0.f){ |
|
|
|
|
holdDownTime="Interface.ScrollDelay"_F; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}else |
|
|
|
|
if(button.bHeld&&holdDownTime>0.f){ |
|
|
|
|
holdDownTime-=game->GetElapsedTime(); |
|
|
|
|
if(holdDownTime<=0.f){ |
|
|
|
|
holdDownTime="Interface.ScrollDelay"_F; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
switch(type){ |
|
|
|
|
case KEY:{ |
|
|
|
|
if(HandleDAS(game->GetKey(Key(key))))inputPressed=true; |
|
|
|
|
}break; |
|
|
|
|
case MOUSE:{ |
|
|
|
|
if(HandleDAS(game->GetMouse(key)))inputPressed=true; |
|
|
|
|
}break; |
|
|
|
|
case CONTROLLER:{ |
|
|
|
|
for(GamePad*gamepad:GamePad::getGamepads()){ |
|
|
|
|
if(gamepad->stillConnected)if(HandleDAS(gamepad->getButton(static_cast<GPButtons>(key))))inputPressed=true; |
|
|
|
|
} |
|
|
|
|
}break; |
|
|
|
|
case ANALOG:{ |
|
|
|
|
//An analog input can never be "pressed". No-op.
|
|
|
|
|
}break; |
|
|
|
|
default:{ |
|
|
|
|
ERR("Invalid Control Scheme detected! We shouldn't be here!! Type is "<<type); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(inputPressed){ |
|
|
|
|
usingGamepad=type==CONTROLLER; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Input::Held(){ |
|
|
|
|
if(!game->IsFocused())return false; |
|
|
|
|
bool inputHeld=false; |
|
|
|
@ -132,6 +186,7 @@ bool Input::Released(){ |
|
|
|
|
} |
|
|
|
|
if(inputReleased){ |
|
|
|
|
usingGamepad=type==CONTROLLER; |
|
|
|
|
initialHoldDownTime=holdDownTime=0.f; //Reset hold times if we release the key.
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -209,6 +264,13 @@ const bool InputGroup::Pressed()const{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const bool InputGroup::PressedDAS()const{ |
|
|
|
|
for(Input input:keys){ |
|
|
|
|
if(input.PressedDAS())return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const bool InputGroup::Held()const{ |
|
|
|
|
for(Input input:keys){ |
|
|
|
|
if(input.Held())return true; |
|
|
|
|