On Wed, 30 Oct 2013 03:04:01 +0900 Kim Shinwoo <kimcinoo....@gmail.com> said:

> Dear all, Hello.
> 
> after i press and release space key while right arrow key is pressed.
> the right arrow key press event does not occur before release and press
> right arrow key again. this is a normal operation on X environment.
> 
> then how can i implement a shooting game on this environment.
> my main actor could fire while he moves to right side. but he can not move
> anymore after the fire stopped before the right arrow key is released and
> pressed.

aaaah you have hit the classic x key repeat problem that games have.

there have been 2 solutions in the past for this. the first and most fragile
has been asking to turn off key repeat globally in x - ie reconfigure the
keyboard (same thing u do with "xset r"). this has a problem. if your app
crashes or is terminated prematurely - you LEAVE the keyboard mis-configured
and users are very unhappy as key repeat is broken. you also have to
effectively handle focus in and out events and reconfigure key repeat on/off on
focus out and in events (so when user switches away from your app keyboard is
back to normal).

the other is to examine your events carefully. you will notice that when there
is a key repeat - they key up and down events that repeat have the EXACT SAME
timestamp for the up and down. you can now use this to filter out such repeated
events - so track the down and up of every key... but when you get an up after
a down, defer handling the up for a bit (an ecore_job or maybe a very short
timer). if you get another down event for the same key with the same timestamp
right after the up - then this up and down pair was a key repeat.. so ignore
it. :)

so then now you only deal with keys on REAL down and up's (ie that a user
physically pressed/released the key). any repeating is up to you to do in a
timer etc. (which is how games do things).

i will admit - this would be a nice feature to have in efl - to do the above
detection for you. the problem is... where to put it? maybe elm should have a
"gamecontroller" interface of some sort that allows you to create a dummy
object that accepts controller input (that means either specific bound keys or
specific mouse events/buttons OR maybe real gamepad devices, joysticks etc. if
we add such things later). and it's job is to do things like handle
bindings/mappings between input devices etc. and give you "usable" callbacks
for a game. :)

-- 
------------- Codito, ergo sum - "I code, therefore I am" --------------
The Rasterman (Carsten Haitzler)    ras...@rasterman.com


------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to