|
|
|
@ -79,60 +79,6 @@ 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; |
|
|
|
@ -186,7 +132,6 @@ bool Input::Released(){ |
|
|
|
|
} |
|
|
|
|
if(inputReleased){ |
|
|
|
|
usingGamepad=type==CONTROLLER; |
|
|
|
|
initialHoldDownTime=holdDownTime=0.f; //Reset hold times if we release the key.
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
@ -264,9 +209,28 @@ const bool InputGroup::Pressed()const{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const bool InputGroup::PressedDAS()const{ |
|
|
|
|
const bool InputGroup::PressedDAS(){ |
|
|
|
|
for(Input input:keys){ |
|
|
|
|
if(input.PressedDAS())return true; |
|
|
|
|
if(input.Pressed()){ |
|
|
|
|
if(initialHoldDownTime==0.f){ |
|
|
|
|
initialHoldDownTime="Interface.InitialScrollDelay"_F; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
}else |
|
|
|
|
if(input.Held()&&initialHoldDownTime>0.f){ |
|
|
|
|
initialHoldDownTime-=game->GetElapsedTime(); |
|
|
|
|
if(initialHoldDownTime<=0.f){ |
|
|
|
|
holdDownTime="Interface.ScrollDelay"_F; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
}else |
|
|
|
|
if(input.Held()&&holdDownTime>0.f){ |
|
|
|
|
holdDownTime-=game->GetElapsedTime(); |
|
|
|
|
if(holdDownTime<=0.f){ |
|
|
|
|
holdDownTime="Interface.ScrollDelay"_F; |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
@ -278,9 +242,12 @@ const bool InputGroup::Held()const{ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const bool InputGroup::Released()const{ |
|
|
|
|
const bool InputGroup::Released(){ |
|
|
|
|
for(Input input:keys){ |
|
|
|
|
if(input.Released())return true; |
|
|
|
|
if(input.Released()){ |
|
|
|
|
initialHoldDownTime=holdDownTime=0.f; //Reset hold times if we release the key.
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|