From http://www.jwz.org/xscreensaver/xscreensaver-5.37.tar.gz
[xscreensaver] / hacks / glx / gltrackball.h
index 3d8ef667bca1a3bd9948308f7ad7f5faafa43b24..ba9e574691e76f46f1eea03d31db976e71d62d39 100644 (file)
@@ -1,4 +1,4 @@
-/* gltrackball, Copyright (c) 2002, 2005 Jamie Zawinski <jwz@jwz.org>
+/* gltrackball, Copyright (c) 2002-2017 Jamie Zawinski <jwz@jwz.org>
  * GL-flavored wrapper for trackball.c
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
@@ -18,7 +18,7 @@ typedef struct trackball_state trackball_state;
 /* Returns a trackball_state object, which encapsulates the stuff necessary
    to make dragging the mouse on the window of a GL program do the right thing.
  */
-extern trackball_state *gltrackball_init (void);
+extern trackball_state *gltrackball_init (int ignore_device_rotation_p);
 
 /* Begin tracking the mouse: Call this when the mouse button goes down.
    x and y are the mouse position relative to the window.
@@ -32,6 +32,10 @@ extern void gltrackball_start (trackball_state *, int x, int y, int w, int h);
  */
 extern void gltrackball_track (trackball_state *, int x, int y, int w, int h);
 
+/* Stop tracking the mouse: Call this when the mouse button goes up.
+ */
+extern void gltrackball_stop (trackball_state *);
+
 /* Execute the rotations current encapsulated in the trackball_state:
    this does something analagous to glRotatef().
  */
@@ -40,10 +44,29 @@ extern void gltrackball_rotate (trackball_state *);
 /* Call this when a mouse-wheel click is detected.
    Clicks act like horizontal or vertical drags.
    Percent is the length of the drag as a percentage of the screen size.
-   Button is 'Button4' or 'Button5'.
+   Button is 'Button4' or 'Button5' (for the vertical wheel)
+   or 'Button5' or 'Button6' (for the horizontal wheel).
+   If `flip_p' is true, swap the horizontal and vertical axes.
  */
 void gltrackball_mousewheel (trackball_state *ts,
-                             int button, int percent, int horizontal_p);
+                             int button, int percent, int flip_p);
 
-#endif /* __GLTRACKBALL_H__ */
+/* Return the quaternion encapsulated by the trackball state.
+ */
+extern void gltrackball_get_quaternion (trackball_state *ts, float q[4]);
 
+/* Reset the trackball to the default unrotated state,
+   plus an optional initial rotation.
+ */
+extern void gltrackball_reset (trackball_state *ts, float x, float y);
+
+/* A utility function for event-handler functions:
+   Handles the various motion and click events related to trackballs.
+   Returns True if the event was handled.
+ */
+extern Bool gltrackball_event_handler (XEvent *,
+                                       trackball_state *,
+                                       int window_width, int window_height,
+                                       Bool *button_down_p);
+
+#endif /* __GLTRACKBALL_H__ */