#define VIBRATION_CONF_PATH FEEDBACK_BASE_PATH"vibration.conf"
#define HAPTIC_CONF_PATH "/etc/feedbackd/haptic.conf"
-#define SIGNAL_CHANGE_HARDKEY "ChangeHardkey"
#define SIGNAL_POWEROFF_STATE "ChangeState"
#define SIGNAL_VIBRATOR_INITIATED "InitiateVibrator"
return h_ops->close_device(g_handle);
}
-static void haptic_hardkey_changed_cb(GDBusConnection *conn,
- const gchar *sender,
- const gchar *path,
- const gchar *iface,
- const gchar *name,
- GVariant *param,
- gpointer data)
-{
- int level, status, ret;
-
- if (!CHECK_VALID_OPS(h_ops, ret)) {
- ret = haptic_module_load();
- if (ret < 0)
- return;
- }
-
- if (!g_handle)
- haptic_internal_init();
-
- /* if haptic is stopped, do not play vibration */
- if (haptic_disabled)
- return;
-
- if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &status) < 0) {
- _E("Failed to get VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL.");
- status = 1;
- }
-
- /* when turn off haptic feedback option */
- if (!status)
- return;
-
- ret = vconf_get_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &level);
- if (ret < 0) {
- _E("Failed to get VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT.");
- level = HARDKEY_VIB_FEEDBACK;
- }
-
- ret = h_ops->vibrate_monotone(g_handle, HARDKEY_VIB_DURATION,
- level*HAPTIC_FEEDBACK_STEP, PRIORITY_HIGH);
- if (ret < 0)
- _E("Failed to vibrate buffer: %d", ret);
-
- return;
-}
-
static void haptic_poweroff_cb(GDBusConnection *conn,
const gchar *sender,
const gchar *path,
return haptic_module_load();
}
-guint id_sig_change_hardkey;
guint id_sig_pwr_off_state;
void haptic_init(void)
if (r < 0)
_E("Failed to init hdbus interface and method: %d", r);
- /* register notifier for below each event */
- id_sig_change_hardkey = subscribe_dbus_signal(NULL, DEVICED_PATH_KEY, DEVICED_INTERFACE_KEY, SIGNAL_CHANGE_HARDKEY, haptic_hardkey_changed_cb, NULL, NULL);
- if (id_sig_change_hardkey <= 0) {
- _E("Failed to register signal handler: %d", r);
- return;
- }
-
id_sig_pwr_off_state = subscribe_dbus_signal(NULL, DEVICED_PATH_POWEROFF, DEVICED_INTERFACE_POWEROFF, SIGNAL_POWEROFF_STATE, haptic_poweroff_cb, NULL, NULL);
if (id_sig_pwr_off_state <= 0) {
_E("Failed to register signal handler: %d", r);
}
/* unregister notifier for below each event */
- unsubscribe_dbus_signal(NULL, id_sig_change_hardkey);
unsubscribe_dbus_signal(NULL, id_sig_pwr_off_state);
/* release haptic data memory */