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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r--source/blender/windowmanager/WM_types.h20
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c54
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c112
-rw-r--r--source/blender/windowmanager/intern/wm_window.c4
-rw-r--r--source/blender/windowmanager/wm_event_types.h50
5 files changed, 236 insertions, 4 deletions
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index 49bd3ede37d..7476410ec19 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -377,6 +377,26 @@ typedef struct wmTabletData {
float Ytilt; /* as above */
} wmTabletData;
+typedef enum { // motion progress, for modal handlers
+ P_NOT_STARTED,
+ P_STARTING, // <--
+ P_IN_PROGRESS, // <-- only these are sent for NDOF motion
+ P_FINISHING, // <--
+ P_FINISHED
+ } wmProgress;
+
+typedef struct wmNDOFMotionData {
+ /* awfully similar to GHOST_TEventNDOFMotionData... */
+ // Each component normally ranges from -1 to +1, but can exceed that.
+ // These use blender standard view coordinates, with positive rotations being CCW about the axis.
+ float tx, ty, tz; // translation
+ float rx, ry, rz; // rotation:
+ // axis = (rx,ry,rz).normalized
+ // amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg]
+ float dt; // time since previous NDOF Motion event
+ wmProgress progress; // is this the first event, the last, or one of many in between?
+} wmNDOFMotionData;
+
typedef struct wmTimer {
struct wmTimer *next, *prev;
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index ce3830b059c..26d72906ece 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2309,6 +2309,28 @@ static void update_tablet_data(wmWindow *win, wmEvent *event)
}
}
+/* adds customdata to event */
+static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* ghost)
+{
+ wmNDOFMotionData* data = MEM_mallocN(sizeof(wmNDOFMotionData), "customdata NDOF");
+
+ data->tx = ghost->tx;
+ data->ty = ghost->ty;
+ data->tz = ghost->tz;
+
+ data->rx = ghost->rx;
+ data->ry = ghost->ry;
+ data->rz = ghost->rz;
+
+ data->dt = ghost->dt;
+
+ data->progress = (wmProgress) ghost->progress;
+
+ event->custom = EVT_DATA_NDOF_MOTION;
+ event->customdata = data;
+ event->customdatafree = 1;
+}
+
/* imperfect but probably usable... draw/enable drags to other windows */
static wmWindow *wm_event_cursor_other_windows(wmWindowManager *wm, wmWindow *win, wmEvent *evt)
{
@@ -2355,7 +2377,7 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
{
wmWindow *owin;
wmEvent event, *evt= win->eventstate;
-
+
/* initialize and copy state (only mouse x y and modifiers) */
event= *evt;
@@ -2557,6 +2579,36 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U
break;
}
+ case GHOST_kEventNDOFMotion: {
+ event.type = NDOF_MOTION;
+ attach_ndof_data(&event, customdata);
+ wm_event_add(win, &event);
+
+ break;
+ }
+
+ case GHOST_kEventNDOFButton: {
+ GHOST_TEventNDOFButtonData* e = customdata;
+
+ event.type = NDOF_BUTTON_NONE + e->button;
+
+ switch (e->action) {
+ case GHOST_kPress:
+ event.val = KM_PRESS;
+ break;
+ case GHOST_kRelease:
+ event.val = KM_RELEASE;
+ break;
+ }
+
+ event.custom = 0;
+ event.customdata = NULL;
+
+ wm_event_add(win, &event);
+
+ break;
+ }
+
case GHOST_kEventUnknown:
case GHOST_kNumEventTypes:
break;
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index 29afdb570ea..32d2adffb01 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -1411,6 +1411,113 @@ static void WM_OT_search_menu(wmOperatorType *ot)
ot->poll= wm_search_menu_poll;
}
+// BEGIN ndof menu -- experimental!
+
+#if 0
+static uiBlock* wm_block_ndof_menu_1st(bContext* C, ARegion* ar, void* UNUSED(arg_op))
+{
+ uiBlock* block;
+ uiBut* but;
+
+ block = uiBeginBlock(C, ar, "ndof_popup_menu", UI_EMBOSS);
+ uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_RET_1|UI_BLOCK_MOVEMOUSE_QUIT);
+// uiBlockSetDirection(block, UI_DOWN);
+// uiBlockBeginAlign(block);
+
+ // uiItemBooleanO(block->curlayout, "enable pan/zoom", ICON_NDOF_TRANS, "toggle_ndof_pan_zoom_enabled", "ndof_pan_zoom_enabled", 1);
+ // uiBlock is used as an opaque type in this file, so can't use members...
+
+ int foo = 333;
+ uiDefButI(block, TOG, 0, "foo", 10, 10, 9*UI_UNIT_X, UI_UNIT_Y, &foo, 0.f, 1.f, 0.1f, 0.9f, "15%");
+ // uiDefBut(block, TOG, 0, "enable pan/zoom", 0, 0, 10, 10, NULL, 0.f, 1.f, 0.f, 1.f, "don't talk to strangers");
+
+// uiBlockEndAlign(block);
+// uiBoundsBlock(block, 6);
+ uiEndBlock(C, block);
+
+ return block;
+}
+
+static int wm_ndof_menu_poll(bContext *C)
+{
+ if(CTX_wm_window(C)==NULL)
+ return 0;
+
+ // if menu is already pulled up, another button press should dismiss it
+ // not sure if that behavior should go here or elsewhere...
+
+ puts("ndof: menu poll");
+ return 1;
+}
+
+static int wm_ndof_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op))
+{
+ puts("ndof: menu exec");
+ return OPERATOR_FINISHED;
+}
+#endif
+
+static int wm_ndof_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
+{
+ uiPupMenuInvoke(C,"VIEW3D_MT_ndof_settings");
+
+ return OPERATOR_CANCELLED; // <-- correct?
+
+/*
+// uiPupMenuNotice(C, "Hello!"); // <-- this works
+// uiPupBlock(C, wm_block_ndof_menu, op); // <-- no luck!
+// ui_popup_menu_create(C, NULL, NULL, NULL, NULL, "Hello!"); // <-- this works
+
+ uiPopupMenu* pup = uiPupMenuBegin(C,"3D mouse settings",ICON_NDOF_TURN);
+ uiLayout* layout = uiPupMenuLayout(pup);
+
+ uiItemS(layout); // separator
+ uiItemFloatO(layout, "sensitivity", 0, 0, "ndof_sensitivity", 1.f);
+ // do I have to look specifically in "UserPreferences" for ndof_sensitivity property?
+
+ // trial & error -- ok, mostly error
+// uiItemBooleanO(layout, "enable pan/zoom", ICON_NDOF_TRANS, "ndof_toggle_pan_zoom_enabled", "ndof_pan_zoom_enabled", 1);
+// uiItemBooleanO(layout, "enable rotation", ICON_NDOF_TURN, "ndof_toggle_rotation_enabled", "ndof_rotation_enabled", 1);
+// uiItemV(layout,"sensitivity",ICON_NDOF_TRANS, 1);
+
+ printf("ndof: menu invoked in ");
+
+ switch (CTX_wm_area(C)->spacetype) // diff spaces can have diff 3d mouse options
+ {
+ case SPACE_VIEW3D:
+ puts("3D area");
+ uiItemS(layout);
+ uiItemL(layout, "3D navigation mode", 0);
+ uiItemBooleanO(layout, "helicopter", ICON_NDOF_FLY, 0, "ndof_fly_helicopter", 1);
+ uiItemBooleanO(layout, "lock horizon", ICON_NDOF_DOM, 0, "ndof_lock_horizon", 1);
+ break;
+ case SPACE_IMAGE:
+ puts("image area");
+ break;
+ default:
+ puts("some iNDOFferent area");
+ }
+
+ //uiBlock* block = uiLayoutGetBlock(layout);
+ //int foo = 1;
+ //uiDefButI(block, TOG, 0, "foo", 10, 10, 9*UI_UNIT_X, UI_UNIT_Y, &foo, 0.f, 1.f, 0.1f, 0.9f, "15%");
+
+ uiPupMenuEnd(C,pup);
+*/
+}
+
+static void WM_OT_ndof_menu(wmOperatorType *ot)
+{
+ puts("ndof: registering menu operator");
+
+ ot->name = "NDOF Menu";
+ ot->idname = "WM_OT_ndof_menu";
+
+ ot->invoke = wm_ndof_menu_invoke;
+}
+
+// END ndof menu
+
static int wm_call_menu_exec(bContext *C, wmOperator *op)
{
char idname[BKE_ST_MAXNAME];
@@ -3453,6 +3560,7 @@ void wm_operatortype_init(void)
WM_operatortype_append(WM_OT_debug_menu);
WM_operatortype_append(WM_OT_splash);
WM_operatortype_append(WM_OT_search_menu);
+ WM_operatortype_append(WM_OT_ndof_menu);
WM_operatortype_append(WM_OT_call_menu);
WM_operatortype_append(WM_OT_radial_control);
#if defined(WIN32)
@@ -3675,7 +3783,9 @@ void wm_window_keymap(wmKeyConfig *keyconf)
WM_keymap_verify_item(keymap, "WM_OT_redraw_timer", TKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_debug_menu", DKEY, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_verify_item(keymap, "WM_OT_search_menu", SPACEKEY, KM_PRESS, 0, 0);
-
+
+ WM_keymap_add_item(keymap, "WM_OT_ndof_menu", NDOF_BUTTON_MENU, KM_PRESS, 0, 0);
+
/* Space switching */
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 9b1695be67a..7d6010786d2 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -621,12 +621,12 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
if (!ghostwin) {
// XXX - should be checked, why are we getting an event here, and
// what is it?
-
+ puts("<!> event has no window");
return 1;
} else if (!GHOST_ValidWindow(g_system, ghostwin)) {
// XXX - should be checked, why are we getting an event here, and
// what is it?
-
+ puts("<!> event has invalid window");
return 1;
} else {
win= GHOST_GetWindowUserData(ghostwin);
diff --git a/source/blender/windowmanager/wm_event_types.h b/source/blender/windowmanager/wm_event_types.h
index ee080e7c0aa..210dd902b99 100644
--- a/source/blender/windowmanager/wm_event_types.h
+++ b/source/blender/windowmanager/wm_event_types.h
@@ -45,6 +45,7 @@
#define EVT_DATA_GESTURE 2
#define EVT_DATA_TIMER 3
#define EVT_DATA_LISTBASE 4
+#define EVT_DATA_NDOF_MOTION 5
/* tablet active, matches GHOST_TTabletMode */
#define EVT_TABLET_NONE 0
@@ -78,6 +79,55 @@
#define INBETWEEN_MOUSEMOVE 17
+/* NDOF (from SpaceNavigator & friends)
+ These should be kept in sync with GHOST_NDOFManager.h
+ Ordering matters, exact values do not. */
+
+#define NDOF_MOTION 400
+
+enum {
+ // used internally, never sent
+ NDOF_BUTTON_NONE = NDOF_MOTION,
+ // these two are available from any 3Dconnexion device
+ NDOF_BUTTON_MENU,
+ NDOF_BUTTON_FIT,
+ // standard views
+ NDOF_BUTTON_TOP,
+ NDOF_BUTTON_BOTTOM,
+ NDOF_BUTTON_LEFT,
+ NDOF_BUTTON_RIGHT,
+ NDOF_BUTTON_FRONT,
+ NDOF_BUTTON_BACK,
+ // more views
+ NDOF_BUTTON_ISO1,
+ NDOF_BUTTON_ISO2,
+ // 90 degree rotations
+ NDOF_BUTTON_ROLL_CW,
+ NDOF_BUTTON_ROLL_CCW,
+ NDOF_BUTTON_SPIN_CW,
+ NDOF_BUTTON_SPIN_CCW,
+ NDOF_BUTTON_TILT_CW,
+ NDOF_BUTTON_TILT_CCW,
+ // device control
+ NDOF_BUTTON_ROTATE,
+ NDOF_BUTTON_PANZOOM,
+ NDOF_BUTTON_DOMINANT,
+ NDOF_BUTTON_PLUS,
+ NDOF_BUTTON_MINUS,
+ // general-purpose buttons
+ NDOF_BUTTON_1,
+ NDOF_BUTTON_2,
+ NDOF_BUTTON_3,
+ NDOF_BUTTON_4,
+ NDOF_BUTTON_5,
+ NDOF_BUTTON_6,
+ NDOF_BUTTON_7,
+ NDOF_BUTTON_8,
+ NDOF_BUTTON_9,
+ NDOF_BUTTON_10,
+ };
+
+
/* SYSTEM : 0x01xx */
#define INPUTCHANGE 0x0103 /* input connected or disconnected */
#define WINDEACTIVATE 0x0104 /* window is deactivated, focus lost */