How to remap keys under Linux?

About BasiliskII, a 68k Mac emulator for Windows, MacOSX, and Linux that can run System 7.x through MacOS 8.1.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
extraordinarymachine
Space Cadet
Posts: 4
Joined: Thu May 20, 2010 11:36 am
Location: Santa Barbara, California

How to remap keys under Linux?

Post by extraordinarymachine »

I'm happily running BasiliskII under Ubuntu Linux 9.10. However, there's one annoying problem: The key being mapped to the (emulated Mac) Option key is my windows-flag key, which my window manager traps (and uses to move any window around by grabbing anywhere in it). I can change which key the window manager traps, but they're all keys that get mapped to something important under BasiliskII.

What this effectively means is that I can't use the option key in the emulated Mac environment. Is there some way to configure keyboard mapping under Linux? The configuration screen lets me browse for some sort of keycodes file, but I can't figure out how to set that up.

Any help is much appreciated. :)
User avatar
24bit
Forum All-Star
Posts: 1424
Joined: Wed Nov 11, 2009 5:47 pm
Location: Germany

Hello !

Post by 24bit »

Hi extraordinarymachine,

some time ago I found this linux codepage file:
http://ubuntuforums.org/showthread.php?t=806800&page=2
The file works very well with BII and SS.
I did not try to change the keys, because I had no problems.
Probably this may be of some use for you.

Best wishes!
extraordinarymachine
Space Cadet
Posts: 4
Joined: Thu May 20, 2010 11:36 am
Location: Santa Barbara, California

Thank you!

Post by extraordinarymachine »

I'll give that a try. Is there any documentation anywhere on how to determine what the keymap codes should be?

Pointing me in the right direction is much appreciated. :)
uhhu
Inquisitive Elf
Posts: 35
Joined: Wed Nov 19, 2008 4:58 pm

Post by uhhu »

extraordinarymachine
Space Cadet
Posts: 4
Joined: Thu May 20, 2010 11:36 am
Location: Santa Barbara, California

Post by extraordinarymachine »

somewhat ... does the keycodes file use ASCII or Mac ADB values?

Thanks much. :)
User avatar
Cat_7
Expert User
Posts: 6145
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Post by Cat_7 »

Hi, the keycodes file looks like the one below, so the corresponding actual key on the keyboard is shown after the comment (#) sign in each line. You can move/swap those pairs of code (e.g. 9 53) to another key

9 53 # Esc
67 122 # F1
68 120 # F2
69 99 # F3
70 118 # F4
71 96 # F5
72 97 # F6
73 98 # F7
74 100 # F8
75 101 # F9
76 109 # F10
95 103 # F11
96 111 # F12
111 105 # PrintScrn
78 107 # Scroll Lock
110 113 # Pause
49 10 # `
10 18 # 1
11 19 # 2
12 20 # 3
13 21 # 4
14 23 # 5
15 22 # 6
16 26 # 7
17 28 # 8
18 25 # 9
19 29 # 0
20 27 # -
21 24 # =
22 51 # Backspace
106 114 # Insert
97 115 # Home
99 116 # Page Up
77 71 # Num Lock
112 75 # KP /
63 67 # KP *
82 78 # KP -
23 48 # Tab
24 12 # Q
25 13 # W
26 14 # E
27 15 # R
28 17 # T
29 16 # Y
30 32 # U
31 34 # I
32 31 # O
33 35 # P
34 33 # [
35 30 # ]
36 36 # Return
107 117 # Delete
103 119 # End
105 121 # Page Down
79 89 # KP 7
80 91 # KP 8
81 92 # KP 9
86 69 # KP +
66 57 # Caps Lock
38 0 # A
39 1 # S
40 2 # D
41 3 # F
42 5 # G
43 4 # H
44 38 # J
45 40 # K
46 37 # L
47 41 # ;
48 39 # '
83 86 # KP 4
84 87 # KP 5
85 88 # KP 6
50 56 # Shift Left
94 50 # International
52 6 # Z
53 7 # X
54 8 # C
55 9 # V
56 11 # B
57 45 # N
58 46 # M
59 43 # ,
60 47 # .
61 44 # /
62 56 # Shift Right
51 42 # \
98 62 # Cursor Up
87 83 # KP 1
88 84 # KP 2
89 85 # KP 3
108 76 # KP Enter
37 54 # Ctrl Left
115 58 # Logo Left (-> Option)
64 55 # Alt Left (-> Command)
65 49 # Space
113 55 # Alt Right (-> Command)
116 58 # Logo Right (-> Option)
117 50 # Menu (-> International)
109 54 # Ctrl Right
100 59 # Cursor Left
104 61 # Cursor Down
102 60 # Cursor Right
90 82 # KP 0
91 65 # KP .
extraordinarymachine
Space Cadet
Posts: 4
Joined: Thu May 20, 2010 11:36 am
Location: Santa Barbara, California

Thanks!

Post by extraordinarymachine »

I'll keep this in mind, but I've found another way of solving the problem, according to this thread in the Ubuntu Forums:

http://ubuntuforums.org/showthread.php?p=9401767

But i want to thank you very much for your help. :)
Eli the Bearded
Space Cadet
Posts: 6
Joined: Tue Mar 25, 2014 4:48 am

Re: How to remap keys under Linux?

Post by Eli the Bearded »

This is a very old thread, but I ran into a similar problem and went with the remap method. The source tree for BasiliskII has a "keycodes" file that is a good starting template, similar to the example above. What that example lacks however is the name of the server. The keycodes file contains sections for different environments. On my Slackware 14.1 system, I need a line containing "The X.Org Foundation" right before the mapping starts because that's how my X11 server IDs itself.

Then for remapping keys: the standard X11 tool xev can report the keycode values for the first column. Just run it and type the key and look for the keycode in the very verbose output. I found a lot of the arrow / editing type (pgup, pgdn, insert, delete, etc) keys to be mapped wrong if I used the "The XFree86 Project, Inc" set relabeled for my system. Letters and numbers were fine, though.

As a single example of xev, I mapped the forward key on my keyboard to KP Enter in the Mac world. First the xev output:

Code: Select all

KeyPress event, serial 38, synthetic NO, window 0x2200001,
    root 0x14d, subw 0x0, time 211921507, (90,69), root:(92,411),
    state 0x0, keycode 167 (keysym 0x1008ff27, XF86Forward), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False
Now the entry in the keymap file:

Code: Select all

167     76      # KP Enter
Post Reply