@@ -180,7 +180,9 @@ static const char Xlib_default_char[256] = {
180180 debuglogstdio (LCF_KEYBOARD, " %s called with keycode %d" , __func__, event_struct->keycode );
181181 // printBacktrace();
182182 KeyCode keycode = event_struct->keycode ;
183- *keysym_return = Xlib_default_keymap[keycode];
183+ if (keysym_return) {
184+ *keysym_return = Xlib_default_keymap[keycode];
185+ }
184186 if (buffer_return && (bytes_buffer > 0 )) {
185187 char c = Xlib_default_char[keycode];
186188 if (c == ' \0 ' ) {
@@ -196,23 +198,26 @@ static const char Xlib_default_char[256] = {
196198{
197199 debuglogstdio (LCF_KEYBOARD, " %s called with keycode %d" , __func__, event->keycode );
198200 KeyCode keycode = event->keycode ;
199- *keysym_return = Xlib_default_keymap[keycode];
201+ KeySym keysym = Xlib_default_keymap[keycode];
200202
201203 /* Return if no associated keysym */
202- if (*keysym_return == NoSymbol) {
204+ if (keysym == NoSymbol) {
203205 *status_return = XLookupNone;
204206 return 0 ;
205207 }
206208
209+ if (keysym_return)
210+ *keysym_return = keysym;
211+
207212 char c = Xlib_default_char[keycode];
208213
209214 /* Return if no associated string */
210215 if (c == ' \0 ' ) {
211- *status_return = XLookupKeySym;
216+ *status_return = keysym_return ? XLookupKeySym : XLookupNone ;
212217 return 0 ;
213218 }
214219
215- *status_return = XLookupBoth;
220+ *status_return = keysym_return ? XLookupBoth : XLookupChars ;
216221 if (buffer_return && (bytes_buffer > 0 )) {
217222 buffer_return[0 ] = c;
218223 return 1 ;
@@ -224,23 +229,27 @@ static const char Xlib_default_char[256] = {
224229{
225230 debuglogstdio (LCF_KEYBOARD, " %s called with keycode %d" , __func__, event->keycode );
226231 KeyCode keycode = event->keycode ;
227- *keysym_return = Xlib_default_keymap[keycode];
232+ KeySym keysym = Xlib_default_keymap[keycode];
228233
229234 /* Return if no associated keysym */
230- if (*keysym_return == NoSymbol) {
235+ if (keysym == NoSymbol) {
231236 *status_return = XLookupNone;
232237 return 0 ;
233238 }
234239
240+ if (keysym_return) {
241+ *keysym_return = keysym;
242+ }
243+
235244 char c = Xlib_default_char[keycode];
236245
237246 /* Return if no associated string */
238247 if (c == ' \0 ' ) {
239- *status_return = XLookupKeySym;
248+ *status_return = keysym_return ? XLookupKeySym : XLookupNone ;
240249 return 0 ;
241250 }
242251
243- *status_return = XLookupBoth;
252+ *status_return = keysym_return ? XLookupBoth : XLookupChars ;
244253 if (buffer_return && (wchars_buffer > 0 )) {
245254 buffer_return[0 ] = c;
246255 return 1 ;
0 commit comments