mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
HID: haptic: add functions handling events
Implement hid_haptic_handle_press_release() which generates haptic feedback as well as saves the pressed state of the haptic device. Add functions to increase and reset the state of the pressure detected by the device. Signed-off-by: Angela Czubak <aczubak@google.com> Co-developed-by: Jonathan Denose <jdenose@google.com> Signed-off-by: Jonathan Denose <jdenose@google.com> Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
This commit is contained in:
parent
7657bf0b7c
commit
a77efca3aa
|
|
@ -50,8 +50,13 @@ EXPORT_SYMBOL_GPL(hid_haptic_feature_mapping);
|
|||
bool hid_haptic_check_pressure_unit(struct hid_haptic_device *haptic,
|
||||
struct hid_input *hi, struct hid_field *field)
|
||||
{
|
||||
if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON)
|
||||
if (field->unit == HID_UNIT_GRAM || field->unit == HID_UNIT_NEWTON) {
|
||||
haptic->force_logical_minimum = field->logical_minimum;
|
||||
haptic->force_physical_minimum = field->physical_minimum;
|
||||
haptic->force_resolution = input_abs_get_res(hi->input,
|
||||
ABS_MT_PRESSURE);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hid_haptic_check_pressure_unit);
|
||||
|
|
@ -508,3 +513,16 @@ int hid_haptic_init(struct hid_device *hdev,
|
|||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hid_haptic_init);
|
||||
|
||||
void hid_haptic_pressure_reset(struct hid_haptic_device *haptic)
|
||||
{
|
||||
haptic->pressure_sum = 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hid_haptic_pressure_reset);
|
||||
|
||||
void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
|
||||
__s32 pressure)
|
||||
{
|
||||
haptic->pressure_sum += pressure;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(hid_haptic_pressure_increase);
|
||||
|
|
|
|||
|
|
@ -70,6 +70,10 @@ int hid_haptic_input_configured(struct hid_device *hdev,
|
|||
struct hid_haptic_device *haptic,
|
||||
struct hid_input *hi);
|
||||
int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device **haptic_ptr);
|
||||
void hid_haptic_handle_press_release(struct hid_haptic_device *haptic);
|
||||
void hid_haptic_pressure_reset(struct hid_haptic_device *haptic);
|
||||
void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
|
||||
__s32 pressure);
|
||||
#else
|
||||
static inline
|
||||
void hid_haptic_feature_mapping(struct hid_device *hdev,
|
||||
|
|
@ -103,4 +107,15 @@ int hid_haptic_init(struct hid_device *hdev, struct hid_haptic_device **haptic_p
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
static inline
|
||||
void hid_haptic_handle_press_release(struct hid_haptic_device *haptic)
|
||||
{}
|
||||
static inline
|
||||
void hid_haptic_pressure_reset(struct hid_haptic_device *haptic)
|
||||
{}
|
||||
static inline
|
||||
void hid_haptic_pressure_increase(struct hid_haptic_device *haptic,
|
||||
__s32 pressure)
|
||||
{}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user