[Bf-blender-cvs] [70f3a47] master: Event System Cleanup: Modifier Key Assignment Switch

julianeisel noreply at git.blender.org
Tue Jan 6 20:33:55 CET 2015


Commit: 70f3a47d57e7cf67fa6c86a9cbd1735679611270
Author: julianeisel
Date:   Tue Jan 6 20:27:59 2015 +0100
Branches: master
https://developer.blender.org/rB70f3a47d57e7cf67fa6c86a9cbd1735679611270

Event System Cleanup: Modifier Key Assignment Switch

Was quite messy previously, think this is much more readable and easier to follow.

===================================================================

M	source/blender/windowmanager/WM_types.h
M	source/blender/windowmanager/intern/wm_event_system.c

===================================================================

diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 2db34bb..e64b115 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -169,7 +169,7 @@ enum {
 #define KM_OSKEY2	128
 
 /* KM_MOD_ flags for wmKeyMapItem and wmEvent.alt/shift/oskey/ctrl  */
-/* note that KM_ANY and false are used with these defines too */
+/* note that KM_ANY and KM_NOTHING are used with these defines too */
 #define KM_MOD_FIRST  1
 #define KM_MOD_SECOND 2
 
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 9473b3e..e7b3de7 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -3196,6 +3196,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
 		case GHOST_kEventKeyUp:
 		{
 			GHOST_TEventKeyData *kd = customdata;
+			short keymodifier = KM_NOTHING;
 			event.type = convert_key(kd->key);
 			event.ascii = kd->ascii;
 			memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/
@@ -3238,25 +3239,36 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
 
 			/* assigning both first and second is strange - campbell */
 			switch (event.type) {
-				case LEFTSHIFTKEY: case RIGHTSHIFTKEY:
-					event.shift = evt->shift = (event.val == KM_PRESS) ?
-					            ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-					            false;
+				case LEFTSHIFTKEY:
+				case RIGHTSHIFTKEY:
+					if (event.val == KM_PRESS) {
+						if (evt->ctrl || evt->alt || evt->oskey) keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
+						else keymodifier = KM_MOD_FIRST;
+					}
+					event.shift = evt->shift = keymodifier;
 					break;
-				case LEFTCTRLKEY: case RIGHTCTRLKEY:
-					event.ctrl = evt->ctrl = (event.val == KM_PRESS) ?
-					            ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-					            false;
+				case LEFTCTRLKEY:
+				case RIGHTCTRLKEY:
+					if (event.val == KM_PRESS) {
+						if (evt->shift || evt->alt || evt->oskey) keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
+						else keymodifier = KM_MOD_FIRST;
+					}
+					event.ctrl = evt->ctrl = keymodifier;
 					break;
-				case LEFTALTKEY: case RIGHTALTKEY:
-					event.alt = evt->alt = (event.val == KM_PRESS) ?
-					            ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-					            false;
+				case LEFTALTKEY:
+				case RIGHTALTKEY:
+					if (event.val == KM_PRESS) {
+						if (evt->ctrl || evt->shift || evt->oskey) keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
+						else keymodifier = KM_MOD_FIRST;
+					}
+					event.alt = evt->alt = keymodifier;
 					break;
 				case OSKEY:
-					event.oskey = evt->oskey = (event.val == KM_PRESS) ?
-					            ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) :
-					            false;
+					if (event.val == KM_PRESS) {
+						if (evt->ctrl || evt->alt || evt->shift) keymodifier = (KM_MOD_FIRST | KM_MOD_SECOND);
+						else keymodifier = KM_MOD_FIRST;
+					}
+					event.oskey = evt->oskey = keymodifier;
 					break;
 				default:
 					if (event.val == KM_PRESS && event.keymodifier == 0)




More information about the Bf-blender-cvs mailing list