diff options
-rw-r--r-- | Init.rfs | bin | 1372 -> 3988 bytes | |||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | Source/Kernel/Core/kmain.wtf.cpp | 12 | ||||
-rw-r--r-- | Source/Kernel/DeviceManager/Kbd.ns.cpp | 27 | ||||
-rw-r--r-- | Source/Kernel/DeviceManager/Kbd.ns.h | 2 | ||||
-rw-r--r-- | Source/Kernel/Library/WChar.class.cpp | 6 | ||||
-rwxr-xr-x | Source/Kernel/Melon.ke | bin | 168416 -> 157958 bytes | |||
-rw-r--r-- | Source/Kernel/Ressources/Keymaps/Keymap.h | 9 | ||||
-rwxr-xr-x | Source/Kernel/Ressources/Keymaps/MakeMKM.sh | 18 | ||||
-rw-r--r-- | Source/Kernel/Ressources/Keymaps/WriteKeymap.cpp | 27 | ||||
-rw-r--r-- | Source/Kernel/Ressources/Keymaps/fr.cxd | 2 | ||||
-rw-r--r-- | Source/Kernel/Ressources/Keymaps/fr.mkm | bin | 0 -> 2560 bytes |
12 files changed, 95 insertions, 11 deletions
Binary files differ @@ -6,7 +6,8 @@ Floppy = Melon.img Projects = Kernel Tools/MakeRamFS RamFS = Init.rfs -RamFSFiles = :/System :/System/Applications :/System/Configuration \ +RamFSFiles = :/System :/System/Applications :/System/Configuration :/System/Keymaps \ + Source/Kernel/Ressources/Keymaps/fr.mkm:/System/Keymaps/fr.mkm \ Source/Kernel/Ressources/Texts/Welcome.txt:/Welcome.txt \ :/Useless \ Source/Kernel/Ressources/Texts/Info.txt:/Useless/Info.txt \ diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp index 4c576b6..6862e18 100644 --- a/Source/Kernel/Core/kmain.wtf.cpp +++ b/Source/Kernel/Core/kmain.wtf.cpp @@ -28,7 +28,6 @@ #include <Core/Log.ns.h> #include <Ressources/Graphics/logo.text.cxd> -#include <Ressources/Keymaps/fr.cxd> extern u32int end; //Placement address @@ -116,7 +115,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { Log::log(KL_STATUS, "kmain : Registered textual VGA output"); Dev::registerDevice(new PS2Keyboard()); //Initialize keyboard driver - Kbd::setKeymap(keymap_normal, keymap_shift, keymap_caps, keymap_altgr, keymap_shiftaltgr); //Load keymap + Kbd::loadKeymap("fr"); Kbd::setFocus(kvt); //Set focus to virtual terminal Log::log(KL_STATUS, "kmain : Keyboard set up"); @@ -138,6 +137,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) { *kvt << " - halt shuts down your computer\n"; *kvt << " - panic causes a kernel panic\n"; *kvt << " - devices shows all detected devices on your computer\n"; + *kvt << " - loadkeys loads specified kekymap\n"; *kvt << " - free shows memory usage (physical frames and kernel heap)\n"; *kvt << " - uptime shows seconds since boot\n"; *kvt << " - part shows all detected block devices and partitions\n"; @@ -243,6 +243,14 @@ void kmain(multiboot_info_t* mbd, u32int magic) { kvt->setCursorCol(25); *kvt << dev[i]->getName() << "\n"; } + } else if (tokens[0] == "loadkeys") { + if (tokens.size() == 1) { + *kvt << "Error : no argument specified.\n"; + } else { + if (!Kbd::loadKeymap(tokens[1])) { + *kvt << "Error while loading keymap " << tokens[1] << ".\n"; + } + } } else if (tokens[0] == "free") { u32int frames = PhysMem::total(), freef = PhysMem::free(); *kvt << " - Free frames : " << (s32int)freef << " (" << (s32int)(freef * 4 / 1024) << "Mo) of " 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); diff --git a/Source/Kernel/Library/WChar.class.cpp b/Source/Kernel/Library/WChar.class.cpp index a6ecf3f..ee42849 100644 --- a/Source/Kernel/Library/WChar.class.cpp +++ b/Source/Kernel/Library/WChar.class.cpp @@ -1,5 +1,9 @@ #include "WChar.class.h" +#ifdef THIS_IS_MELON +using namespace CMem; +#endif + WChar WChar::CP437[] = { //These are the UTF8 equivalents for the 128 extra characters of code page 437 "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ", @@ -42,7 +46,7 @@ u32int WChar::ucharLen(const char* c, u8int encoding) { } u32int WChar::utfLen(const char* c, u8int encoding) { - int i = 0, l = CMem::strlen(c), co = 0; + int i = 0, l = strlen(c), co = 0; while (i < l) { i += ucharLen(c + i, encoding); co++; diff --git a/Source/Kernel/Melon.ke b/Source/Kernel/Melon.ke Binary files differindex adf785c..22a7a87 100755 --- a/Source/Kernel/Melon.ke +++ b/Source/Kernel/Melon.ke diff --git a/Source/Kernel/Ressources/Keymaps/Keymap.h b/Source/Kernel/Ressources/Keymaps/Keymap.h new file mode 100644 index 0000000..304e52c --- /dev/null +++ b/Source/Kernel/Ressources/Keymaps/Keymap.h @@ -0,0 +1,9 @@ +#include <Library/WChar.class.h> + +struct melon_keymap_t { + WChar normal[128]; + WChar shift[128]; + WChar caps[128]; + WChar altgr[128]; + WChar shiftaltgr[128]; +}; diff --git a/Source/Kernel/Ressources/Keymaps/MakeMKM.sh b/Source/Kernel/Ressources/Keymaps/MakeMKM.sh new file mode 100755 index 0000000..ac54ce8 --- /dev/null +++ b/Source/Kernel/Ressources/Keymaps/MakeMKM.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +#DIR=`pwd` +#DIR=`dirname $DIR` +#cd $DIR + +for KM in `ls | grep cxd`; do + echo "#define THIS_IS_NOT_MELON" > kmtemp.cpp + echo "#include <cstring>" >> kmtemp.cpp + echo "#include <Library/WChar.class.cpp>" >> kmtemp.cpp + echo "#include \"$KM\"" >> kmtemp.cpp + cat WriteKeymap.cpp >> kmtemp.cpp + + g++ kmtemp.cpp -o kmtemp -I ../.. + ./kmtemp +done + +rm kmtemp* diff --git a/Source/Kernel/Ressources/Keymaps/WriteKeymap.cpp b/Source/Kernel/Ressources/Keymaps/WriteKeymap.cpp new file mode 100644 index 0000000..c3aa61c --- /dev/null +++ b/Source/Kernel/Ressources/Keymaps/WriteKeymap.cpp @@ -0,0 +1,27 @@ +/* #define THIS_IS_NOT_MELON +#include <cstring> +#include <Library/WChar.class.cpp> +#include "fr.cxd" */ +#include "Keymap.h" +#include <fstream> +#include <string> + +using namespace std; + +int main() { + melon_keymap_t km; + memcpy(km.normal, keymap_normal, 128 * sizeof(WChar)); + memcpy(km.shift, keymap_shift, 128 * sizeof(WChar)); + memcpy(km.caps, keymap_caps, 128 * sizeof(WChar)); + memcpy(km.altgr, keymap_altgr, 128 * sizeof(WChar)); + memcpy(km.shiftaltgr, keymap_shiftaltgr, 128 * sizeof(WChar)); + + string a = LANG; + a += ".mkm"; + + fstream output(a.c_str(), ios::out | ios::binary); + output.write((char*)&km, sizeof(km)); + output.close(); + + return 0; +} diff --git a/Source/Kernel/Ressources/Keymaps/fr.cxd b/Source/Kernel/Ressources/Keymaps/fr.cxd index 8cfdf8c..d2d9ead 100644 --- a/Source/Kernel/Ressources/Keymaps/fr.cxd +++ b/Source/Kernel/Ressources/Keymaps/fr.cxd @@ -1,3 +1,5 @@ +#define LANG "fr" + //This file is precious !!! Very precious !! WChar keymap_normal[128] = { diff --git a/Source/Kernel/Ressources/Keymaps/fr.mkm b/Source/Kernel/Ressources/Keymaps/fr.mkm Binary files differnew file mode 100644 index 0000000..94c72ec --- /dev/null +++ b/Source/Kernel/Ressources/Keymaps/fr.mkm |