Removed keymaps from the API

This is unnecessary complication for applications. We can always add it again later if we find that it's really useful.
This commit is contained in:
Sam Lantinga
2024-08-05 18:04:17 -07:00
parent 1966472f73
commit a13c993e40
11 changed files with 70 additions and 220 deletions

View File

@@ -185,103 +185,22 @@ extern SDL_DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void);
extern SDL_DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate);
/**
* A keymap is a mapping from scancode and modifier state to keycode.
* Get the key code corresponding to the given scancode according to the
* current keyboard layout.
*
* \sa SDL_GetCurrentKeymap
* \sa SDL_GetKeymapKeycode
* \sa SDL_GetKeymapScancode
* \sa SDL_ReleaseKeymap
*/
typedef struct SDL_Keymap SDL_Keymap;
/**
* Get a reference to the current keyboard layout.
* If you want to get the keycode as it would be delivered in key events, including options specified in SDL_HINT_KEYCODE_OPTIONS, then you should pass `key_event` as SDL_TRUE. Otherwise this function simply translates the scancode based on the given modifier state.
*
* You should release the reference to the keymap with SDL_ReleaseKeymap()
* when you're done with it.
*
* \returns the current keymap, or NULL if the default US-QWERTY keymap is
* being used.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetKeymapKeycode
* \sa SDL_GetKeymapScancode
* \sa SDL_ReleaseKeymap
*/
extern SDL_DECLSPEC SDL_Keymap * SDLCALL SDL_GetCurrentKeymap(void);
/**
* Get the key code corresponding to the given scancode and modifier state
* using the provided keymap.
*
* Note that this is not the same as the input that would be generated by
* pressing this key. There are many factors involved, such as dead key
* composition, input method editors, etc. If you're looking for a way to get
* text input, you should handle SDL_EVENT_TEXT_INPUT.
*
* \param keymap the SDL_Keymap to query, or NULL for the default keymap.
* \param scancode the SDL_Scancode to translate.
* \param scancode the desired SDL_Scancode to query.
* \param modstate the modifier state to use when translating the scancode to
* a keycode.
* \param key_event SDL_TRUE if the keycode will be used in key events.
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetCurrentKeymap
* \sa SDL_GetKeymapScancode
* \sa SDL_GetKeyName
*/
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeymapKeycode(SDL_Keymap *keymap, SDL_Scancode scancode, SDL_Keymod modstate);
/**
* Get the scancode and modifier state corresponding to the given key code
* using the provided keymap.
*
* Note that there may be multiple scancode+modifier states that can generate
* this keycode, this will just return the first one found.
*
* \param keymap the SDL_Keymap to query, or NULL for the default keymap.
* \param keycode the SDL_Keycode to translate.
* \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_GetCurrentKeymap
* \sa SDL_GetKeymapKeycode
*/
extern SDL_DECLSPEC SDL_Scancode SDLCALL SDL_GetKeymapScancode(SDL_Keymap *keymap, SDL_Keycode keycode, SDL_Keymod *modstate);
/**
* Release a reference to the current keyboard layout.
*
* \param keymap the SDL_Keymap to release, may be NULL.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetCurrentKeymap
*/
extern SDL_DECLSPEC void SDLCALL SDL_ReleaseKeymap(SDL_Keymap *keymap);
/**
* Get the key code that would be sent with the given scancode in a key event.
*
* This uses the information from the current keymap along with the options
* specified in SDL_HINT_KEYCODE_OPTIONS to get the keycode that would be
* delivered to the application in a key event. This is typically the
* unmodified version of the key based on the current keyboard layout. For
* example, the keycode for SDL_SCANCODE_A + SDL_KMOD_SHIFT using the US
* QWERTY layout would be 'a'.
*
* \param scancode the SDL_Scancode to translate.
* \param modstate the modifier state to use when translating the scancode to
* a keycode.
* \returns the SDL_Keycode that corresponds to the given SDL_Scancode.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate);
extern SDL_DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode, SDL_Keymod modstate, SDL_bool key_event);
/**
* Set a human-readable name for a scancode.