added get_modifier_key() as proposed by Olivier Cortes. Thanks.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28812 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2008-12-14 14:43:49 +00:00
parent c6e951f4e6
commit 2bbb828870
4 changed files with 87 additions and 17 deletions
+1
View File
@@ -14,6 +14,7 @@
#define IS_SET_KEY_REPEAT_DELAY 'Isrd'
#define IS_GET_KEY_INFO 'Igki'
#define IS_GET_MODIFIERS 'Igmd'
#define IS_GET_MODIFIER_KEY 'Igmk'
#define IS_SET_MODIFIER_KEY 'Ismk'
#define IS_SET_KEYBOARD_LOCKS 'Iskl'
#define IS_GET_MOUSE_SPEED 'Igms'
+45 -17
View File
@@ -376,12 +376,10 @@ get_mouse_type(int32 *type)
BMessage command(IS_GET_MOUSE_TYPE);
BMessage reply;
_control_input_server_(&command, &reply);
if (reply.FindInt32("mouse_type", type) != B_OK)
return B_ERROR;
return B_OK;
status_t err = _control_input_server_(&command, &reply);
if (err != B_OK)
return err;
return reply.FindInt32("mouse_type", type);
}
@@ -391,7 +389,9 @@ set_mouse_type(int32 type)
BMessage command(IS_SET_MOUSE_TYPE);
BMessage reply;
command.AddInt32("mouse_type", type);
status_t err = command.AddInt32("mouse_type", type);
if (err != B_OK)
return err;
return _control_input_server_(&command, &reply);
}
@@ -404,10 +404,11 @@ get_mouse_map(mouse_map *map)
const void *data = 0;
ssize_t count;
_control_input_server_(&command, &reply);
if (reply.FindData("mousemap", B_RAW_TYPE, &data, &count) != B_OK)
return B_ERROR;
status_t err = _control_input_server_(&command, &reply);
if (err == B_OK)
err = reply.FindData("mousemap", B_RAW_TYPE, &data, &count);
if (err != B_OK)
return err;
memcpy(map, data, count);
@@ -421,7 +422,9 @@ set_mouse_map(mouse_map *map)
BMessage command(IS_SET_MOUSE_MAP);
BMessage reply;
command.AddData("mousemap", B_RAW_TYPE, map, sizeof(mouse_map));
status_t err = command.AddData("mousemap", B_RAW_TYPE, map, sizeof(mouse_map));
if (err != B_OK)
return err;
return _control_input_server_(&command, &reply);
}
@@ -432,8 +435,10 @@ get_click_speed(bigtime_t *speed)
BMessage command(IS_GET_CLICK_SPEED);
BMessage reply;
_control_input_server_(&command, &reply);
status_t err = _control_input_server_(&command, &reply);
if (err != B_OK)
return err;
if (reply.FindInt64("speed", speed) != B_OK)
*speed = 500000;
@@ -457,8 +462,10 @@ get_mouse_speed(int32 *speed)
BMessage command(IS_GET_MOUSE_SPEED);
BMessage reply;
_control_input_server_(&command, &reply);
status_t err = _control_input_server_(&command, &reply);
if (err != B_OK)
return err;
if (reply.FindInt32("speed", speed) != B_OK)
*speed = 65536;
@@ -637,13 +644,34 @@ get_keyboard_id(uint16 *id)
_control_input_server_(&command, &reply);
reply.FindInt16("id", (int16 *)&kid);
status_t err = reply.FindInt16("id", (int16 *)&kid);
if (err != B_OK)
return err;
*id = kid;
return B_OK;
}
status_t
get_modifier_key(uint32 modifier, uint32 *key)
{
BMessage command(IS_GET_MODIFIER_KEY);
BMessage reply;
uint32 rkey;
command.AddInt32("modifier", modifier);
_control_input_server_(&command, &reply);
status_t err = reply.FindInt32("key", (int32 *) &rkey);
if (err != B_OK)
return err;
*key = rkey;
return B_OK;
}
void
set_modifier_key(uint32 modifier, uint32 key)
{
+40
View File
@@ -520,6 +520,9 @@ InputServer::MessageReceived(BMessage* message)
case IS_GET_MODIFIERS:
status = HandleGetModifiers(message, &reply);
break;
case IS_GET_MODIFIER_KEY:
status = HandleGetModifierKey(message, &reply);
break;
case IS_SET_MODIFIER_KEY:
status = HandleSetModifierKey(message, &reply);
break;
@@ -722,6 +725,43 @@ InputServer::HandleGetModifiers(BMessage* message, BMessage* reply)
}
status_t
InputServer::HandleGetModifierKey(BMessage* message, BMessage* reply)
{
int32 modifier;
if (message->FindInt32("modifier", &modifier) == B_OK) {
switch (modifier) {
case B_CAPS_LOCK:
return reply->AddInt32("key", fKeys.caps_key);
case B_NUM_LOCK:
return reply->AddInt32("key", fKeys.num_key);
case B_SCROLL_LOCK:
return reply->AddInt32("key", fKeys.scroll_key);
case B_LEFT_SHIFT_KEY:
return reply->AddInt32("key", fKeys.left_shift_key);
case B_RIGHT_SHIFT_KEY:
return reply->AddInt32("key", fKeys.right_shift_key);
case B_LEFT_COMMAND_KEY:
return reply->AddInt32("key", fKeys.left_command_key);
case B_RIGHT_COMMAND_KEY:
return reply->AddInt32("key", fKeys.right_command_key);
case B_LEFT_CONTROL_KEY:
return reply->AddInt32("key", fKeys.left_control_key);
case B_RIGHT_CONTROL_KEY:
return reply->AddInt32("key", fKeys.right_control_key);
case B_LEFT_OPTION_KEY:
return reply->AddInt32("key", fKeys.left_option_key);
case B_RIGHT_OPTION_KEY:
return reply->AddInt32("key", fKeys.right_option_key);
case B_MENU_KEY:
return reply->AddInt32("key", fKeys.menu_key);
}
}
return B_ERROR;
}
status_t
InputServer::HandleSetModifierKey(BMessage* message, BMessage* reply)
{
+1
View File
@@ -131,6 +131,7 @@ class InputServer : public BApplication {
status_t HandleGetSetKeyRepeatDelay(BMessage* message, BMessage* reply);
status_t HandleGetKeyInfo(BMessage* message, BMessage* reply);
status_t HandleGetModifiers(BMessage* message, BMessage* reply);
status_t HandleGetModifierKey(BMessage* message, BMessage* reply);
status_t HandleSetModifierKey(BMessage* message, BMessage* reply);
status_t HandleSetKeyboardLocks(BMessage* message, BMessage* reply);
status_t HandleGetSetMouseSpeed(BMessage* message, BMessage* reply);