Hi,
Le jeudi 13 décembre 2007, Melchior FRANZ a écrit :
> * Cédric Lucantis -- Thursday 13 December 2007:
> > I'd like to know if the 'repeatable' flag in the key bindings is
> > supposed to work ?
>
> Yes, but only with SDL. It does (AFAIK) not yet work with osgViewer,
> and it will probably never work with glut.
>
ok it works, thanks for the tip, but now I have a bigger problem ;) It
concerns keys using the alt-gr modifier (and sometimes some other
modifiers) : when not repeatable, those only work the first time you
press them and then get 'stuck' and never work again. I found that it's
because SDL does not report an unicode value for key release events so
convertEvent (in fg_os_sdl.cxx) tries to guess it from the
SDL_Keysym.sym value which is not always right. As a consequence,
FGInput::doKey does not always get the same keycode for a key-press and
the corresponding key-release event and can't see that some keys are
released. I wrote a fix for it (patch attached) which saves the unicode
value of any key-press in a scancode-indexed array and uses this value
for the key-release. Not sure it is the best solution, but it fixes the
problem for me. Hope it can help...
thanks,
--
Cédric Lucantis
Index: src/Main/fg_os_sdl.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Main/fg_os_sdl.cxx,v
retrieving revision 1.20
diff -u -p -r1.20 fg_os_sdl.cxx
--- src/Main/fg_os_sdl.cxx 12 Dec 2007 22:36:23 -0000 1.20
+++ src/Main/fg_os_sdl.cxx 15 Dec 2007 16:22:07 -0000
@@ -110,17 +110,26 @@ void fgOSOpenWindow(int w, int h, int bp
class SDLKeyTranslator : osgGA::GUIEventAdapter
{
public:
- static int handleKey(int key, int raw, int keyup);
+ static int handleKey(int key, int raw, int scan, int keyup);
+private:
+ static Uint16 uniscan[256];
};
-int SDLKeyTranslator::handleKey(int key, int raw, int keyup)
+Uint16 SDLKeyTranslator::uniscan[256] = { 0, };
+
+int SDLKeyTranslator::handleKey(int key, int raw, int scan, int keyup)
{
using namespace osgGA;
int modmask = 0;
int osgKey = 0;
- if (key == 0)
- key = raw;
+ if (keyup) {
+ key = SDLKeyTranslator::uniscan[scan];
+ } else {
+ if (!key) key = raw;
+ SDLKeyTranslator::uniscan[scan] = key;
+ }
+
// Don't pass capslock or numlock to the FGManipulator; SDL
// already transforms the key properly, so FGManipulator will get
// confused.
@@ -203,6 +212,7 @@ bool convertEvent(SDL_Event& event, osgG
{
int realKey = SDLKeyTranslator::handleKey(event.key.keysym.unicode,
event.key.keysym.sym,
+ event.key.keysym.scancode,
event.type == SDL_KEYUP);
if (realKey < -1)
return true;
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel