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:
authorMike Erwin <significant.bit@gmail.com>2011-07-02 01:51:44 +0400
committerMike Erwin <significant.bit@gmail.com>2011-07-02 01:51:44 +0400
commit14c72f379cea8be411e649f08fd5ac9f8943e56d (patch)
tree83da9c33f453d023f42ab67dde2f2a3b2dbdadb4 /intern/ghost
parentabd4a881dba7a554caa8cb7d48d2dceb2f27d9a8 (diff)
implemented ndof 'dead zone' around home position, fixed X11 active window determination, removed old X11 ndof code
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_NDOFManager.cpp11
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp56
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.h9
3 files changed, 18 insertions, 58 deletions
diff --git a/intern/ghost/intern/GHOST_NDOFManager.cpp b/intern/ghost/intern/GHOST_NDOFManager.cpp
index 54192c0d669..4d2f06f8191 100644
--- a/intern/ghost/intern/GHOST_NDOFManager.cpp
+++ b/intern/ghost/intern/GHOST_NDOFManager.cpp
@@ -27,6 +27,7 @@
#include "GHOST_WindowManager.h"
#include <string.h> // for memory functions
#include <stdio.h> // for error/info reporting
+#include <math.h>
#ifdef DEBUG_NDOF_BUTTONS
static const char* ndof_button_names[] = {
@@ -301,6 +302,12 @@ void GHOST_NDOFManager::updateButtons(int button_bits, GHOST_TUns64 time)
}
}
+static bool atHomePosition(GHOST_TEventNDOFMotionData* ndof, float threshold)
+ {
+ #define HOME(foo) (fabsf(ndof->foo) < threshold)
+ return HOME(tx) && HOME(ty) && HOME(tz) && HOME(rx) && HOME(ry) && HOME(rz);
+ }
+
bool GHOST_NDOFManager::sendMotionEvent()
{
if (m_atRest)
@@ -336,9 +343,7 @@ bool GHOST_NDOFManager::sendMotionEvent()
m_system.pushEvent(event);
// 'at rest' test goes at the end so that the first 'rest' event gets sent
- m_atRest = m_rotation[0] == 0 && m_rotation[1] == 0 && m_rotation[2] == 0 &&
- m_translation[0] == 0 && m_translation[1] == 0 && m_translation[2] == 0;
- // this needs to be aware of calibration -- 0.01 0.01 0.03 might be 'rest'
+ m_atRest = atHomePosition(data, 0.05f);
return true;
}
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index 5e59ac91809..4c62e5e62b4 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -75,22 +75,6 @@
#include <stdio.h> // for fprintf only
#include <cstdlib> // for exit
-#if 0 // obsolete SpaceNav code
-
-typedef struct NDOFPlatformInfo {
- Display *display;
- Window window;
- volatile GHOST_TEventNDOFData *currValues;
- Atom cmdAtom;
- Atom motionAtom;
- Atom btnPressAtom;
- Atom btnRelAtom;
-} NDOFPlatformInfo;
-
-static NDOFPlatformInfo sNdofInfo = {NULL, 0, NULL, 0, 0, 0, 0};
-
-#endif
-
//these are for copy and select copy
static char *txt_cut_buffer= NULL;
static char *txt_select_buffer= NULL;
@@ -612,6 +596,8 @@ GHOST_SystemX11::processEvent(XEvent *xe)
case FocusOut:
{
XFocusChangeEvent &xfe = xe->xfocus;
+
+ printf("X: focus %s for window %d\n", xfe.type == FocusIn ? "in" : "out", (int) xfe.window);
// May have to look at the type of event and filter some
// out.
@@ -643,36 +629,6 @@ GHOST_SystemX11::processEvent(XEvent *xe)
} else
#endif
-#if 0 // obsolete SpaceNav code
-
- if (sNdofInfo.currValues) {
- static GHOST_TEventNDOFData data = {0,0,0,0,0,0,0,0,0,0,0};
- if (xcme.message_type == sNdofInfo.motionAtom)
- {
- data.changed = 1;
- data.delta = xcme.data.s[8] - data.time;
- data.time = xcme.data.s[8];
- data.tx = xcme.data.s[2] >> 2;
- data.ty = xcme.data.s[3] >> 2;
- data.tz = xcme.data.s[4] >> 2;
- data.rx = xcme.data.s[5];
- data.ry = xcme.data.s[6];
- data.rz =-xcme.data.s[7];
- g_event = new GHOST_EventNDOF(getMilliSeconds(),
- GHOST_kEventNDOFMotion,
- window, data);
- } else if (xcme.message_type == sNdofInfo.btnPressAtom) {
- data.changed = 2;
- data.delta = xcme.data.s[8] - data.time;
- data.time = xcme.data.s[8];
- data.buttons = xcme.data.s[2];
- g_event = new GHOST_EventNDOF(getMilliSeconds(),
- GHOST_kEventNDOFButton,
- window, data);
- }
-
-#endif
-
if (((Atom)xcme.data.l[0]) == m_wm_take_focus) {
XWindowAttributes attr;
Window fwin;
@@ -730,6 +686,14 @@ GHOST_SystemX11::processEvent(XEvent *xe)
xce.y_root
);
}
+
+ printf("X: %s window %d\n", xce.type == EnterNotify ? "entering" : "leaving", (int) xce.window);
+
+ if (xce.type == EnterNotify)
+ m_windowManager->setActiveWindow(window);
+ else
+ m_windowManager->setWindowInactive(window);
+
break;
}
case MapNotify:
diff --git a/intern/ghost/intern/GHOST_SystemX11.h b/intern/ghost/intern/GHOST_SystemX11.h
index e551b5fb2fe..f70f67dec18 100644
--- a/intern/ghost/intern/GHOST_SystemX11.h
+++ b/intern/ghost/intern/GHOST_SystemX11.h
@@ -203,15 +203,6 @@ public:
return m_display;
}
-#if 0 // obsolete SpaceNav code
-
- void *
- prepareNdofInfo(
- volatile GHOST_TEventNDOFData *current_values
- );
-
-#endif
-
/* Helped function for get data from the clipboard. */
void getClipboard_xcout(XEvent evt, Atom sel, Atom target,
unsigned char **txt, unsigned long *len,