From Stephan Huber, "attached you'll find a first version of multi-touch-support for OS X (>=
10.6), which will forward all multi-touch events from a trackpad to the corresponding osgGA-event-structures. The support is switched off per default, but you can enable multi-touch support via a new flag for GraphicsWindowCocoa::WindowData or directly via the GraphicsWindowCocoa-class. After switching multi-touch-support on, all mouse-events from the trackpad get ignored, otherwise you'll have multiple events for the same pointer which is very confusing (as the trackpad reports absolute movement, and as a mouse relative movement). I think this is not a problem, as multi-touch-input is a completely different beast as a mouse, so you'll have to code your own event-handlers anyway. While coding this stuff, I asked myself if we should refactor GUIEventAdapter/EventQueue and assign a specific event-type for touch-input instead of using PUSH/DRAG/RELEASE. This will make it clearer how to use the code, but will break the mouse-emulation for the first touch-point and with that all existing manipulators. What do you think? I am happy to code the proposed changes. Additionally I created a small (and ugly) example osgmultitouch which makes use of the osgGA::MultiTouchTrackballManipulator, shows all touch-points on a HUD and demonstrates how to get the touchpoints from an osgGA::GUIEventAdapter. There's even a small example video here: http://vimeo.com/31611842"
This commit is contained in:
@@ -60,7 +60,12 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
|
||||
_checkForEvents(true),
|
||||
_ownsWindow(true),
|
||||
_currentCursor(RightArrowCursor),
|
||||
_window(NULL)
|
||||
_window(NULL),
|
||||
_view(NULL),
|
||||
_context(NULL),
|
||||
_pixelformat(NULL),
|
||||
_updateContext(false),
|
||||
_multiTouchEnabled(false)
|
||||
{
|
||||
_traits = traits;
|
||||
|
||||
@@ -134,11 +139,12 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
|
||||
class WindowData : public osg::Referenced
|
||||
{
|
||||
public:
|
||||
enum Options { CreateOnlyView = 1, CheckForEvents = 2, PoseAsStandaloneApp = 4};
|
||||
enum Options { CreateOnlyView = 1, CheckForEvents = 2, PoseAsStandaloneApp = 4, EnableMultiTouch = 8};
|
||||
WindowData(unsigned int options)
|
||||
: _createOnlyView(options & CreateOnlyView),
|
||||
: _createOnlyView(options & CreateOnlyView),
|
||||
_checkForEvents(options & CheckForEvents),
|
||||
_poseAsStandaloneApp(options & PoseAsStandaloneApp),
|
||||
_multiTouchEnabled(options & EnableMultiTouch),
|
||||
_view(NULL)
|
||||
{
|
||||
}
|
||||
@@ -147,12 +153,13 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
|
||||
bool createOnlyView() const { return _createOnlyView; }
|
||||
bool checkForEvents() const { return _checkForEvents; }
|
||||
bool poseAsStandaloneApp() const { return _poseAsStandaloneApp; }
|
||||
bool isMultiTouchEnabled() const { return _multiTouchEnabled; }
|
||||
|
||||
protected:
|
||||
inline void setCreatedNSView(NSView* view) { _view = view; }
|
||||
|
||||
private:
|
||||
bool _createOnlyView, _checkForEvents, _poseAsStandaloneApp;
|
||||
bool _createOnlyView, _checkForEvents, _poseAsStandaloneApp, _multiTouchEnabled;
|
||||
NSView* _view;
|
||||
|
||||
friend class GraphicsWindowCocoa;
|
||||
@@ -168,6 +175,9 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
|
||||
/** adapts a resize / move of the window, coords in global screen space */
|
||||
void adaptResize(int x, int y, int w, int h);
|
||||
|
||||
bool isMultiTouchEnabled();
|
||||
void setMultiTouchEnabled(bool b);
|
||||
|
||||
protected:
|
||||
|
||||
void init();
|
||||
@@ -195,7 +205,7 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
|
||||
GraphicsWindowCocoaGLView* _view;
|
||||
NSOpenGLContext* _context;
|
||||
NSOpenGLPixelFormat* _pixelformat;
|
||||
bool _updateContext;
|
||||
bool _updateContext, _multiTouchEnabled;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user