MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ModifierHeld

Function ModifierHeld

engine/Poseidon/Input/InputSubsystem.cpp:212–236  ·  view source on GitHub ↗

Modifier check: a v1 binding can carry an optional held input in the parallel userKeysModifiers[] array. If set, the modifier must be currently held for the binding to fire. Returns true if no modifier is required OR the modifier is held.

Source from the content-addressed store, hash-verified

210// currently held for the binding to fire. Returns true if no modifier
211// is required OR the modifier is held.
212static bool ModifierHeld(const Input& in, UserAction action, int slot)
213{
214 if (slot >= in.userKeysModifiers[action].Size())
215 return true;
216 int mod = in.userKeysModifiers[action][slot];
217 if (mod < 0)
218 return true;
219
220 const int value = InputBindingValue(mod);
221 switch (InputBindingDevice(mod))
222 {
223 case INPUT_DEVICE_KEYBOARD:
224 return value >= 0 && value < SDL_SCANCODE_COUNT && in.keyboard.keys[value] > 0.0f;
225 case INPUT_DEVICE_MOUSE:
226 return value >= 0 && value < N_MOUSE_BUTTONS && in.mouse.buttons[value] > 0.0f;
227 case INPUT_DEVICE_STICK:
228 return value >= 0 && value < N_JOYSTICK_BUTTONS && in.gamepad.stickButtons[value] > 0.0f;
229 case INPUT_DEVICE_STICK_AXIS:
230 return value >= 0 && value < N_JOYSTICK_AXES && std::fabs(in.gamepad.stickAxis[value]) > 0.8f;
231 case INPUT_DEVICE_STICK_POV:
232 return value >= 0 && value < N_JOYSTICK_POV && in.gamepad.stickPov[value];
233 default:
234 return false;
235 }
236}
237
238static float QueryAction(const Input& in, UserAction action, bool checkFocus)
239{

Callers 2

QueryActionFunction · 0.85
QueryActionToDoFunction · 0.85

Calls 4

InputBindingValueFunction · 0.85
InputBindingDeviceFunction · 0.85
fabsFunction · 0.85
SizeMethod · 0.45

Tested by

no test coverage detected