shithub: patch

Download patch

ref: 2d073110583825959df332129732ed7a07dc7b82
parent: bc95af71977649adbba75addb6aedac7631cec26
author: qwx <qwx@sciops.net>
date: Tue Dec 20 10:30:16 EST 2022

npe-modhacks: fix not clearing modkeys correctly

--- a/npe-modhacks
+++ b/npe-modhacks
@@ -1,7 +1,7 @@
 diff c653369e862d2b2235133cfcb0391bc4809ce4b1 uncommitted
 --- a/include/npe/SDL2/SDL_keycode.h
 +++ b/include/npe/SDL2/SDL_keycode.h
-@@ -79,23 +79,24 @@
+@@ -79,28 +79,30 @@
  
  	SDLK_LALT = Kalt,
  	SDLK_RALT = Kaltgr, /* FIXME what about keyboards without it? */
@@ -24,18 +24,39 @@
  	SDLK_AC_BACK,
  
 -	/* FIXME no distinction */
++	KMOD_NONE = 0,
  	KMOD_LSHIFT = 1<<0,
 -	KMOD_RSHIFT = KMOD_LSHIFT,
-+	KMOD_RSHIFT = 1<<6,
- 	KMOD_LCTRL = 1<<1,
+-	KMOD_LCTRL = 1<<1,
 -	KMOD_RCTRL = KMOD_LCTRL,
+-	KMOD_LALT = 1<<2,
+-	KMOD_RALT = 1<<3,
+-	KMOD_LGUI = 1<<4,
++	KMOD_RSHIFT = 1<<1,
++	KMOD_LCTRL = 1<<6,
 +	KMOD_RCTRL = 1<<7,
- 	KMOD_LALT = 1<<2,
- 	KMOD_RALT = 1<<3,
- 	KMOD_LGUI = 1<<4,
++	KMOD_LALT = 1<<8,
++	KMOD_RALT = 1<<9,
++	KMOD_LGUI = 1<<10,
+ 	KMOD_RGUI = KMOD_LGUI,
+-	KMOD_CAPS = 1<<5,
++	KMOD_CAPS = 1<<13,
+ 
+ 	KMOD_SHIFT = KMOD_LSHIFT|KMOD_RSHIFT,
+ 	KMOD_CTRL = KMOD_LCTRL|KMOD_RCTRL,
+--- a/include/npe/SDL2/SDL_scancode.h
++++ b/include/npe/SDL2/SDL_scancode.h
+@@ -107,6 +107,7 @@
+ 	SDL_SCANCODE_MUTE = 0x7f,
+ 	SDL_SCANCODE_VOLUMEUP,
+ 	SDL_SCANCODE_VOLUMEDOWN,
++	SDL_SCANCODE_PLAYPAUSE,
+ 
+ 	SDL_SCANCODE_LCTRL = 0xe0,
+ 	SDL_SCANCODE_LSHIFT,
 --- a/libnpe_sdl2/events.c
 +++ b/libnpe_sdl2/events.c
-@@ -206,6 +206,11 @@
+@@ -206,6 +206,12 @@
  	if(r == Kalt) return SDL_SCANCODE_LALT;
  	if(r == Kmod4) return SDL_SCANCODE_LGUI;
  	if(r == Kaltgr) return SDL_SCANCODE_RALT;
@@ -44,10 +65,11 @@
 +	if(r == Krctl) return SDL_SCANCODE_RCTRL;
 +	if(r == Kvolup) return SDL_SCANCODE_VOLUMEUP;
 +	if(r == Kvoldn) return SDL_SCANCODE_VOLUMEDOWN;
++	if(r == Kpause) return SDL_SCANCODE_PLAYPAUSE;
  
  	if(r >= (KF|1) && r <= (KF|12)) return SDL_SCANCODE_F1 + r - (KF|1);
  
-@@ -294,6 +299,8 @@
+@@ -294,6 +300,8 @@
  						kmod |= KMOD_LALT;
  					}else if (r == Kshift)
  						kmod |= KMOD_LSHIFT;
@@ -56,7 +78,7 @@
  					else if(r == Kctl)
  						kmod |= KMOD_LCTRL;
  					else if(r == Kaltgr)
-@@ -300,6 +307,10 @@
+@@ -300,6 +308,10 @@
  						kmod |= KMOD_RALT;
  					else if(r == Kmod4)
  						kmod |= KMOD_LGUI;
@@ -67,15 +89,24 @@
  					else{
  						o = npe_sdl.textinput ? r : tolowerrune(r);
  						continue;
-@@ -323,6 +334,12 @@
+@@ -319,10 +331,20 @@
+ 				if(utfrune(buf+1, r) == nil){
+ 					if(r == Kalt)
+ 						kmod &= ~KMOD_LALT;
+-					else if(r == Kshift)
++					else if (r == Kshift)
  						kmod &= ~KMOD_LSHIFT;
- 					else if(r == Kctl)
- 						kmod &= ~KMOD_LCTRL;
 +					else if (r == Kcaps)
 +						kmod &= ~KMOD_CAPS;
-+					else if (r == Krshift)
+ 					else if(r == Kctl)
+ 						kmod &= ~KMOD_LCTRL;
++					else if(r == Kaltgr)
++						kmod &= ~KMOD_RALT;
++					else if(r == Kmod4)
++						kmod &= ~KMOD_LGUI;
++					else if(r == Krshift)
 +						kmod &= ~KMOD_RSHIFT;
-+					else if (r == Krctl)
++					else if(r == Krctl)
 +						kmod &= ~KMOD_RCTRL;
  					else{
  						t = Rup;