From bfa77f611f750510e1ee0eda15d987990281ef7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Luc=20Peuri=C3=A8re?= Date: Sun, 29 Jul 2007 18:03:36 +0000 Subject: more work on the ndof system. turntable code should work reasonabilly well now. fly code need works but is no more insane on Os X. transform object is not present here. if you find the movements a bit slow, you can speed it in the preferences up to 2x in the view & controls panel. button1 (left) of the device let you switch between the 3 modes. button2 let you switch between unconstrained and dominant mode. the plugin must be named 3DxNdofBlender.plug and be placed in a folder named plugins in same folder as executable check no scaling is done in the plugin please check it works ok on 3 platforms --- intern/ghost/GHOST_Types.h | 3 ++- intern/ghost/intern/GHOST_SystemCarbon.cpp | 17 ++++++++++++++-- intern/ghost/intern/GHOST_SystemX11.cpp | 32 +++++++++++++----------------- 3 files changed, 31 insertions(+), 21 deletions(-) (limited to 'intern') diff --git a/intern/ghost/GHOST_Types.h b/intern/ghost/GHOST_Types.h index 0de4c162ab8..379b3323f53 100644 --- a/intern/ghost/GHOST_Types.h +++ b/intern/ghost/GHOST_Types.h @@ -137,7 +137,8 @@ typedef enum { GHOST_kEventButtonUp, /// Mouse button event GHOST_kEventWheel, /// Mouse wheel event - GHOST_kEventNDOFMotion, /// N degree of freedom device motion event + GHOST_kEventNDOFMotion, /// N degree of freedom device motion event + GHOST_kEventNDOFButton, /// N degree of freedom device button event GHOST_kEventKeyDown, GHOST_kEventKeyUp, diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index 056addddeb1..756de42f227 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -984,7 +984,7 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event) GHOST_ASSERT(ghostWindow, "GHOST_SystemCarbon::handleMouseEvent: ghostWindow==0"); if (::TrackGoAway(window, mousePos)) { - // todo: add option-close, because itØs in the HIG + // todo: add option-close, because itÿs in the HIG // if (event.modifiers & optionKey) { // Close the clean documents, others will be confirmed one by one. //} @@ -1069,6 +1069,7 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even OSStatus err = eventNotHandledErr; GHOST_IWindow* window; GHOST_TEventNDOFData data; + UInt32 kind; switch (::GetEventClass(event)) { @@ -1090,7 +1091,19 @@ OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, Even case kEventClassBlender : window = sys->m_windowManager->getActiveWindow(); sys->m_ndofManager->GHOST_NDOFGetDatas(data); - sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data)); + kind = ::GetEventKind(event); + + switch (kind) + { + case 1: + sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFMotion, window, data)); + // printf("motion\n"); + break; + case 2: + sys->m_eventManager->pushEvent(new GHOST_EventNDOF(sys->getMilliSeconds(), GHOST_kEventNDOFButton, window, data)); +// printf("button\n"); + break; + } err = noErr; break; default : diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index e3d4ee405e8..f3891995f54 100755 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -462,25 +462,21 @@ GHOST_SystemX11::processEvent(XEvent *xe) } else #endif if (sNdofInfo.currValues) { - sNdofInfo.currValues->changed = 1; - sNdofInfo.currValues->delta = xcme.data.s[8] - sNdofInfo.currValues->time; - sNdofInfo.currValues->time = xcme.data.s[8]; - sNdofInfo.currValues->tx = xcme.data.s[2] >> 4; - sNdofInfo.currValues->ty = xcme.data.s[3] >> 4; - sNdofInfo.currValues->tz = xcme.data.s[4] >> 4; - sNdofInfo.currValues->rx = xcme.data.s[5]; - sNdofInfo.currValues->ry = xcme.data.s[6]; - sNdofInfo.currValues->rz = xcme.data.s[7]; - - /*fprintf(stderr, "ClientMessage: [%d %d %d][%d %d %d] t=%llu\n", - sNdofInfo.currValues->tx, sNdofInfo.currValues->ty, - sNdofInfo.currValues->tz, sNdofInfo.currValues->rx, - sNdofInfo.currValues->ry, sNdofInfo.currValues->rz, - sNdofInfo.currValues->time); */ + 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); - g_event = new GHOST_EventNDOF(getMilliSeconds(), - GHOST_kEventNDOFMotion, - window, *sNdofInfo.currValues); } else { /* Unknown client message, ignore */ } -- cgit v1.2.3