Page 1 of 1

Backspace key don't works?

Posted: Sun Nov 11, 2007 5:35 am
by kapitan_hak
Hi!

I'm writing simple keyboard driver. My problem is backspace key, it's support code is here:

Code: Select all

            if ((_char==0x08)&&(strlen((char*)prompt)<curpos))
            {
                curpos--;
                video.setX(curpos);
                video.putch(0x20);
                video.setX(curpos);
                video.move_csr();
            }
Here is screenshot: [img=http://img265.imageshack.us/img265/2947/screenshotgz3.th.png]:(. What is bad in this code?

Posted: Sun Nov 11, 2007 5:41 am
by Craze Frog
The "internal keyboard buffer full" doesn't look good.

Re: Backspace key don't works?

Posted: Sun Nov 11, 2007 5:46 am
by AndrewAPrice
Try:

Code: Select all

            if ((_char==0x08)&&(strlen((char*)prompt)<curpos))
            {
                // Step 1:
                // Erase what character is under the cursor by going back
                // character and printing a whitespace.
                curpos--;
                video.setX(curpos);
                video.putch(0x20);

                // Step 2:
                // Move the cursor back one position

                // I am assuming putch() increments curpos?
                // In that case, when we "blanked" the character, curpos was
                // incremented, so we must decrement it again.
                curpos--;
                video.setX(curpos);
                video.move_csr();
            }

Posted: Sun Nov 11, 2007 5:50 am
by XCHG
Yeah you have to read from port 0x60 when a key stroke is detected. Just do a simple IN AL , 0x60 and the scan code is in AL then. Watch out for extended keys (2 or even 3 bytes).