Touch Screen Input


Rockthesmurf

Advanced Member
Joined
Jul 18, 2003
Messages
1,115
Age
40
Location
Manchester, UK
Website
Visit site
Hi there,

I have the first pass of getting my game running on Pandora complete (hurrah), but have a small things I hope to iron out, one of them being input. The game is driven by touch screen input, and I am using X11 to get input events. On the whole it works, I can control my game in much the same way as I can on other devices (IPhone/Android/PC/Mac), however, I find the controls can be a bit 'hit and miss'. As in you can be 100% sure you are making adequate contact between stylus and screen, but the input isn't registered. The game is a reasonably paced game, where you need to be making quite fast, accurate input swipes, so missing input events is a real problem! The game runs at a solid 60 FPS, and the times that input isn't registered do not seem to correlate to any frame rate his, so I'm not entirely sure what is causing the problem. So my two rough questions would be:

  • Any ideas what could be causing this issue?
  • Is there a way to get a more 'raw' access to touch screen input events? If so, would these likely to be more robust?

Also, just for the record, this is all being built from a 100% Windows PC, with no Virtual Machines/Cygwin/etc. I do plan to put together some information on how to do this, as it may potential be of interest to other developers. The good news is once you know what to do, it is actually very straight forward.

I look forward to your input,

Steve
 
Oh, I thought some code example of what I am doing for input might be appropriate:

Code:
        XEvent xev;
        while( XPending( m_XDisplay ) )
        {
            XNextEvent( m_XDisplay, &xev );
            switch ( xev.type )
            {
                case ButtonPress:
                {
                    if ( xev.xbutton.button == Button1 )
                    {
                        m_IOSystem.xInputPress( xev.xbutton.x, xev.xbutton.y );
                    }
                }
                break;

                case ButtonRelease:
                {
                    if ( xev.xbutton.button == Button1 )
                    {
                        m_IOSystem.xInputRelease( xev.xbutton.x, xev.xbutton.y );
                    }
                }
                break;

                case MotionNotify:
                {
                    m_IOSystem.xInputMotion( xev.xmotion.x, xev.xmotion.y );
                }
                break;

                // Remove other cases for this example
                
            default:
                break;
            }
        }

Steve
 
I've observed some unresponsiveness even just tapping through the XFCE menu, but I've no idea where it comes from. You can get events straight from the kernel (have a look at the kernel interface stuff on the wiki) but these are about as raw as they get (i.e. uncalibrated). Using tslib on top of this makes things a bit more manageable. I can't say whether any of this will result in any better response.

There is a little input test program which you could try which lists raw events in real time. I don't remember if it's included as standard or you need compile it from the git sources, but it should at least show if your swipes are generating any events at all.
 
I get the raw commands without tslib and use the calibration values manually as shown in Penjin source:
http://code.google.com/p/penjin/source/browse/trunk/SimpleJoy.cpp#265

No idea if it will improve your problems, but I haven't noticed any input lag so far.
 
I compiled up evtest.c and gave that a go (console program that reads events directly from /dev/input/eventX), it seems if I do *very* fast input swipes it misses them (but they had to be pretty fast for this to happen - probably fast enough that one shouldn't expect them to register), but it did feel in general that inputs were mainly getting through. It felt like occasionally inputs were getting missed, but it is hard to tell just from a console program.

Unfortunately I am on holiday for a 10 days from this Thursday, and I don't think I'll have any time before I go, but the next things I'll try are:

  1. Assert if my motion function is hit without my button press function being hit (as if that happens it'll indicate the press event is not getting through)
  2. If the assert is getting hit, as a workaround I might be able to just say 'if motion function hit and not pressed, then set press = true'
  3. If the above don't appear to help, I'll take a look at reading events from /dev/input/eventX to see if I get any data from there which I am not getting with X (and if the data comes through any quicker)

With regards to the input lag, I'm not talking about seconds of delay, or anything like that, more that if I swipe, reasonably quickly, from the left of my screen, to the right of my screen, the cursor will be about half way across the screen by time I get to the other side. On the whole, the lag seems decent enough, but certainly I seem to find (with X11) it'll sometimes lag *more* on one stroke than the next. This can be quite frustrating as if you are trying to gesture to make a character jump in game, a little extra latency can mean the guy just falls to his death, which goes beyond the players control. :(

Steve
 
Back
Top