mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-05 22:30:29 +00:00
In OSX, when we change from one application to other and in them middle of the transition animation we press a modifier key, the modifier key down is not sent to the application.
Adding the checking of the modifier to see if it was correctly handled when checking a later key down.
This commit is contained in:
parent
863670c0a8
commit
41869b753b
1 changed files with 46 additions and 1 deletions
|
|
@ -383,9 +383,51 @@ void Cocoa_SetTextInputRect(_THIS, const SDL_Rect *rect)
|
|||
[data.fieldEdit setInputRect:rect];
|
||||
}
|
||||
|
||||
#define isBitSet(x,y) ((x & y) == y)
|
||||
|
||||
static void HandleModifiersIfDifferent(_THIS, unsigned int modflags){
|
||||
|
||||
SDL_Keymod currentMod;
|
||||
|
||||
currentMod = SDL_GetModState();
|
||||
|
||||
if(isBitSet(currentMod, KMOD_LSHIFT) != isBitSet(modflags, NX_DEVICELSHIFTKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_LSHIFT, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_LCTRL) != isBitSet(modflags, NX_DEVICELCTLKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_LCTRL, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_LALT) != isBitSet(modflags, NX_DEVICELALTKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_LALT, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_LGUI) != isBitSet(modflags, NX_DEVICELCMDKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_LGUI, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_RSHIFT) != isBitSet(modflags, NX_DEVICERSHIFTKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_RSHIFT, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_RCTRL) != isBitSet(modflags, NX_DEVICERCTLKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_RCTRL, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_RALT) != isBitSet(modflags, NX_DEVICERALTKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_RALT, modflags);
|
||||
}
|
||||
|
||||
if(isBitSet(currentMod, KMOD_RGUI) != isBitSet(modflags, NX_DEVICERCMDKEYMASK)){
|
||||
HandleModifiers(_this, SDL_SCANCODE_RGUI, modflags);
|
||||
}
|
||||
}
|
||||
|
||||
void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
||||
{
|
||||
unsigned short scancode;
|
||||
unsigned int modflags;
|
||||
SDL_Scancode code;
|
||||
SDL_VideoData *data = _this ? ((__bridge SDL_VideoData *) _this->driverdata) : nil;
|
||||
if (!data) {
|
||||
|
|
@ -409,6 +451,8 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
|||
code = SDL_SCANCODE_UNKNOWN;
|
||||
}
|
||||
|
||||
modflags = (unsigned int)[event modifierFlags];
|
||||
|
||||
switch ([event type]) {
|
||||
case NSEventTypeKeyDown:
|
||||
if (![event isARepeat]) {
|
||||
|
|
@ -416,6 +460,8 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
|||
UpdateKeymap(data, SDL_TRUE);
|
||||
}
|
||||
|
||||
HandleModifiersIfDifferent(_this, modflags);
|
||||
|
||||
SDL_SendKeyboardKey(SDL_PRESSED, code);
|
||||
#ifdef DEBUG_SCANCODES
|
||||
if (code == SDL_SCANCODE_UNKNOWN) {
|
||||
|
|
@ -439,7 +485,6 @@ void Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
|
|||
break;
|
||||
case NSEventTypeFlagsChanged: {
|
||||
// see if the new modifierFlags mean any existing keys should be pressed/released...
|
||||
const unsigned int modflags = (unsigned int)[event modifierFlags];
|
||||
HandleModifiers(_this, SDL_SCANCODE_LSHIFT, modflags);
|
||||
HandleModifiers(_this, SDL_SCANCODE_LCTRL, modflags);
|
||||
HandleModifiers(_this, SDL_SCANCODE_LALT, modflags);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue