Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-21 20:39:07 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-09-21 20:39:07 +0400
commit6117d9c6e27970cef86c4532dc77b18101071beb (patch)
treecf83e9a1b3d03a4790f50d3e490f6a893a29101f /source
parent04ec0ea1908f8b15f167ffebd789e678fa6803c6 (diff)
Fix #19361: BGE keyboard sensor allowed to set mouse events
too, should only be keyboard events.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface.c3
-rw-r--r--source/blender/editors/interface/interface_handlers.c1
-rw-r--r--source/blender/editors/space_logic/logic_window.c23
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c4
-rw-r--r--source/blender/windowmanager/wm_event_types.h7
6 files changed, 31 insertions, 9 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 848432b5f42..dc4744c9832 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -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);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index fbc3c859f20..f79f2f8c378 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -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 */
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index e8d813d8ff9..01a8f983dc6 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -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;
diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c
index cd02f2c6304..b99f7b94170 100644
--- a/source/blender/editors/space_logic/logic_window.c
+++ b/source/blender/editors/space_logic/logic_window.c
@@ -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 */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 4acfe1e524a..503eb5a1b9a 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -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;
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index 898c6358f3a..cc6041ce529 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -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 ********************* */