mouse: get/set acceleration factor by mouse name
* Create and use *_mouse_acceleration_by_name functions to replace older *_mouse_acceleration functions. Now consistent with related functions (such as *_mouse_speed_by_name). * Passing mouse_name to HandleGetSetMouseAcceleration in the BMessage fixes mouse acceleration changes not applying properly. Change-Id: I668cdbbbb81e3cb9069a3fc2ce77e6ef75ba8476 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5189 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -432,6 +432,8 @@ status_t get_mouse_speed_by_name(BString mouse_name, int32* speed);
|
||||
status_t set_mouse_speed_by_name(BString mouse_name, int32 speed);
|
||||
status_t get_mouse_acceleration(int32* speed);
|
||||
status_t set_mouse_acceleration(int32 speed);
|
||||
status_t get_mouse_acceleration_by_name(BString mouse_name, int32* speed);
|
||||
status_t set_mouse_acceleration_by_name(BString mouse_name, int32 speed);
|
||||
|
||||
status_t get_key_repeat_rate(int32* rate);
|
||||
status_t set_key_repeat_rate(int32 rate);
|
||||
|
||||
@@ -532,7 +532,7 @@ MouseDevice::_UpdateSettings()
|
||||
if (get_mouse_speed_by_name(fDeviceRef.name, &fSettings.accel.speed) != B_OK)
|
||||
LOG_ERR("error when get_mouse_speed\n");
|
||||
else {
|
||||
if (get_mouse_acceleration(&fSettings.accel.accel_factor) != B_OK)
|
||||
if (get_mouse_acceleration_by_name(fDeviceRef.name, &fSettings.accel.accel_factor) != B_OK)
|
||||
LOG_ERR("error when get_mouse_acceleration\n");
|
||||
else {
|
||||
mouse_accel accel;
|
||||
|
||||
@@ -683,6 +683,35 @@ set_mouse_acceleration(int32 speed)
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_mouse_acceleration_by_name(BString mouse_name, int32 *speed)
|
||||
{
|
||||
BMessage command(IS_GET_MOUSE_ACCELERATION);
|
||||
BMessage reply;
|
||||
command.AddString("mouse_name", mouse_name.String());
|
||||
|
||||
_control_input_server_(&command, &reply);
|
||||
|
||||
if (reply.FindInt32("speed", speed) != B_OK)
|
||||
*speed = 65536;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
set_mouse_acceleration_by_name(BString mouse_name, int32 speed)
|
||||
{
|
||||
BMessage command(IS_SET_MOUSE_ACCELERATION);
|
||||
BMessage reply;
|
||||
command.AddString("mouse_name", mouse_name.String());
|
||||
|
||||
command.AddInt32("speed", speed);
|
||||
|
||||
return _control_input_server_(&command, &reply);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
get_key_repeat_rate(int32 *rate)
|
||||
{
|
||||
|
||||
@@ -95,7 +95,7 @@ MouseSettings::_RetrieveSettings()
|
||||
return B_ERROR;
|
||||
if (get_mouse_speed_by_name(fName, &fSettings.accel.speed) != B_OK)
|
||||
return B_ERROR;
|
||||
if (get_mouse_acceleration(&fSettings.accel.accel_factor) != B_OK)
|
||||
if (get_mouse_acceleration_by_name(fName, &fSettings.accel.accel_factor) != B_OK)
|
||||
return B_ERROR;
|
||||
if (get_mouse_type_by_name(fName, &fSettings.type) != B_OK)
|
||||
return B_ERROR;
|
||||
@@ -294,7 +294,7 @@ MouseSettings::SetMouseSpeed(int32 speed)
|
||||
void
|
||||
MouseSettings::SetAccelerationFactor(int32 factor)
|
||||
{
|
||||
if (set_mouse_acceleration(factor) == B_OK)
|
||||
if (set_mouse_acceleration_by_name(fName, factor) == B_OK)
|
||||
fSettings.accel.accel_factor = factor;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user