Activated NDOF capture for Windows. Robust++ for generic NDOF manager. Removed experimental Win32 mouse and NDOF code now that good solutions are in place. Cleaned up formatting.

This commit is contained in:
Mike Erwin 2010-07-24 11:06:08 +00:00
parent a51ebf247f
commit a7ba245fe3
3 changed files with 446 additions and 594 deletions

@ -15,21 +15,26 @@
* along with this program; if not, write to the Free Software Foundation, * along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* *
* Contributor(s): none yet. * Contributor(s): Mike Erwin, July 2010.
* *
* ***** END GPL LICENSE BLOCK ***** * ***** END GPL LICENSE BLOCK *****
*/ */
#include "GHOST_NDOFManager.h" #include "GHOST_NDOFManager.h"
#include "GHOST_EventNDOF.h" #include "GHOST_EventNDOF.h"
#include <string.h> // for memory functions
#include <stdio.h> // for debug tracing
GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys) GHOST_NDOFManager::GHOST_NDOFManager(GHOST_System& sys)
: m_system(sys) : m_system(sys)
// , m_translation((short[]){0,0,0})
// , m_rotation((short[]){0,0,0})
, m_buttons(0) , m_buttons(0)
, m_atRest(true) , m_atRest(true)
{ } {
// to avoid the rare situation where one triple is updated and
// the other is not, initialize them both here:
memset(m_translation, 0, sizeof(m_translation));
memset(m_rotation, 0, sizeof(m_rotation));
}
void GHOST_NDOFManager::updateTranslation(short t[3], GHOST_TUns64 time) void GHOST_NDOFManager::updateTranslation(short t[3], GHOST_TUns64 time)
{ {
@ -68,7 +73,9 @@ bool GHOST_NDOFManager::sendMotionEvent()
GHOST_TEventNDOFData* data = (GHOST_TEventNDOFData*) event->getData(); GHOST_TEventNDOFData* data = (GHOST_TEventNDOFData*) event->getData();
const float scale = 1.f / 350.f; // SpaceNavigator sends +/- 350 usually const float scale = 1.f / 350.f; // SpaceNavigator sends +/- 350 usually
// 350 according to their developer's guide; others recommend 500 as comfortable
// possible future enhancement
// scale *= m_sensitivity; // scale *= m_sensitivity;
data->tx = scale * m_translation[0]; data->tx = scale * m_translation[0];
@ -80,7 +87,6 @@ bool GHOST_NDOFManager::sendMotionEvent()
data->rz = scale * m_rotation[2]; data->rz = scale * m_rotation[2];
printf("sending T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f)\n", data->tx, data->ty, data->tz, data->rx, data->ry, data->rz); printf("sending T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f)\n", data->tx, data->ty, data->tz, data->rx, data->ry, data->rz);
fflush(stdout);
m_system.pushEvent(event); m_system.pushEvent(event);

File diff suppressed because it is too large Load Diff

@ -304,10 +304,9 @@ protected:
* Creates and sends mouse or multi-axis events. * Creates and sends mouse or multi-axis events.
* @param raw a single RawInput structure * @param raw a single RawInput structure
* @param window The window receiving the event (the active window). * @param window The window receiving the event (the active window).
* @param x,y current mouse coordinates, which may be updated by this function
* @return Whether any events (possibly more than one) were created and sent. * @return Whether any events (possibly more than one) were created and sent.
*/ */
bool processRawInput(RAWINPUT const& raw, GHOST_WindowWin32* window /*, int& x, int& y */ ); bool processRawInput(RAWINPUT const& raw, GHOST_WindowWin32* window);
/** /**
* Creates and sends mouse events for mouse movements "in between" WM_MOUSEMOVEs. * Creates and sends mouse events for mouse movements "in between" WM_MOUSEMOVEs.
@ -333,10 +332,11 @@ protected:
/** /**
* Windows call back routine for our window class. * Windows call back routine for our window class.
* This handles general errors, then passes control to handleEvent.
*/ */
static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
// non-static version of WndProc /** Non-static version of WndProc. */
bool handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM wParam, LPARAM lParam); bool handleEvent(GHOST_WindowWin32* window, UINT msg, WPARAM wParam, LPARAM lParam);
/** The current state of the modifier keys. */ /** The current state of the modifier keys. */