STRUCT FF_DEVICE(9)
๐ struct ff_device(9) โ the kernel API manual, but make it make sense
okay so bestie, welcome to the struct ff_device page from the Kernel API Manual โจ this is literally the force-feedback part of an input device โ rumble, shake, the whole vibe ๐ฎ๐ฅ let's get into it.
๐ธ NAME ๐ธ
struct ff_device โ the force-feedback part of an input device. that's it, that's the whole thing, she's the haptic main character ๐
โจ SYNOPSIS โจ
struct ff_device {
int (*upload)(struct input_dev *dev, struct ff_effect *effect,
struct ff_effect *old);
int (*erase)(struct input_dev *dev, int effect_id);
int (*playback)(struct input_dev *dev, int effect_id, int value);
void (*set_gain)(struct input_dev *dev, u16 gain);
void (*set_autocenter)(struct input_dev *dev, u16 magnitude);
void (*destroy)(struct ff_device *);
void (*stop)(struct ff_device *);
void *private;
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
struct mutex mutex;
int max_effects;
struct ff_effect *effects;
struct file *effect_owners[];
};
๐ Members ๐
uploadโ called to upload a new effect into the device. yeah, this one's on the must-have list, no skipping ๐ซถeraseโ called to erase an effect from the device. optional but honestly iconic of herplaybackโ called to request the device start playing the specified effect. also mandatory, bestieset_gainโ called to set the specified gainset_autocenterโ called to auto-center the devicedestroyโ called by the input core when the parent input device is being destroyed ๐stopโ called by the input core when the parent input device is being unregisteredprivateโ driver-specific data, and it gets freed automatically, so don't you dare double-free it ๐ffbitโ bitmap of force-feedback capabilities truly supported by the device (not emulated like the ones ininput_dev->ffbit). yes, truly. she's not pretending ๐mutexโ mutex for serializing access to the device. one at a time, bestiesmax_effectsโ maximum number of effects supported by the deviceeffectsโ pointer to an array of effects currently loaded into the deviceeffect_ownersโ array of effect owners; when the file handle owning an effect gets closed, the effect is automatically erased. self-cleaning queen โจ
๐ฆ Description ๐ฆ
Every force-feedback device must implement upload and playback methods โ those two are non-negotiable, periodt. erase is optional. And set_gain and set_autocenter only need to be implemented if the driver sets up the FF_GAIN and FF_AUTOCENTER bits.
โ ๏ธ okay this part is so important: note thatplayback,set_gainandset_autocenterare called withdev->event_lockspinlock held and interrupts off, which means they may not sleep. not even a lil nap. don't do it ๐ญ
๐ฅ SEE ALSO ๐ฅ
- Kernel file
./include/linux/input.h struct input_value(9)struct input_dev(9)struct input_handler(9)struct input_handle(9)input_set_events_per_packet(9)
go read those too, iykyk ๐๐
and that's the whole page, bestie ๐ this livable little doc lives at ./include/linux and it's dated October 2026 โ so like, future vibes fr fr. stay hydrated, don't sleep in a spinlock, and slay ๐
๐๐ฆ
๐ฆ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms