Cycles: svn merge -r41157:41182 ^/trunk/blender
[blender.git] / source / blender / windowmanager / intern / wm_event_system.c
index c08a14307b5fc8ba0afc6e0be94a52644a699904..ae0019a60d60920a85512b01382d369e1fbdbb81 100644 (file)
 #include "wm_event_types.h"
 #include "wm_draw.h"
 
+#ifndef NDEBUG
+#  include "RNA_enum_types.h"
+#endif
+
 static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA *properties, ReportList *reports, short context, short poll_only);
 
 /* ************ event management ************** */
@@ -441,6 +445,35 @@ static void wm_operator_print(bContext *C, wmOperator *op)
        MEM_freeN(buf);
 }
 
+/* for debugging only, getting inspecting events manually is tedious */
+#ifndef NDEBUG
+
+void WM_event_print(wmEvent *event)
+{
+       if(event) {
+               const char *unknown= "UNKNOWN";
+               const char *type_id= unknown;
+               const char *val_id= unknown;
+
+               RNA_enum_identifier(event_type_items, event->type, &type_id);
+               RNA_enum_identifier(event_value_items, event->val, &val_id);
+
+               printf("wmEvent - type:%d/%s, val:%d/%s, "
+                          "shift:%d, ctrl:%d, alt:%d, oskey:%d, keymodifier:%d, "
+                          "mouse:(%d,%d), ascii:'%c', utf8:'%.6s', "
+                          "keymap_idname:%s, pointer:%p\n",
+                          event->type, type_id, event->val, val_id,
+                          event->shift, event->ctrl, event->alt, event->oskey, event->keymodifier,
+                          event->x, event->y, event->ascii, event->utf8_buf,
+                          event->keymap_idname, (void *)event);
+       }
+       else {
+               printf("wmEvent - NULL\n");
+       }
+}
+
+#endif /* NDEBUG */
+
 static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int popup)
 {
        if(popup) {