00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : David Mott (MMM yyyy) 00025 **=======================================================================*/ 00026 /*======================================================================= 00027 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00028 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00029 *** *** 00030 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00031 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00032 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00033 *** *** 00034 *** RESTRICTED RIGHTS LEGEND *** 00035 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00036 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00037 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00038 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00039 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00040 *** *** 00041 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00042 *** BORDEAUX, FRANCE *** 00043 *** ALL RIGHTS RESERVED *** 00044 **=======================================================================*/ 00045 /*======================================================================= 00046 ** Modified by : VSG (MMM YYYY) 00047 **=======================================================================*/ 00048 00049 00050 #ifdef SOQT 00051 # include <Inventor/Qt/devices/SoQtSpaceball.h> 00052 #elif defined _WIN32 00053 # include <Inventor/Win/devices/SoWinSpaceball.h> 00054 #else 00055 00056 #ifndef _SO_XT_SPACEBALL_ 00057 #define _SO_XT_SPACEBALL_ 00058 00059 #include <X11/X.h> 00060 #ifndef __NUTC__ 00061 # include <X11/extensions/XInput.h> 00062 #endif 00063 00064 #include <Inventor/Xt/SoXt.h> 00065 #include <Inventor/Xt/devices/SoXtDevice.h> 00066 #include <Inventor/events/SoMotion3Event.h> 00067 #include <Inventor/events/SoSpaceballButtonEvent.h> 00068 00069 #include <Inventor/Gui/devices/SoGuiSpaceball.h> 00070 00084 class SoXtSpaceball : public SoXtDevice 00085 { 00086 public: 00087 00088 // 00089 // valid event mask values: 00090 // SoXtSpaceball::MOTION - spaceball translation and rotation 00091 // SoXtSpaceball::PRESS - spaceball button press 00092 // SoXtSpaceball::RELEASE - spaceball button release 00093 // SoXtSpaceball::ALL - all spaceball events 00094 // Bitwise OR these to specify whichEvents this device should queue. 00095 // 00096 // The second constructor allows the spaceball to be attached 00097 // to a different display than the one used by SoXt::init(). 00098 00102 SoXtSpaceball(SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL); 00106 SoXtSpaceball(Display *d, SoGuiSpaceball::Mask mask = SoGuiSpaceball::ALL); 00110 ~SoXtSpaceball(); 00111 00117 virtual void enable(SoWidget w, XtEventHandler f, 00118 XtPointer data, Window win = NULL); 00124 virtual void disable(SoWidget w, XtEventHandler f, XtPointer data); 00125 00130 virtual const SoEvent * translateEvent(XAnyEvent *xevent); 00131 00137 void setRotationScaleFactor(float f) { m_guiSpaceball->setRotationScaleFactor( f ); } 00141 float getRotationScaleFactor() const { return m_guiSpaceball->getRotationScaleFactor(); } 00147 void setTranslationScaleFactor(float f) { m_guiSpaceball->setTranslationScaleFactor( f ); } 00151 float getTranslationScaleFactor() const { return m_guiSpaceball->getTranslationScaleFactor(); } 00152 00156 static SbBool exists() { return exists(SoXt::getDisplay()); } 00160 static SbBool exists(Display *d); 00161 00168 void setFocusToWindow(SbBool flag); 00172 SbBool isFocusToWindow() const { return m_guiSpaceball->isFocusToWindow(); } 00173 00174 private: 00175 SoMotion3Event *motionEvent; // spaceball rotation/translation 00176 SoSpaceballButtonEvent *buttonEvent; // spball button press/release 00177 00178 SoWidget parentWidget; 00179 00180 SoGuiSpaceball* m_guiSpaceball; // Implementation class for SoXxSpaceball 00181 00182 // the X display 00183 Display *display; 00184 00185 // flag indicating when to receive events. 00186 SbBool focusToWindow; 00187 00188 // the window receiving events 00189 Window window; 00190 00191 // event translators for SPACE BALL! 00192 SoMotion3Event *translateMotionEvent(XDeviceMotionEvent *me); 00193 SoSpaceballButtonEvent *translateButtonEvent(XEvent *be, 00194 SoButtonEvent::State whichState); 00195 // event translators for MAGELLAN SPACE MOUSE! 00196 SoMotion3Event *translateMotionEventMagellan(XEvent *me); 00197 00198 void constructorCommon(Display *d, SoGuiSpaceball::Mask mask); 00199 00200 }; 00201 00202 #endif /* _SO_XT_SPACEBALL_ */ 00203 00204 #endif // _WIN32 00205 00206 00207