I know it sounds like a simple question, but the numpad + and ENTER keys are on two different rows.
I'm trying to structure a keyboard packet with the coordinates of the keys on the keyboard.
Which row should I set those two keys to?
Numpad + is on row 2&3 (starting from zero) and numpad ENTER is on row 4&5.
which row is numpad (+) and (Enter) on?
which row is numpad (+) and (Enter) on?
Skylight: https://github.com/austanss/skylight
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
Re: which row is numpad (+) and (Enter) on?
I'm a bit confused as to the purpose of what you are doing here. Assuming you mean the physical row of the keyboard that a key is on, what interest is that? And bear in mind that different keyboards have different sized keys and even different key layouts.rizxt wrote:I'm trying to structure a keyboard packet with the coordinates of the keys on the keyboard.
Re: which row is numpad (+) and (Enter) on?
I'm trying to know the row/column of the key pressed/released on a US QWERTY keyboard.iansjack wrote:I'm a bit confused as to the purpose of what you are doing here. Assuming you mean the physical row of the keyboard that a key is on, what interest is that? And bear in mind that different keyboards have different sized keys and even different key layouts.rizxt wrote:I'm trying to structure a keyboard packet with the coordinates of the keys on the keyboard.
Skylight: https://github.com/austanss/skylight
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
Re: which row is numpad (+) and (Enter) on?
But why? Surely the scan code is the important thing.
Re: which row is numpad (+) and (Enter) on?
You bring a fair point. I could manufacture my key codes... differently.iansjack wrote:But why? Surely the scan code is the important thing.
Skylight: https://github.com/austanss/skylight
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
Re: which row is numpad (+) and (Enter) on?
I was kind of confused about this thread as well.
If you want to use your own key codes, then the answer to your original question is: It doesn't matter. You could assign some completely random numbers to your keys and it would be just fine, as long as you stick with it and use the same number everywhere. I, for example, like to use virtual key codes from Windows.
If you want to use your own key codes, then the answer to your original question is: It doesn't matter. You could assign some completely random numbers to your keys and it would be just fine, as long as you stick with it and use the same number everywhere. I, for example, like to use virtual key codes from Windows.
Re: which row is numpad (+) and (Enter) on?
This is what I settled on for my keycodes:
Code: Select all
struct keyboard_packet kbpacket;
uint16_t scan_code = io::inb(0x60);
// if we get E0 from PS/2, read another byte and append it
if (scan_code == 0xE0)
{
scan_code <<= 8;
scan_code |= io::inb(0x60);
}
// If we have an extended scancode
if ((scan_code >> 8) == 0xE0)
{
// Discard the E0 byte
scan_code &= 0x00FF;
// Subtract 0x10 from the scancode, as that is where the E0 scancodes start
scan_code -= 0x10;
// 0x90 (max E0 "press" scancode) subtracted by 0x10, if less than 0x80 then it was a press
if (scan_code < 0x80)
{
kbpacket.release_or_press = 1;
}
// If greater than 0x80 it was a release
else
{
// signal the release and subtract 0x80 to get its press scancode
kbpacket.release_or_press = 0;
scan_code -= 0x80;
}
// Append 0x80 to scan code to put it an a "E0 scancode space"
scan_code += 0x80;
// kbpacket.key_code is 8 bits
kbpacket.key_code = (scan_code & 0x00FF);
}
// If not an E0 byte, do a similar process without putting the scancode in the E0 space
else
{
if (scan_code < 0x80)
{
kbpacket.release_or_press = 1;
kbpacket.key_code = scan_code;
}
else
{
kbpacket.release_or_press = 0;
kbpacket.key_code = scan_code - 0x80;
}
}
Skylight: https://github.com/austanss/skylight
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: which row is numpad (+) and (Enter) on?
Well, this definitely won't work on some computers. You need to wait for the next IRQ before reading the next byte from port 0x60. Otherwise, you may end up reading garbage, or the same byte again, or a byte belonging to the other device attached to the PS/2 controller.rizxt wrote:This is what I settled on for my keycodes:
Even if it does work, it may cause a spurious IRQ.
(And what will you do for USB keyboards? Those don't use the same scan codes as PS/2 keyboards.)
Re: which row is numpad (+) and (Enter) on?
Assuming USB keyboard won't run on IRQ1, USB keyboards will have a different handler yet same keyboard event system, with same keyboard packet structure.Octocontrabass wrote:Well, this definitely won't work on some computers. You need to wait for the next IRQ before reading the next byte from port 0x60. Otherwise, you may end up reading garbage, or the same byte again, or a byte belonging to the other device attached to the PS/2 controller.rizxt wrote:This is what I settled on for my keycodes:
Even if it does work, it may cause a spurious IRQ.
(And what will you do for USB keyboards? Those don't use the same scan codes as PS/2 keyboards.)
Skylight: https://github.com/austanss/skylight
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".
I make stupid mistakes and my vision is terrible. Not a good combination.
NOTE: Never respond to my posts with "it's too hard".