mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-25 22:19:10 +00:00
Re-added SDL_GetScancodeFromKey()
This commit is contained in:
parent
4f7c0e7c46
commit
afec46dbee
5 changed files with 34 additions and 7 deletions
|
@ -199,9 +199,29 @@ extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
|
|||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyName
|
||||
* \sa SDL_GetScancodeFromKey
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, SDL_bool key_event);
|
||||
|
||||
/**
|
||||
* Get the scancode corresponding to the given key code according to the
|
||||
* current keyboard layout.
|
||||
*
|
||||
* Note that there may be multiple scancode+modifier states that can generate
|
||||
* this keycode, this will just return the first one found.
|
||||
*
|
||||
* \param key the desired SDL_Keycode to query.
|
||||
* \param modstate a pointer to the modifier state that would be used when the
|
||||
* scancode generates this key, may be NULL.
|
||||
* \returns the SDL_Scancode that corresponds to the given SDL_Keycode.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetKeyFromScancode
|
||||
* \sa SDL_GetScancodeName
|
||||
*/
|
||||
extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate);
|
||||
|
||||
/**
|
||||
* Set a human-readable name for a scancode.
|
||||
*
|
||||
|
|
|
@ -411,6 +411,7 @@ SDL3_0.0.0 {
|
|||
SDL_GetRendererProperties;
|
||||
SDL_GetRevision;
|
||||
SDL_GetSIMDAlignment;
|
||||
SDL_GetScancodeFromKey;
|
||||
SDL_GetScancodeFromName;
|
||||
SDL_GetScancodeName;
|
||||
SDL_GetSemaphoreValue;
|
||||
|
|
|
@ -436,6 +436,7 @@
|
|||
#define SDL_GetRendererProperties SDL_GetRendererProperties_REAL
|
||||
#define SDL_GetRevision SDL_GetRevision_REAL
|
||||
#define SDL_GetSIMDAlignment SDL_GetSIMDAlignment_REAL
|
||||
#define SDL_GetScancodeFromKey SDL_GetScancodeFromKey_REAL
|
||||
#define SDL_GetScancodeFromName SDL_GetScancodeFromName_REAL
|
||||
#define SDL_GetScancodeName SDL_GetScancodeName_REAL
|
||||
#define SDL_GetSemaphoreValue SDL_GetSemaphoreValue_REAL
|
||||
|
|
|
@ -456,6 +456,7 @@ SDL_DYNAPI_PROC(const char *,SDL_GetRendererName,(SDL_Renderer *a),(a),return)
|
|||
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetRendererProperties,(SDL_Renderer *a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetRevision,(void),(),return)
|
||||
SDL_DYNAPI_PROC(size_t,SDL_GetSIMDAlignment,(void),(),return)
|
||||
SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromKey,(SDL_Keycode a, SDL_Keymod *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromName,(const char *a),(a),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetScancodeName,(SDL_Scancode a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint32,SDL_GetSemaphoreValue,(SDL_Semaphore *a),(a),return)
|
||||
|
|
|
@ -453,11 +453,11 @@ static SDL_Keycode SDL_ConvertNumpadKeycode(SDL_Keycode keycode, SDL_bool numloc
|
|||
SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, SDL_bool key_event)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
SDL_Keycode keycode;
|
||||
|
||||
if (key_event) {
|
||||
SDL_Keymap *keymap = SDL_GetCurrentKeymap();
|
||||
SDL_bool numlock = (modstate & SDL_KMOD_NUM) != 0;
|
||||
SDL_Keycode keycode;
|
||||
|
||||
// We won't be applying any modifiers by default
|
||||
modstate = SDL_KMOD_NONE;
|
||||
|
@ -474,15 +474,19 @@ SDL_Keycode SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, S
|
|||
if (keyboard->keycode_options & KEYCODE_OPTION_HIDE_NUMPAD) {
|
||||
keycode = SDL_ConvertNumpadKeycode(keycode, numlock);
|
||||
}
|
||||
} else {
|
||||
// Use the real keymap
|
||||
SDL_Keymap *keymap = keyboard->keymap;
|
||||
|
||||
keycode = SDL_GetKeymapKeycode(keymap, scancode, modstate);
|
||||
}
|
||||
return keycode;
|
||||
}
|
||||
|
||||
return SDL_GetKeymapKeycode(keyboard->keymap, scancode, modstate);
|
||||
}
|
||||
|
||||
SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
return SDL_GetKeymapScancode(keyboard->keymap, key, modstate);
|
||||
}
|
||||
|
||||
static int SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, Uint8 state)
|
||||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue