2
This file is part of libspnav, part of the spacenav project (spacenav.sf.net)
3
Copyright (C) 2007-2010 John Tsiombikas <nuclear@member.fsf.org>
5
Redistribution and use in source and binary forms, with or without
6
modification, are permitted provided that the following conditions are met:
8
1. Redistributions of source code must retain the above copyright notice, this
9
list of conditions and the following disclaimer.
10
2. Redistributions in binary form must reproduce the above copyright notice,
11
this list of conditions and the following disclaimer in the documentation
12
and/or other materials provided with the distribution.
13
3. The name of the author may not be used to endorse or promote products
14
derived from this software without specific prior written permission.
16
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28
/* spnav_magellan.h and spnav_magellan.c provide source-level compatibility
29
* with the original proprietary Magellan SDK provided by 3Dconnexion.
30
* It is actually implemented as a wrapper on top of the new spnav interface
33
#include "spnav_magellan.h"
36
int MagellanInit(Display *dpy, Window win)
38
return spnav_x11_open(dpy, win) == -1 ? 0 : 1;
41
int MagellanClose(Display *dpy)
43
return spnav_close() == -1 ? 0 : 1;
46
int MagellanSetWindow(Display *dpy, Window win)
48
return spnav_x11_window(win) == -1 ? 0 : 1;
51
int MagellanApplicationSensitivity(Display *dpy, double sens)
53
return spnav_sensitivity(sens) == -1 ? 0 : 1;
57
int MagellanInputEvent(Display *dpy, XEvent *xev, MagellanIntEvent *mev)
62
if(!spnav_x11_event(xev, &event)) {
66
if(event.type == SPNAV_EVENT_MOTION) {
67
mev->type = MagellanInputMotionEvent;
70
mev->u.data[i] = event.motion.data[i];
72
mev->u.data[6] = event.motion.period * 1000 / 60;
74
mev->type = event.button.press ? MagellanInputButtonPressEvent : MagellanInputButtonReleaseEvent;
75
mev->u.button = event.button.bnum;
82
int MagellanTranslateEvent(Display *dpy, XEvent *xev, MagellanFloatEvent *mev, double tscale, double rscale)
87
if(!spnav_x11_event(xev, &event)) {
91
if(event.type == SPNAV_EVENT_MOTION) {
92
mev->MagellanType = MagellanInputMotionEvent;
95
mev->MagellanData[i] = (double)event.motion.data[i] * (i < 3 ? tscale : rscale);
97
mev->MagellanPeriod = event.motion.period;
99
mev->MagellanType = event.button.press ? MagellanInputButtonPressEvent : MagellanInputButtonReleaseEvent;
100
mev->MagellanButton = event.button.bnum;
103
return mev->MagellanType;
106
int MagellanRemoveMotionEvents(Display *dpy)
108
return spnav_remove_events(SPNAV_EVENT_MOTION);
112
int MagellanRotationMatrix(double mat[4][4], double x, double y, double z)
117
int MagellanMultiplicationMatrix(double mat_a[4][4], double mat_b[4][4], double mat_c[4][4])