Backspace key don't works?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kapitan_hak
Posts: 3
Joined: Sat Nov 10, 2007 1:03 pm

Backspace key don't works?

Post 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?
Craze Frog
Member
Member
Posts: 368
Joined: Sun Sep 23, 2007 4:52 am

Post by Craze Frog »

The "internal keyboard buffer full" doesn't look good.
User avatar
AndrewAPrice
Member
Member
Posts: 2309
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Backspace key don't works?

Post 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();
            }
My OS is Perception.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post 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).
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
Post Reply