From 7965e64e98091fafe733336a0ced252f2503f184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Luc=20Peuri=C3=A8re?= Date: Thu, 2 Aug 2007 20:37:30 +0000 Subject: [PATCH] linux plugin support for ndof by Ettore Pasquini --- intern/ghost/intern/GHOST_SystemX11.cpp | 45 ++++++++++++++++--------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index f3891995f54..9d4717b00ef 100755 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -71,9 +71,13 @@ 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}; +static NDOFPlatformInfo sNdofInfo = {NULL, 0, NULL, 0, 0, 0, 0}; using namespace std; @@ -462,21 +466,30 @@ GHOST_SystemX11::processEvent(XEvent *xe) } else #endif if (sNdofInfo.currValues) { - GHOST_TEventNDOFData data; - data.changed = 1; - data.delta = xcme.data.s[8] - data.time; - data.time = xcme.data.s[8]; - data.tx = xcme.data.s[2] >> 4; - data.ty = xcme.data.s[3] >> 4; - data.tz = xcme.data.s[4] >> 4; - 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); - + 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]; + data.ty = xcme.data.s[3]; + data.tz = xcme.data.s[4]; + 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); + } } else { /* Unknown client message, ignore */ }