From Stephan Huber, "attached you’ll find a bunch of fixes + enhancements for iOS and OS X based on current trunk. I incorporated + tested the submission from Colin Cochran, so his submission is not needed anymore.

* fixed a bug with multi-touch and touch-id-generation on iOS and OS X. (will fix a bug reported by Colin Cochran, without ditching the existing logic)
* removed unnecessary warning-flagss when generating xcode-projects via cmake, will enable the usage of OSG_AGGRESSIVE_WARNING_FLAGS
* added support for 10.9 (OS X)
* new cmake-variable: IPHONE_VERSION_MIN, this will set the deployment-target (previously hard-coded) If you set the IPHONE_VERSION_MIN to something like 7.0 osg gets compiled also for 64bit (amd64)
* cmake defaults now to the clang compiler if IPHONE_VERSION_MIN > 4.2
* cmake now sets some xcode-settings so the compiler uses the c++98-standard (clang defaults to c++11, w/o this I got a lot of linking errors)
* removed include-dir for avfoundation-plugin as not needed on OSX/IOS.
* enhanced the ios-example, will now show multitouch-information on a hud (similar to the  osgmultitouch-example), and more importantly, will compile + link out of the box
* small enhancements for the osc-device-plugin (send only one msg for MOVE/DRAG, even if multiple msgs/event is enabled)
* better memory-handling for the zeroconf-plugin
* fixed a possible bug in the rest-http-plugin when receiving mouse-events.
* incorporated a fix from Colin Cochran "forwarded touch events are not transformed into the GL UIView“
"
This commit is contained in:
Robert Osfield
2013-10-07 10:38:58 +00:00
parent 320c51aa96
commit 2f71509ebf
14 changed files with 378 additions and 176 deletions

View File

@@ -267,6 +267,11 @@ RestHttpDevice::RestHttpDevice(const std::string& listening_address, const std::
, _firstEventLocalTimeStamp()
, _firstEventRemoteTimeStamp(-1)
, _lastEventRemoteTimeStamp(0)
, _currentMouseX(0.0f)
, _currentMouseY(0.0f)
, _targetMouseX(0.0f)
, _targetMouseY(0.0f)
, _targetMouseChanged(false)
{
setCapabilities(RECEIVE_EVENTS);

View File

@@ -171,7 +171,7 @@ public:
virtual bool checkEvents()
{
if ((fabs(_currentMouseX - _targetMouseY) > 0.1f) || (fabs(_currentMouseY - _targetMouseY) > 0.1))
if (_targetMouseChanged && (fabs(_currentMouseX - _targetMouseY) > 0.1f) || (fabs(_currentMouseY - _targetMouseY) > 0.1))
{
static const float scalar = 0.2f;
_currentMouseX = (1.0f - scalar) * _currentMouseX + scalar * _targetMouseX;
@@ -183,6 +183,7 @@ public:
void setTargetMousePosition(float x, float y, bool force = false)
{
_targetMouseChanged = true;
_targetMouseX = x; _targetMouseY = y;
if (force) {
_currentMouseX = x; _currentMouseY = y;
@@ -200,6 +201,7 @@ private:
double _firstEventRemoteTimeStamp;
double _lastEventRemoteTimeStamp;
float _currentMouseX, _currentMouseY, _targetMouseX, _targetMouseY;
bool _targetMouseChanged;
};

View File

@@ -68,10 +68,8 @@
@property (readonly, retain) NSMutableArray *services;
@property (readwrite, retain) NSString *type;
@property (readwrite, assign) BOOL isConnected;
@property (readwrite, retain) NSNetServiceBrowser *browser;
@property (readwrite, retain) NSNetService *connectedService;
@end
@@ -80,15 +78,12 @@
@synthesize browser;
@synthesize type;
@synthesize services;
@synthesize isConnected;
@synthesize connectedService;
-(id)initWithType: (NSString*) in_type withImpl:(AutoDiscoveryClientImpl*) in_impl {
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
services = [NSMutableArray new];
self.browser = [[NSNetServiceBrowser new] init];
self.browser.delegate = self;
self.isConnected = NO;
self.type = in_type;
impl = in_impl;
[self.browser searchForServicesOfType:in_type inDomain:@""];
@@ -97,9 +92,15 @@
}
-(void)dealloc {
self.connectedService = nil;
[self.browser stop];
self.browser.delegate = nil;
self.browser = nil;
[services makeObjectsPerformSelector:@selector(setDelegate:) withObject:nil];
[services makeObjectsPerformSelector:@selector(stop)];
[services release];
[super dealloc];
}
@@ -118,16 +119,11 @@
{
int ndx = [services indexOfObject: aService];
impl->servicesRemoved([services objectAtIndex: ndx]);
aService.delegate = nil;
[services removeObject:aService];
if ( aService == self.connectedService ) self.isConnected = NO;
}
-(void)netServiceDidResolveAddress:(NSNetService *)service {
self.isConnected = YES;
self.connectedService = service;
//NSLog(@"hostname: %@", [service hostName]);
@@ -220,4 +216,4 @@ void AutoDiscoveryClientImpl::servicesRemoved(void* key)
AutoDiscoveryClientImpl::~AutoDiscoveryClientImpl()
{
[_controller release];
}
}

View File

@@ -1,6 +1,5 @@
INCLUDE_DIRECTORIES( ${AV_FOUNDATION_INCLUDE_DIR} )
SET(TARGET_SRC
SET(TARGET_SRC
OSXAVFoundationVideo.mm
OSXAVFoundationVideo.h
../QTKit/VideoFrameDispatcher.h

View File

@@ -51,9 +51,14 @@ void OscSendingDevice::sendEvent(const osgGA::GUIEventAdapter &ea)
{
static osc::int64 msg_id(0);
bool msg_sent(false);
for(unsigned int i = 0; i < _numMessagesPerEvent; ++i) {
unsigned int num_messages = _numMessagesPerEvent;
if((ea.getEventType() == osgGA::GUIEventAdapter::DRAG) || (ea.getEventType() == osgGA::GUIEventAdapter::MOVE))
num_messages = 1;
for(unsigned int i = 0; i < num_messages; ++i) {
msg_sent = sendEventImpl(ea, msg_id);
if ((_delayBetweenSendsInMilliSecs > 0) && (i < _numMessagesPerEvent-1))
if ((_delayBetweenSendsInMilliSecs > 0) && (i < num_messages-1))
OpenThreads::Thread::microSleep(1000 * _delayBetweenSendsInMilliSecs);
}
if (msg_sent)

View File

@@ -312,7 +312,7 @@ static NSRect convertToQuartzCoordinates(const NSRect& rect)
#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6)
- (osgGA::GUIEventAdapter::TouchPhase) convertTouchPhase: (NSTouchPhase) phase;
- (unsigned int)computeTouchId: (NSTouch*) touch;
- (unsigned int)computeTouchId: (NSTouch*) touch mayCleanup: (BOOL) may_cleanup;
- (void)touchesBeganWithEvent:(NSEvent *)event;
- (void)touchesMovedWithEvent:(NSEvent *)event;
- (void)touchesEndedWithEvent:(NSEvent *)event;
@@ -813,7 +813,7 @@ static NSRect convertToQuartzCoordinates(const NSRect& rect)
}
- (unsigned int)computeTouchId: (NSTouch*) touch
- (unsigned int)computeTouchId: (NSTouch*) touch mayCleanup: (BOOL) may_cleanup
{
unsigned int result(0);
@@ -847,7 +847,8 @@ static NSRect convertToQuartzCoordinates(const NSRect& rect)
{
NSNumber* n = [_touchPoints objectForKey: [touch identity]];
result = [n intValue];
[_touchPoints removeObjectForKey: [touch identity]];
if(may_cleanup)
[_touchPoints removeObjectForKey: [touch identity]];
if([_touchPoints count] == 0) {
_lastTouchPointId = 0;
}
@@ -876,7 +877,7 @@ static NSRect convertToQuartzCoordinates(const NSRect& rect)
NSTouch *touch = [[allTouches allObjects] objectAtIndex:i];
NSPoint pos = [touch normalizedPosition];
osg::Vec2 pixelPos(pos.x * bounds.size.width, (1-pos.y) * bounds.size.height);
unsigned int touch_id = [self computeTouchId: touch];
unsigned int touch_id = [self computeTouchId: touch mayCleanup:FALSE];
if (!osg_event) {
osg_event = _win->getEventQueue()->touchBegan(touch_id, [self convertTouchPhase: [touch phase]], pixelPos.x(), pixelPos.y());
} else {
@@ -897,7 +898,7 @@ static NSRect convertToQuartzCoordinates(const NSRect& rect)
NSTouch *touch = [[allTouches allObjects] objectAtIndex:i];
NSPoint pos = [touch normalizedPosition];
osg::Vec2 pixelPos(pos.x * bounds.size.width, (1 - pos.y) * bounds.size.height);
unsigned int touch_id = [self computeTouchId: touch];
unsigned int touch_id = [self computeTouchId: touch mayCleanup:FALSE];
if (!osg_event) {
osg_event = _win->getEventQueue()->touchMoved(touch_id, [self convertTouchPhase: [touch phase]], pixelPos.x(), pixelPos.y());
} else {
@@ -919,7 +920,7 @@ static NSRect convertToQuartzCoordinates(const NSRect& rect)
NSTouch *touch = [[allTouches allObjects] objectAtIndex:i];
NSPoint pos = [touch normalizedPosition];
osg::Vec2 pixelPos(pos.x * bounds.size.width, (1 - pos.y) * bounds.size.height);
unsigned int touch_id = [self computeTouchId: touch];
unsigned int touch_id = [self computeTouchId: touch mayCleanup: TRUE];
if (!osg_event) {
osg_event = _win->getEventQueue()->touchEnded(touch_id, [self convertTouchPhase: [touch phase]], pixelPos.x(), pixelPos.y(), 1);
} else {

View File

@@ -163,7 +163,7 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
}
- (unsigned int)computeTouchId: (UITouch*) touch
- (unsigned int)computeTouchId: (UITouch*) touch mayCleanup: (bool)may_cleanup
{
unsigned int result(0);
@@ -202,10 +202,10 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
{
TouchPointsIdMapping::iterator itr = _touchPointsIdMapping->find(touch);
// std::cout<< "remove: " << touch << " num: " << _touchPointsIdMapping->size() << " found: " << (itr != _touchPointsIdMapping->end()) << std::endl;
if (itr != _touchPointsIdMapping->end()) {
result = itr->second;
_touchPointsIdMapping->erase(itr);
if(may_cleanup)
_touchPointsIdMapping->erase(itr);
}
if(_touchPointsIdMapping->size() == 0) {
_lastTouchPointId = 0;
@@ -576,9 +576,9 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:i];
CGPoint pos = [touch locationInView:touch.view];
CGPoint pos = [touch locationInView:self];
osg::Vec2 pixelPos = [self convertPointToPixel: osg::Vec2(pos.x,pos.y)];
unsigned int touch_id = [self computeTouchId: touch];
unsigned int touch_id = [self computeTouchId: touch mayCleanup: FALSE];
if (!osg_event) {
osg_event = _win->getEventQueue()->touchBegan(touch_id, [self convertTouchPhase: [touch phase]], pixelPos.x(), pixelPos.y());
@@ -599,9 +599,9 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
for(int i=0; i<[allTouches count]; i++)
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:i];
CGPoint pos = [touch locationInView:touch.view];
CGPoint pos = [touch locationInView:self];
osg::Vec2 pixelPos = [self convertPointToPixel: osg::Vec2(pos.x,pos.y)];
unsigned int touch_id = [self computeTouchId: touch];
unsigned int touch_id = [self computeTouchId: touch mayCleanup: FALSE];
if (!osg_event) {
osg_event = _win->getEventQueue()->touchMoved(touch_id, [self convertTouchPhase: [touch phase]], pixelPos.x(), pixelPos.y());
@@ -623,9 +623,9 @@ typedef std::map<void*, unsigned int> TouchPointsIdMapping;
for(int i=0; i<[allTouches count]; i++)
{
UITouch *touch = [[allTouches allObjects] objectAtIndex:i];
CGPoint pos = [touch locationInView:touch.view];
CGPoint pos = [touch locationInView:self];
osg::Vec2 pixelPos = [self convertPointToPixel: osg::Vec2(pos.x,pos.y)];
unsigned int touch_id = [self computeTouchId: touch];
unsigned int touch_id = [self computeTouchId: touch mayCleanup: TRUE];
if (!osg_event) {
osg_event = _win->getEventQueue()->touchEnded(touch_id, [self convertTouchPhase: [touch phase]], pixelPos.x(), pixelPos.y(), [touch tapCount]);
} else {