SDL and mouse x and y axis swapped

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

Post Reply
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

SDL and mouse x and y axis swapped

Post by BillSargent »

Hi,

I'm new to this forum.

I recently compiled openttd for my mini2440 development board. It's an armv4t device with a tslib touchscreen.

OpenTTD runs very nicely on it, however, the x and y axis of the touch screen is wrong. When I move the mouse up and down, it moves left and right. The calibration tool with tslib shows its fine.

I Looked at the SDL environment variables to see if there was anything there I could tweak, but I couldn't find anything that would work.

Is there some trick to getting the raw mouse events to work with SDL and with openttd? I Do not want to end up having to run this in X. My little dev board can hardly handle it.

Thanks,
Bill
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: SDL and mouse x and y axis swapped

Post by Rubidium »

Maybe the calibration tool is coded with to work with a bug in SDL that swaps the axis.

To test this you should test some other SDL applications as well to see whether they work correctly or are broken as well. If they're broken as well it's most likely something in SDL that needs to be fixed, though it might be something "stupid" in OpenTTD as well. In any case, testing some other generic SDL application should give an idea where the bug is.
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: SDL and mouse x and y axis swapped

Post by BillSargent »

Rubidium wrote:Maybe the calibration tool is coded with to work with a bug in SDL that swaps the axis.

To test this you should test some other SDL applications as well to see whether they work correctly or are broken as well. If they're broken as well it's most likely something in SDL that needs to be fixed, though it might be something "stupid" in OpenTTD as well. In any case, testing some other generic SDL application should give an idea where the bug is.

As far as I know, ts_calib isn't written at all with SDL in mind. It's simply a low level calibration tool that uses libts (tslib) to create a calibration file. Theres a ts_test as well which shows whether the calibration is correct or not, which allows you to draw lines and shows a crosshair to show that it's working correctly.

I really don't know of any simple SDL applications I could test. I'm actually new to SDL altogether. Is there a specific version of SDL that is recommended for OpenTTD compilation? And has anyone else successfully got this working on ARM with a touch screen?

Bill
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: SDL and mouse x and y axis swapped

Post by BillSargent »

Oh I should note, that I used OpenEmbedded to compile openttd since it already had a recipe for bitbake in it.

0.7.4 is the version of openttd its compiling.

The recipe configures it this way:

Code: Select all

do_configure() {
  # The way the OTTD configure system handles the application's directories
  # isn't the way autotools does it. Mainly prefix is always prepended even if
  # absolute binary-dir and data-dir is given.

  ${S}/configure \
        --host=${TARGET_SYS} \
        --windres=${MACHINE_DISPLAY_WIDTH_PIXELS}x${MACHINE_DISPLAY_HEIGHT_PIXELS} \
        --os=UNIX \
        --endian=${SITEINFO_ENDIANNESS} \
        --prefix-dir=${prefix} \
        --binary-dir=bin \
        --with-midi=/bin/true \
        --with-zlib=${STAGING_LIBDIR} \
        --with-png \
        --with-freetype \
        --without-icu \
        --without-allegro \
        --cc-build=gcc \
        --cc-host=${TARGET_SYS}-gcc \
        --cxx-build=g++ \
        --cxx-host=${TARGET_SYS}-g++ \
        --cxx-build=g++ \
        --cxx-host=${TARGET_SYS}-g++ \
        --strip=${TARGET_SYS}-strip \
        --install-dir=${D}
}

And it has dependencies of

Code: Select all

DEPENDS = "libsdl-net libpng zlib freetype fontconfig"
It's using libsdl-net 1.2.7


You may be saying this is something I should post on a openembedded forum, but since it compiles clean and runs, nobody there can help. And nobody there seems to be running this on my device so they dont seem to have any help for me.

Bill
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: SDL and mouse x and y axis swapped

Post by Rubidium »

OpenTTD doesn't need libsdl-net, just libsdl. It should work fine with any recent version, where recent is everything since early 2008, or basically libsdl versions 1.2.13 and 1.2.14.

Also, if the calibration thing doesn't use libsdl then it's quite likely libsdl itself is actually broken.
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: SDL and mouse x and y axis swapped

Post by BillSargent »

Rubidium wrote:OpenTTD doesn't need libsdl-net, just libsdl. It should work fine with any recent version, where recent is everything since early 2008, or basically libsdl versions 1.2.13 and 1.2.14.

Also, if the calibration thing doesn't use libsdl then it's quite likely libsdl itself is actually broken.
Ok I'm going to work on this recipe and swap out libsdl-net with libsdl. I'll keep you posted on my progress. It might be helpful to someone else if I can get this fixed :)

Bill
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: SDL and mouse x and y axis swapped

Post by BillSargent »

It'll be awhile before I can get back to this. Seems that most of the SDL recipes in Openembedded are broken. Won't even compile.

I'll have to wait until those people get around to fixing it. But I will keep you posted. A nice arm port of this with instructions wouldnt be a bad idea. Surely someone could use it ;)
BillSargent
Engineer
Engineer
Posts: 49
Joined: 09 Oct 2010 13:45
Location: Göteborg, Sweden

Re: SDL and mouse x and y axis swapped

Post by BillSargent »

Forget that last post. I just pulled the latest svn of openembedded and they've apparently corrected libsdl so that it compiles and its 1.2.14

Same problem. Beyond what I've tried, I don't know what else I can do. I don't know enough about SDL or OpenTTD to attempt to patch it.If someone knows of a quick and dirty way to swap x and y, that would probably be the best approach for a quick fix.

Bill
User avatar
Zuu
OpenTTD Developer
OpenTTD Developer
Posts: 4553
Joined: 09 Jun 2003 18:21
Location: /home/sweden

Re: SDL and mouse x and y axis swapped

Post by Zuu »

I'd check in driver/sdl_v or similar where the sdl video driver for OpenTTD is located in the source code. To me it seems likely that each video driver (sdl, directx, etc.) has a function to get the mouse location. In this function you could just swap x and y before the location is returned.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 21 guests