Keyboard over sensitivity....

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
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Keyboard over sensitivity....

Post 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
User avatar
AndrewAPrice
Member
Member
Posts: 2327
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Keyboard over sensitivity....

Post 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?
My OS is Perception.
User avatar
octa
Member
Member
Posts: 50
Joined: Sat Jun 28, 2008 9:15 am

Re: Keyboard over sensitivity....

Post by octa »

MessiahAndrw wrote:you're not handling key pressed and key released events correctly.
think this is the prob
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Keyboard over sensitivity....

Post 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
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: Keyboard over sensitivity....

Post 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
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Keyboard over sensitivity....

Post 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///
User avatar
Solar
Member
Member
Posts: 7637
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Keyboard over sensitivity....

Post 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?
Every good solution is obvious once you've found it.
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: Keyboard over sensitivity....

Post 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.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
User avatar
suthers
Member
Member
Posts: 672
Joined: Tue Feb 20, 2007 3:00 pm
Location: London UK
Contact:

Re: Keyboard over sensitivity....

Post 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
Post Reply