Page 1 of 1

Keyboard over sensitivity....

Posted: Sun Jul 20, 2008 11:50 am
by suthers
I've encountered a weird problem, I recently added some stuff to my TUI and I decided to add the ability to have upper case insert, etc...
I already had code that turned the lights on the keyboard on, but it didn't do anything else....
So I added code to do this, I added code so that 'Ins' would appear at the bottom when insert was tiped in...
That worked fine, then I added another keymap with the data for caps, and some code that changed the keymap used depending on the state of the caps...
But when I ran this I found that my keyboard had become hyper sensitive, when I press the caps, scroll or num lock or any other modifying keys such as insert, it triggered quite a few interrupts, so it would be very difficult if at all possible to control the state of the modifiers, strangely this did not affect the character keys and this would disappear if I removed the character map with the caps...
It would still occur if I removed the code to change character maps when Caps was pressed (restoring the code to it's original state when it worked...), but if I left the character map the hyper sensitivity would still occur...
It would only disappear if I removed the character map.
Any body have any ideas what I could be doing wrong?
Thanks in advance,

Jules

P.S. I'm proud to announce that I finally have a fully working cross compiler, so it shouldn't be problems with different variables writing over each other anymore... :D

Re: Keyboard over sensitivity....

Posted: Thu Jul 24, 2008 4:01 am
by AndrewAPrice
Buffer overflow in your character map possibly? Or you're not handling key pressed and key released events correctly.

By the way, how did you come up with the name Virginix?

Re: Keyboard over sensitivity....

Posted: Thu Jul 24, 2008 4:15 am
by octa
MessiahAndrw wrote:you're not handling key pressed and key released events correctly.
think this is the prob

Re: Keyboard over sensitivity....

Posted: Thu Jul 24, 2008 9:08 am
by suthers
I don't think it is buffer overflow I've checked all my values properly...
But Iver tracked down the exact line of code that causes the error:

Code: Select all

else kbd = (unsigned short *) &kbdus;
This changes the kbd pointer to a pointer to the lower case character map...
I have absolutely no idea why this would cause a problem, but when I comment out this individual line, the problem goes away...
The name virginix is the name of a friend of mine mixed with 'Unix' to form an OS style name...
Jules

Re: Keyboard over sensitivity....

Posted: Thu Jul 24, 2008 9:22 pm
by thepowersgang
most probebly the variable `kbdus` is an array so you do not need to reference it.

Try without the & sign in front of it and see what that does

Re: Keyboard over sensitivity....

Posted: Fri Jul 25, 2008 7:46 am
by suthers
I don't need to, but I prefer to... :D
I also found out something else, that when I press the CAPS key the first time, no problem, no hyper sensitivity, it changes to CAPS easily, no problems, the CAPS light turns and the character map changes, so it types in CAPS...
Thereafter, when I press CAPS to change it back, I see the CAPS light flash but always comes back to CAPS ON...
Thanks to the magic of bochs, I've discovered that this is because after the first CAPS, each time I press CAPS two keyboard IRQs are automatically triggered meaning it automatically switches back to CAPS ON every time...
This remedied by removing the line commented above...
I also noted that I I hold down CAPS, but before it starts triggering a string of IRQs, I press another key, firstly the CAPS light stays and the key maps changes back...
But as soon as I let go, it reverts, meaning the second IRQ is triggered by the release of the key, is this normal behavior? (I don't think so...)
Any ideas?
Thanks in advance,

Jules

P.S. the previous assertion that it triggered loads of IRQs was wrong, it turns that was just because when the break point occurred, bochs saved all the IRQs to the IRQ cue and as the 'clock' had stopped, I presume it no longer limits the IRQ speed when in this situation///

Re: Keyboard over sensitivity....

Posted: Fri Jul 25, 2008 8:10 am
by Solar
suthers wrote:But as soon as I let go, it reverts, meaning the second IRQ is triggered by the release of the key, is this normal behavior? (I don't think so...)
Language confusion here - you are aware that key-press and key-release are two seperate events?

Re: Keyboard over sensitivity....

Posted: Fri Jul 25, 2008 8:15 am
by Korona
You should get a 0x3A scancode when you press capslock and a 0xBA scancode when you release the key.
Some keyboards send fake shift / capslocks scancodes when you press other keys while shift / capslock is active but that should not be a problem.

Re: Keyboard over sensitivity....

Posted: Fri Jul 25, 2008 1:39 pm
by suthers
weird, does accessing an array loop? i.e. In an 128bit array, and I try to access the 129th bit, does it return the 1st bit, because that's the only way that it could be explained...
I just moved my check for a key release to right at the beginning of the keyboard handler...
Which fixed it...
Thanks for all the help.
Thanks,

Jules