shithub: npe

Download patch

ref: 2cf5623e6397d8b5c689f3c82e62eb45f0bc1200
parent: 1a9bd82a0d44bd6220ee986cc7bc2f556eb53973
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Jul 30 08:59:39 EDT 2021

sdl2: treat Kaltgr and right Alt

--- a/include/npe/SDL2/SDL_keycode.h
+++ b/include/npe/SDL2/SDL_keycode.h
@@ -96,10 +96,10 @@
 	KMOD_LCTRL = 1<<1,
 	KMOD_RCTRL = KMOD_LCTRL,
 	KMOD_LALT = 1<<2,
-	KMOD_RALT = KMOD_LALT,
-	KMOD_LGUI = 1<<3,
+	KMOD_RALT = 1<<3,
+	KMOD_LGUI = 1<<4,
 	KMOD_RGUI = KMOD_LGUI,
-	KMOD_CAPS = 1<<4,
+	KMOD_CAPS = 1<<5,
 
 	KMOD_SHIFT = KMOD_LSHIFT|KMOD_RSHIFT,
 	KMOD_CTRL = KMOD_LCTRL|KMOD_RCTRL,
--- a/libnpe_sdl2/events.c
+++ b/libnpe_sdl2/events.c
@@ -197,6 +197,7 @@
 	if(r == Kshift) return SDL_SCANCODE_LSHIFT;
 	if(r == Kalt) return SDL_SCANCODE_LALT;
 	if(r == Kmod4) return SDL_SCANCODE_LGUI;
+	if(r == Kaltgr) return SDL_SCANCODE_RALT;
 
 	if(r >= (KF|1) && r <= (KF|12)) return SDL_SCANCODE_F1 + r - (KF|1);
 
@@ -277,6 +278,7 @@
 			while(*s){
 				s += chartorune(&r, s);
 				if(utfrune(buf2+1, r) == nil){
+					t = Rdown;
 					if(r == Kalt){
 						/* magic trick: write Alt scancode to disable the "compose" mode */
 						/* FIXME: does this work in both native AND drawterm? */
@@ -286,10 +288,15 @@
 						kmod |= KMOD_LSHIFT;
 					else if(r == Kctl)
 						kmod |= KMOD_LCTRL;
+					else if(r == Kaltgr)
+						kmod |= KMOD_RALT;
 					else{
-						t = Rdown;
 						o = npe_sdl.textinput ? r : tolowerrune(r);
+						continue;
 					}
+					send(salt[Ckey].c, &r);
+					send(salt[Ckeytype].c, &t);
+					t = Rrepeat;
 				}
 			}
 			break;