SFML community forums

Help => Window => Topic started by: spacechase0 on April 29, 2015, 04:49:54 am

Title: Touch position inconsistency on iOS with NSHighResolutionCapable
Post by: spacechase0 on April 29, 2015, 04:49:54 am
When NSHighResolutionCapable is set to true in the application plist, sf::Touch::getPosition is returning values that don't match the corresponding events. It doesn't seem to take the retina display into account.

#include <iostream>
#include <SFML/Graphics.hpp>
#include <SFML/Main.hpp>

int main( int argc, char* argv[] )
{
        sf::RenderWindow window( sf::VideoMode::getDesktopMode(), "Test" );

        while ( window.isOpen() )
        {
                sf::Event event;
                while ( window.pollEvent( event ) )
                {
                        if ( event.type == sf::Event::TouchBegan )
                        {
                                std::cout << "A: " << event.touch.x << ", " << event.touch.y << std::endl;
                                sf::Vector2i pos = sf::Touch::getPosition( event.touch.finger );
                                std::cout << "B: " << pos.x << ", " << pos.y << std::endl;
                        }
                }

                window.clear();
                window.display();
        }

        return 0;
}

I tested it in both the 4s and 6+ simulators (target SDK 8.1), using the bugfix/gles branch.
Title: Re: Touch position inconsistency on iOS with NSHighResolutionCapable
Post by: Hiura on April 29, 2015, 12:27:59 pm
It seems that the backing factor is not taken into account when data is inserted in touchPositions (example: SFAppDelegate.mm:248 (https://github.com/SFML/SFML/blob/master/src/SFML/Window/iOS/SFAppDelegate.mm#L248), but there are other places, but is when the event is generated. I guess it should either be taken into account when stored, or when extracted from InputImpl.mm:102 (https://github.com/SFML/SFML/blob/master/src/SFML/Window/iOS/InputImpl.mm#L102) . Keeping in mind that InputImpl::isTouchDown (https://github.com/SFML/SFML/blob/master/src/SFML/Window/iOS/InputImpl.mm#L95) should still work, of course.

Could you try implementing a patch? I'm not sure Laurent has currently the time.
Title: Re: Touch position inconsistency on iOS with NSHighResolutionCapable
Post by: spacechase0 on April 29, 2015, 05:56:44 pm
Sure (https://github.com/SFML/SFML/pull/875).