diff --git a/docs/user/interface/InterfaceDefs.dox b/docs/user/interface/InterfaceDefs.dox index bd247de38f..ed1ee99dce 100644 --- a/docs/user/interface/InterfaceDefs.dox +++ b/docs/user/interface/InterfaceDefs.dox @@ -756,57 +756,157 @@ If there are multiple mouses connected, the number of buttons for one of 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) - \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) + \fn status_t get_mouse_type(const char* mouse_name, int32* type) \brief Get the number of buttons for a specific mouse. 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. 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) - \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. + + \deprecated Use \ref "get_mouse_speed(const char* mouse_name, int32* speed)" + instead. */ /*! - \fn status_t set_mouse_speed(int32 speed) - \brief Set the mouse speed - \deprecated use set_mouse_speed_by_name instead. + \fn status_t get_mouse_speed(const char* mouse_name, int32* speed) + \brief Get the mouse speed setting for a specific mouse. + + \since Haiku R1 */ /*! - \fn status_t get_mouse_speed_by_name(BString 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) + \fn status_t set_mouse_speed(const char* mouse_name, int32 speed) \brief Set the mouse speed for a specific mouse. 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 */ diff --git a/headers/os/interface/InterfaceDefs.h b/headers/os/interface/InterfaceDefs.h index 9c2a991720..231e43ef26 100644 --- a/headers/os/interface/InterfaceDefs.h +++ b/headers/os/interface/InterfaceDefs.h @@ -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(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 set_mouse_map(mouse_map* map); -status_t get_click_speed(bigtime_t* speed); -status_t set_click_speed(bigtime_t speed); +status_t get_mouse_map(mouse_map* map); // deprecated +status_t get_mouse_map(const char* mouse_name, mouse_map* map); +status_t set_mouse_map(mouse_map* map); // deprecated +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(const char* mouse_name, int32* speed); status_t set_mouse_speed(const char* mouse_name, int32 speed); diff --git a/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp b/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp index 55b80b21fe..0695e6e4c9 100644 --- a/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp +++ b/src/add-ons/input_server/devices/easypen/EasyPenInputDevice.cpp @@ -58,6 +58,7 @@ FILE *EasyPenInputDevice::sLogFile = NULL; #define CALLED() LOG("%s\n", __PRETTY_FUNCTION__) const static uint32 kTabletThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4; +const static char* kDeviceName = "Genius EasyPen"; struct tablet_device { tablet_device(BSerialPort *port); @@ -152,7 +153,7 @@ EasyPenInputDevice::InitCheck() LOG("Found %ld devices\n", fDevices.CountItems()); - get_click_speed(&fClickSpeed); + get_click_speed(kDeviceName, &fClickSpeed); 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); if (command == B_CLICK_SPEED_CHANGED) - get_click_speed(&fClickSpeed); + get_click_speed(kDeviceName, &fClickSpeed); return B_OK; } @@ -292,7 +293,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg) message->AddFloat("be:tablet_x", movements.xpos); message->AddFloat("be:tablet_y", movements.ypos); 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) { message->AddFloat("be:tablet_tilt_x", movements.tilt_x); message->AddFloat("be:tablet_tilt_y", movements.tilt_y); @@ -327,7 +328,7 @@ tablet_device::tablet_device(BSerialPort *port) serial = port; device_watcher = -1; active = false; - device_ref.name = strdup("Genius EasyPen"); + device_ref.name = strdup(kDeviceName); device_ref.type = B_POINTING_DEVICE; device_ref.cookie = this; }; diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp index a926355754..d2e5dff2f1 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp @@ -555,14 +555,12 @@ MouseDevice::_UpdateSettings() MD_CALLED(); // 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"); - else { - fDeviceRemapsButtons - = ioctl(fDevice, MS_SET_MAP, &fSettings.map) == B_OK; - } + else + fDeviceRemapsButtons = 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) fTouchpadMovementMaker.click_speed = fSettings.click_speed; ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed); diff --git a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp index ee3cadda74..ab355fb116 100644 --- a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp @@ -118,25 +118,23 @@ MouseInputDevice::InitFromSettings(void* cookie, uint32 opcode) { CALLED(); mouse_device* device = (mouse_device*) cookie; + const char* name = device->device_ref.name; // retrieve current values. // 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"); - 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"); - 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"); - else - { - if (get_mouse_acceleration(&device->settings.accel.accel_factor) != B_OK) - LOG_ERR("error when get_mouse_acceleration\n"); - } + else if (get_mouse_acceleration(name, &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"); return B_OK; diff --git a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp index 439da1a455..403d50c87d 100644 --- a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp +++ b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp @@ -415,7 +415,7 @@ TabletDevice::_UpdateSettings() { 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"); else ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed, sizeof(bigtime_t)); diff --git a/src/add-ons/input_server/devices/virtio/VirtioInputDevice.cpp b/src/add-ons/input_server/devices/virtio/VirtioInputDevice.cpp index 7ca2383228..f8378d5003 100644 --- a/src/add-ons/input_server/devices/virtio/VirtioInputDevice.cpp +++ b/src/add-ons/input_server/devices/virtio/VirtioInputDevice.cpp @@ -637,7 +637,7 @@ TabletHandler::Reset() fLastClick = -1; fLastClickBtn = -1; - get_click_speed(&fClickSpeed); + get_click_speed(Ref()->name, &fClickSpeed); TRACE(" fClickSpeed: %" B_PRIdBIGTIME "\n", fClickSpeed); } @@ -647,7 +647,7 @@ TabletHandler::Control(uint32 command, BMessage* message) { switch (command) { case B_CLICK_SPEED_CHANGED: { - get_click_speed(&fClickSpeed); + get_click_speed(Ref()->name, &fClickSpeed); TRACE(" fClickSpeed: %" B_PRIdBIGTIME "\n", fClickSpeed); return B_OK; } diff --git a/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp b/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp index c01df681c9..bbb9bef980 100644 --- a/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp +++ b/src/add-ons/input_server/devices/wacom/MasterServerDevice.cpp @@ -27,6 +27,7 @@ static const char* kWatchFolder = "input/wacom/usb"; static const char* kDeviceFolder = "/dev/input/wacom/usb"; +static const char* kDeviceName = "Wacom Tablet"; //static const char* kPS2MouseThreadName = "PS/2 Mouse"; @@ -48,9 +49,9 @@ MasterServerDevice::MasterServerDevice() fPS2DisablerThread(B_ERROR), fDeviceLock("device list lock") { - get_mouse_speed(&fSpeed); - get_mouse_acceleration(&fAcceleration); - get_click_speed(&fDblClickSpeed); + get_mouse_speed(kDeviceName, &fSpeed); + get_mouse_acceleration(kDeviceName, &fAcceleration); + get_click_speed(kDeviceName, &fDblClickSpeed); _CalculateAccelerationTable(); if (_LockDevices()) { @@ -141,7 +142,7 @@ MasterServerDevice::Control(const char* device, void* cookie, uint32 code, BMess _CalculateAccelerationTable(); break; case B_CLICK_SPEED_CHANGED: - get_click_speed(&fDblClickSpeed); + get_click_speed(device, &fDblClickSpeed); break; case B_MOUSE_ACCELERATION_CHANGED: get_mouse_acceleration(device, &fAcceleration); @@ -215,8 +216,7 @@ MasterServerDevice::_AddDevice(const char* path) // start device polling only if we're started if (fActive) device->Start(); - input_device_ref device = { (char *)"Wacom Tablet", - B_POINTING_DEVICE, (void*)this }; + input_device_ref device = { (char*)kDeviceName, B_POINTING_DEVICE, (void*)this }; input_device_ref* deviceList[2] = { &device, NULL }; RegisterDevices(deviceList); } else { diff --git a/src/kits/interface/InterfaceDefs.cpp b/src/kits/interface/InterfaceDefs.cpp index 97628450ee..0b57d431f1 100644 --- a/src/kits/interface/InterfaceDefs.cpp +++ b/src/kits/interface/InterfaceDefs.cpp @@ -582,33 +582,48 @@ set_mouse_type(const char* mouse_name, int32 type) 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 reply; const void *data = 0; 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) err = reply.FindData("mousemap", B_RAW_TYPE, &data, &count); - if (err != B_OK) - return err; + if (err == B_OK) + memcpy(map, data, count); - memcpy(map, data, count); - - return B_OK; + return err; } 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 reply; - status_t err = command.AddData("mousemap", B_RAW_TYPE, map, - sizeof(mouse_map)); + status_t err = command.AddString("mouse_name", mouse_name); + if (err == B_OK) + err = command.AddData("mousemap", B_RAW_TYPE, map, sizeof(mouse_map)); if (err != B_OK) return err; return _control_input_server_(&command, &reply); @@ -616,12 +631,28 @@ set_mouse_map(mouse_map *map) 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 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) return err; @@ -633,11 +664,16 @@ get_click_speed(bigtime_t *speed) 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 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); } diff --git a/src/preferences/input/MouseSettings.cpp b/src/preferences/input/MouseSettings.cpp index 53e9765a70..3926001733 100644 --- a/src/preferences/input/MouseSettings.cpp +++ b/src/preferences/input/MouseSettings.cpp @@ -41,9 +41,9 @@ status_t MouseSettings::_RetrieveSettings() { // retrieve current values - if (get_mouse_map(&fSettings.map) != B_OK) + if (get_mouse_map(fName, &fSettings.map) != B_OK) 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; if (get_mouse_speed(fName, &fSettings.accel.speed) != B_OK) return B_ERROR; @@ -73,15 +73,8 @@ MouseSettings::Defaults() SetAcceptFirstClick(kDefaultAcceptFirstClick); mouse_map map; - if (get_mouse_map(&map) != B_OK) { - // Set some default values - 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); - } + for (int i = 0; i < B_MAX_MOUSE_BUTTONS; i++) + map.button[i] = B_MOUSE_BUTTON(i + 1); SetMapping(map); } @@ -160,7 +153,7 @@ MouseSettings::ClickSpeed() const void MouseSettings::SetClickSpeed(bigtime_t clickSpeed) { - if (set_click_speed(clickSpeed) == B_OK) + if (set_click_speed(fName, clickSpeed) == B_OK) fSettings.click_speed = clickSpeed; } @@ -199,14 +192,14 @@ void MouseSettings::SetMapping(int32 index, uint32 button) { fSettings.map.button[index] = button; - set_mouse_map(&fSettings.map); + set_mouse_map(fName, &fSettings.map); } void MouseSettings::SetMapping(mouse_map& map) { - if (set_mouse_map(&map) == B_OK) + if (set_mouse_map(fName, &map) == B_OK) fSettings.map = map; }