MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / AS_GetInputDownFiltered

Function AS_GetInputDownFiltered

Source/Scripting/angelscript/asfuncs.cpp:237–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237static bool AS_GetInputDownFiltered(int controller_id, const std::string& which_key, uint32_t filter) {
238 PlayerInput* controller = Input::Instance()->GetController(controller_id);
239
240 if (controller == NULL) {
241 return false;
242 }
243
244 bool key_down = false;
245
246 PlayerInput::KeyDownMap::iterator iter = controller->key_down.find(which_key);
247 if (iter != controller->key_down.end()) {
248 return iter->second.depth_count != 0;
249 } else {
250 if (which_key == "move_left") {
251 key_down = controller->key_down["left"].count != 0;
252 } else if (which_key == "move_right") {
253 key_down = controller->key_down["right"].count != 0;
254 } else if (which_key == "move_up") {
255 key_down = controller->key_down["up"].count != 0;
256 } else if (which_key == "move_down") {
257 key_down = controller->key_down["down"].count != 0;
258 } else if (which_key == "skip_dialogue") {
259 key_down = controller->key_down["skip_dialogue"].count != 0;
260 } else if (which_key == "mouse0") {
261 key_down = Input::Instance()->getMouse().mouse_down_[Mouse::LEFT] != 0;
262 } else if (which_key == "mousescrollup") {
263 key_down = Input::Instance()->getMouse().wheel_delta_y_ > 0;
264 } else if (which_key == "mousescrolldown") {
265 key_down = Input::Instance()->getMouse().wheel_delta_y_ < 0;
266 } else if (which_key == "mousescrollleft") {
267 key_down = Input::Instance()->getMouse().wheel_delta_x_ < 0;
268 } else if (which_key == "mousescrollright") {
269 key_down = Input::Instance()->getMouse().wheel_delta_x_ > 0;
270 } else {
271 SDL_Scancode key = StringToSDLScancode(which_key);
272 if (key != SDL_SCANCODE_SYSREQ) {
273 key_down = Input::Instance()->getKeyboard().isScancodeDown(key, filter);
274 }
275 }
276 }
277
278 return key_down;
279}
280
281static bool AS_GetInputDown(int controller_id, const std::string& which_key) {
282 return AS_GetInputDownFiltered(controller_id, which_key, KIMF_PLAYING);

Callers 1

AS_GetInputDownFunction · 0.85

Calls 5

StringToSDLScancodeFunction · 0.85
GetControllerMethod · 0.80
isScancodeDownMethod · 0.80
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected