Bug #920

NeL - X11 Modifier Keys (Patch included)

Added by rti over 8 years ago. Updated about 8 years ago.

Status:Closed Start date:05/20/2010
Priority:Normal Due date:
Assignee:kervala % Done:

100%

Category:OS: GNU/Linux
Target version:Version 0.8.0

Description

This patch adds modifier support to key events and alt modifier support to mouse events.

For example pressing <SHIFT> + <1> generated until now:

  • one event containing the <SHIFT> and an empty text string
  • a second event containing the combination of both (eg. "!") and a string containing "!"

Now the following is generated:

  • one event containing the <SHIFT> and an empty text string (like before)
  • a second event containing the <1> key, a modifier mask set to <SHIFT> and a string containing "!"

This way the Ryzom client can detect the "1" part of the key event to trigger eg the spell bar while still creating "Text Events" for like chatting.
Combinations like <CTRL> + <ALT> + <SHIFT> + <A> are working as well.

The <ALT> modifier key was not implemented. The new implementation for that is only tested on Mac. No idea if this will work on Linux as well (contains a hardcoded value here because none of the Mod[1,5]Mask defines worked on Mac).

nel_x11_key_handling.patch (3.9 kB) Magnifier rti, 05/22/2010 05:57 pm

History

#1 Updated by vl over 8 years ago

  • Status changed from New to Assigned
  • Assignee set to kervala

#2 Updated by rti over 8 years ago

Ok, seems like on Linux non QWERTY layouts and the ALT key modifier are not supported by this patch. Needs some further investigation here.

#3 Updated by kervala over 8 years ago

When I press alt+t, it opens a linux Terminal :p

#4 Updated by rti over 8 years ago

Maybe it is a way to look up the secondary entries in the keycode to keysym tables. Just tried it, somehow it solves the problem. Will have a deeper look into that tomorrow.

#5 Updated by rti over 8 years ago

This one is a replacement for nel_x11_modifier_keys.patch.
The problems related to number keys on french layouts and not working modifiers on Linux should be fixed now.
I tested it on Ubuntu 10.4 and MacOS 10.6 with german QWERTZ and french AZERTY layouts.
Furthermore I did not screw the line endings this time. Yay! :)

#6 Updated by kervala over 8 years ago

  • File deleted (nel_x11_modifier_keys.patch)

#7 Updated by kervala over 8 years ago

I tested the last patch on my system (Ubuntu 10.04 x64 with French locale and keyboard) and some keys are not working anymore :(

When I'm in the Key window to configure my keys, I noticed all keys are associated automatically with <Alt> so when I press <Backspace> it detects <Alt>+<Backspace>, when I press "1" it detects <Alt>+1, etc... That's why no shortcut are working :)

When I'm in chat, <Backspace> and <Tab> are not recognized anymore, <Delete> doesn't delete character but only adds a ".", but most of <AltGr> combinations are working fine :)

#8 Updated by kervala over 8 years ago

After little tweaks, it's working perfectly :)

#9 Updated by rti over 8 years ago

What exactly did you change? Should I retest it on Mac?

#10 Updated by kervala over 8 years ago

In only changed AltMask on Linux so you shouldn't need to test it :)

Btw I found that AltMask was defined in <xorg/atKeynames.h> but I'm not sure it's existing only under Linux or everywhere.

#11 Updated by kervala over 8 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Applied in changeset r215.

#12 Updated by kervala over 8 years ago

  • Target version set to Version 0.8.0

The problem on Linux was that Mod2Mask is always enabled :s I put nlwarning with the modifier and I always get 16 when I was idle.

KanaMask (= Mod4Mask) is Windows key, ScrollLockMask (= Mod5Mask) is AltGr key (to do special characters).

On Linux :

  • defined in <X.h>
/* Key masks. Used as modifiers to GrabButton and GrabKey, results of QueryPointer,
   state in various key-, mouse-, and button-related events. */
#define ShiftMask               (1<<0)
#define LockMask                (1<<1)
#define ControlMask             (1<<2)
#define Mod1Mask                (1<<3)
#define Mod2Mask                (1<<4)
#define Mod3Mask                (1<<5)
#define Mod4Mask                (1<<6)
#define Mod5Mask                (1<<7)
  • defined in <xorg/atKeynames.h> (but don't think it's a standard X11 header)
#define AltMask         Mod1Mask
#define NumLockMask     Mod2Mask
#define AltLangMask     Mod3Mask
#define KanaMask        Mod4Mask
#define ScrollLockMask  Mod5Mask

#13 Updated by rti over 8 years ago

The break you removed was important for GCC ;)

diff with working copy (ac38ff6ee826)
--- a/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp    Sun May 23 17:54:46 2010 +0200
+++ b/code/nel/src/3d/driver/opengl/unix_event_emitter.cpp    Sun May 23 22:06:16 2010 +0200
@@ -222,6 +222,7 @@
     case XK_Z:
     case XK_z: return KeyZ;
     default: //nldebug ("0x%x %d '%c'", keysym, keysym, keysym);
+    break;
     }
     return KeyNOKEY;
 }

#14 Updated by kervala about 8 years ago

Applied in changeset r217.

#15 Updated by vl about 8 years ago

  • Status changed from Resolved to Closed

#16 Updated by kervala about 8 years ago

  • Category changed from NeL: General to OS: GNU/Linux

Also available in: Atom PDF