summaryrefslogtreecommitdiff
path: root/Source/Kernel/DeviceManager
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-02 12:36:52 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-02 12:36:52 +0200
commitaa5aa4482314078c52f86226a1753511d3f4a4cb (patch)
tree63663f87a5375a957829d85f6d11d268cbdd1f4b /Source/Kernel/DeviceManager
parent8c9f3cc95987f2aee2771d96a0956241b6f96cb3 (diff)
downloadMelon-aa5aa4482314078c52f86226a1753511d3f4a4cb.tar.gz
Melon-aa5aa4482314078c52f86226a1753511d3f4a4cb.zip
Maybee some changes
Diffstat (limited to 'Source/Kernel/DeviceManager')
-rw-r--r--Source/Kernel/DeviceManager/Kbd.ns.cpp9
-rw-r--r--Source/Kernel/DeviceManager/Kbd.ns.h8
2 files changed, 10 insertions, 7 deletions
diff --git a/Source/Kernel/DeviceManager/Kbd.ns.cpp b/Source/Kernel/DeviceManager/Kbd.ns.cpp
index 256037b..135d521 100644
--- a/Source/Kernel/DeviceManager/Kbd.ns.cpp
+++ b/Source/Kernel/DeviceManager/Kbd.ns.cpp
@@ -75,6 +75,7 @@ void updateLeds() {
void keyPress(u8int scancode) {
keypress_t kp;
kp.pressed = true;
+ kp.modifiers = kbdstatus & 0x0F;
u8int cmd = ctrlkeys[scancode];
scancode &= 0x7F;
if (cmd == 0) cmd = ctrlkeys[scancode];
@@ -83,7 +84,6 @@ void keyPress(u8int scancode) {
kp.character = 0;
if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) {
kp.hascmd = true;
- kp.command = kbdstatus & 0x0F;
}
if ((kbdstatus & STATUS_SHIFT) xor (kbdstatus & STATUS_CAPS)) {
if (kbdstatus & STATUS_ALTGR) {
@@ -102,7 +102,6 @@ void keyPress(u8int scancode) {
kp.haschar = true;
if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) {
kp.hascmd = true;
- kp.command = kbdstatus & 0xF0;
}
if (cmd == KBDC_KPDEL) {
kp.character = (u32int)'.';
@@ -113,7 +112,6 @@ void keyPress(u8int scancode) {
kp.haschar = true;
if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) {
kp.hascmd = true;
- kp.command = kbdstatus & 0xF0;
}
kp.character = (u32int)'/';
} else if (cmd == KBDC_ALT) {
@@ -144,6 +142,7 @@ void keyPress(u8int scancode) {
void keyRelease(u8int scancode) {
keypress_t kp;
kp.pressed = false;
+ kp.modifiers = kbdstatus & 0x0F;
u8int cmd = ctrlkeys[scancode];
scancode &= 0x7F;
if (cmd == 0) cmd = ctrlkeys[scancode];
@@ -152,7 +151,6 @@ void keyRelease(u8int scancode) {
kp.character = 0;
if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) {
kp.hascmd = true;
- kp.command = kbdstatus & 0x0F;
}
if ((kbdstatus & STATUS_SHIFT) xor (kbdstatus & STATUS_CAPS)) {
if (kbdstatus & STATUS_ALTGR) {
@@ -171,7 +169,6 @@ void keyRelease(u8int scancode) {
kp.haschar = true;
if ((kbdstatus & STATUS_ALT) or (kbdstatus & STATUS_CTRL)) {
kp.hascmd = true;
- kp.command = kbdstatus & 0xF0;
}
if (cmd == KBDC_KPDEL) {
kp.character = (u32int)'.';
@@ -187,7 +184,7 @@ void keyRelease(u8int scancode) {
} else if (cmd == KBDC_LEFTSHIFT or cmd == KBDC_RIGHTSHIFT) {
kbdstatus &= ~STATUS_SHIFT;
}
- if (!kp.haschar) {
+ if (!kp.haschar && cmd) {
kp.hascmd = true;
kp.command = cmd;
}
diff --git a/Source/Kernel/DeviceManager/Kbd.ns.h b/Source/Kernel/DeviceManager/Kbd.ns.h
index ee73414..efd7a48 100644
--- a/Source/Kernel/DeviceManager/Kbd.ns.h
+++ b/Source/Kernel/DeviceManager/Kbd.ns.h
@@ -76,11 +76,17 @@
class VirtualTerminal;
namespace Kbd {
+ //== Possible cases for keypress_t :
+ // - hascmd && !haschar : this is a command key press/release (all grey keys except alt/ctrl/altgr/shift)
+ // - haschar && !hascmd : this is a character key press/release. Modifiers can haz STATUS_SHIFT or STATUS_ALTGR
+ // - haschar && hascmd : this is a character key press, but with ctrl and/or alt. See that in modifiers.
+ // - !haschar && !hascmd : invalid keypress
struct keypress_t {
bool pressed;
bool hascmd;
bool haschar;
- u8int command; //is 0 if !hascmd, is one of KBDC_* if !haschar, and is a mask of STATUS_* if haschar
+ u8int modifiers;
+ u8int command;
wchar character; //is 0 if !haschar
keypress_t() : hascmd(false), haschar(false), command(0), character('\0') {};
};