diff options
author | Alexis211 <alexis211@gmail.com> | 2009-09-20 15:06:07 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-09-20 15:06:07 +0200 |
commit | 9bdc18da391979479ad5c677770c3e8dffa1cb9a (patch) | |
tree | 412f79bf1dcbc5ea11d8aff6d2b016dacab2de3c /Source/Kernel/DeviceManager | |
parent | af3ff7f8c80bb3953f261a602316f92ec662daa8 (diff) | |
download | Melon-9bdc18da391979479ad5c677770c3e8dffa1cb9a.tar.gz Melon-9bdc18da391979479ad5c677770c3e8dffa1cb9a.zip |
Keymaps are now loaded from ramfs.
Diffstat (limited to 'Source/Kernel/DeviceManager')
-rw-r--r-- | Source/Kernel/DeviceManager/Kbd.ns.cpp | 27 | ||||
-rw-r--r-- | Source/Kernel/DeviceManager/Kbd.ns.h | 2 |
2 files changed, 22 insertions, 7 deletions
diff --git a/Source/Kernel/DeviceManager/Kbd.ns.cpp b/Source/Kernel/DeviceManager/Kbd.ns.cpp index fddf0dd..df419b7 100644 --- a/Source/Kernel/DeviceManager/Kbd.ns.cpp +++ b/Source/Kernel/DeviceManager/Kbd.ns.cpp @@ -3,6 +3,9 @@ #include <Library/Vector.class.h> #include <Devices/Keyboard/Keyboard.proto.h> #include <VTManager/VirtualTerminal.proto.h> +#include <Ressources/Keymaps/Keymap.h> +#include <VFS/File.class.h> +#include <Core/Log.ns.h> namespace Kbd { @@ -26,6 +29,7 @@ u8int ctrlkeys[] = { /* 0xF0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +melon_keymap_t km; WChar *keymapNormal = NULL, *keymapShift = NULL, *keymapCaps = NULL, *keymapAltgr = NULL, *keymapShiftAltgr = NULL; u8int kbdstatus = 0; VirtualTerminal *focusedVT = NULL; //This is the VT that must receive the character @@ -58,12 +62,23 @@ void setFocus(VirtualTerminal* vt) { focusedVT = vt; } -void setKeymap(WChar* kmNormal, WChar* kmShift, WChar* kmCaps, WChar* kmAltgr, WChar* kmShiftAltgr) { - keymapNormal = kmNormal; - keymapShift = kmShift; - keymapCaps = kmCaps; - keymapAltgr = kmAltgr; - keymapShiftAltgr = kmShiftAltgr; +bool loadKeymap(String lang) { + String file = "/System/Keymaps/"; + file += lang; + file += ".mkm"; + File f(file, FM_READ); + if (!f.valid()) return false; + + f.read(sizeof(melon_keymap_t), (u8int*)&km); + + keymapNormal = km.normal; + if (km.shift[0x10] != 0) keymapShift = km.shift; else keymapShift = keymapNormal; + if (km.caps[0x10] != 0) keymapCaps = km.caps; else keymapShift = keymapShift; + if (km.altgr[0x10] != 0) keymapAltgr = km.altgr; else keymapShift = keymapNormal; + if (km.shiftaltgr[0x10] != 0) keymapShiftAltgr = km.shiftaltgr; else keymapShift = keymapAltgr; + + Log::log(KL_STATUS, String("Kbd.ns : loaded keymap : ") += file); + return true; } void updateLeds() { diff --git a/Source/Kernel/DeviceManager/Kbd.ns.h b/Source/Kernel/DeviceManager/Kbd.ns.h index 34ad0e4..50cd746 100644 --- a/Source/Kernel/DeviceManager/Kbd.ns.h +++ b/Source/Kernel/DeviceManager/Kbd.ns.h @@ -92,7 +92,7 @@ namespace Kbd { }; void setFocus(VirtualTerminal* vt); - void setKeymap(WChar* kmNormal, WChar* kmShift, WChar* kmCaps, WChar* kmAltgr, WChar* kmShiftAltgr = NULL); + bool loadKeymap(String lang); void updateLeds(); void keyPress(u8int scancode); void keyRelease(u8int scancode); |