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

Method IsKeyDown

Source/UserInput/input.cpp:1013–1033  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1011}
1012
1013bool Input::IsKeyDown(const char* name) {
1014 if (strlen(name) <= 5 || memcmp(name, "mouse", 5) != 0) {
1015 return keyboard_.isScancodeDown(StringToSDLScancode(name), KIMF_PLAYING);
1016 } else if (strcmp(name, "mousescrollup") == 0) {
1017 return mouse_.wheel_delta_y_ > 0;
1018 } else if (strcmp(name, "mousescrolldown") == 0) {
1019 return mouse_.wheel_delta_y_ < 0;
1020 } else if (strcmp(name, "mousescrollleft") == 0) {
1021 return mouse_.wheel_delta_x_ < 0;
1022 } else if (strcmp(name, "mousescrollright") == 0) {
1023 return mouse_.wheel_delta_x_ > 0;
1024 } else {
1025 int button = atoi(name + 5);
1026 if (button >= 0 && button < Mouse::MouseButton::NUM_BUTTONS)
1027 return mouse_.mouse_down_[button] == Mouse::ClickState::HELD;
1028 else {
1029 LOGW << "Unknown mouse button \"" << name << "\"" << std::endl;
1030 return false;
1031 }
1032 }
1033}
1034
1035bool Input::IsControllerConnected() {
1036 return !open_joysticks_.empty();

Callers

nothing calls this directly

Calls 2

StringToSDLScancodeFunction · 0.85
isScancodeDownMethod · 0.80

Tested by

no test coverage detected