diff --git a/profiles/input/device.c b/profiles/input/device.c
index 0688a02..b6f9028 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
}
static void input_device_enter_reconnect_mode(struct input_device *idev);
+static bool is_device_sdp_disable(const sdp_record_t *rec);
+static void extract_hid_props(struct input_device *idev,
+ const sdp_record_t *rec);
static const char *reconnect_mode_to_string(const enum reconnect_mode_t mode);
static struct input_device *find_device_by_path(GSList *list, const char *path)
}
static struct input_device *input_device_new(struct btd_device *device,
- const char *path, const uint32_t handle,
- bool disable_sdp)
+ struct btd_profile *p)
{
+ const char *path = device_get_path(device);
+ const sdp_record_t *rec = btd_device_get_record(device, p->remote_uuid);
struct btd_adapter *adapter = device_get_adapter(device);
struct input_device *idev;
char name[HCI_MAX_NAME_LENGTH + 1];
bacpy(&idev->dst, device_get_address(device));
idev->device = btd_device_ref(device);
idev->path = g_strdup(path);
- idev->handle = handle;
- idev->disable_sdp = disable_sdp;
+ idev->handle = rec->handle;
+ idev->disable_sdp = is_device_sdp_disable(rec);
device_get_name(device, name, HCI_MAX_NAME_LENGTH);
if (strlen(name) > 0)
idev->name = g_strdup(name);
+ /* Initialize device properties */
+ extract_hid_props(idev, rec);
+
return idev;
}
{ }
};
-int input_device_register(struct btd_device *device,
- const char *path, const char *uuid,
- const sdp_record_t *rec)
+int input_device_register(struct btd_profile *p, struct btd_device *device)
{
+ const char *path = device_get_path(device);
struct input_device *idev;
DBG("%s", path);
if (idev)
return -EEXIST;
- idev = input_device_new(device, path, rec->handle,
- is_device_sdp_disable(rec));
+ idev = input_device_new(device, p);
if (!idev)
return -EINVAL;
- /* Initialize device properties */
- extract_hid_props(idev, rec);
-
if (g_dbus_register_interface(btd_get_dbus_connection(),
idev->path, INPUT_INTERFACE,
NULL, NULL,
return NULL;
}
-void input_device_unregister(const char *path, const char *uuid)
+void input_device_unregister(struct btd_profile *p, struct btd_device *device)
{
+ const char *path = device_get_path(device);
struct input_device *idev;
DBG("%s", path);
diff --git a/profiles/input/device.h b/profiles/input/device.h
index 798b4b0..1c237fc 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
void input_set_idle_timeout(int timeout);
-int input_device_register(struct btd_device *device, const char *path,
- const char *uuid, const sdp_record_t *rec);
-void input_device_unregister(const char *path, const char *uuid);
+int input_device_register(struct btd_profile *p, struct btd_device *device);
+void input_device_unregister(struct btd_profile *p, struct btd_device *device);
int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm,
GIOChannel *io);
diff --git a/profiles/input/manager.c b/profiles/input/manager.c
index cdcabfe..51cd4cf 100644
--- a/profiles/input/manager.c
+++ b/profiles/input/manager.c
#include "server.h"
#include "manager.h"
-static void input_remove(struct btd_device *device, const char *uuid)
-{
- const char *path = device_get_path(device);
-
- DBG("path %s", path);
-
- input_device_unregister(path, uuid);
-}
-
-static int hid_device_probe(struct btd_profile *p, struct btd_device *device)
-{
- const char *path = device_get_path(device);
- const sdp_record_t *rec = btd_device_get_record(device, HID_UUID);
-
- DBG("path %s", path);
-
- if (!rec)
- return -1;
-
- return input_device_register(device, path, HID_UUID, rec);
-}
-
-static void hid_device_remove(struct btd_profile *p, struct btd_device *device)
-{
- input_remove(device, HID_UUID);
-}
-
static int hid_server_probe(struct btd_profile *p, struct btd_adapter *adapter)
{
return server_start(adapter_get_address(adapter));
.connect = input_device_connect,
.disconnect = input_device_disconnect,
- .device_probe = hid_device_probe,
- .device_remove = hid_device_remove,
+ .device_probe = input_device_register,
+ .device_remove = input_device_unregister,
.adapter_probe = hid_server_probe,
.adapter_remove = hid_server_remove,