LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Need Help Remapping Right Alt Key in Mate 18.3/GPD Pocket (https://www.linuxquestions.org/questions/linux-software-2/need-help-remapping-right-alt-key-in-mate-18-3-gpd-pocket-4175628113/)

jakfish 04-21-2018 07:19 AM

Need Help Remapping Right Alt Key in Mate 18.3/GPD Pocket
 
In /usr/share/X11/xkb/symbols/pc, I've successfully remapped several keys on the keyboard of my GPD Pocket. But I'm lost at how to remap the right alt key into a Delete key. For now, my workaround is to use the deprecated xmodmap in this startup script:

xmodmap -e "remove mod1 = Alt_R"
xmodmap -e "keycode 108 = Delete"

Which works, but I would like the remapping to be in /usr/share/X11/xkb/symbols/pc. Here is the pc file--can anyone advise where-and-what I would change to make the right alt key function as a repeating delete key?

default partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {

key <ESC> { [ Escape ] };

// The extra key on many European keyboards:
key <LSGT> { [ less, greater, bar, brokenbar ] };

// The following keys are common to all layouts.
key <BKSL> { [ backslash, bar ] };
key <SPCE> { [ space ] };

include "srvr_ctrl(fkey2vt)"
include "pc(editing)"
include "keypad(x11)"

key <BKSP> { [ BackSpace, BackSpace ] };

key <TAB> { [ Tab, ISO_Left_Tab ] };
key <RTRN> { [ Return ] };

key <CAPS> { [ Caps_Lock ] };
key <NMLK> { [ Num_Lock ] };

key <LFSH> { [ Shift_L ] };
key <LCTL> { [ Control_L ] };
key <LWIN> { [ Super_L ] };

key <RTSH> { [ Shift_R ] };
key <RCTL> { [ Control_R ] };
key <RWIN> { [ Super_R ] };
key <MENU> { [ Menu ] };

// Beginning of modifier mappings.
modifier_map Shift { Shift_L, Shift_R };
modifier_map Lock { Caps_Lock };
modifier_map Control{ Control_L, Control_R };
modifier_map Mod2 { Num_Lock };
modifier_map Mod4 { Super_L, Super_R };

// Fake keys for virtual<->real modifiers mapping:
key <LVL3> { [ ISO_Level3_Shift ] };
key <MDSW> { [ Mode_switch ] };
modifier_map Mod5 { <LVL3>, <MDSW> };

key <ALT> { [ NoSymbol, Alt_L ] };
include "altwin(meta_alt)"

key <META> { [ NoSymbol, Meta_L ] };
modifier_map Mod1 { <META> };

key <SUPR> { [ NoSymbol, Super_L ] };
modifier_map Mod4 { <SUPR> };

key <HYPR> { [ NoSymbol, Hyper_L ] };
modifier_map Mod4 { <HYPR> };
// End of modifier mappings.

key <OUTP> { [ XF86Display ] };
key <KITG> { [ XF86KbdLightOnOff ] };
key <KIDN> { [ XF86KbdBrightnessDown ] };
key <KIUP> { [ XF86KbdBrightnessUp ] };
};

hidden partial alphanumeric_keys
xkb_symbols "editing" {
key <PRSC> {
type= "PC_ALT_LEVEL2",
symbols[Group1]= [ Print, Sys_Req ]
};
key <SCLK> { [ Scroll_Lock ] };
key <PAUS> {
type= "PC_CONTROL_LEVEL2",
symbols[Group1]= [ Pause, Break ]
};
key <INS> { [ Insert ] };
key <HOME> { [ Home ] };
key <PGUP> { [ Prior ] };
key <DELE> { [ BackSpace, BackSpace ] };
key <END> { [ End ] };
key <PGDN> { [ Next ] };

key <UP> { [ Up ] };
key <LEFT> { [ Left ] };
key <DOWN> { [ Down ] };
key <RGHT> { [ Right ] };
};

DavidMcCann 04-21-2018 11:09 AM

The quickest way is to alter /usr/share/X11/xkb/keycodes/evdev instead. You'll see it has the entries
<RALT> = 108;
<DELE> = 119;
Swap the numbers and that's it.

jakfish 04-21-2018 04:51 PM

Many thanks for your quick post.

I did as said suggested, but ran into technical difficulties perhaps because my Delete key is already remapped as a BackSpace.

When I did your switch, the Right Alt became a BackSpace for some reason, and my remapped Delete-to-BackSpace had no response at all.

Is there another remap that comes to mind?

Again, thank you for your help,
Jake

DavidMcCann 04-22-2018 11:18 AM

Your symbols/pc file sets BKSP to BackSpace, so the problem must be in the evdev file. Look there and see what's mapped to <BKSP>. I have 22. You can find the keycodes by running xev, which gives results like
Code:

KeyPress event, serial 32, synthetic NO, window 0x3200001,
    root 0x112, subw 0x0, time 893490, (297,-205), root:(536,328),
    state 0x0, keycode 22 (keysym 0xff08, BackSpace), same_screen YES,
    XLookupString gives 1 bytes: (08) "
    XmbLookupString gives 1 bytes: (08) "
    XFilterEvent returns: False

Check the keycodes and make sure that evdev assigns them to what you need.

jakfish 04-22-2018 04:07 PM

Thank you for your follow-up.

I'm still at a loss but your help has perhaps helped me understand the problem.

Since I've already programmed the Delete key to be a BackSpace in the pc file, I no longer have an actual substitute key in evdev to finish the remapped equation <RALT> = ;

While my Delete key may be mapped in evdev as <DELE> = 119; the pc file has it as:

key <DELE> { [ BackSpace, BackSpace ] };

And the pc file appears to trump.

And I was incorrect when I said my delete-to-backspace was dead after putting in your evdev suggestions--it actually became a right alt key, leading me to believe that evdev needs to have keys switched rather than willing to lose the right alt altogether.

What I'm striving for is:

Right Alt = Delete
Delete = BackSpace
BackSpace = BackSpace

Which has no "key = Right Alt" in any equation, either in pc or evdev file.

It does seem that xmodmap is still necessary; I was only hoping to make the remapping cleaner, taking place only in /usr/share/X11/xkb

And my curiosity was piqued; you always feel that there's a solution in Linux.

DavidMcCann 04-23-2018 11:37 AM

Quote:

Originally Posted by jakfish (Post 5846333)
While my Delete key may be mapped in evdev as <DELE> = 119; the pc file has it as:
key <DELE> { [ BackSpace, BackSpace ] };
And the pc file appears to trump.

What's happening is that the two files are used together to create a driver that is then compiled. In that, 119 is directly equated to BackSpace. The reason for the intermediate use of the names like BKSP is to enable Linux to use keyboards other than the normal PC (Sun, Apple, etc) where the scancodes are quite different. Currently the Alternate keys are being handles by the file symbols/altwin, not symbols/pc. You can alter them from the pc file, though, as that trumps altwin!

So,
1. Use xev to find the codes of BKSP, DELE, and RALT. Make sure that evdev has them correctly assigned.
2. Make sure that pc has DELE and BKSP both defined as BackSpace
3. Add a line to pc
key <RALT> {[Delete]};

jakfish 04-23-2018 06:11 PM

I very much appreciate you sticking with this.

I followed your latest instructions and while I have both backspace and delete acting as BackSpace, when I add:

key <RALT> {[Delete]};

to pc, it remains a right alt.

I'm not certain it's compiling b/c when I run:

sudo dpkg-reconfigure keyboard-configuration

I get this in console after all gui windows come up:

Your console font configuration will be updated the next time your system
boots. If you want to update it now, run 'setupcon' from a virtual console.
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
update-initramfs: deferring update (trigger activated)

I've never see that message when I was remapping other keys successfully.

Rebooting only produces a right alt = right alt


All times are GMT -5. The time now is 12:24 PM.