STRUCT INPUT_HANDLER(9)
π
struct input_handler(9) β Kernel API Manual, but make it make sense π
okay so bestie, welcome to the Kernel API Manual entry for struct input_handler(9). This is the struct that implements one of interfaces for input devices β and yes, weβre keeping that phrase exactly, because the kernel said what it said πβ¨
πΈ NAME πΈ
struct input_handler β implements one of interfaces for input devices
β¨ SYNOPSIS β¨
Hereβs the whole struct, copied exactly so nobody comes for me:
struct input_handler {
void *private;
void (*event)(struct input_handle *handle, unsigned int type,
unsigned int code, int value);
unsigned int (*events)(struct input_handle *handle, struct
input_value *vals, unsigned int count);
bool (*filter)(struct input_handle *handle, unsigned int type,
unsigned int code, int value);
bool (*match)(struct input_handler *handler, struct input_dev *dev);
int (*connect)(struct input_handler *handler, struct input_dev *dev,
const struct input_device_id *id);
void (*disconnect)(struct input_handle *handle);
void (*start)(struct input_handle *handle);
bool passive_observer;
bool legacy_minors;
int minor;
const char *name;
const struct input_device_id *id_table;
struct list_head h_list;
struct list_head node;
};
π Members π
okay bestie, member-by-member, no skips, no crumbs:
privateβ driver-specific data. literally the driverβs own little stash.eventβ event handler. This method is being called by input core with interrupts disabled anddev->event_lockspinlock held and so it may not sleep. Bestie, that means do not sleep here β this context is not giving nap time π.eventsβ event sequence handler. This method is being called by input core with interrupts disabled anddev->event_lockspinlock held and so it may not sleep. The method must return number of events passed to it. So return the count, periodt.filterβ similar toevent; separates normal event handlers from "filters". Itβs the vibe check between normal handlers and filters.matchβ called after comparing deviceβsidwith handlerβsid_tableto perform fine-grained matching between device and handler. Fine-grained, no cap.connectβ called when attaching a handler to an input device. the attach moment π«Άdisconnectβ disconnects a handler from input device. the un-attach moment πstartβ starts handler for given handle. This function is called by input core when device is open and ready to process events, and also when device is uninhibited or when a process that "grabbed" a device releases it. main character energy for the handle β¨passive_observerβ set totrueby drivers only interested in observing data stream from devices if there are other users present. Such drivers will not result in starting underlying hardware device wheninput_open_deviceis called for their handles. just here to watch, not to wake the hardware πlegacy_minorsβ set totrueby drivers using legacy minor ranges. legacy era behavior πminorβ beginning of range of 32 legacy minors for devices this driver can provide. 32 minors, iconic number.nameβ name of the handler, to be shown in/proc/bus/input/handlers. your handlerβs government name πid_tableβ pointer to a table ofinput_device_idsthis driver can handle. the matchmaking table.h_listβ list of input handles associated with the handler. the handle squad.nodeβ for placing the driver ontoinput_handler_list. the driverβs spot on the list π¦
π¦ Description π¦
okay so hereβs the vibe: Input handlers attach to input devices and create input handles. There are likely several handlers attached to any given input device at the same time. All of them will get their copy of input event generated by the device. Every single one, bestie β they each get their own copy, no cap. π
The very same structure is used to implement input filters. Input core allows filters to run first and will not pass event to regular handlers if any of the filters indicate that the event should be filtered (by returning true from their filter method). Filters get first dibs, and if they say no, the event does not pass go. π«β¨
Note that input core serializes calls to connect and disconnect methods. So those calls are not out here doing chaos in parallel β input core keeps them in line. π
π SEE ALSO π
Kernel file ./include/linux/input.h is right there, plus struct input_value(9), struct input_dev(9), struct input_handle(9), input_set_events_per_packet(9), and struct ff_device(9). Go read them, bestie β theyβre all part of the lore π
source/version: ./include/linux, dated October 2026 β page: struct input_handler(9) π
β¨π
π¦ 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