We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2471

Summary: Finger motion outside of screen area not tracked when moving back inside on one side of device
Product: SDL Reporter: christoph.boehler
Component: eventsAssignee: Sam Lantinga <slouken>
Status: ASSIGNED --- QA Contact: Sam Lantinga <slouken>
Severity: minor    
Priority: P2 CC: amaranth72, christoph.boehler
Version: 2.0.3   
Hardware: iPhone/iPod touch   
OS: iOS (All)   

Description christoph.boehler 2014-03-29 14:46:03 UTC
Tracking the SDL_FINGERMOTION/SDL_FINGERDOWN event, I experience unconsistent behaviour. When I push and hold the finger somewhere outside of the screen (ie next to the home button) and then move inside the screen area I expect to receive a fingerdown and subsequent fingermotion events.

This works on all sides of the device, except for the side opposite of the home button. Starting there I get no events at all until I release the finger and press again somewhere else.

The same thing happens when you start inside the screen area and move outside (again opposite of the home button) - touch events from that finger won't be fired again until you release the finger and press it anew.
Comment 1 Alex Szpakowski 2014-03-30 08:40:40 UTC
Does this work as expected for you in other non-SDL apps?
Comment 2 christoph.boehler 2014-04-01 14:17:34 UTC
Sorry for not testing this beforehand, but you're right, it seems to be innate to iOS. I will notify and slap the responsible authorities at apple :) thanks
Comment 3 christoph.boehler 2014-04-01 16:17:13 UTC
Ups, I've seemed to be a bit overzealous with my assessment. I've also tried another native iOS app (I've made myself without SDL) where the problem doesn't occur, so I guess by chance my other 2 tests from before were either (coincidentally) made with SDL too or just have the same problem.

Overloading UIApplication's -(void)sendEvent:(UIEvent *)event correctly returns touch events in the above mentioned situations in my native iOS app. So the problem should be related to SDL.

It's probably not really an issue on most apps, but since my app requires a lot of touches on the border it leads to some frustrating scenarios.
Comment 4 Sam Lantinga 2014-04-18 05:39:37 UTC
Can you debug the SDL code and see what's happening?

Thanks!
Comment 5 christoph.boehler 2014-04-22 22:07:23 UTC
Hello Sam, I found the culprit, though I'm not 100% sure why it's not working. Adding this to SDL_uikitview:

> - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
> {
>   NSLog(@"\nframe: %@\ntouchpoint: %@", NSStringFromCGRect(self.frame), NSStringFromCGPoint(point));
>   return YES;
> }

touching somewhere close to the rightmost edge of the screen the logoutput results in:

frame: {{0, 0}, {768, 1024}}
touchpoint: {1012, 538.5}

When calling [super pointInside...] I always get true unless coming from outside in. Touchpoint's x value will be 1024 in that case and I assume that either 1024 is considered outside or the rotation of the point causes a rounding problems? Those are my guesses anyways. Anyway, the simple solution would be to just add this to SDL_uikitview:


> - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
> {
>   return YES;
> }

Since the view always fills the entire screen. If that's not the case, let me know!
Comment 6 Sam Lantinga 2014-04-26 19:48:46 UTC
That sounds fine to me. Where's the best place to put that in the file? Do you have to declare it as well?
Comment 7 christoph.boehler 2014-05-01 17:14:05 UTC
Insert into SDL_uikitview.m

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
  return YES;
}

I'm not sure if the declaration in the .h file is necessary since it's an overriden method, but it surely doesn't hurt.

I'm not sure what you mean with "best place", i'd say above the

- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize;

method makes sense if that's what you mean.