Skip to content

enable_event_code doc comment gives incorrect advice #113

@LunNova

Description

@LunNova

The enable_event_code documentation claims:

    /// Forcibly enable an event type on this device, even if the underlying
    /// device does not support it. While this cannot make the device actually
    /// report such events, it will now return true for libevdev_has_event_code().
    ///
    /// The last argument depends on the type and code:
    /// If type is EV_ABS, data must be a pointer to a struct input_absinfo
    /// containing the data for this axis.
    /// If type is EV_REP, data must be a pointer to a int containing the data
    /// for this axis.
    /// For all other types, the argument must be `None`.
    ///
    /// Note: Please use the `enable` function instead. This function is only
    /// available for the sake of maintaining compatibility with libevdev.
    fn enable_event_code(

This is wrong in two ways.

  1. For an UninitDevice that you are going to turn into a virtual input device enable_event_code does impact the event codes offered by the device that shows up in /dev/input after creation, as reflected in evtest. It's required to call this to mark your device as supporting these codes to avoid confusing applications that read events from your device.
  2. enable() is not a substitute. impl Enable for EventCode internally calls device.enable_event_code(self, None) which is invalid if the event type is EV_ABS or EV_REP, as more info is required than available in the EventCode struct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions