Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Stupid mistake of XFree86
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
MadEgg
l33t
l33t


Joined: 06 Jun 2002
Posts: 678
Location: Netherlands

PostPosted: Tue Apr 15, 2003 4:33 pm    Post subject: Stupid mistake of XFree86 Reply with quote

I'm one of those from the old days ;) that still like to use the directional keys on the numpad instead of directional keys left of the numpad.

That works most of the time, but X has some stupid mistake that confuses Shift with numlock.

When I press and hold shift and push one of the directional keys, it assumes I want the number of that key, instead of moving in that direction, so when I press shift + right, I get a 6, while I was just trying to expand my selection to the right. And that should only happen when numlock is on. It happens the other way around when I press numlock, making numlock act as an alternative capslock for the numpad. IMHO that is completely wrong.

Is there any way I can stop X from toggling between cursors and numbers when pressing shift, but keep toggling when using numlock?
_________________
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Back to top
View user's profile Send private message
MadEgg
l33t
l33t


Joined: 06 Jun 2002
Posts: 678
Location: Netherlands

PostPosted: Thu Apr 17, 2003 7:26 pm    Post subject: Reply with quote

*subtle bump*
_________________
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Back to top
View user's profile Send private message
MadEgg
l33t
l33t


Joined: 06 Jun 2002
Posts: 678
Location: Netherlands

PostPosted: Fri Apr 18, 2003 5:13 pm    Post subject: Reply with quote

noone? :(
_________________
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Back to top
View user's profile Send private message
PowerFactor
Veteran
Veteran


Joined: 30 Jan 2003
Posts: 1693
Location: out of it

PostPosted: Fri Apr 18, 2003 6:04 pm    Post subject: Reply with quote

Well, you could try playing with xmodmap some. I tried briefly but didn't get it to work like you wanted.
Back to top
View user's profile Send private message
MadEgg
l33t
l33t


Joined: 06 Jun 2002
Posts: 678
Location: Netherlands

PostPosted: Fri Apr 18, 2003 9:35 pm    Post subject: Reply with quote

Yea, that's what I tried.. but this seems something completely different...
_________________
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20048

PostPosted: Fri Apr 18, 2003 9:39 pm    Post subject: Reply with quote

Have you tried using xev to see if that helps? Run it from a terminal so you can see the output.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
j-kidd
Apprentice
Apprentice


Joined: 20 Feb 2003
Posts: 213

PostPosted: Sat Apr 19, 2003 2:45 am    Post subject: Reply with quote

I found a partial solution, which not only disable the effect of capslock on keypad, but disable the effect of numlock as well :roll:

Just put this into ~/.xmodmap
Code:

keycode 0x4F =  KP_Home
keycode 0x50 =  KP_Up
keycode 0x51 =  KP_Prior
keycode 0x53 =  KP_Left
keycode 0x55 =  KP_Right
keycode 0x57 =  KP_End
keycode 0x58 =  KP_Down
keycode 0x59 =  KP_Next


And then add this line into ~/.xinitrc
Code:

xmodmap ~/.xmodmap


In my opinion, "Shift + keypad = number" is a really stupid behavior... if I want to type a few numbers, I use the row of 1234567890... if I want to type a lot of numbers, I switch on numlock and use the keypad... why Shift? :?

Anyway, I really hope someone can come up with a good solution :)
Back to top
View user's profile Send private message
MadEgg
l33t
l33t


Joined: 06 Jun 2002
Posts: 678
Location: Netherlands

PostPosted: Sat Apr 19, 2003 8:03 am    Post subject: Reply with quote

Ok, this solves that part of the problem, but indeed it would be cool to do have them output numbers on numlock...

Hmmz, I figure I gotta do something with numlock as a modifier key then.
_________________
Pentium 4 Prescott 3,2 GHz
Asus P4P800 SE, i865PE chipset
1024 MB PC3200 RAM
AOpen Aeolus GeForce 6800 Ultra 256 MB DDR2
Creative Audigy2 ZS
gentoo-sources-2.6.20-r7
nVidia-drivers version 9755
Back to top
View user's profile Send private message
grant.mcdorman
Apprentice
Apprentice


Joined: 29 Jan 2003
Posts: 295
Location: Toronto, ON, Canada

PostPosted: Wed Apr 23, 2003 3:08 am    Post subject: Reply with quote

j-kidd wrote:
I found a partial solution, which not only disable the effect of capslock on keypad, but disable the effect of numlock as well :roll:

Just put this into ~/.xmodmap
Code:

keycode 0x4F =  KP_Home
keycode 0x50 =  KP_Up


snip..

This style of xmodmap code is usually A Bad Idea. The problem is that it will only work for your current keyboard - and possibly even your current version of XFree86. It will definitely break if you use VNC.

A better way of doing these things is:
Code:

keysym KP_7 = KP_Home
keysym KP_8 = KP_Up

etc.

To answer the original question, though: what you want is supported by X, at least using xmodmap. I don't know much about the X keyboard extension (XKb) unfortunately.

The keypad normally has two symbols for each key; that is:
Code:

7: KP_Home KP_7
8: KP_Up KP_8

and so forth. The shift key, of course, selects the second symbol. NumLock reverses the behavior, so the second symbol is selected when unshifted. There is no way to have the keypad ignore the shift key.

This behaviour is the same on Windows (and even in MS-DOS), for the most part.

It would be possible, however, to get a program to trap NumLock presses and dynamically change the keymap; I just whipped up a little program (54 lines) that can do this for you:

watch_numlock.c:
Code:

#include <stdio.h>

#include <X11/Xlib.h>
#define XK_MISCELLANY
#include <X11/keysymdef.h>

static Display * disp;
static Screen  * scrn;
static Window    root;
static XEvent    event;
static KeyCode code;
static int is_on = 0;

int main(int argc, char *argv[])
{
    if (argc != 3) {
        fprintf(stderr, "Usage: %s num-lock-on-cmd num-lock-off-cmd\n",
                argv[0]);
        exit(1);
    }

    disp = XOpenDisplay(NULL);
    if (disp == NULL) {
        fprintf(stderr, "Could not open display\n");
        exit(1);
    }

    scrn = DefaultScreenOfDisplay(disp);
    root = RootWindowOfScreen(scrn);
    code = XKeysymToKeycode(disp, XK_Num_Lock);


    XGrabKey(disp, code, AnyModifier, root,
                True,
                GrabModeAsync, GrabModeAsync);


    while (1) {
        XNextEvent(disp, &event);
        if (event.xany.type == KeyRelease &&
            event.xkey.keycode == code) {
            XKeyboardState  keyboard_state;
            XGetKeyboardControl(disp, &keyboard_state);
            /* LED 2 is Num Lock */
            if (keyboard_state.led_mask & 2) {
                system(argv[1]);
            } else {
                system(argv[2]);
            }

        }
    }
    return -1;
}


Compile with
Code:

gcc -o watch_numlock watch_numlock.c -L /usr/X11R6/lib -lX11


You could run it like this when you sign in to X:
Code:

watch_numlock 'xmodmap -e make_num_keypad' 'xmodmap -e make_ctrl_keypad'


where make_num_keypad would look like:
Code:

keysym KP_Home = KP_7
keysym KP_Up = KP_8
keysym KP_Prior = KP_9

and so on, and make_ctrl_keypad would be the reverse.

Hope this resolves your problem.
Back to top
View user's profile Send private message
grant.mcdorman
Apprentice
Apprentice


Joined: 29 Jan 2003
Posts: 295
Location: Toronto, ON, Canada

PostPosted: Wed Apr 23, 2003 4:47 pm    Post subject: More comments on my last post Reply with quote

Some further comments.

First off, most applications can be set up with their own meanings for the numeric pad keys (or any other keys, for that matter). Older applications, like xterm, use the Intrinsics translation mechanism. Newer applications use different mechanism; KDE's konsole, for example, uses a key table (various key tables can be found in <KDE>/share/apps/konsole/). Gnome applications presumably have their own mechanism; I don't use Gnome apps that much, though, so I'm not familiar with them.

However, the solution (hack!) I gave changes the numeric keypad for *everything*.

For reference, the default Sun Solaris [XSun] keypad map looks like:
Code:

keycode 53  = F25           F25       KP_Divide
keycode 54  = F26           F26       KP_Multiply
keycode 57  = Delete        Delete    KP_Decimal
keycode 75  = F27           F27       KP_7          Home
keycode 76  = Up            F28       KP_8
keycode 77  = F29           F29       KP_9          Prior
keycode 78  = KP_Subtract
keycode 97  = KP_Enter
keycode 98  = Left          F30         KP_4
keycode 99  = F31           F31       KP_5
keycode 100 = Right         F32       KP_6
keycode 101 = KP_Insert     KP_Insert KP_0
keycode 119 = F33           F33       KP_1          End
keycode 120 = Down          F34       KP_2
keycode 121 = F35           F35       KP_3            Next
keycode 132 = KP_Add

An interesting thing to note about this keyboard is that the shifted keys are, technically, neither the number nor the control. Sun's keyboard mappings are wierd in general, though. (For example, F11 is not F11 but SunF35; this is because F11 didn't exist on early Sun keyboards, so it was assigned to a key labeled Stop on the left side of the Sun keyboard).

The standard XFree86 US XKB layout is:
Code:

symbols/us:    key <KPDV> {     [  KP_Divide            ]       };
symbols/us:    key <KPMU> {     [  KP_Multiply          ]       };
symbols/us:    key <KPSU> {     [  KP_Subtract          ]       };
symbols/us:    key  <KP7> {     [  KP_Home,     KP_7    ]       };
symbols/us:    key  <KP8> {     [  KP_Up,       KP_8    ]       };
symbols/us:    key  <KP9> {     [  KP_Prior,    KP_9    ]       };
symbols/us:    key <KPAD> {     [       KP_Add          ]       };
symbols/us:    key  <KP4> {     [  KP_Left,     KP_4    ]       };
symbols/us:    key  <KP5> {     [  KP_Begin,    KP_5    ]       };
symbols/us:    key  <KP6> {     [  KP_Right,    KP_6    ]       };
symbols/us:    key  <KP1> {     [  KP_End,      KP_1    ]       };
symbols/us:    key  <KP2> {     [  KP_Down,     KP_2    ]       };
symbols/us:    key  <KP3> {     [  KP_Next,     KP_3    ]       };
symbols/us:    key <KPEN> {     [       KP_Enter        ]       };
symbols/us:    key  <KP0> {     [  KP_Insert,   KP_0    ]       };
symbols/us:    key  <KP0> {     [  KP_Insert,   KP_0    ]       };
symbols/us:    key <KPDL> {  [  KP_Delete,      KP_Decimal ]    };


VNC (Xnvc) does not have a keypad setup.

Thus, a generic, fully portable, set of xmodmap files would be as follows. These files will work on any server at all, including the Sun Solaris server, XFree86 (any version) and VNC.

set numeric mode:
Code:

! Ensure that we have all keysyms we're going to use assigned to something.

keycode any = KP_Insert
keycode any = KP_End
keycode any = KP_Down
keycode any = KP_Next
keycode any = KP_Left
keycode any = KP_Right
keycode any = KP_Home
keycode any = KP_Up
keycode any = KP_Prior
keycode any = KP_Delete

! Set the keypad to numeric mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_Insert = KP_0
keysym KP_End    = KP_1
keysym KP_Down   = KP_2
keysym KP_Next   = KP_3
keysym KP_Left   = KP_4
keysym KP_Right  = KP_6
keysym KP_Home   = KP_7
keysym KP_Up     = KP_8
keysym KP_Prior  = KP_9
keysym KP_Delete = KP_Decimal


set control mode:
Code:

! Ensure that we have all keysyms we're going to use defined.

keycode any = KP_0
keycode any = KP_1
keycode any = KP_2
keycode any = KP_3
keycode any = KP_4
keycode any = KP_6
keycode any = KP_7
keycode any = KP_8
keycode any = KP_9
keycode any = KP_Decimal

! Set the keypad to control mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_0 = KP_Insert
keysym KP_1 = KP_End
keysym KP_2 = KP_Down
keysym KP_3 = KP_Next
keysym KP_4 = KP_Left
keysym KP_6 = KP_Right
keysym KP_7 = KP_Home
keysym KP_8 = KP_Up
keysym KP_9 = KP_Prior
keysym KP_Decimal = KP_Delete


Default mode:
Code:

! Ensure that we have all keysyms we're going to use defined.

keycode any = KP_0
keycode any = KP_1
keycode any = KP_2
keycode any = KP_3
keycode any = KP_4
keycode any = KP_6
keycode any = KP_7
keycode any = KP_8
keycode any = KP_9
keycode any = KP_Decimal

! Set the keypad to normal (Num Lock controled) mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_0 = KP_Insert         KP_0
keysym KP_1 = KP_End            KP_1
keysym KP_2 = KP_Down           KP_2
keysym KP_3 = KP_Next           KP_3
keysym KP_4 = KP_Left           KP_4
keysym KP_6 = KP_Right          KP_6
keysym KP_7 = KP_Home           KP_7
keysym KP_8 = KP_Up             KP_8
keysym KP_9 = KP_Prior          KP_9
keysym KP_Decimal = KP_Delete   KP_Decimal


[edit: fixed syntax error, corrected 'keysym any' to 'keycode any']
Back to top
View user's profile Send private message
j-kidd
Apprentice
Apprentice


Joined: 20 Feb 2003
Posts: 213

PostPosted: Tue Apr 20, 2004 1:19 am    Post subject: Reply with quote

I just noticed that since months ago there has been an option added to toggle this behavior (bug #558 at xfee86 bugzilla).

So, to have the keypad working like in Windows, just add this line to your XF86Config or xorg.conf under the keyboard section
Code:
Option "XkbTypes"   "default+numpad(microsoft)"

It has been 1 year since I last posted in this thread. I am glad that it is fully working now 8)
(my apologize to bump an old thread, as some people may find this useful)
Back to top
View user's profile Send private message
sufehmi
n00b
n00b


Joined: 20 Sep 2003
Posts: 6

PostPosted: Sat Jul 30, 2005 4:04 am    Post subject: Reply with quote

j-kidd wrote:
I just noticed that since months ago there has been an option added to toggle this behavior (bug #558 at xfee86 bugzilla).

So, to have the keypad working like in Windows, just add this line to your XF86Config or xorg.conf under the keyboard section
Code:
Option "XkbTypes"   "default+numpad(microsoft)"

It has been 1 year since I last posted in this thread. I am glad that it is fully working now 8)
(my apologize to bump an old thread, as some people may find this useful)


Indeed I have :D I'm having a problem with VNC/Wine/Crossover Office, but it seems that this thread will finally enable me to resolve it.

I'll keep you all posted.


Thanks!
Harry
Back to top
View user's profile Send private message
sufehmi
n00b
n00b


Joined: 20 Sep 2003
Posts: 6

PostPosted: Mon Aug 01, 2005 7:36 am    Post subject: Solved ! Reply with quote

Oh yes :D finally cracked it.
Now on Windows apps on Wine/Crossover Office, accessed via VNC, NumPad works !

Here's how I did it :

1. Create a xmodmap file, with these contents :

Code:

! initialization,
! Ensure that we have all keysyms we're going to use assigned to something.

keycode any = KP_Insert
keycode any = KP_End
keycode any = KP_Down
keycode any = KP_Next
keycode any = KP_Left
keycode any = KP_Begin
keycode any = KP_Right
keycode any = KP_Home
keycode any = KP_Up
keycode any = KP_Prior
keycode any = KP_Delete

! Set the keypad to numeric mode.
! You may need to adjust KP_Next/KP_Prior; possible alternatives
! are KP_Page_Down/KP_Page_Up or just Next/Prior.
! just Next.
keysym KP_Insert = KP_0
keysym KP_End    = KP_1
keysym KP_Down   = KP_2
keysym KP_Next   = KP_3
keysym KP_Left   = KP_4
keysym KP_Begin  = KP_5
keysym KP_Right  = KP_6
keysym KP_Home   = KP_7
keysym KP_Up     = KP_8
keysym KP_Prior  = KP_9
keysym KP_Delete = KP_Decimal


Yes, it's quite similar to grant.mcdorman's post, with one addition: settings for Numpad 5 / KP_Begin key.

2. VNC sessions doesn't use ~/.xinitrc, but ~/.vnc/xstartup instead.
So that's where we put the following lines :

Code:

# The line below is to enable NumPad in Windows Apps
xmodmap ~/.xmodmap


Done ! Problem solved.

Many thanks to everyone, especially to grant.mcdorman


cheers,
Harry
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum