VirtualBox

Changeset 6863 in vbox


Ignore:
Timestamp:
Feb 8, 2008 11:14:05 AM (17 years ago)
Author:
vboxsync
Message:

Frontends/VirtualBox: added new logging to the Linux keyboard handler which users can activate using an environment variable. Hopefully this will finally give me a hint as to why some layouts fail for some users and work for me.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/linux
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard-new.c

    r6503 r6863  
    6060#include <stdarg.h>
    6161#include <string.h>
     62#include <stdlib.h>
     63#include <stdio.h>
    6264
    6365static unsigned keyc2scan[256];
     66static int log_kb_1 = 0;
     67static int log_kb_2 = 0;
     68
     69#define LOG_KB_1(a) \
     70do { \
     71    if (log_kb_1) { \
     72        printf a; \
     73    } \
     74} while (0)
     75
     76#define LOG_KB_2(a) \
     77do { \
     78    if (log_kb_2) { \
     79        printf a; \
     80    } \
     81} while (0)
    6482
    6583/* Keyboard layout tables for guessing the current keyboard layout. */
     
    145163        determine the direction that the keycodes are running in. */
    146164    int pkey = -1;
    147     TRACE("Attempting to match against \"%s\"\n", main_key_tab[current].comment);
     165    LOG_KB_2(("Attempting to match against \"%s\"\n", main_key_tab[current].comment));
    148166    for (keyc = min_keycode; keyc <= max_keycode; keyc++) {
    149167      if (0 != ckey[keyc][0]) {
     
    189207              str[0] = ckey[keyc][0];
    190208          }
    191           TRACE_(key)("mismatch for keycode %d, keysym \"%s\" (0x%.2hx 0x%.2hx)\n",
    192                        keyc, str, ckey[keyc][0], ckey[keyc][1]);
     209          LOG_KB_2(("Mismatch for keycode %d, keysym \"%s\" (0x%.2hx 0x%.2hx)\n",
     210                       keyc, str, ckey[keyc][0], ckey[keyc][1]));
    193211#endif /* DEBUG defined */
    194212        }
    195213      }
    196214    }
    197     TRACE("matches=%d, seq=%d\n",
    198            match, seq);
     215    LOG_KB_2(("Matches=%d, seq=%d\n", match, seq));
    199216    if (   (match > max_score)
    200217        || ((match == max_score) && (seq > max_seq))
     
    207224  }
    208225  /* we're done, report results if necessary */
    209   TRACE("detected layout is \"%s\", matches=%d, seq=%d\n",
    210         main_key_tab[kbd_layout].comment, max_score, max_seq);
     226  LOG_KB_1(("Detected layout is \"%s\", matches=%d, seq=%d\n",
     227        main_key_tab[kbd_layout].comment, max_score, max_seq));
    211228  return kbd_layout;
    212229}
     
    232249    unsigned matches = 0, entries = 0;
    233250
     251    /* Should we log to standard output? */
     252    if (NULL != getenv("LOG_KB_PRIMARY")) {
     253        log_kb_1 = 1;
     254    }
     255    if (NULL != getenv("LOG_KB_SECONDARY")) {
     256        log_kb_1 = 1;
     257        log_kb_2 = 1;
     258    }
    234259    XDisplayKeycodes(display, &min_keycode, &max_keycode);
    235260
     
    279304                ++matches;
    280305              }
    281 #ifdef DEBUG
    282306              if (0 == scan) {
    283307                /* print spaces instead of \0's */
     
    289313                    str[1] = shifted;
    290314                }
    291                 TRACE_(key)("No match found for keycode %d, keysym \"%s\" (0x%x 0x%x)\n",
    292                              keyc, str, unshifted, shifted);
    293             }
    294 #endif /* DEBUG defined */
     315                LOG_KB_1(("No match found for keycode %d, keysym \"%s\" (0x%x 0x%x)\n",
     316                             keyc, str, unshifted, shifted));
     317              } else if ((keyc > 8) && (keyc < 97) && (keyc - scan != 8)) {
     318                /* print spaces instead of \0's */
     319                char str[3] = "  ";
     320                if ((unshifted > 32) && (unshifted < 127)) {
     321                    str[0] = unshifted;
     322                }
     323                if ((shifted > 32) && (shifted < 127)) {
     324                    str[1] = shifted;
     325                }
     326                LOG_KB_1(("Warning - keycode %d, keysym \"%s\" (0x%x 0x%x) was matched to scancode %d\n",
     327                             keyc, str, unshifted, shifted, scan));
     328              }
    295329            }
    296330        }
     
    305339        }
    306340    }
    307     TRACE("Finished mapping keyboard, matches=%d, entries=%d\n", matches, entries);
     341    LOG_KB_1(("Finished mapping keyboard, matches=%d, entries=%d\n", matches, entries));
    308342    if (matches != entries)
    309343    {
  • trunk/src/VBox/Frontends/VirtualBox/src/linux/keyboard.h

    r6509 r6863  
    2222 */
    2323
    24 #ifndef __H_KEYBOARD_OUTOFWINE
    25 #define __H_KEYBOARD_OUTOFWINE
     24#ifndef __H_KEYBOARD
     25#define __H_KEYBOARD
    2626
    2727#include <X11/Xlib.h>
     
    4242#endif
    4343
    44 /* debug macros */
    45 #if 0 && defined(DEBUG)
    46 # include <stdio.h>
    47 # define noop printf
    48 #else
    49 #ifdef __cplusplus
    50 inline static void noop(char *, ...)
    51 #else
    52 inline static void noop(char *arg, ...)
    53 #endif
    54 {
    55 }
    56 #endif
    57 
    58 #define TRACE noop
    59 /* #define TRACE printf */
    60 #define TRACE_(a) noop
    61 /* #define TRACE_(ch) printf */
    62 #define TRACE_ON(a) 0
    63 #define WARN noop
    64 #define ERR noop
    65 
    66 #endif /* __H_KEYBOARD_OUTOFWINE */
     44#endif /* __H_KEYBOARD */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette