Skip to content

Commit

Permalink
name error
Browse files Browse the repository at this point in the history
  • Loading branch information
kmamal committed Feb 6, 2024
1 parent 5e55282 commit 0ce8f66
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/native/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ keyboard::getScancode(const Napi::CallbackInfo &info)
std::string keyname = info[0].As<Napi::String>().Utf8Value();

SDL_Keycode keycode = SDL_GetKeyFromName(keyname.c_str());
if (keycode == SDLK_UNKNOWN) { return env.Null(); }
if (keycode == SDLK_UNKNOWN) {
SDL_ClearError();
return env.Null();
}

int scancode = SDL_GetScancodeFromKey(keycode);
if (scancode == 0) { return env.Null(); }
if (scancode == 0) {
SDL_ClearError();
return env.Null();
}

return Napi::Number::New(env, scancode);
}
Expand Down

0 comments on commit 0ce8f66

Please sign in to comment.