Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoXtSpaceball.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : David Mott (MMM yyyy)
25**=======================================================================*/
26/*=======================================================================
27 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
28 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
29 *** ***
30 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
31 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
32 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
33 *** ***
34 *** RESTRICTED RIGHTS LEGEND ***
35 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
36 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
37 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
38 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
39 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
40 *** ***
41 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
42 *** BORDEAUX, FRANCE ***
43 *** ALL RIGHTS RESERVED ***
44**=======================================================================*/
45/*=======================================================================
46** Modified by : VSG (MMM YYYY)
47**=======================================================================*/
48
49
50#ifdef SOQT
51# include <Inventor/Qt/devices/SoQtSpaceball.h>
52#elif defined _WIN32
53# include <Inventor/Win/devices/SoWinSpaceball.h>
54#else
55
56#ifndef _SO_XT_SPACEBALL_
57#define _SO_XT_SPACEBALL_
58
59#include <X11/X.h>
60#include <X11/extensions/XInput.h>
61
62#include <Inventor/Xt/SoXt.h>
63#include <Inventor/Xt/devices/SoXtDevice.h>
64#include <Inventor/events/SoMotion3Event.h>
65#include <Inventor/events/SoSpaceballButtonEvent.h>
66
67#include <Inventor/Gui/devices/SoGuiSpaceball.h>
68
82{
83 public:
84
85 //
86 // valid event mask values:
87 // SoXtSpaceball::MOTION - spaceball translation and rotation
88 // SoXtSpaceball::PRESS - spaceball button press
89 // SoXtSpaceball::RELEASE - spaceball button release
90 // SoXtSpaceball::ALL - all spaceball events
91 // Bitwise OR these to specify whichEvents this device should queue.
92 //
93 // The second constructor allows the spaceball to be attached
94 // to a different display than the one used by SoXt::init().
95
99 SoXtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
103 SoXtSpaceball(Display *d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL);
108
114 virtual void enable(SoWidget w, XtEventHandler f,
115 XtPointer data, Window win = 0);
121 virtual void disable(SoWidget w, XtEventHandler f, XtPointer data);
122
127 virtual const SoEvent * translateEvent(XAnyEvent *xevent);
128
134 void setRotationScaleFactor(float f) { m_guiSpaceball->setRotationScaleFactor( f ); }
138 float getRotationScaleFactor() const { return m_guiSpaceball->getRotationScaleFactor(); }
144 void setTranslationScaleFactor(float f) { m_guiSpaceball->setTranslationScaleFactor( f ); }
148 float getTranslationScaleFactor() const { return m_guiSpaceball->getTranslationScaleFactor(); }
149
153 static SbBool exists() { return exists(SoXt::getDisplay()); }
157 static SbBool exists(Display *d);
158
169 SbBool isFocusToWindow() const { return m_guiSpaceball->isFocusToWindow(); }
170
171 private:
172 SoMotion3Event *motionEvent; // spaceball rotation/translation
173 SoSpaceballButtonEvent *buttonEvent; // spball button press/release
174
175 SoWidget parentWidget;
176
177 SoGuiSpaceball* m_guiSpaceball; // Implementation class for SoXxSpaceball
178
179 // the X display
180 Display *display;
181
182 // flag indicating when to receive events.
183 SbBool focusToWindow;
184
185 // the window receiving events
186 Window window;
187
188 // event translators for SPACE BALL!
189 SoMotion3Event *translateMotionEvent(XDeviceMotionEvent *me);
190 SoSpaceballButtonEvent *translateButtonEvent(XEvent *be,
191 SoButtonEvent::State whichState);
192 // event translators for MAGELLAN SPACE MOUSE!
193 SoMotion3Event *translateMotionEventMagellan(XEvent *me);
194
195 void constructorCommon(Display *d, SoGuiSpaceball::Mask mask);
196
197};
198
199#endif /* _SO_XT_SPACEBALL_ */
200
201#endif // _WIN32
202
203
Base class for all events.
Definition SoEvent.h:116
3D motion events.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Spaceball button...
Abstract base class for input devices.
Definition SoXtDevice.h:85
Translates and reports events for a SpaceBall or SpaceMouse (Magellan) device.
static SbBool exists(Display *d)
Returns whether or not the spaceball device exists for use.
float getRotationScaleFactor() const
Returns the rotation scale factor.
~SoXtSpaceball()
Destructor.
SoXtSpaceball(Display *d, SoGuiSpaceball::Mask mask=SoGuiSpaceball::ALL)
Constructor.
virtual const SoEvent * translateEvent(XAnyEvent *xevent)
This converts a system event into an SoEvent, returning NULL if the event is not from this device.
void setTranslationScaleFactor(float f)
The spaceball reports rotations and translations as integers.
SbBool isFocusToWindow() const
Gets the input focus method.
SoXtSpaceball(SoGuiSpaceball::Mask mask=SoGuiSpaceball::ALL)
Constructor.
virtual void enable(SoWidget w, XtEventHandler f, XtPointer data, Window win=0)
Enables this device for the passed widget.
virtual void disable(SoWidget w, XtEventHandler f, XtPointer data)
Disables this device for the passed widget.
static SbBool exists()
Returns whether or not the spaceball device exists for use.
void setFocusToWindow(SbBool flag)
Sets the input focus method used to get events from the space ball.
float getTranslationScaleFactor() const
Returns the translation scale factor.
void setRotationScaleFactor(float f)
The spaceball reports rotations and translations as integers.
int SbBool
Boolean type.
Definition SbBase.h:87
union _XEvent XEvent
Definition SoQtDef.h:126
void * XtPointer
Definition SoQtDef.h:122