STRUCT INPUT_DEV(9)
π NAME
struct input_dev β it's literally the whole vibe of an input device, like the main character struct that holds everything the kernel needs to know about your keyboard, mouse, touchpad, whatever π
β¨ SYNOPSIS
okay so here's the whole glow-up, no cap, every field exactly as it is:
struct input_dev {
const char *name;
const char *phys;
const char *uniq;
struct input_id id;
unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];
unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
unsigned int hint_events_per_packet;
unsigned int keycodemax;
unsigned int keycodesize;
void *keycode;
int (*setkeycode)(struct input_dev *dev, const struct input_keymap_entry *ke, unsigned int *old_keycode);
int (*getkeycode)(struct input_dev *dev, struct input_keymap_entry *ke);
struct ff_device *ff;
struct input_dev_poller *poller;
unsigned int repeat_key;
struct timer_list timer;
int rep[REP_CNT];
struct input_mt *mt;
struct input_absinfo *absinfo;
unsigned long key[BITS_TO_LONGS(KEY_CNT)];
unsigned long led[BITS_TO_LONGS(LED_CNT)];
unsigned long snd[BITS_TO_LONGS(SND_CNT)];
unsigned long sw[BITS_TO_LONGS(SW_CNT)];
int (*open)(struct input_dev *dev);
void (*close)(struct input_dev *dev);
int (*flush)(struct input_dev *dev, struct file *file);
int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
struct input_handle *grab;
spinlock_t event_lock;
struct mutex mutex;
unsigned int users;
bool going_away;
struct device dev;
struct list_head h_list;
struct list_head node;
unsigned int num_vals;
unsigned int max_vals;
struct input_value *vals;
bool devres_managed;
ktime_t timestamp[INPUT_CLK_MAX];
bool inhibited;
bool ready;
};
π«Ά Members
okay bestie, member-by-member tour, let's go π
nameβ the name of the device. iconic, essential, the whole identity β¨physβ physical path to the device in the system hierarchyuniqβ unique identification code for the device (if the device has it). iykykidβ id of the device (struct input_id)propbitβ bitmap of device properties and quirksevbitβ bitmap of types of events supported by the device (EV_KEY,EV_REL, etc.)keybitβ bitmap of keys/buttons this device hasrelbitβ bitmap of relative axes for the deviceabsbitβ bitmap of absolute axes for the devicemscbitβ bitmap of miscellaneous events supported by the deviceledbitβ bitmap of leds present on the devicesndbitβ bitmap of sound effects supported by the deviceffbitβ bitmap of force feedback effects supported by the deviceswbitβ bitmap of switches present on the devicehint_events_per_packetβ average number of events generated by the device in a packet (betweenEV_SYN/SYN_REPORTevents). Event handlers use it to estimate the size of the buffer needed to hold events π«Άkeycodemaxβ size of keycode tablekeycodesizeβ size of elements in keycode tablekeycodeβ map of scancodes to keycodes for this devicesetkeycodeβ optional method to alter current keymap, used to implement sparse keymaps. If it's not supplied, the default mechanism will be used. Heads up bestie: this method is being called while holdingevent_lockand thus must not sleep π΄π«getkeycodeβ optional legacy method to retrieve current keymap.ffβ force feedback structure associated with the device if the device supports force feedback effectspollerβ poller structure associated with the device if the device is set up to use polling moderepeat_keyβ stores key code of the last key pressed; used to implement software autorepeat πtimerβ timer for software autorepeatrepβ current values for autorepeat parameters (delay, rate)mtβ pointer to multitouch stateabsinfoβ array ofstruct input_absinfoelements holding information about absolute axes (current value, min, max, flat, fuzz, resolution)keyβ reflects current state of device's keys/buttonsledβ reflects current state of device's LEDssndβ reflects current state of sound effectsswβ reflects current state of device's switchesopenβ this method is called when the very first user callsinput_open_device. The driver must prepare the device to start generating events (start polling thread, request an IRQ, submit URB, etc.). The meaning ofopenis to start providing events to the input core π±closeβ this method is called when the very last user callsinput_close_device. The meaning ofcloseis to stop providing events to the input core π₯flushβ purges the device. Most commonly used to get rid of force feedback effects loaded into the device when disconnecting from iteventβ event handler for events sent to the device, likeEV_LEDorEV_SND. The device is expected to carry out the requested action (turn on a LED, play sound, etc.). The call is protected byevent_lockand must not sleep πgrabβ input handle that currently has the device grabbed (via theEVIOCGRABioctl). When a handle grabs a device it becomes the sole recipient for all input events coming from the device βevent_lockβ this spinlock is taken when the input core receives and processes a new event for the device (ininput_event). Code that accesses and/or modifies parameters of a device (such as keymap orabsmin,absmax,absfuzz, etc.) after the device has been registered with the input core must take this lock πmutexβ serializes calls toopen,closeandflushmethodsusersβ stores number of users (input handlers) that opened this device. It is used byinput_open_deviceandinput_close_deviceto make sure thatdev->openis only called when the first user opens the device anddev->closeis called when the very last user closes the devicegoing_awayβ marks devices that are in the middle of unregistering and causesinput_open_deviceandinput_inhibit/uninhibit_deviceto fail with-ENODEV. it's giving farewell era πdevβ driver model's view of this deviceh_listβ list of input handles associated with the device. When accessing the list,dev->mutexmust be heldnodeβ used to place the device ontoinput_dev_listnum_valsβ number of values queued in the current framemax_valsβ maximum number of values queued in a framevalsβ array of values queued in the current framedevres_managedβ indicates that the device is managed with the devres framework and needs not be explicitly unregistered or freed. lazy girlie win β¨timestampβ storage for a timestamp set byinput_set_timestampcalled by a driverinhibitedβ indicates that the input device is inhibited. If that's the case then the input core ignores any events generated by the device. Device'scloseis called when it is being inhibited and itsopenis called when it is being uninhibitedreadyβ indicates that the device has been successfully opened and is prepared to process events (like LEDs or sounds) sent from the input core π
π SEE ALSO
go read these next bestie, they're all in Kernel file ./include/linux/input.h:
struct input_value(9)struct input_handler(9)struct input_handle(9)input_set_events_per_packet(9)struct ff_device(9)
okay that's the whole page π¦ this came from ./include/linux, October 2026 edition β so if it's stale by the time you read it, not my fault bestie π slay, go write a driver π
π¦ 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