implemented safemode info
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8719 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <File.h>
|
||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
@@ -56,6 +57,9 @@ extern "C" void RegisterDevices(input_device_ref** devices)
|
|||||||
CALLED();
|
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.
|
// Static InputServer member variables.
|
||||||
//
|
//
|
||||||
@@ -87,15 +91,24 @@ int main()
|
|||||||
* Method: InputServer::InputServer()
|
* Method: InputServer::InputServer()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE)
|
InputServer::InputServer(void) : BApplication(INPUTSERVER_SIGNATURE),
|
||||||
|
sSafeMode(false)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
void *pointer=NULL;
|
void *pointer=NULL;
|
||||||
|
|
||||||
EventLoop(pointer);
|
EventLoop(pointer);
|
||||||
|
|
||||||
|
uint8 p1;
|
||||||
|
uint32 p2 = 1;
|
||||||
|
|
||||||
|
if (_kget_safemode_option_("safemode", &p1, &p2) == B_OK)
|
||||||
|
sSafeMode = true;
|
||||||
|
|
||||||
gDeviceManager.LoadState();
|
gDeviceManager.LoadState();
|
||||||
|
|
||||||
|
InitKeyboardMouseStates();
|
||||||
|
|
||||||
fAddOnManager = new AddOnManager();
|
fAddOnManager = new AddOnManager();
|
||||||
fAddOnManager->LoadState();
|
fAddOnManager->LoadState();
|
||||||
}
|
}
|
||||||
@@ -145,16 +158,56 @@ void
|
|||||||
InputServer::InitKeyboardMouseStates(void)
|
InputServer::InitKeyboardMouseStates(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
// This is where we read in the preferences data for the mouse and keyboard as well as
|
// This is where we determine the screen resolution from the app_server and find the center of the screen
|
||||||
// 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 is then set to the center of the screen.
|
||||||
|
|
||||||
sMousePos.x = 200;
|
sMousePos.x = 200;
|
||||||
sMousePos.y = 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; i<sizeof(fKeys)/4; i++)
|
||||||
|
((uint32*)&fKeys)[i] = B_BENDIAN_TO_HOST_INT32(((uint32*)&fKeys)[i]);
|
||||||
|
|
||||||
|
if (file.Read(&fCharsSize, sizeof(uint32)) < (ssize_t)sizeof(uint32)) {
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
fCharsSize = B_BENDIAN_TO_HOST_INT32(fCharsSize);
|
||||||
|
if (!fChars)
|
||||||
|
delete[] fChars;
|
||||||
|
fChars = new char[fCharsSize];
|
||||||
|
err = file.Read(fChars, fCharsSize);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::QuitRequested()
|
* Method: InputServer::QuitRequested()
|
||||||
* Descr:
|
* Descr:
|
||||||
@@ -203,7 +256,7 @@ InputServer::MessageReceived(BMessage *message)
|
|||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
status_t status;
|
status_t status = B_OK;
|
||||||
|
|
||||||
switch(message->what)
|
switch(message->what)
|
||||||
{
|
{
|
||||||
@@ -597,11 +650,11 @@ InputServer::HandleGetSetKeyMap(BMessage *message,
|
|||||||
{
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
if (message->what == IS_GET_KEY_MAP) {
|
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)
|
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 {
|
} else {
|
||||||
// TODO : reload keymap
|
LoadKeymap();
|
||||||
|
|
||||||
status = ControlDevices(NULL, B_KEYBOARD_DEVICE, B_KEY_MAP_CHANGED, NULL);
|
status = ControlDevices(NULL, B_KEYBOARD_DEVICE, B_KEY_MAP_CHANGED, NULL);
|
||||||
}
|
}
|
||||||
@@ -1361,7 +1414,7 @@ InputServer::SetMousePos(long *,
|
|||||||
bool
|
bool
|
||||||
InputServer::SafeMode(void)
|
InputServer::SafeMode(void)
|
||||||
{
|
{
|
||||||
return true;
|
return sSafeMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -182,6 +182,8 @@ public:
|
|||||||
static DeviceManager gDeviceManager;
|
static DeviceManager gDeviceManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
status_t LoadKeymap();
|
||||||
|
|
||||||
bool sEventLoopRunning;
|
bool sEventLoopRunning;
|
||||||
bool sSafeMode;
|
bool sSafeMode;
|
||||||
port_id sEventPort;
|
port_id sEventPort;
|
||||||
@@ -193,9 +195,9 @@ private:
|
|||||||
MouseSettings fMouseSettings;
|
MouseSettings fMouseSettings;
|
||||||
|
|
||||||
key_info s_key_info; // current key info
|
key_info s_key_info; // current key info
|
||||||
key_map s_key_map; // current key_map
|
key_map fKeys; // current key_map
|
||||||
char *sChars; // current keymap chars
|
char *fChars; // current keymap chars
|
||||||
int32 sCharCount; // current keymap char count
|
uint32 fCharsSize; // current keymap char count
|
||||||
|
|
||||||
port_id ISPort;
|
port_id ISPort;
|
||||||
port_id EventLooperPort;
|
port_id EventLooperPort;
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ BInputServerMethod::BInputServerMethod(const char *name,
|
|||||||
*/
|
*/
|
||||||
BInputServerMethod::~BInputServerMethod()
|
BInputServerMethod::~BInputServerMethod()
|
||||||
{
|
{
|
||||||
|
delete fOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user