Skip to content
Snippets Groups Projects
Commit 942a70c7 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Fix up input so it's always in the current codepage

parent 88cc7fe8
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #4113 passed
...@@ -718,6 +718,14 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs) ...@@ -718,6 +718,14 @@ static void sdl_add_key(unsigned int keyval, struct video_stats *vs)
} }
} }
static void
sdl_add_key_uc(unsigned int keyval, struct video_stats *vs)
{
if (keyval < 128)
keyval = cpchar_from_unicode_cpoint(getcodepage(), keyval, keyval);
sdl_add_key(keyval, vs);
}
/* Called from event thread only */ /* Called from event thread only */
static unsigned int sdl_get_char_code(unsigned int keysym, unsigned int mod) static unsigned int sdl_get_char_code(unsigned int keysym, unsigned int mod)
{ {
...@@ -942,11 +950,11 @@ void sdl_video_event_thread(void *data) ...@@ -942,11 +950,11 @@ void sdl_video_event_thread(void *data)
|| ev.key.keysym.sym == SDLK_KP_PLUS || ev.key.keysym.sym == SDLK_KP_PLUS
|| ev.key.keysym.sym == SDLK_KP_PERIOD)) || ev.key.keysym.sym == SDLK_KP_PERIOD))
break; break;
sdl_add_key(sdl_get_char_code(ev.key.keysym.sym, ev.key.keysym.mod), &cvstat); sdl_add_key_uc(sdl_get_char_code(ev.key.keysym.sym, ev.key.keysym.mod), &cvstat);
} }
else if (!isprint(ev.key.keysym.sym)) { else if (!isprint(ev.key.keysym.sym)) {
if (ev.key.keysym.sym < 128) if (ev.key.keysym.sym < 128)
sdl_add_key(ev.key.keysym.sym, &cvstat); sdl_add_key_uc(ev.key.keysym.sym, &cvstat);
} }
break; break;
case SDL_TEXTINPUT: case SDL_TEXTINPUT:
...@@ -954,7 +962,7 @@ void sdl_video_event_thread(void *data) ...@@ -954,7 +962,7 @@ void sdl_video_event_thread(void *data)
unsigned int charcode = sdl_get_char_code(last_sym, last_mod & ~(KMOD_ALT)); unsigned int charcode = sdl_get_char_code(last_sym, last_mod & ~(KMOD_ALT));
// If the key is exactly what we would expect, use sdl_get_char_code() // If the key is exactly what we would expect, use sdl_get_char_code()
if (*(uint8_t *)ev.text.text == charcode) if (*(uint8_t *)ev.text.text == charcode)
sdl_add_key(sdl_get_char_code(last_sym, last_mod), &cvstat); sdl_add_key_uc(sdl_get_char_code(last_sym, last_mod), &cvstat);
else else
sdl_add_keys((uint8_t *)ev.text.text, &cvstat); sdl_add_keys((uint8_t *)ev.text.text, &cvstat);
} }
......
...@@ -976,8 +976,8 @@ static int x11_event(XEvent *ev) ...@@ -976,8 +976,8 @@ static int x11_event(XEvent *ev)
case XLookupChars: case XLookupChars:
if (lus == XLookupChars || ((ev->xkey.state & (Mod1Mask | ControlMask)) == 0)) { if (lus == XLookupChars || ((ev->xkey.state & (Mod1Mask | ControlMask)) == 0)) {
for (i = 0; i < cnt; i++) { for (i = 0; i < cnt; i++) {
if (wbuf[i] < 127) if (wbuf[i] < 128)
ch = wbuf[i]; ch = cpchar_from_unicode_cpoint(getcodepage(), wbuf[i], wbuf[i]);
else else
ch = cpchar_from_unicode_cpoint(getcodepage(), wbuf[i], 0); ch = cpchar_from_unicode_cpoint(getcodepage(), wbuf[i], 0);
if (ch) { if (ch) {
...@@ -1164,6 +1164,8 @@ static int x11_event(XEvent *ev) ...@@ -1164,6 +1164,8 @@ static int x11_event(XEvent *ev)
} }
if (scan != 0xffff) { if (scan != 0xffff) {
uint16_t key=scan; uint16_t key=scan;
if (key < 128)
key = cpchar_from_unicode_cpoint(getcodepage(), key, key);
write(key_pipe[1], &key, (scan&0xff)?1:2); write(key_pipe[1], &key, (scan&0xff)?1:2);
} }
break; break;
......
...@@ -4244,8 +4244,6 @@ doterm(struct bbslist *bbs) ...@@ -4244,8 +4244,6 @@ doterm(struct bbslist *bbs)
case 96: /* No backtick */ case 96: /* No backtick */
break; break;
default: default:
if (key < 128)
key = cpchar_from_unicode_cpoint(getcodepage(), key, key);
if (key < 256) { if (key < 256) {
/* ASCII Translation */ /* ASCII Translation */
if (key < 123) { if (key < 123) {
...@@ -4330,8 +4328,6 @@ doterm(struct bbslist *bbs) ...@@ -4330,8 +4328,6 @@ doterm(struct bbslist *bbs)
conn_send(ch, 1, 0); conn_send(ch, 1, 0);
break; break;
default: default:
if (key < 128)
key = cpchar_from_unicode_cpoint(getcodepage(), key, key);
if (key < 256) { if (key < 256) {
ch[0] = key; ch[0] = key;
conn_send(ch, 1, 0); conn_send(ch, 1, 0);
...@@ -4535,8 +4531,6 @@ doterm(struct bbslist *bbs) ...@@ -4535,8 +4531,6 @@ doterm(struct bbslist *bbs)
/* FALLTHROUGH to default */ /* FALLTHROUGH to default */
default: default:
if (key < 128)
key = cpchar_from_unicode_cpoint(getcodepage(), key, key);
if ((key < 256) && (key >= 0)) { if ((key < 256) && (key >= 0)) {
ch[0] = key; ch[0] = key;
conn_send(ch, 1, 0); conn_send(ch, 1, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment