Ticket #5163: modifiers_check.patch

File modifiers_check.patch, 1.7 KB (added by tqh, 11 years ago)

Here is the patch I use. (Not sure if it's up to style, just an example).

  • src/system/boot/platform/bios_ia32/keyboard.cpp

     
    3333}
    3434
    3535
     36static uint16
     37check_for_modifiers(void)
     38{
     39    bios_regs regs;
     40    regs.eax = 0x0200;
     41    call_bios(0x16, &regs);
     42
     43    return regs.eax & 0xffff;
     44}
     45
     46
    3647extern "C" void
    3748clear_key_buffer(void)
    3849{
     
    5465    return key;
    5566}
    5667
     68#define RIGHT_SHIFT 1
     69#define LEFT_SHIFT 1
     70#define CTRL 4
     71#define ALT 8
    5772
    5873extern "C" uint32
    5974check_for_boot_keys(void)
    6075{
    6176    union key key;
    6277    uint32 options = 0;
     78    uint32 modifiers = check_for_modifiers();
     79   
     80    if (modifiers & (CTRL | ALT))
     81        options |= BOOT_OPTION_MENU;
    6382
     83    if (modifiers & (LEFT_SHIFT | RIGHT_SHIFT))
     84        options |= BOOT_OPTION_DEBUG_OUTPUT;
     85   
     86#if 0   
     87    // wait a bit to give the user the opportunity to press a key
     88    spin(750000);
     89
    6490    while ((key.ax = check_for_key()) != 0) {
    6591        switch (key.code.ascii) {
    6692            case ' ':
     
    75101                break;
    76102        }
    77103    }
    78 
     104#endif
    79105    dprintf("options = %ld\n", options);
    80106    return options;
    81107}
  • src/system/boot/platform/bios_ia32/start.c

     
    129129    mmu_init();
    130130    parse_multiboot_commandline(&args);
    131131
    132     // wait a bit to give the user the opportunity to press a key
    133     spin(750000);
    134 
    135132    // reading the keyboard doesn't seem to work in graphics mode
    136133    // (maybe a bochs problem)
    137134    sBootOptions = check_for_boot_keys();