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 1603 - Changing orientation on the devices throws off touch scaling
Summary: Changing orientation on the devices throws off touch scaling
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All Android (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on: 1506
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-20 07:11 UTC by vctos
Modified: 2012-09-21 06:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vctos 2012-09-20 07:11:29 UTC
+++ This bug was initially created as a clone of Bug #1506 +++

>I think the best would be to remove all touch devices when the screen 
>size changes, the question is how... (SDL_TouchQuit ?)
calling SDL_TouchQuit() is good solution.
we can add this call in SDL_QuitSubSystem function.
another variant - add call SDL_TouchQuit() in CommonQuit() like function in common.c sample file. 
void CommonQuit(CommonState * state)
{
    int i;
	SDL_Log("==== CommonQuit() ====\n");

    if (state->windows) {
        SDL_free(state->windows);
    }
    if (state->renderers) {
        for (i = 0; i < state->num_windows; ++i) {
            if (state->renderers[i]) {
                SDL_DestroyRenderer(state->renderers[i]);
            }
        }
        SDL_free(state->renderers);
    }
	SDL_TouchQuit(); // vctos: not called from SDL_QuitSubSystem(Uint32 flags)!!!
    if (state->flags & SDL_INIT_VIDEO) {
        SDL_VideoQuit();
    }
    if (state->flags & SDL_INIT_AUDIO) {
        SDL_AudioQuit();
    }
	SDL_Quit();
    SDL_free(state);
}


for Android it is good solution to return from SDL_main() every time when screen orientation changed. all we need for this is to disable exit() call:
static void quit(int rc)
{
	TTF_Quit();
	CommonQuit(state);
	if (rc){
	    exit(rc);
	}
}

current modification http://hg.libsdl.org/SDL/rev/2ed5671bc5e0 based on mismatch touch.native_xres/native_yres values. this produce incompatibles with other platforms.
Comment 1 Gabriel Jacobo 2012-09-20 07:28:36 UTC
I'm having problems understanding why you opened this report, what's the problem you are seeing? Currently Android does the exact same thing the iOS backend does, so I guess I don't understand what you mean by "this produce incompatibles with
other platforms."
Comment 2 vctos 2012-09-21 00:01:39 UTC
IMHO, struct SDL_Touch oriented not only for android & ios, it has members "for future use" (for use with tablet digitizer like device). puppose such data sets is to produce coordinate convertion from device (tablet digitizer) coordinat system into (video) screen coordinat system.
in current implementation when x_min always 0 and x_max always 1.0, native_xres member redundant.
I hope Sam Lantinga can say us exactly, what he mean in SDL_Touch field list.
Comment 3 Gabriel Jacobo 2012-09-21 06:06:09 UTC
The SDL_Touch structure is made to be as generic as possible, if you look at what information digitizers provider, you'll see it's very similar to what SDL_Touch stores. If you have further doubts you can clear them up in the mailing list.