Ticket #2918: kbd.1.diff

File kbd.1.diff, 2.8 KB (added by Adek336, 15 years ago)

proof of concept

  • src/system/kernel/arch/x86/arch_debug_console.c

     
    104104 *  again if anything else requests the interrupt 1.
    105105 */
    106106
     107bool tmp = false;
     108
    107109static int32
    108110debug_keyboard_interrupt(void *data)
    109111{
     
    111113    static bool altPressed;
    112114    uint8 key;
    113115
     116    if (tmp) {
     117        ktrace_printf("KS!\n");
     118        return B_HANDLED_INTERRUPT;
     119    }
     120
    114121    key = in8(PS2_PORT_DATA);
    115122    //dprintf("debug_keyboard_interrupt: key = 0x%x\n", key);
    116123
     124    ktrace_printf("KSi\n");
     125
    117126    if (key & 0x80) {
    118127        if (key == LEFT_CONTROL)
    119128            controlPressed = false;
     
    188197    static uint8 special = 0;
    189198    static uint8 special2 = 0;
    190199    uint8 key = 0;
     200    tmp=true;
     201    ktrace_printf("KSa\n");
    191202
    192203    if (special & 0x80) {
    193204        special &= ~0x80;
    194         return '[';
     205        ktrace_printf("KSb\n");
     206        tmp=false;return '[';
    195207    }
    196208    if (special != 0) {
    197209        key = special;
    198210        special = 0;
    199         return key;
     211        ktrace_printf("KSc\n");
     212        tmp=false;return key;
    200213    }
    201214    if (special2 != 0) {
    202215        key = special2;
    203216        special2 = 0;
    204         return key;
     217        ktrace_printf("KSd\n");
     218        tmp=false;return key;
    205219    }
    206220
    207221    while (true) {
     
    220234            // we read mouse data, ignore it
    221235            continue;
    222236        }
     237        ktrace_printf("KSe\n");
    223238
    224239        if (key & 0x80) {
    225240            // key up
     
    254269                // start escape sequence for cursor movement
    255270                case CURSOR_UP:
    256271                    special = 0x80 | 'A';
    257                     return '\x1b';
     272                    tmp=false;return '\x1b';
    258273                case CURSOR_DOWN:
    259274                    special = 0x80 | 'B';
    260                     return '\x1b';
     275                    tmp=false;return '\x1b';
    261276                case CURSOR_RIGHT:
    262277                    special = 0x80 | 'C';
    263                     return '\x1b';
     278                    tmp=false;return '\x1b';
    264279                case CURSOR_LEFT:
    265280                    special = 0x80 | 'D';
    266                     return '\x1b';
     281                    tmp=false;return '\x1b';
    267282                case CURSOR_HOME:
    268283                    special = 0x80 | 'H';
    269                     return '\x1b';
     284                    tmp=false;return '\x1b';
    270285                case CURSOR_END:
    271286                    special = 0x80 | 'F';
    272                     return '\x1b';
     287                    tmp=false;return '\x1b';
    273288                case PAGE_UP:
    274289                    special = 0x80 | '5';
    275290                    special2 = '~';
    276                     return '\x1b';
     291                    tmp=false;return '\x1b';
    277292                case PAGE_DOWN:
    278293                    special = 0x80 | '6';
    279294                    special2 = '~';
    280                     return '\x1b';
     295                    tmp=false;return '\x1b';
    281296
    282297
    283298                case DELETE:
     
    286301
    287302                    special = 0x80 | '3';
    288303                    special2 = '~';
    289                     return '\x1b';
     304                    tmp=false;return '\x1b';
    290305
    291306                default:
    292307                    if (controlPressed) {
    293308                        char c = kShiftedKeymap[key];
    294309                        if (c >= 'A' && c <= 'Z')
    295                             return 0x1f & c;
     310                            tmp=false;return 0x1f & c;
    296311                    }
    297312
    298313                    if (altPressed)
    299                         return kAltedKeymap[key];
     314                        tmp=false;return kAltedKeymap[key];
    300315
    301                     return shiftPressed
     316                    tmp=false;return shiftPressed
    302317                        ? kShiftedKeymap[key] : kUnshiftedKeymap[key];
    303318            }
    304319        }