Well monks, here's another round for you.

I'm using SDLx::App and SDL::Events to control a simple test object on screen. I was finally able to handle multiple arrow key events for smooth movements. However, I added another sub to the event handler to create additional objects upon pressing the space key.

The current puzzler I'm experiencing is that when using the arrow keys (creating events), the space key generates events just fine. Likewise, if all keys are up and space is pressed, events are generated fine. The actual problem occurs when releasing all arrow keys with the space bar still pressed. As far as I can tell, the space bar does not continue to repeat events after the arrows are released.

My question regards the SDLx::Controller module. What is the typical way to handle events so that no keys are "blocking" other keys and that repeat events continue to happen in the example above? With the current system, event subs are only processed when events actually happen. This means that once SDL decides that I'm no longer pressing the space bar (even though I am still), it won't even go into the sub to check if the space bar is pressed. It waits until another event happens, then continues to process the space bar events. It would seem that using the arrow keys while the space bar is pressed, blocks the repeating space bar events from making it into the queue.

I'm pretty sure that didn't make a whole lot of sense, but I'm not sure how code could help in this case. I'm fairly certain it is not a programming bug at this point, but more of a lack of understanding on my part about how the SDL event loop is processed within the SDLx::App.

UPDATE: A quick fix for this problem is to add an empty event to the queue during each iteration of the game loop. This effectively makes all event subs get processed each frame. I'm sure this isn't an ideal solution, but it alleviates the need to re-press keys in order to keep the event queue polling. Ideally, I would like to not use this little hack, but I'm not even sure where that code would go, since most of the looping is taken care of in SDLx::App. scrottie: I considered this and changed things around to use different keys, but to no avail. I think it is an internal SDL issue (or my improper use of the interface) rather than hardware at this point. To be more clear, it's not that I'm hitting a zillion keys at once, just hitting them in different combinations.

In reply to SDLx::App and keyboard events 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.