summaryrefslogtreecommitdiff
path: root/Source/Kernel/DeviceManager/Kbd.ns.cpp
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-20 15:06:07 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-20 15:06:07 +0200
commit9bdc18da391979479ad5c677770c3e8dffa1cb9a (patch)
tree412f79bf1dcbc5ea11d8aff6d2b016dacab2de3c /Source/Kernel/DeviceManager/Kbd.ns.cpp
parentaf3ff7f8c80bb3953f261a602316f92ec662daa8 (diff)
downloadMelon-9bdc18da391979479ad5c677770c3e8dffa1cb9a.tar.gz
Melon-9bdc18da391979479ad5c677770c3e8dffa1cb9a.zip
Keymaps are now loaded from ramfs.
Diffstat (limited to 'Source/Kernel/DeviceManager/Kbd.ns.cpp')
-rw-r--r--Source/Kernel/DeviceManager/Kbd.ns.cpp27
1 files changed, 21 insertions, 6 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() {