Re: [Flightgear-devel] local key bindings ... Meta Super

2007-12-02 Thread Melchior FRANZ
Here's my Crazy Idea Of The Day:

The question was asked a few times, whether there are keys
reserved for local customization purposes. There are none.
But we have some completely unused shift levels. The X window
system supports 8 modifiers (usually called shift, ctrl, alt,
capslock, meta, super, hyper, and-another-one). All of them
can be combined. You can have Super-Meta-Ctrl-Shift-Alt-q.
But this isn't only hard to type in for those with only
10 fingers, it's also not supported everywhere (MS Windows?).

What we could do, though, is to invent a new modifier level
for local use. One that works everywhere. By just redefining
a key that is bigger than the others and easy to hit, just
like the other modifiers ... umm ... except alt, altgr)

Tadaaa: The TAB modifier!   :-)

With the attached simple script the TAB key becomes a modifier
that shifts all key codes up by adding 1000 to them. So, if you
press TAB-a, you get the key n=1098 definition triggered.
This works also in combination with regular modifiers Shift-Tab-a,
etc. (Except that Shit-Tab-a only triggers the mod-shift part
of A, not A itself. Could easily be changed, but that's left
as an exercise to the student.)

m.
var local = 0;
var active = {};

_setlistener(/devices/status/keyboard/event, func {
var event = cmdarg();
event.getNode(key).setValue(handle_key_event(event));
});

var handle_key_event = func(e) {
var key = e.getNode(key).getValue();
var pressed = e.getNode(pressed).getValue();

if (key == `\t`) {
local = pressed;
return 0;

} elsif (local) {
active[key] = e.getNode(modifier).getValue();
return key + 1000;

} elsif (!pressed and contains(active, key)) {
e.getNode(modifier).setValue(active[key]);
key += 1000;
}
delete(active, key);
return key;
}

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] local key bindings ... Meta Super

2007-12-02 Thread Stuart Buchanan
--- Melchior FRANZ wrote:
 Here's my Crazy Idea Of The Day:

snip

 What we could do, though, is to invent a new modifier level
 for local use. One that works everywhere. By just redefining
 a key that is bigger than the others and easy to hit, just
 like the other modifiers ... umm ... except alt, altgr)
 
 Tadaaa: The TAB modifier!   :-)

That is an excellent idea, and gives users plenty of choice.

However, I expect that a lot of people won't have the skills required to
include such Nasal code themselves. Would it be possible to integrate the
function more thoroughly into the codebase, so that it is Just There for
new users and they can simply add new key bindings to keyboard.xml?

One or two aircraft also currently use Tab (including the Vulcan) for
other purposes, but I'm more than happy to swap the Vulcan to use another
key (though it would be nice to define the reserved aircraft keys first ;)
).

-Stuart





  ___
Support the World Aids Awareness campaign this month with Yahoo! For Good 
http://uk.promotions.yahoo.com/forgood/

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] local key bindings ... Meta Super

2007-12-02 Thread Melchior FRANZ
* Melchior FRANZ -- Sunday 02 December 2007:
 Tadaaa: The TAB modifier!   :-)

D'oh! I had tried it with +500, and just to make it prettier I
changed it to 1000 before posting. And that crashes, because
input.cxx sets MAX_KEYS = 1024. So we are back at 500, which
is good enough.

New version attached, even shorter, even cooler.  ;-)

m.
var local = 0;
var active = {};

_setlistener(/devices/status/keyboard/event, func {
var e = cmdarg();
var keyN = e.getNode(key);
var key = keyN.getValue();
var pressed = e.getNode(pressed).getValue();

if (key == `\t`) {
local = pressed;
key = 0;

} elsif (local) {
active[key] = e.getNode(modifier).getValue();
return keyN.setValue(key + 500);

} elsif (!pressed and contains(active, key)) {
e.getNode(modifier).setValue(active[key]);
key += 500;
}
delete(active, key);
keyN.setValue(key);
});

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] local key bindings ... Meta Super

2007-12-02 Thread AnMaster
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512



Melchior FRANZ wrote:
 Here's my Crazy Idea Of The Day:
 
 The question was asked a few times, whether there are keys
 reserved for local customization purposes. There are none.
 But we have some completely unused shift levels. The X window
 system supports 8 modifiers (usually called shift, ctrl, alt,
 capslock, meta, super, hyper, and-another-one). All of them
 can be combined. You can have Super-Meta-Ctrl-Shift-Alt-q.
 But this isn't only hard to type in for those with only
 10 fingers, it's also not supported everywhere (MS Windows?).
 
 What we could do, though, is to invent a new modifier level
 for local use. One that works everywhere. By just redefining
 a key that is bigger than the others and easy to hit, just
 like the other modifiers ... umm ... except alt, altgr)
 
 Tadaaa: The TAB modifier!   :-)
 
 With the attached simple script the TAB key becomes a modifier
 that shifts all key codes up by adding 1000 to them. So, if you
 press TAB-a, you get the key n=1098 definition triggered.
 This works also in combination with regular modifiers Shift-Tab-a,
 etc. (Except that Shit-Tab-a only triggers the mod-shift part
 of A, not A itself. Could easily be changed, but that's left
 as an exercise to the student.)
 
A lot of keyboards have problems registering more than x keys (however Alt,
shift and such normally work anyway). For example left arrow key, space and ctrl
doesn't work together on my keyboard. I got no idea of if tab got any problems
but it is worth thinking about if you add modifier keys that are not normally
modifiers.

Another thing, a few aircrafts use tab iirc. They will need to be updated.

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQFHUvJPWmK6ng/aMNkRCo1NAJ9EdNXybxoVrx24Yw/SjcC+AfP7qgCeNsap
UKzr9v+vs7EP8nvx8imKjC4=
=E3Qt
-END PGP SIGNATURE-

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


[Flightgear-devel] local key bindings ... Meta Super

2007-12-01 Thread Melchior FRANZ
It's now possible to query Meta  Super modifier keys:

  SDL  ... Meta  Super supported
  OSG  ... only Meta supported  (would be easy to fix in OSG)
  GLUT ... no support, as usual  :-}

These modifier keys are set in keyboard events
(/devices/status/keyboard/events/modifiers/{meta,super}) and
can also be queried independent of events via
/devices/status/keyboard/{meta,super}.

  binding
  condition
  property/devices/status/keyboard/super/property
  /condition
  commandexit/command
  /binding

Because not all operating systems, all keyboards, and all
setups support these modifiers, they must *not* be used in
files committed to CVS. (That's why I didn't bother to add
mod-meta/mod-super XML tags.) But they can be used for
local key definitions, where they are safe from changes to
regular fgfs key bindings.

On Unices you can turn Windows/Menu keys into modifiers,
by putting something like this in your ~/.Xmodmap:

   clear mod5
   keycode 115 = Super_L
   keycode 116 = Super_R
   add mod5 = Super_L Super_R

These may be different key numbers on some keyboards (129 and 131
here). Use xev to get the number. I use the attached script at
the moment, to assign functions to Meta-v, Meta-s, Meta-`. I have
yet to migrate my other local key bindings to this new system.

m.



PS: support for Hyper is not planned.  :-)
_setlistener(/devices/status/keyboard/event, func {
var event = cmdarg();
if (handle_key_event(event.getValues()))
event.getNode(key).setValue(0);
});


var handle_key_event = func(e) {
#debug.dump(e);
if (!e.pressed or !e.modifier.meta and !e.modifier.super)
return 0;

if (e.key == `s`) { # toggle shadows
var i = !getprop(/sim/rendering/shadows-ac);
setprop(/sim/rendering/shadows-ac, i);
setprop(/sim/rendering/shadows-to, i);
setprop(/sim/rendering/shadows-ai, i);

} elsif (e.key == `v`) {# save aircraft state
ac_state.save();

} elsif (e.key == `\``) {   # set daytime midnight
fgcommand(timeofday, props.Node.new({ timeofday : midnight 
}));

} else {
debug.dump(e);
return 0;
}
return 1;
}

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel


Re: [Flightgear-devel] local key bindings ... Meta Super

2007-12-01 Thread Melchior FRANZ
* Melchior FRANZ -- Saturday 01 December 2007:
 Because not all operating systems, all keyboards, and all
 setups support these modifiers, they must *not* be used in
 files committed to CVS. (That's why I didn't bother to add
 mod-meta/mod-super XML tags.)

Now I *did* bother (but it's still recommended not to use them
in aircraft, and a bug to use them in files in CVS). You can
now add a Meta or Super binding:

   key n=113
   nameq/name
   mod-meta !-- or mod-super --
   binding
   commandexit/command
/binding
/mod-meta
/key

And it's still *your* job to convince your OS to report Meta
or Super modifier keys properly. Mine does.  :-)

m.

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel