From 9bdc18da391979479ad5c677770c3e8dffa1cb9a Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 20 Sep 2009 15:06:07 +0200 Subject: Keymaps are now loaded from ramfs. --- Source/Kernel/DeviceManager/Kbd.ns.cpp | 27 +++++++++++++++++++++------ Source/Kernel/DeviceManager/Kbd.ns.h | 2 +- 2 files changed, 22 insertions(+), 7 deletions(-) (limited to 'Source/Kernel/DeviceManager') 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 #include #include +#include +#include +#include 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); -- cgit v1.2.3