forked from bartvdbraak/blender
Fix #19361: BGE keyboard sensor allowed to set mouse events
too, should only be keyboard events.
This commit is contained in:
parent
04ec0ea190
commit
6117d9c6e2
@ -431,7 +431,7 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, char *
|
||||
uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int retval, int icon, short x1, short y1, short x2, short y2, char *tip);
|
||||
uiBut *uiDefIconTextBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int icon, char *str, short x1, short y1, short x2, short y2, char *tip);
|
||||
|
||||
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
|
||||
uiBut *uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip);
|
||||
uiBut *uiDefHotKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *keypoin, short *modkeypoin, char *tip);
|
||||
|
||||
uiBut *uiDefSearchBut(uiBlock *block, void *arg, int retval, int icon, int maxlen, short x1, short y1, short x2, short y2, char *tip);
|
||||
|
@ -3098,10 +3098,11 @@ uiBut *uiDefIconBlockBut(uiBlock *block, uiBlockCreateFunc func, void *arg, int
|
||||
return but;
|
||||
}
|
||||
|
||||
void uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip)
|
||||
uiBut *uiDefKeyevtButS(uiBlock *block, int retval, char *str, short x1, short y1, short x2, short y2, short *spoin, char *tip)
|
||||
{
|
||||
uiBut *but= ui_def_but(block, KEYEVT|SHO, retval, str, x1, y1, x2, y2, spoin, 0.0, 0.0, 0.0, 0.0, tip);
|
||||
ui_check_but(but);
|
||||
return but;
|
||||
}
|
||||
|
||||
/* short pointers hardcoded */
|
||||
|
@ -855,6 +855,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut
|
||||
ui_apply_but_CHARTAB(C, but, data);
|
||||
break;
|
||||
#endif
|
||||
case KEYEVT:
|
||||
case HOTKEYEVT:
|
||||
ui_apply_but_BUT(C, but, data);
|
||||
break;
|
||||
|
@ -1067,6 +1067,19 @@ static void test_scenepoin_but(struct bContext *C, char *name, ID **idpp)
|
||||
*idpp= NULL;
|
||||
}
|
||||
|
||||
|
||||
static void test_keyboard_event(struct bContext *C, void *arg_ks, void *arg_unused)
|
||||
{
|
||||
bKeyboardSensor *ks= (bKeyboardSensor*)arg_ks;
|
||||
|
||||
if(!ISKEYBOARD(ks->key))
|
||||
ks->key= 0;
|
||||
if(!ISKEYBOARD(ks->qual))
|
||||
ks->qual= 0;
|
||||
if(!ISKEYBOARD(ks->qual2))
|
||||
ks->qual2= 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a toggle for pulse mode, a frequency field and a toggle to invert
|
||||
* the value of this sensor. Operates on the shared data block of sensors.
|
||||
@ -1131,6 +1144,7 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
|
||||
bJoystickSensor *joy = NULL;
|
||||
bActuatorSensor *as = NULL;
|
||||
bDelaySensor *ds = NULL;
|
||||
uiBut *but;
|
||||
short ysize;
|
||||
char *str;
|
||||
|
||||
@ -1279,12 +1293,15 @@ static short draw_sensorbuttons(bSensor *sens, uiBlock *block, short xco, short
|
||||
|
||||
if ((ks->type&1)==0) { /* is All Keys option off? */
|
||||
/* line 2: hotkey and allkeys toggle */
|
||||
uiDefKeyevtButS(block, 0, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code");
|
||||
but= uiDefKeyevtButS(block, 0, "", xco+40, yco-44, (width)/2, 19, &ks->key, "Key code");
|
||||
uiButSetFunc(but, test_keyboard_event, ks, NULL);
|
||||
|
||||
/* line 3: two key modifyers (qual1, qual2) */
|
||||
uiDefBut(block, LABEL, 0, "Hold", xco, yco-68, 40, 19, NULL, 0, 0, 0, 0, "");
|
||||
uiDefKeyevtButS(block, 0, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code");
|
||||
uiDefKeyevtButS(block, 0, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code");
|
||||
but= uiDefKeyevtButS(block, 0, "", xco+40, yco-68, (width-50)/2, 19, &ks->qual, "Modifier key code");
|
||||
uiButSetFunc(but, test_keyboard_event, ks, NULL);
|
||||
but= uiDefKeyevtButS(block, 0, "", xco+40+(width-50)/2, yco-68, (width-50)/2, 19, &ks->qual2, "Second Modifier key code");
|
||||
uiButSetFunc(but, test_keyboard_event, ks, NULL);
|
||||
}
|
||||
|
||||
/* line 4: toggle property for string logging mode */
|
||||
|
@ -718,7 +718,7 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi)
|
||||
|
||||
/* the matching rules */
|
||||
if(kmitype==KM_TEXTINPUT)
|
||||
if(ISKEYBOARD(winevent->type) && winevent->ascii) return 1;
|
||||
if(ISTEXTINPUT(winevent->type) && winevent->ascii) return 1;
|
||||
if(kmitype!=KM_ANY)
|
||||
if(winevent->type!=kmitype) return 0;
|
||||
|
||||
@ -741,7 +741,7 @@ static int wm_eventmatch(wmEvent *winevent, wmKeymapItem *kmi)
|
||||
/* key modifiers always check when event has it */
|
||||
/* otherwise regular keypresses with keymodifier still work */
|
||||
if(winevent->keymodifier)
|
||||
if(ISKEYBOARD(winevent->type))
|
||||
if(ISTEXTINPUT(winevent->type))
|
||||
if(winevent->keymodifier!=kmi->keymodifier) return 0;
|
||||
|
||||
return 1;
|
||||
|
@ -194,10 +194,13 @@
|
||||
|
||||
/* for event checks */
|
||||
/* only used for KM_TEXTINPUT, so assume that we want all user-inputtable ascii codes included */
|
||||
#define ISKEYBOARD(event) (event >=' ' && event <=255)
|
||||
#define ISTEXTINPUT(event) (event >=' ' && event <=255)
|
||||
|
||||
/* test wether the event is a key on the keyboard */
|
||||
#define ISKEYBOARD(event) (event >=' ' && event <=320)
|
||||
|
||||
/* test whether event type is acceptable as hotkey, excluding modifiers */
|
||||
#define ISHOTKEY(event) (event >=' ' && event <=320 && !(event>=LEFTCTRLKEY && event<=ESCKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY))
|
||||
#define ISHOTKEY(event) (ISKEYBOARD(event) && !(event>=LEFTCTRLKEY && event<=ESCKEY) && !(event>=UNKNOWNKEY && event<=GRLESSKEY))
|
||||
|
||||
|
||||
/* **************** BLENDER GESTURE EVENTS ********************* */
|
||||
|
Loading…
Reference in New Issue
Block a user