Added get_set_mulitple_mouse_type() functions

Change-Id: I95f85a15a77c3a548bb672cb966ae7b13fcefcc8
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3127
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Preetpal Kaur 2020-08-04 15:52:44 +05:30 committed by Adrien Destugues
parent 68c67d9c5a
commit 37d793236c
4 changed files with 39 additions and 5 deletions

View File

@ -8,6 +8,7 @@
#include <GraphicsDefs.h>
#include <OS.h>
#include <String.h>
class BBitmap;
@ -419,6 +420,8 @@ status_t set_scroll_bar_info(scroll_bar_info* info);
status_t get_mouse_type(int32* type);
status_t set_mouse_type(int32 type);
status_t get_mouse_type_by_name(BString mouse_name, int32* type);
status_t set_mouse_type_by_name(BString mouse_name, int32 type);
status_t get_mouse_map(mouse_map* map);
status_t set_mouse_map(mouse_map* map);
status_t get_click_speed(bigtime_t* speed);

View File

@ -544,7 +544,7 @@ MouseDevice::_UpdateSettings()
}
}
if (get_mouse_type(&fSettings.type) != B_OK)
if (get_mouse_type_by_name(fDeviceRef.name, &fSettings.type) != B_OK)
LOG_ERR("error when get_mouse_type\n");
else
ioctl(fDevice, MS_SET_TYPE, &fSettings.type);

View File

@ -504,6 +504,38 @@ set_mouse_type(int32 type)
}
status_t
get_mouse_type_by_name(BString mouse_name, int32 *type)
{
BMessage command(IS_GET_MOUSE_TYPE);
BMessage reply;
status_t err = _control_input_server_(&command, &reply);
if (err != B_OK)
return err;
return reply.FindInt32("mouse_type", type);
}
status_t
set_mouse_type_by_name(BString mouse_name, int32 type)
{
BMessage command(IS_SET_MOUSE_TYPE);
BMessage reply;
status_t err_mouse_name = command.AddString("mouse_name",
mouse_name.String());
if (err_mouse_name != B_OK)
return err_mouse_name;
status_t err = command.AddInt32("mouse_type", type);
if (err != B_OK)
return err;
return _control_input_server_(&command, &reply);
}
status_t
get_mouse_map(mouse_map *map)
{

View File

@ -85,8 +85,8 @@ MouseSettings::_RetrieveSettings()
fprintf(stderr, "error when get_mouse_speed\n");
if (get_mouse_acceleration(&fSettings.accel.accel_factor) != B_OK)
fprintf(stderr, "error when get_mouse_acceleration\n");
if (get_mouse_type(&fSettings.type) != B_OK)
fprintf(stderr, "error when get_mouse_type\n");
if (get_mouse_type_by_name(fname, &fSettings.type) != B_OK)
fprintf(stderr, "error when get_multiple_mouse_type\n");
fMode = mouse_mode();
fFocusFollowsMouseMode = focus_follows_mouse_mode();
@ -238,7 +238,7 @@ MouseSettings::IsRevertable()
void
MouseSettings::SetMouseType(int32 type)
{
if (set_mouse_type(type) == B_OK)
if (set_mouse_type_by_name(fname, type) == B_OK)
fSettings.type = type;
}
@ -345,7 +345,6 @@ MultipleMouseSettings::MultipleMouseSettings()
#ifdef DEBUG
Dump();
#endif
}