diff --git a/src/servers/input/InputServer.cpp b/src/servers/input/InputServer.cpp index febe9ce5c8..d15e211d2e 100644 --- a/src/servers/input/InputServer.cpp +++ b/src/servers/input/InputServer.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,9 @@ extern "C" void RegisterDevices(input_device_ref** devices) CALLED(); }; +// i don't know the exact signature but this one works +extern "C" status_t _kget_safemode_option_(char* name, uint8 *p1, uint32 *p2); + // Static InputServer member variables. // @@ -87,15 +91,24 @@ int main() * Method: InputServer::InputServer() * Descr: */ -InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE) +InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE), + sSafeMode(false) { CALLED(); void *pointer=NULL; EventLoop(pointer); - + + uint8 p1; + uint32 p2 = 1; + + if (_kget_safemode_option_("safemode", &p1, &p2) == B_OK) + sSafeMode = true; + gDeviceManager.LoadState(); + InitKeyboardMouseStates(); + fAddOnManager = new AddOnManager(); fAddOnManager->LoadState(); } @@ -145,16 +158,56 @@ void InputServer::InitKeyboardMouseStates(void) { CALLED(); - // This is where we read in the preferences data for the mouse and keyboard as well as - // determine the screen resolution from the app_server and find the center of the screen + // This is where we determine the screen resolution from the app_server and find the center of the screen // sMousePos is then set to the center of the screen. sMousePos.x = 200; sMousePos.y = 200; + LoadKeymap(); } +status_t +InputServer::LoadKeymap() +{ + BPath path; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path)!=B_OK) + return B_BAD_VALUE; + + path.Append("Key_map"); + + entry_ref ref; + get_ref_for_path(path.Path(), &ref); + + status_t err; + + BFile file(&ref, B_READ_ONLY); + if ((err = file.InitCheck()) != B_OK) { + printf("error %s\n", strerror(err)); + return err; + } + + if (file.Read(&fKeys, sizeof(fKeys)) < (ssize_t)sizeof(fKeys)) { + return B_BAD_VALUE; + } + + for (uint32 i=0; iwhat) { @@ -597,11 +650,11 @@ InputServer::HandleGetSetKeyMap(BMessage *message, { status_t status; if (message->what == IS_GET_KEY_MAP) { - status = reply->AddData("keymap", B_ANY_TYPE, &s_key_map, sizeof(s_key_map)); + status = reply->AddData("keymap", B_ANY_TYPE, &fKeys, sizeof(fKeys)); if (status == B_OK) - status = reply->AddData("key_buffer", B_ANY_TYPE, sChars, sCharCount); + status = reply->AddData("key_buffer", B_ANY_TYPE, fChars, fCharsSize); } else { - // TODO : reload keymap + LoadKeymap(); status = ControlDevices(NULL, B_KEYBOARD_DEVICE, B_KEY_MAP_CHANGED, NULL); } @@ -1361,7 +1414,7 @@ InputServer::SetMousePos(long *, bool InputServer::SafeMode(void) { - return true; + return sSafeMode; } diff --git a/src/servers/input/InputServer.h b/src/servers/input/InputServer.h index 670e9f8b39..3192bd62bc 100644 --- a/src/servers/input/InputServer.h +++ b/src/servers/input/InputServer.h @@ -182,6 +182,8 @@ public: static DeviceManager gDeviceManager; private: + status_t LoadKeymap(); + bool sEventLoopRunning; bool sSafeMode; port_id sEventPort; @@ -193,9 +195,9 @@ private: MouseSettings fMouseSettings; key_info s_key_info; // current key info - key_map s_key_map; // current key_map - char *sChars; // current keymap chars - int32 sCharCount; // current keymap char count + key_map fKeys; // current key_map + char *fChars; // current keymap chars + uint32 fCharsSize; // current keymap char count port_id ISPort; port_id EventLooperPort; diff --git a/src/servers/input/InputServerMethod.cpp b/src/servers/input/InputServerMethod.cpp index 3d56a4e901..5a2eeff28a 100644 --- a/src/servers/input/InputServerMethod.cpp +++ b/src/servers/input/InputServerMethod.cpp @@ -49,6 +49,7 @@ BInputServerMethod::BInputServerMethod(const char *name, */ BInputServerMethod::~BInputServerMethod() { + delete fOwner; }