};
static int idle_timeout = 0;
-static bool uhid_enabled = true;
+static uhid_state_t uhid_state = UHID_ENABLED;
static bool classic_bonded_only = true;
void input_set_idle_timeout(int timeout)
idle_timeout = timeout;
}
-void input_enable_userspace_hid(bool state)
+void input_set_userspace_hid(char *state)
{
- uhid_enabled = state;
+ if (!strcasecmp(state, "false") || !strcasecmp(state, "no") ||
+ !strcasecmp(state, "off"))
+ uhid_state = UHID_DISABLED;
+ else if (!strcasecmp(state, "true") || !strcasecmp(state, "yes") ||
+ !strcasecmp(state, "on"))
+ uhid_state = UHID_ENABLED;
+ else if (!strcasecmp(state, "persist"))
+ uhid_state = UHID_PERSIST;
+ else
+ error("Unknown value '%s'", state);
+}
+
+uint8_t input_get_userspace_hid(void)
+{
+ return uhid_state;
}
void input_set_classic_bonded_only(bool state)
if (idev->virtual_cable_unplug && !force)
force = true;
+ if (!force && uhid_state != UHID_PERSIST)
+ force = true;
+
err = bt_uhid_destroy(idev->uhid, force);
if (err < 0) {
error("bt_uhid_destroy: %s", strerror(-err));
if (!idev)
return -EINVAL;
- if (uhid_enabled) {
+ if (uhid_state) {
idev->uhid = bt_uhid_new_default();
if (!idev->uhid) {
error("bt_uhid_new_default: failed");
if (!idev)
return -ENOENT;
- if (uhid_enabled)
+ if (uhid_state)
cond |= G_IO_IN;
switch (psm) {
#define L2CAP_PSM_HIDP_CTRL 0x11
#define L2CAP_PSM_HIDP_INTR 0x13
+typedef enum {
+ UHID_DISABLED = 0,
+ UHID_ENABLED,
+ UHID_PERSIST
+} uhid_state_t;
+
struct input_device;
struct input_conn;
void input_set_idle_timeout(int timeout);
-void input_enable_userspace_hid(bool state);
+void input_set_userspace_hid(char *state);
+uint8_t input_get_userspace_hid(void);
void input_set_classic_bonded_only(bool state);
bool input_get_classic_bonded_only(void);
{
struct hog_device *dev = btd_service_get_user_data(service);
- bt_hog_detach(dev->hog, false);
+ if (input_get_userspace_hid() == UHID_PERSIST)
+ bt_hog_detach(dev->hog, false);
+ else
+ bt_hog_detach(dev->hog, true);
btd_service_disconnecting_complete(service, 0);
#IdleTimeout=0
# Enable HID protocol handling in userspace input profile
-# Defaults to true (Use UHID instead of kernel HIDP)
+# Possible values:
+# - persist: Use UHID in persistent mode (keyboard only)
+# - true: Use UHID instead
+# - false: User kernel HIDP
+# Defaults to true
#UserspaceHID=true
# Limit HID connections to bonded devices
config = load_config_file(CONFIGDIR "/input.conf");
if (config) {
int idle_timeout;
-#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
- gboolean uhid_enabled, classic_bonded_only;
-#else
- gboolean uhid_enabled, classic_bonded_only, auto_sec;
+ char *uhid_enabled;
+ gboolean classic_bonded_only;
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ gboolean auto_sec;
#endif
idle_timeout = g_key_file_get_integer(config, "General",
"IdleTimeout", &err);
} else
g_clear_error(&err);
- uhid_enabled = g_key_file_get_boolean(config, "General",
+ uhid_enabled = g_key_file_get_string(config, "General",
"UserspaceHID", &err);
if (!err) {
- DBG("input.conf: UserspaceHID=%s", uhid_enabled ?
- "true" : "false");
- input_enable_userspace_hid(uhid_enabled);
+ DBG("input.conf: UserspaceHID=%s", uhid_enabled);
+ input_set_userspace_hid(uhid_enabled);
+ free(uhid_enabled);
} else
g_clear_error(&err);