I would like the user to be able to hold down the space bar and have things "keep happening" as long as the key is held. Preferrably, I'll be able to control the time between events.

Just poking thru the /examples/SDLx programs, the SDLx_controller_two_squares.pl seems to do that. You can control the arrow keys, but maybe your needs are more demanding? A minimal example might be helpful if you want some of us to look at it.

From my experience with Gtk2, the callbacks are designed to allow continued processing depending on whether you return a 1 or 0, TRUE or FALSE, from the callback. It looks like SDL does the same thing. I may have it slightly wrong, as it gets a bit confusing, for normal callbacks that would be stacked, returning a 1 means "I handled it, stop other callbacks"; while in a timer, returning 1 means continue the timer and a 0 means stop the timer. So if you want to play with timers within keyboard event callbacks, you may be able to return 0 or 1, depending on the state of the key you are interested in. Like set a global variable for whether a particular key is up or down, and in the timer callback, return a 0 or 1 accordingly. I hope I made sense. :-)


I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

In reply to Re: SDLx::App event loop by zentara
in thread SDLx::App event loop by Ransom

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.