Input server: add mouse-specific API for button map and click speed
Convert users of those and other parameters to the new API. Fix mouse preferences "Default" button not changing button map. Change-Id: I9184011fd3067fd0b229e1db6376c1b41f06dab9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7878 Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
df803c0f3f
commit
caed67a8cb
@@ -756,57 +756,157 @@
|
|||||||
|
|
||||||
If there are multiple mouses connected, the number of buttons for one of
|
If there are multiple mouses connected, the number of buttons for one of
|
||||||
them picked at random will be returned.
|
them picked at random will be returned.
|
||||||
|
|
||||||
|
\deprecated Use \ref "get_mouse_type(const char* mouse_name, int32* type)"
|
||||||
|
instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn status_t set_mouse_type(int32 type)
|
\fn status_t get_mouse_type(const char* mouse_name, int32* type)
|
||||||
\brief Set the number of buttons of the mouse.
|
|
||||||
\deprecated use set_mouse_type_by_name instead.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn status_t get_mouse_type_by_name(BString mouse_name, int32* type)
|
|
||||||
\brief Get the number of buttons for a specific mouse.
|
\brief Get the number of buttons for a specific mouse.
|
||||||
|
|
||||||
Mouse names can be known from BInputDevice.
|
Mouse names can be known from BInputDevice.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn status_t set_mouse_type_by_name(BString mouse_name, int32 type)
|
\fn status_t set_mouse_type(const char* mouse_name, int32 type)
|
||||||
\brief Configure the number of buttons for a specific mouse.
|
\brief Configure the number of buttons for a specific mouse.
|
||||||
|
|
||||||
The setting is saved and persists accross reboots.
|
The setting is saved and persists accross reboots.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t get_mouse_map(mouse_map* map)
|
||||||
|
\brief Get the button map of the mouse.
|
||||||
|
|
||||||
|
\deprecated Use \ref "get_mouse_map(const char* mouse_name, mouse_map* map)"
|
||||||
|
instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t get_mouse_map(const char* mouse_name, mouse_map* map)
|
||||||
|
\brief Get the button map for a specific mouse.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t set_mouse_map(mouse_map* map)
|
||||||
|
\brief Set the button map of the mouse.
|
||||||
|
|
||||||
|
\deprecated Use \ref "set_mouse_map(const char* mouse_name, mouse_map* map)"
|
||||||
|
instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t set_mouse_map(const char* mouse_name, mouse_map* map)
|
||||||
|
\brief Set the button map for a specific mouse.
|
||||||
|
|
||||||
|
The setting is saved and persists accross reboots.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t get_click_speed(bigtime_t* speed)
|
||||||
|
\brief Get the double-click maximum delay.
|
||||||
|
|
||||||
|
\deprecated Use \ref "get_click_speed(const char* mouse_name, bigtime_t* speed)"
|
||||||
|
instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t get_click_speed(const char* mouse_name, bigtime_t* speed)
|
||||||
|
\brief Get the double-click maximum delay for a specific mouse.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t set_click_speed(bigtime_t speed)
|
||||||
|
\brief Set the double-click maximum delay.
|
||||||
|
|
||||||
|
\deprecated Use \ref "get_click_speed(const char* mouse_name, bigtime_t* speed)"
|
||||||
|
instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t set_click_speed(const char* mouse_name, bigtime_t speed)
|
||||||
|
\brief Set the double-click maximum delay for a specific mouse.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn status_t get_mouse_speed(int32* speed)
|
\fn status_t get_mouse_speed(int32* speed)
|
||||||
\brief Get the mouse speed
|
\brief Get the mouse speed.
|
||||||
|
|
||||||
If there are multiple mouses connected, this function return the speed
|
If there are multiple mouses connected, this function returns the speed
|
||||||
from a random one.
|
from a random one.
|
||||||
|
|
||||||
|
\deprecated Use \ref "get_mouse_speed(const char* mouse_name, int32* speed)"
|
||||||
|
instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn status_t set_mouse_speed(int32 speed)
|
\fn status_t get_mouse_speed(const char* mouse_name, int32* speed)
|
||||||
\brief Set the mouse speed
|
\brief Get the mouse speed setting for a specific mouse.
|
||||||
\deprecated use set_mouse_speed_by_name instead.
|
|
||||||
|
\since Haiku R1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\fn status_t get_mouse_speed_by_name(BString mouse_name, int32* speed)
|
\fn status_t set_mouse_speed(const char* mouse_name, int32 speed)
|
||||||
\brief Get the mouse speed setting for a specific mouse
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\fn status_t set_mouse_speed_by_name(BString mouse_name, int32 speed)
|
|
||||||
\brief Set the mouse speed for a specific mouse.
|
\brief Set the mouse speed for a specific mouse.
|
||||||
|
|
||||||
The setting is saved and persists accross reboots.
|
The setting is saved and persists accross reboots.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t get_mouse_acceleration(int32* speed)
|
||||||
|
\brief Get the mouse acceleration.
|
||||||
|
|
||||||
|
If there are multiple mouses connected, this function returns the speed
|
||||||
|
from a random one.
|
||||||
|
|
||||||
|
\deprecated Use \ref "get_mouse_acceleration(const char* mouse_name, int32* speed)"
|
||||||
|
instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t get_mouse_acceleration(const char* mouse_name, int32* speed)
|
||||||
|
\brief Get the mouse acceleration setting for a specific mouse.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\fn status_t set_mouse_acceleration(const char* mouse_name, int32 speed)
|
||||||
|
\brief Set the mouse acceleration for a specific mouse.
|
||||||
|
|
||||||
|
The setting is saved and persists accross reboots.
|
||||||
|
|
||||||
|
\since Haiku R1
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -425,10 +425,14 @@ status_t set_scroll_bar_info(scroll_bar_info* info);
|
|||||||
status_t get_mouse_type(int32* type); // deprecated
|
status_t get_mouse_type(int32* type); // deprecated
|
||||||
status_t get_mouse_type(const char* mouse_name, int32* type);
|
status_t get_mouse_type(const char* mouse_name, int32* type);
|
||||||
status_t set_mouse_type(const char* mouse_name, int32 type);
|
status_t set_mouse_type(const char* mouse_name, int32 type);
|
||||||
status_t get_mouse_map(mouse_map* map);
|
status_t get_mouse_map(mouse_map* map); // deprecated
|
||||||
status_t set_mouse_map(mouse_map* map);
|
status_t get_mouse_map(const char* mouse_name, mouse_map* map);
|
||||||
status_t get_click_speed(bigtime_t* speed);
|
status_t set_mouse_map(mouse_map* map); // deprecated
|
||||||
status_t set_click_speed(bigtime_t speed);
|
status_t set_mouse_map(const char* mouse_name, mouse_map* map);
|
||||||
|
status_t get_click_speed(bigtime_t* speed); // deprecated
|
||||||
|
status_t get_click_speed(const char* mouse_name, bigtime_t* speed);
|
||||||
|
status_t set_click_speed(bigtime_t speed); // deprecated
|
||||||
|
status_t set_click_speed(const char* mouse_name, bigtime_t speed);
|
||||||
status_t get_mouse_speed(int32* speed); // deprecated
|
status_t get_mouse_speed(int32* speed); // deprecated
|
||||||
status_t get_mouse_speed(const char* mouse_name, int32* speed);
|
status_t get_mouse_speed(const char* mouse_name, int32* speed);
|
||||||
status_t set_mouse_speed(const char* mouse_name, int32 speed);
|
status_t set_mouse_speed(const char* mouse_name, int32 speed);
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ FILE *EasyPenInputDevice::sLogFile = NULL;
|
|||||||
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
const static uint32 kTabletThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
const static uint32 kTabletThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
||||||
|
const static char* kDeviceName = "Genius EasyPen";
|
||||||
|
|
||||||
struct tablet_device {
|
struct tablet_device {
|
||||||
tablet_device(BSerialPort *port);
|
tablet_device(BSerialPort *port);
|
||||||
@@ -152,7 +153,7 @@ EasyPenInputDevice::InitCheck()
|
|||||||
|
|
||||||
LOG("Found %ld devices\n", fDevices.CountItems());
|
LOG("Found %ld devices\n", fDevices.CountItems());
|
||||||
|
|
||||||
get_click_speed(&fClickSpeed);
|
get_click_speed(kDeviceName, &fClickSpeed);
|
||||||
|
|
||||||
return fDevices.CountItems() > 0 ? B_OK : B_ERROR;
|
return fDevices.CountItems() > 0 ? B_OK : B_ERROR;
|
||||||
}
|
}
|
||||||
@@ -206,7 +207,7 @@ EasyPenInputDevice::Control(const char *name, void *cookie,
|
|||||||
LOG("%s(%s, code: %lu)\n", __PRETTY_FUNCTION__, name, command);
|
LOG("%s(%s, code: %lu)\n", __PRETTY_FUNCTION__, name, command);
|
||||||
|
|
||||||
if (command == B_CLICK_SPEED_CHANGED)
|
if (command == B_CLICK_SPEED_CHANGED)
|
||||||
get_click_speed(&fClickSpeed);
|
get_click_speed(kDeviceName, &fClickSpeed);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -292,7 +293,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg)
|
|||||||
message->AddFloat("be:tablet_x", movements.xpos);
|
message->AddFloat("be:tablet_x", movements.xpos);
|
||||||
message->AddFloat("be:tablet_y", movements.ypos);
|
message->AddFloat("be:tablet_y", movements.ypos);
|
||||||
message->AddFloat("be:tablet_pressure", movements.pressure);
|
message->AddFloat("be:tablet_pressure", movements.pressure);
|
||||||
message->AddInt32("be:tablet_eraser", movements.eraser);
|
message->AddInt32("be:tablet_eraser", (movements.switches & B_ERASER) != 0);
|
||||||
if (movements.tilt_x != 0.0 || movements.tilt_y != 0.0) {
|
if (movements.tilt_x != 0.0 || movements.tilt_y != 0.0) {
|
||||||
message->AddFloat("be:tablet_tilt_x", movements.tilt_x);
|
message->AddFloat("be:tablet_tilt_x", movements.tilt_x);
|
||||||
message->AddFloat("be:tablet_tilt_y", movements.tilt_y);
|
message->AddFloat("be:tablet_tilt_y", movements.tilt_y);
|
||||||
@@ -327,7 +328,7 @@ tablet_device::tablet_device(BSerialPort *port)
|
|||||||
serial = port;
|
serial = port;
|
||||||
device_watcher = -1;
|
device_watcher = -1;
|
||||||
active = false;
|
active = false;
|
||||||
device_ref.name = strdup("Genius EasyPen");
|
device_ref.name = strdup(kDeviceName);
|
||||||
device_ref.type = B_POINTING_DEVICE;
|
device_ref.type = B_POINTING_DEVICE;
|
||||||
device_ref.cookie = this;
|
device_ref.cookie = this;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -555,14 +555,12 @@ MouseDevice::_UpdateSettings()
|
|||||||
MD_CALLED();
|
MD_CALLED();
|
||||||
// retrieve current values
|
// retrieve current values
|
||||||
|
|
||||||
if (get_mouse_map(&fSettings.map) != B_OK)
|
if (get_mouse_map(fDeviceRef.name, &fSettings.map) != B_OK)
|
||||||
LOG_ERR("error when get_mouse_map\n");
|
LOG_ERR("error when get_mouse_map\n");
|
||||||
else {
|
else
|
||||||
fDeviceRemapsButtons
|
fDeviceRemapsButtons = ioctl(fDevice, MS_SET_MAP, &fSettings.map) == B_OK;
|
||||||
= ioctl(fDevice, MS_SET_MAP, &fSettings.map) == B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_click_speed(&fSettings.click_speed) == B_OK) {
|
if (get_click_speed(fDeviceRef.name, &fSettings.click_speed) == B_OK) {
|
||||||
if (fIsTouchpad)
|
if (fIsTouchpad)
|
||||||
fTouchpadMovementMaker.click_speed = fSettings.click_speed;
|
fTouchpadMovementMaker.click_speed = fSettings.click_speed;
|
||||||
ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed);
|
ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed);
|
||||||
|
|||||||
@@ -118,25 +118,23 @@ MouseInputDevice::InitFromSettings(void* cookie, uint32 opcode)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
mouse_device* device = (mouse_device*) cookie;
|
mouse_device* device = (mouse_device*) cookie;
|
||||||
|
const char* name = device->device_ref.name;
|
||||||
|
|
||||||
// retrieve current values.
|
// retrieve current values.
|
||||||
// TODO: shouldn't we use sane values if we get errors here?
|
// TODO: shouldn't we use sane values if we get errors here?
|
||||||
|
|
||||||
if (get_mouse_map(&device->settings.map) != B_OK)
|
if (get_mouse_map(name, &device->settings.map) != B_OK)
|
||||||
LOG_ERR("error when get_mouse_map\n");
|
LOG_ERR("error when get_mouse_map\n");
|
||||||
|
|
||||||
if (get_click_speed(&device->settings.click_speed) != B_OK)
|
if (get_click_speed(name, &device->settings.click_speed) != B_OK)
|
||||||
LOG_ERR("error when get_click_speed\n");
|
LOG_ERR("error when get_click_speed\n");
|
||||||
|
|
||||||
if (get_mouse_speed(&device->settings.accel.speed) != B_OK)
|
if (get_mouse_speed(name, &device->settings.accel.speed) != B_OK)
|
||||||
LOG_ERR("error when get_mouse_speed\n");
|
LOG_ERR("error when get_mouse_speed\n");
|
||||||
else
|
else if (get_mouse_acceleration(name, &device->settings.accel.accel_factor) != B_OK)
|
||||||
{
|
LOG_ERR("error when get_mouse_acceleration\n");
|
||||||
if (get_mouse_acceleration(&device->settings.accel.accel_factor) != B_OK)
|
|
||||||
LOG_ERR("error when get_mouse_acceleration\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (get_mouse_type(&device->settings.type) != B_OK)
|
if (get_mouse_type(name, &device->settings.type) != B_OK)
|
||||||
LOG_ERR("error when get_mouse_type\n");
|
LOG_ERR("error when get_mouse_type\n");
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ TabletDevice::_UpdateSettings()
|
|||||||
{
|
{
|
||||||
TD_CALLED();
|
TD_CALLED();
|
||||||
|
|
||||||
if (get_click_speed(&fSettings.click_speed) != B_OK)
|
if (get_click_speed(fDeviceRef.name, &fSettings.click_speed) != B_OK)
|
||||||
LOG_ERR("error when get_click_speed\n");
|
LOG_ERR("error when get_click_speed\n");
|
||||||
else
|
else
|
||||||
ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed, sizeof(bigtime_t));
|
ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed, sizeof(bigtime_t));
|
||||||
|
|||||||
@@ -637,7 +637,7 @@ TabletHandler::Reset()
|
|||||||
fLastClick = -1;
|
fLastClick = -1;
|
||||||
fLastClickBtn = -1;
|
fLastClickBtn = -1;
|
||||||
|
|
||||||
get_click_speed(&fClickSpeed);
|
get_click_speed(Ref()->name, &fClickSpeed);
|
||||||
TRACE(" fClickSpeed: %" B_PRIdBIGTIME "\n", fClickSpeed);
|
TRACE(" fClickSpeed: %" B_PRIdBIGTIME "\n", fClickSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,7 +647,7 @@ TabletHandler::Control(uint32 command, BMessage* message)
|
|||||||
{
|
{
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case B_CLICK_SPEED_CHANGED: {
|
case B_CLICK_SPEED_CHANGED: {
|
||||||
get_click_speed(&fClickSpeed);
|
get_click_speed(Ref()->name, &fClickSpeed);
|
||||||
TRACE(" fClickSpeed: %" B_PRIdBIGTIME "\n", fClickSpeed);
|
TRACE(" fClickSpeed: %" B_PRIdBIGTIME "\n", fClickSpeed);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
static const char* kWatchFolder = "input/wacom/usb";
|
static const char* kWatchFolder = "input/wacom/usb";
|
||||||
static const char* kDeviceFolder = "/dev/input/wacom/usb";
|
static const char* kDeviceFolder = "/dev/input/wacom/usb";
|
||||||
|
static const char* kDeviceName = "Wacom Tablet";
|
||||||
|
|
||||||
//static const char* kPS2MouseThreadName = "PS/2 Mouse";
|
//static const char* kPS2MouseThreadName = "PS/2 Mouse";
|
||||||
|
|
||||||
@@ -48,9 +49,9 @@ MasterServerDevice::MasterServerDevice()
|
|||||||
fPS2DisablerThread(B_ERROR),
|
fPS2DisablerThread(B_ERROR),
|
||||||
fDeviceLock("device list lock")
|
fDeviceLock("device list lock")
|
||||||
{
|
{
|
||||||
get_mouse_speed(&fSpeed);
|
get_mouse_speed(kDeviceName, &fSpeed);
|
||||||
get_mouse_acceleration(&fAcceleration);
|
get_mouse_acceleration(kDeviceName, &fAcceleration);
|
||||||
get_click_speed(&fDblClickSpeed);
|
get_click_speed(kDeviceName, &fDblClickSpeed);
|
||||||
_CalculateAccelerationTable();
|
_CalculateAccelerationTable();
|
||||||
|
|
||||||
if (_LockDevices()) {
|
if (_LockDevices()) {
|
||||||
@@ -141,7 +142,7 @@ MasterServerDevice::Control(const char* device, void* cookie, uint32 code, BMess
|
|||||||
_CalculateAccelerationTable();
|
_CalculateAccelerationTable();
|
||||||
break;
|
break;
|
||||||
case B_CLICK_SPEED_CHANGED:
|
case B_CLICK_SPEED_CHANGED:
|
||||||
get_click_speed(&fDblClickSpeed);
|
get_click_speed(device, &fDblClickSpeed);
|
||||||
break;
|
break;
|
||||||
case B_MOUSE_ACCELERATION_CHANGED:
|
case B_MOUSE_ACCELERATION_CHANGED:
|
||||||
get_mouse_acceleration(device, &fAcceleration);
|
get_mouse_acceleration(device, &fAcceleration);
|
||||||
@@ -215,8 +216,7 @@ MasterServerDevice::_AddDevice(const char* path)
|
|||||||
// start device polling only if we're started
|
// start device polling only if we're started
|
||||||
if (fActive)
|
if (fActive)
|
||||||
device->Start();
|
device->Start();
|
||||||
input_device_ref device = { (char *)"Wacom Tablet",
|
input_device_ref device = { (char*)kDeviceName, B_POINTING_DEVICE, (void*)this };
|
||||||
B_POINTING_DEVICE, (void*)this };
|
|
||||||
input_device_ref* deviceList[2] = { &device, NULL };
|
input_device_ref* deviceList[2] = { &device, NULL };
|
||||||
RegisterDevices(deviceList);
|
RegisterDevices(deviceList);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -582,33 +582,48 @@ set_mouse_type(const char* mouse_name, int32 type)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_mouse_map(mouse_map *map)
|
get_mouse_map(mouse_map* map)
|
||||||
|
{
|
||||||
|
return get_mouse_map("", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
set_mouse_map(mouse_map* map)
|
||||||
|
{
|
||||||
|
return set_mouse_map("", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
get_mouse_map(const char* mouse_name, mouse_map* map)
|
||||||
{
|
{
|
||||||
BMessage command(IS_GET_MOUSE_MAP);
|
BMessage command(IS_GET_MOUSE_MAP);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
const void *data = 0;
|
const void *data = 0;
|
||||||
ssize_t count;
|
ssize_t count;
|
||||||
|
|
||||||
status_t err = _control_input_server_(&command, &reply);
|
status_t err = command.AddString("mouse_name", mouse_name);
|
||||||
|
if (err == B_OK)
|
||||||
|
err = _control_input_server_(&command, &reply);
|
||||||
if (err == B_OK)
|
if (err == B_OK)
|
||||||
err = reply.FindData("mousemap", B_RAW_TYPE, &data, &count);
|
err = reply.FindData("mousemap", B_RAW_TYPE, &data, &count);
|
||||||
if (err != B_OK)
|
if (err == B_OK)
|
||||||
return err;
|
memcpy(map, data, count);
|
||||||
|
|
||||||
memcpy(map, data, count);
|
return err;
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
set_mouse_map(mouse_map *map)
|
set_mouse_map(const char* mouse_name, mouse_map* map)
|
||||||
{
|
{
|
||||||
BMessage command(IS_SET_MOUSE_MAP);
|
BMessage command(IS_SET_MOUSE_MAP);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
|
|
||||||
status_t err = command.AddData("mousemap", B_RAW_TYPE, map,
|
status_t err = command.AddString("mouse_name", mouse_name);
|
||||||
sizeof(mouse_map));
|
if (err == B_OK)
|
||||||
|
err = command.AddData("mousemap", B_RAW_TYPE, map, sizeof(mouse_map));
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
@@ -616,12 +631,28 @@ set_mouse_map(mouse_map *map)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
get_click_speed(bigtime_t *speed)
|
get_click_speed(bigtime_t* speed)
|
||||||
|
{
|
||||||
|
return get_click_speed("", speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
set_click_speed(bigtime_t speed)
|
||||||
|
{
|
||||||
|
return set_click_speed("", speed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
get_click_speed(const char* mouse_name, bigtime_t* speed)
|
||||||
{
|
{
|
||||||
BMessage command(IS_GET_CLICK_SPEED);
|
BMessage command(IS_GET_CLICK_SPEED);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
|
|
||||||
status_t err = _control_input_server_(&command, &reply);
|
status_t err = command.AddString("mouse_name", mouse_name);
|
||||||
|
if (err == B_OK)
|
||||||
|
err = _control_input_server_(&command, &reply);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
@@ -633,11 +664,16 @@ get_click_speed(bigtime_t *speed)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
set_click_speed(bigtime_t speed)
|
set_click_speed(const char* mouse_name, bigtime_t speed)
|
||||||
{
|
{
|
||||||
BMessage command(IS_SET_CLICK_SPEED);
|
BMessage command(IS_SET_CLICK_SPEED);
|
||||||
BMessage reply;
|
BMessage reply;
|
||||||
command.AddInt64("speed", speed);
|
|
||||||
|
status_t err = command.AddString("mouse_name", mouse_name);
|
||||||
|
if (err == B_OK)
|
||||||
|
err = command.AddInt64("speed", speed);
|
||||||
|
if (err != B_OK)
|
||||||
|
return err;
|
||||||
return _control_input_server_(&command, &reply);
|
return _control_input_server_(&command, &reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,9 @@ status_t
|
|||||||
MouseSettings::_RetrieveSettings()
|
MouseSettings::_RetrieveSettings()
|
||||||
{
|
{
|
||||||
// retrieve current values
|
// retrieve current values
|
||||||
if (get_mouse_map(&fSettings.map) != B_OK)
|
if (get_mouse_map(fName, &fSettings.map) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
if (get_click_speed(&fSettings.click_speed) != B_OK)
|
if (get_click_speed(fName, &fSettings.click_speed) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
if (get_mouse_speed(fName, &fSettings.accel.speed) != B_OK)
|
if (get_mouse_speed(fName, &fSettings.accel.speed) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -73,15 +73,8 @@ MouseSettings::Defaults()
|
|||||||
SetAcceptFirstClick(kDefaultAcceptFirstClick);
|
SetAcceptFirstClick(kDefaultAcceptFirstClick);
|
||||||
|
|
||||||
mouse_map map;
|
mouse_map map;
|
||||||
if (get_mouse_map(&map) != B_OK) {
|
for (int i = 0; i < B_MAX_MOUSE_BUTTONS; i++)
|
||||||
// Set some default values
|
map.button[i] = B_MOUSE_BUTTON(i + 1);
|
||||||
map.button[0] = B_PRIMARY_MOUSE_BUTTON;
|
|
||||||
map.button[1] = B_SECONDARY_MOUSE_BUTTON;
|
|
||||||
map.button[2] = B_TERTIARY_MOUSE_BUTTON;
|
|
||||||
map.button[3] = B_MOUSE_BUTTON(4);
|
|
||||||
map.button[4] = B_MOUSE_BUTTON(5);
|
|
||||||
map.button[5] = B_MOUSE_BUTTON(6);
|
|
||||||
}
|
|
||||||
SetMapping(map);
|
SetMapping(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +153,7 @@ MouseSettings::ClickSpeed() const
|
|||||||
void
|
void
|
||||||
MouseSettings::SetClickSpeed(bigtime_t clickSpeed)
|
MouseSettings::SetClickSpeed(bigtime_t clickSpeed)
|
||||||
{
|
{
|
||||||
if (set_click_speed(clickSpeed) == B_OK)
|
if (set_click_speed(fName, clickSpeed) == B_OK)
|
||||||
fSettings.click_speed = clickSpeed;
|
fSettings.click_speed = clickSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,14 +192,14 @@ void
|
|||||||
MouseSettings::SetMapping(int32 index, uint32 button)
|
MouseSettings::SetMapping(int32 index, uint32 button)
|
||||||
{
|
{
|
||||||
fSettings.map.button[index] = button;
|
fSettings.map.button[index] = button;
|
||||||
set_mouse_map(&fSettings.map);
|
set_mouse_map(fName, &fSettings.map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MouseSettings::SetMapping(mouse_map& map)
|
MouseSettings::SetMapping(mouse_map& map)
|
||||||
{
|
{
|
||||||
if (set_mouse_map(&map) == B_OK)
|
if (set_mouse_map(fName, &map) == B_OK)
|
||||||
fSettings.map = map;
|
fSettings.map = map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user