From Preetpal Kaur <preetpalok123@xxxxxxxxx>:
Preetpal Kaur has uploaded this change for review. (
https://review.haiku-os.org/c/haiku/+/3039 ;)
Change subject: WIP: Update thr Input_Server files to get the settings working
......................................................................
WIP: Update thr Input_Server files to get the settings working
Change-Id: I3d9880935990e671e6f98ff1895edc1e448000e0
---
M headers/os/interface/InterfaceDefs.h
M src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp
M src/kits/interface/InterfaceDefs.cpp
M src/preferences/input/MouseSettings.cpp
M src/preferences/input/MouseSettings.h
5 files changed, 156 insertions(+), 20 deletions(-)
git pull ssh://git.haiku-os.org:22/haiku refs/changes/39/3039/1
diff --git a/headers/os/interface/InterfaceDefs.h
b/headers/os/interface/InterfaceDefs.h
index 3b66e1a..df5456a 100644
--- a/headers/os/interface/InterfaceDefs.h
+++ b/headers/os/interface/InterfaceDefs.h
@@ -417,8 +417,8 @@
status_t get_scroll_bar_info(scroll_bar_info* info);
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(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);
diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp
b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp
index e4960d3..d914e09 100644
--- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp
+++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp
@@ -32,6 +32,7 @@
#include <kb_mouse_settings.h>
#include <keyboard_mouse_driver.h>
+#include <MouseSettings.h>
#include <touchpad_settings.h>
@@ -88,6 +89,7 @@
# define MID_CALLED(x...) TRACE(x)
# define LOG_ERR(x...) debug_printf(x)
# define LOG_EVENT(x...) TRACE(x)
+# define LOG_CRIT(x...) debug_printf(x)
#endif
@@ -176,6 +178,8 @@
fTouchpadSettingsMessage(NULL),
fTouchpadSettingsLock("Touchpad settings lock")
{
+ LOG_CRIT("MYLOG: MouseDevice\n");
+
MD_CALLED();
fDeviceRef.name = _BuildShortName();
@@ -191,6 +195,9 @@
MouseDevice::~MouseDevice()
{
+ LOG_CRIT("MYLOG: ~MouseDevice\n");
+
+
MD_CALLED();
TRACE("delete\n");
@@ -205,6 +212,9 @@
status_t
MouseDevice::Start()
{
+ LOG_CRIT("MYLOG: Start\n");
+
+
MD_CALLED();
fDevice = open(fPath.String(), O_RDWR);
@@ -240,6 +250,9 @@
void
MouseDevice::Stop()
{
+ LOG_CRIT("MYLOG: Stop\n");
+
+
MD_CALLED();
fActive = false;
@@ -262,6 +275,9 @@
status_t
MouseDevice::UpdateSettings()
{
+ LOG_CRIT("MYLOG: UpdateSettings\n");
+
+
MD_CALLED();
if (fThread < 0)
@@ -299,6 +315,9 @@
char*
MouseDevice::_BuildShortName() const
{
+ LOG_CRIT("MYLOG: _BuildShortName(\n");
+
+
// TODO It would be simpler and better to use B_GET_DEVICE_NAME, but...
// - This is currently called before the device is open
// - We need to implement that in our input drivers first
@@ -349,6 +368,8 @@
status_t
MouseDevice::_ControlThreadEntry(void* arg)
{
+ LOG_CRIT("MYLOG: _ControlThreadEntry\n");
+
MouseDevice* device = (MouseDevice*)arg;
device->_ControlThread();
return B_OK;
@@ -358,6 +379,8 @@
void
MouseDevice::_ControlThread()
{
+ LOG_CRIT("MYLOG: _ControlThread\n");
+
MD_CALLED();
if (fDevice < 0) {
@@ -495,6 +518,8 @@
void
MouseDevice::_ControlThreadCleanup()
{
+ LOG_CRIT("MYLOG: _ControlThreadCleanUp\n");
+
// NOTE: Only executed when the control thread detected an error
// and from within the control thread!
@@ -514,40 +539,80 @@
void
MouseDevice::_UpdateSettings()
{
+ LOG_CRIT("MYLOG: _UpdateSettings\n");
+
+ LOG_CRIT("MYLOG: %d Mouse Type Before update: \n",
get_mouse_type(fDeviceRef.name, &fSettings.type) );
+
MD_CALLED();
+ LOG_CRIT("MYLOG: %d After MD_CALLED Before update: \n",
get_mouse_type(fDeviceRef.name , &fSettings.type) );
+
+
// retrieve current values
if (get_mouse_map(&fSettings.map) != B_OK)
+ {
LOG_ERR("error when get_mouse_map\n");
- else {
+ LOG_CRIT("MYLOG: %s: %d (IF) MAP update \n",
_BuildShortName(),fSettings.type);
+
+ }
+ else
+ {
fDeviceRemapsButtons
= ioctl(fDevice, MS_SET_MAP, &fSettings.map) == B_OK;
+ LOG_CRIT("MYLOG: %s: %d (ELSE) MAP update \n",
_BuildShortName(),fSettings.type);
}
if (get_click_speed(&fSettings.click_speed) != B_OK)
+ {
LOG_ERR("error when get_click_speed\n");
+ LOG_CRIT("MYLOG: %s: %d (IF) CLICK_SPEED update \n",
_BuildShortName(),fSettings.type);
+ }
else
+ {
ioctl(fDevice, MS_SET_CLICKSPEED, &fSettings.click_speed);
+ LOG_CRIT("MYLOG: %s: %d (ELSE) CLICK_SPEED update \n",
_BuildShortName(),fSettings.type);
+
+ }
if (get_mouse_speed(&fSettings.accel.speed) != B_OK)
+ {
LOG_ERR("error when get_mouse_speed\n");
- else {
+ LOG_CRIT("MYLOG: %s: %d (IF) SPEED update \n",
_BuildShortName(),fSettings.type);
+ }
+ else
+ {
if (get_mouse_acceleration(&fSettings.accel.accel_factor) !=
B_OK)
+ {
LOG_ERR("error when get_mouse_acceleration\n");
- else {
+ LOG_CRIT("MYLOG: %s: %d (ELSE) (IF) ACCEL FACTOR
update \n", _BuildShortName(),fSettings.type);
+ }
+ else
+ {
mouse_accel accel;
ioctl(fDevice, MS_GET_ACCEL, &accel);
accel.speed = fSettings.accel.speed;
accel.accel_factor = fSettings.accel.accel_factor;
ioctl(fDevice, MS_SET_ACCEL, &fSettings.accel);
+
+ LOG_CRIT("MYLOG: %s: %d (ELSE) (IF) (ELSE) ACCEL
FACTOR update \n", _BuildShortName(),fSettings.type);
+
}
}
+ LOG_CRIT("MYLOG: %s: %d Before update \n",
_BuildShortName(),fSettings.type );
- if (get_mouse_type(&fSettings.type) != B_OK)
+ if (get_mouse_type(fDeviceRef.name , &fSettings.type) != B_OK)
+ {
+ LOG_CRIT("MYLOG: %s: %d (IF) TYPE update \n",
_BuildShortName(),fSettings.type );
+
LOG_ERR("error when get_mouse_type\n");
+ }
else
+ {
ioctl(fDevice, MS_SET_TYPE, &fSettings.type);
+ LOG_CRIT("MYLOG: %s: %d (ELSE) TYPE update \n",
_BuildShortName(),fSettings.type );
+
+ }
}
@@ -600,6 +665,9 @@
MouseDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons,
int32 deltaX, int32 deltaY) const
{
+ LOG_CRIT("MYLOG: _BuildMessage\n");
+
+
BMessage* message = new BMessage(what);
if (message == NULL)
return NULL;
@@ -687,6 +755,9 @@
fDevices(2, true),
fDeviceListLock("MouseInputDevice list")
{
+ LOG_CRIT("MYLOG: MouseInputDevices\n");
+
+
MID_CALLED();
StartMonitoringDevice(kMouseDevicesDirectory);
@@ -698,6 +769,9 @@
MouseInputDevice::~MouseInputDevice()
{
+ LOG_CRIT("MYLOG: ~MouseInputDevices\n");
+
+
MID_CALLED();
StopMonitoringDevice(kTouchpadDevicesDirectory);
@@ -709,6 +783,9 @@
status_t
MouseInputDevice::InitCheck()
{
+ LOG_CRIT("MYLOG: InitCheck\n");
+
+
MID_CALLED();
return BInputServerDevice::InitCheck();
@@ -718,6 +795,9 @@
status_t
MouseInputDevice::Start(const char* name, void* cookie)
{
+ LOG_CRIT("MYLOG: Start\n");
+
+
MID_CALLED();
MouseDevice* device = (MouseDevice*)cookie;
@@ -729,6 +809,9 @@
status_t
MouseInputDevice::Stop(const char* name, void* cookie)
{
+
+ LOG_CRIT("MYLOG: Stop\n");
+
TRACE("%s(%s)\n", __PRETTY_FUNCTION__, name);
MouseDevice* device = (MouseDevice*)cookie;
@@ -742,6 +825,10 @@
MouseInputDevice::Control(const char* name, void* cookie,
uint32 command, BMessage* message)
{
+ LOG_CRIT("MYLOG: Control\n");
+
+ LOG_CRIT("MYLOG: %s: NAME\n", name);
+
TRACE("%s(%s, code: %lu)\n", __PRETTY_FUNCTION__, name, command);
MouseDevice* device = (MouseDevice*)cookie;
@@ -763,6 +850,8 @@
status_t
MouseInputDevice::_HandleMonitor(BMessage* message)
{
+ LOG_CRIT("MYLOG: _HandleMonitor\n");
+
MID_CALLED();
const char* path;
@@ -787,6 +876,9 @@
void
MouseInputDevice::_RecursiveScan(const char* directory)
{
+ LOG_CRIT("MYLOG: _RecursiveScan\n");
+
+
MID_CALLED();
BEntry entry;
@@ -811,6 +903,9 @@
MouseDevice*
MouseInputDevice::_FindDevice(const char* path) const
{
+ LOG_CRIT("MYLOG: _FindDevice\n");
+
+
MID_CALLED();
for (int32 i = fDevices.CountItems() - 1; i >= 0; i--) {
@@ -826,6 +921,8 @@
status_t
MouseInputDevice::_AddDevice(const char* path)
{
+ LOG_CRIT("MYLOG: _AddDevice\n");
+
MID_CALLED();
BAutolock _(fDeviceListLock);
@@ -848,6 +945,8 @@
devices[0] = device->DeviceRef();
devices[1] = NULL;
+// LOG_CRIT("MYLOG: %c \n DEVICES: ", device->DeviceRef());
+
TRACE("adding path: %s, name: %s\n", path, devices[0]->name);
return RegisterDevices(devices);
@@ -857,6 +956,8 @@
status_t
MouseInputDevice::_RemoveDevice(const char* path)
{
+ LOG_CRIT("MYLOG: _RemoveDevice\n");
+
MID_CALLED();
BAutolock _(fDeviceListLock);
diff --git a/src/kits/interface/InterfaceDefs.cpp
b/src/kits/interface/InterfaceDefs.cpp
index c57ea88..16d9fa5 100644
--- a/src/kits/interface/InterfaceDefs.cpp
+++ b/src/kits/interface/InterfaceDefs.cpp
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <cstring>
+
#include <Bitmap.h>
#include <Clipboard.h>
@@ -54,6 +56,7 @@
#include <WidthBuffer.h>
#include <WindowInfo.h>
+#include <syslog.h>
using namespace BPrivate;
@@ -479,25 +482,38 @@
status_t
-get_mouse_type(int32 *type)
+get_mouse_type(const char* mouse_name, int32 *type)
{
+ fprintf(stderr, "MYLOG_SEE: get working\n");
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);
+
+ // TODO: Find some better way for concate
+ char s[200];
+ std::strcpy(s, mouse_name);
+ std::strcat(s, ":mouse_type");
+
+ return reply.FindInt32(s, type);
}
status_t
-set_mouse_type(int32 type)
+set_mouse_type(const char* mouse_name, int32 type)
{
+ fprintf(stderr, "MYLOG_SEE: set working type: %d\n", type);
BMessage command(IS_SET_MOUSE_TYPE);
BMessage reply;
- status_t err = command.AddInt32("mouse_type", type);
+ // TODO: Find some better way for concate
+ char s[200];
+ std::strcpy(s, mouse_name);
+ std::strcat(s, ":mouse_type");
+
+ status_t err = command.AddInt32(s, type);
if (err != B_OK)
return err;
return _control_input_server_(&command, &reply);
@@ -507,6 +523,8 @@
status_t
get_mouse_map(mouse_map *map)
{
+ fprintf(stderr, "MYLOG_SEE: working\n");
+ syslog(LOG_CRIT, "MYLOG_SEE: working\n");
BMessage command(IS_GET_MOUSE_MAP);
BMessage reply;
const void *data = 0;
@@ -518,6 +536,13 @@
if (err != B_OK)
return err;
+ int i = 0;
+ BString deviceName;
+ while (reply.FindString("mouseDevice", i, &deviceName) == B_OK) {
+ syslog(LOG_CRIT, "MYLOG_SEE: %s\n", deviceName);
+ i++;
+ }
+
memcpy(map, data, count);
return B_OK;
diff --git a/src/preferences/input/MouseSettings.cpp
b/src/preferences/input/MouseSettings.cpp
index 971383c..32c52ad 100644
--- a/src/preferences/input/MouseSettings.cpp
+++ b/src/preferences/input/MouseSettings.cpp
@@ -29,10 +29,12 @@
static const bool kDefaultAcceptFirstClick = true;
-MouseSettings::MouseSettings()
+MouseSettings::MouseSettings(BString name)
:
fWindowPosition(-1, -1)
{
+ fname = name;
+ fprintf(stderr, "MYLOG_PREF: name %s\n", fname.String());
_RetrieveSettings();
fOriginalSettings = fSettings;
@@ -41,10 +43,11 @@
fOriginalAcceptFirstClick = fAcceptFirstClick;
}
-MouseSettings::MouseSettings(mouse_settings settings)
+MouseSettings::MouseSettings(mouse_settings settings, BString name)
:
fSettings(settings)
{
+ fname = name;
#ifdef DEBUG
Dump();
@@ -59,6 +62,7 @@
MouseSettings::~MouseSettings()
{
+ fprintf(stderr, "MYLOG_PREF: destructure %s\n", fname.String());
}
@@ -87,7 +91,7 @@
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)
+ if (get_mouse_type(fname.String(), &fSettings.type) != B_OK)
fprintf(stderr, "error when get_mouse_type\n");
fMode = mouse_mode();
@@ -265,7 +269,9 @@
void
MouseSettings::SetMouseType(int32 type)
{
- if (set_mouse_type(type) == B_OK)
+
+ fprintf(stderr, "MYLOG_SEE: set working before type: %d\n", type);
+ if (set_mouse_type(fname.String(), type) == B_OK)
fSettings.type = type;
else
fprintf(stderr, "error when set_mouse_type\n");
@@ -439,7 +445,7 @@
while (message.FindString("mouseDevice", i, &deviceName) ==
B_OK) {
message.FindData("mouseSettings", B_ANY_TYPE, i,
(const void**)&settings, &size);
- MouseSettings* mouseSettings = new
MouseSettings(*settings);
+ MouseSettings* mouseSettings = new
MouseSettings(*settings, deviceName);
fMouseSettingsObject.insert(std::pair<BString,
MouseSettings*>
(deviceName, mouseSettings));
i++;
@@ -449,7 +455,8 @@
else {
IsRetrievedSettingsDeprecated = true;
- fDeprecatedMouseSettings = new MouseSettings();
+ BString* s = new BString("");
+ fDeprecatedMouseSettings = new MouseSettings(*s);
fDeprecatedMouseSettings->_RetrieveSettings();
}
}
@@ -528,6 +535,7 @@
(*fDeprecatedMouseSettings);
if (RetrievedSettings != NULL) {
+ RetrievedSettings->fname = mouse_name; // TODO
fMouseSettingsObject.insert(std::pair<BString,
MouseSettings*>
(mouse_name, RetrievedSettings));
@@ -541,7 +549,7 @@
if (itr != fMouseSettingsObject.end())
return GetMouseSettings(mouse_name);
- MouseSettings* settings = new (std::nothrow) MouseSettings();
+ MouseSettings* settings = new (std::nothrow) MouseSettings(mouse_name);
if(settings !=NULL) {
fMouseSettingsObject.insert(std::pair<BString, MouseSettings*>
diff --git a/src/preferences/input/MouseSettings.h
b/src/preferences/input/MouseSettings.h
index 96459d6..cc80410 100644
--- a/src/preferences/input/MouseSettings.h
+++ b/src/preferences/input/MouseSettings.h
@@ -19,16 +19,18 @@
#include <InterfaceDefs.h>
#include <Point.h>
#include <SupportDefs.h>
+#include <String.h>
#include "kb_mouse_settings.h"
-
class BPath;
class MouseSettings {
public:
- MouseSettings();
- MouseSettings(mouse_settings settings);
+ // TODO: declare in fname in private and define its method
+ BString fname;
+ MouseSettings(BString name);
+ MouseSettings(mouse_settings settings, BString name);
~MouseSettings();
void Revert();
--
To view, visit https://review.haiku-os.org/c/haiku/+/3039
To unsubscribe, or for help writing mail filters, visit
https://review.haiku-os.org/settings
Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: I3d9880935990e671e6f98ff1895edc1e448000e0
Gerrit-Change-Number: 3039
Gerrit-PatchSet: 1
Gerrit-Owner: Preetpal Kaur <preetpalok123@xxxxxxxxx>
Gerrit-MessageType: newchange