PS2 keyboard

01 Jul 2011

I am fiddling with the PS2 library and would like to set a flag when the BREAK or Ctrl-BREAK key is pressed even when the program is not reading the keyboard. Can this be done inside the clk interrupt of the PS2 routines ? I came up with something like this in PS2KB.cpp:

       extern bool runflag, coldboot;

       case 10:    // 10 bits received so byte is in buffer
            /*
             * Stop bit.
             */
            if (dat.read() != 1) {
                // printf("Illegal stop bit condition.\n");
            }
            if (work.cStart != ((work.cEnd + 1) % RINGBUFSIZ)) {
                work.cEnd++;
                work.cEnd = work.cEnd % RINGBUFSIZ;
                work.bitcnt = 0;
            } else {
                // printf("Buffer overrun.\n");
            }

            // trap ctrl-break
            if (work.buffer[(work.cEnd-2)%RINGBUFSIZ]==0xe0 && work.buffer[(work.cEnd-1)%RINGBUFSIZ]==0x7e) {
                runflag=0;
                coldboot=1;
              //  printf("BREAK!");
            }

            break;

It seems to work as long as I don't press other keys before the Ctrl-Break, now for the Break key alone I have to check for the combination E1 14 77 E1 F0 14 F0 77 The flags need to be set regardless what is in the keyboard buffer. Any ideas ?

Gert