Fixed bug 1916 - SDL_Keysym contains a deprecated field for unicode which may be removed.
Philipp Wiesemann SDL_Keysym contains a deprecated field for unicode which may be removed for SDL 2.0 release. As far as I can tell the field is not set on all "major" platforms and therefore will not be useful for most users. Its existence in a public header therefore becomes (in my opinion) only confusing.
This commit is contained in:
parent
46487bd122
commit
9293678409
4 changed files with 21 additions and 36 deletions
|
@ -41,13 +41,15 @@ extern "C" {
|
|||
|
||||
/**
|
||||
* \brief The SDL keysym structure, used in key events.
|
||||
*
|
||||
* \note If you are looking for translated character input, see the ::SDL_TEXTINPUT event.
|
||||
*/
|
||||
typedef struct SDL_Keysym
|
||||
{
|
||||
SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */
|
||||
SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */
|
||||
Uint16 mod; /**< current key modifiers */
|
||||
Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
|
||||
Uint32 unused;
|
||||
} SDL_Keysym;
|
||||
|
||||
/* Function prototypes */
|
||||
|
|
|
@ -774,7 +774,6 @@ SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
|
|||
event.key.keysym.scancode = scancode;
|
||||
event.key.keysym.sym = keyboard->keymap[scancode];
|
||||
event.key.keysym.mod = modstate;
|
||||
event.key.keysym.unicode = 0;
|
||||
event.key.windowID = keyboard->focus ? keyboard->focus->id : 0;
|
||||
posted = (SDL_PushEvent(&event) > 0);
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ static SDL_Scancode oskeymap[256];
|
|||
|
||||
|
||||
static SDL_Keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
|
||||
SDL_Keysym * keysym);
|
||||
SDL_Keysym * keysym, Uint32 *unicode);
|
||||
static SDL_Keysym *DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
|
||||
SDL_Keysym * keysym);
|
||||
SDL_Keysym * keysym, Uint32 *unicode);
|
||||
|
||||
static void DirectFB_InitOSKeymap(_THIS, SDL_Scancode * keypmap, int numkeys);
|
||||
static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
|
||||
|
@ -176,6 +176,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt)
|
|||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_DFB_WINDOWDATA(sdlwin);
|
||||
SDL_Keysym keysym;
|
||||
Uint32 unicode;
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
|
||||
|
||||
if (evt->clazz == DFEC_WINDOW) {
|
||||
|
@ -231,12 +232,12 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt)
|
|||
break;
|
||||
case DWET_KEYDOWN:
|
||||
if (!devdata->use_linux_input) {
|
||||
DirectFB_TranslateKey(_this, evt, &keysym);
|
||||
DirectFB_TranslateKey(_this, evt, &keysym, &unicode);
|
||||
/*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id);*/
|
||||
SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode);
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_zero(text);
|
||||
UnicodeToUtf8(keysym.unicode, text);
|
||||
UnicodeToUtf8(unicode, text);
|
||||
if (*text) {
|
||||
SDL_SendKeyboardText_ex(0, text);
|
||||
}
|
||||
|
@ -245,7 +246,7 @@ ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt)
|
|||
break;
|
||||
case DWET_KEYUP:
|
||||
if (!devdata->use_linux_input) {
|
||||
DirectFB_TranslateKey(_this, evt, &keysym);
|
||||
DirectFB_TranslateKey(_this, evt, &keysym, &unicode);
|
||||
SDL_SendKeyboardKey_ex(0, SDL_RELEASED, keysym.scancode);
|
||||
}
|
||||
break;
|
||||
|
@ -309,6 +310,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
|||
SDL_DFB_DEVICEDATA(_this);
|
||||
SDL_Keysym keysym;
|
||||
int kbd_idx;
|
||||
Uint32 unicode;
|
||||
char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
|
||||
|
||||
if (!devdata->use_linux_input) {
|
||||
|
@ -366,12 +368,12 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
|||
break;
|
||||
case DIET_KEYPRESS:
|
||||
kbd_idx = KbdIndex(_this, ievt->device_id);
|
||||
DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym);
|
||||
DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym, &unicode);
|
||||
/*printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); */
|
||||
SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode);
|
||||
if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
SDL_zero(text);
|
||||
UnicodeToUtf8(keysym.unicode, text);
|
||||
UnicodeToUtf8(unicode, text);
|
||||
if (*text) {
|
||||
SDL_SendKeyboardText_ex(kbd_idx, text);
|
||||
}
|
||||
|
@ -379,7 +381,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt)
|
|||
break;
|
||||
case DIET_KEYRELEASE:
|
||||
kbd_idx = KbdIndex(_this, ievt->device_id);
|
||||
DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym);
|
||||
DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym, &unicode);
|
||||
SDL_SendKeyboardKey_ex(kbd_idx, SDL_RELEASED, keysym.scancode);
|
||||
break;
|
||||
case DIET_BUTTONPRESS:
|
||||
|
@ -575,7 +577,7 @@ DirectFB_InitOSKeymap(_THIS, SDL_Scancode * keymap, int numkeys)
|
|||
}
|
||||
|
||||
static SDL_Keysym *
|
||||
DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_Keysym * keysym)
|
||||
DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_Keysym * keysym, Uint32 *unicode)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int kbd_idx = 0; /* Window events lag the device source KbdIndex(_this, evt->device_id); */
|
||||
|
@ -595,18 +597,18 @@ DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_Keysym * keysym)
|
|||
keysym->scancode = SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
keysym->unicode =
|
||||
*unicode =
|
||||
(DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
|
||||
if (keysym->unicode == 0 &&
|
||||
if (*unicode == 0 &&
|
||||
(evt->key_symbol > 0 && evt->key_symbol < 255))
|
||||
keysym->unicode = evt->key_symbol;
|
||||
*unicode = evt->key_symbol;
|
||||
|
||||
return keysym;
|
||||
}
|
||||
|
||||
static SDL_Keysym *
|
||||
DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
|
||||
SDL_Keysym * keysym)
|
||||
SDL_Keysym * keysym, Uint32 *unicode)
|
||||
{
|
||||
SDL_DFB_DEVICEDATA(_this);
|
||||
int kbd_idx = KbdIndex(_this, evt->device_id);
|
||||
|
@ -625,11 +627,11 @@ DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt,
|
|||
keysym->scancode = SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
keysym->unicode =
|
||||
*unicode =
|
||||
(DFB_KEY_TYPE(evt->key_symbol) == DIKT_UNICODE) ? evt->key_symbol : 0;
|
||||
if (keysym->unicode == 0 &&
|
||||
if (*unicode == 0 &&
|
||||
(evt->key_symbol > 0 && evt->key_symbol < 255))
|
||||
keysym->unicode = evt->key_symbol;
|
||||
*unicode = evt->key_symbol;
|
||||
|
||||
return keysym;
|
||||
}
|
||||
|
|
|
@ -107,24 +107,6 @@ PrintKey(SDL_Keysym * sym, SDL_bool pressed, SDL_bool repeat)
|
|||
SDL_GetScancodeName(sym->scancode),
|
||||
pressed ? "pressed " : "released");
|
||||
}
|
||||
|
||||
/* Print the translated character, if one exists */
|
||||
if (sym->unicode) {
|
||||
/* Is it a control-character? */
|
||||
if (sym->unicode < ' ') {
|
||||
print_string(&spot, &left, " (^%c)", sym->unicode + '@');
|
||||
} else {
|
||||
#ifdef UNICODE
|
||||
print_string(&spot, &left, " (%c)", sym->unicode);
|
||||
#else
|
||||
/* This is a Latin-1 program, so only show 8-bits */
|
||||
if (!(sym->unicode & 0xFF00))
|
||||
print_string(&spot, &left, " (%c)", sym->unicode);
|
||||
else
|
||||
print_string(&spot, &left, " (0x%X)", sym->unicode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
print_modifiers(&spot, &left);
|
||||
if (repeat) {
|
||||
print_string(&spot, &left, " (repeat)");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue