📄 input.h
字号:
#define ABS_RZ 0x05#define ABS_THROTTLE 0x06#define ABS_RUDDER 0x07#define ABS_WHEEL 0x08#define ABS_GAS 0x09#define ABS_BRAKE 0x0a#define ABS_HAT0X 0x10#define ABS_HAT0Y 0x11#define ABS_HAT1X 0x12#define ABS_HAT1Y 0x13#define ABS_HAT2X 0x14#define ABS_HAT2Y 0x15#define ABS_HAT3X 0x16#define ABS_HAT3Y 0x17#define ABS_PRESSURE 0x18#define ABS_DISTANCE 0x19#define ABS_TILT_X 0x1a#define ABS_TILT_Y 0x1b#define ABS_TOOL_WIDTH 0x1c#define ABS_VOLUME 0x20#define ABS_MISC 0x28#define ABS_MAX 0x3f/* * Switch events */#define SW_0 0x00#define SW_1 0x01#define SW_2 0x02#define SW_3 0x03#define SW_4 0x04#define SW_5 0x05#define SW_6 0x06#define SW_7 0x07#define SW_MAX 0x0f/* * Misc events */#define MSC_SERIAL 0x00#define MSC_PULSELED 0x01#define MSC_GESTURE 0x02#define MSC_RAW 0x03#define MSC_SCAN 0x04#define MSC_MAX 0x07/* * LEDs */#define LED_NUML 0x00#define LED_CAPSL 0x01#define LED_SCROLLL 0x02#define LED_COMPOSE 0x03#define LED_KANA 0x04#define LED_SLEEP 0x05#define LED_SUSPEND 0x06#define LED_MUTE 0x07#define LED_MISC 0x08#define LED_MAIL 0x09#define LED_CHARGING 0x0a#define LED_MAX 0x0f/* * Autorepeat values */#define REP_DELAY 0x00#define REP_PERIOD 0x01#define REP_MAX 0x01/* * Sounds */#define SND_CLICK 0x00#define SND_BELL 0x01#define SND_TONE 0x02#define SND_MAX 0x07/* * IDs. */#define ID_BUS 0#define ID_VENDOR 1#define ID_PRODUCT 2#define ID_VERSION 3#define BUS_PCI 0x01#define BUS_ISAPNP 0x02#define BUS_USB 0x03#define BUS_HIL 0x04#define BUS_BLUETOOTH 0x05#define BUS_ISA 0x10#define BUS_I8042 0x11#define BUS_XTKBD 0x12#define BUS_RS232 0x13#define BUS_GAMEPORT 0x14#define BUS_PARPORT 0x15#define BUS_AMIGA 0x16#define BUS_ADB 0x17#define BUS_I2C 0x18#define BUS_HOST 0x19#define BUS_GSC 0x1A/* * Values describing the status of an effect */#define FF_STATUS_STOPPED 0x00#define FF_STATUS_PLAYING 0x01#define FF_STATUS_MAX 0x01/* * Structures used in ioctls to upload effects to a device * The first structures are not passed directly by using ioctls. * They are sub-structures of the actually sent structure (called ff_effect) */struct ff_replay { __u16 length; /* Duration of an effect in ms. All other times are also expressed in ms */ __u16 delay; /* Time to wait before to start playing an effect */};struct ff_trigger { __u16 button; /* Number of button triggering an effect */ __u16 interval; /* Time to wait before an effect can be re-triggered (ms) */};struct ff_envelope { __u16 attack_length; /* Duration of attack (ms) */ __u16 attack_level; /* Level at beginning of attack */ __u16 fade_length; /* Duration of fade (ms) */ __u16 fade_level; /* Level at end of fade */};/* FF_CONSTANT */struct ff_constant_effect { __s16 level; /* Strength of effect. Negative values are OK */ struct ff_envelope envelope;};/* FF_RAMP */struct ff_ramp_effect { __s16 start_level; __s16 end_level; struct ff_envelope envelope;};/* FF_SPRING of FF_FRICTION */struct ff_condition_effect { __u16 right_saturation; /* Max level when joystick is on the right */ __u16 left_saturation; /* Max level when joystick in on the left */ __s16 right_coeff; /* Indicates how fast the force grows when the joystick moves to the right */ __s16 left_coeff; /* Same for left side */ __u16 deadband; /* Size of area where no force is produced */ __s16 center; /* Position of dead zone */};/* FF_PERIODIC */struct ff_periodic_effect { __u16 waveform; /* Kind of wave (sine, square...) */ __u16 period; /* in ms */ __s16 magnitude; /* Peak value */ __s16 offset; /* Mean value of wave (roughly) */ __u16 phase; /* 'Horizontal' shift */ struct ff_envelope envelope;/* Only used if waveform == FF_CUSTOM */ __u32 custom_len; /* Number of samples */ __s16 *custom_data; /* Buffer of samples *//* Note: the data pointed by custom_data is copied by the driver. You can * therefore dispose of the memory after the upload/update */};/* FF_RUMBLE *//* Some rumble pads have two motors of different weight. strong_magnitude represents the magnitude of the vibration generated by the heavy motor.*/struct ff_rumble_effect { __u16 strong_magnitude; /* Magnitude of the heavy motor */ __u16 weak_magnitude; /* Magnitude of the light one */};/* * Structure sent through ioctl from the application to the driver */struct ff_effect { __u16 type;/* Following field denotes the unique id assigned to an effect. * If user sets if to -1, a new effect is created, and its id is returned in the same field * Else, the user sets it to the effect id it wants to update. */ __s16 id; __u16 direction; /* Direction. 0 deg -> 0x0000 (down) 90 deg -> 0x4000 (left) 180 deg -> 0x8000 (up) 270 deg -> 0xC000 (right) */ struct ff_trigger trigger; struct ff_replay replay; union { struct ff_constant_effect constant; struct ff_ramp_effect ramp; struct ff_periodic_effect periodic; struct ff_condition_effect condition[2]; /* One for each axis */ struct ff_rumble_effect rumble; } u;};/* * Force feedback effect types */#define FF_RUMBLE 0x50#define FF_PERIODIC 0x51#define FF_CONSTANT 0x52#define FF_SPRING 0x53#define FF_FRICTION 0x54#define FF_DAMPER 0x55#define FF_INERTIA 0x56#define FF_RAMP 0x57/* * Force feedback periodic effect types */#define FF_SQUARE 0x58#define FF_TRIANGLE 0x59#define FF_SINE 0x5a#define FF_SAW_UP 0x5b#define FF_SAW_DOWN 0x5c#define FF_CUSTOM 0x5d/* * Set ff device properties */#define FF_GAIN 0x60#define FF_AUTOCENTER 0x61#define FF_MAX 0x7fstruct input_device_id { kernel_ulong_t flags; struct input_id id; kernel_ulong_t evbit[EV_MAX/BITS_PER_LONG+1]; kernel_ulong_t keybit[KEY_MAX/BITS_PER_LONG+1]; kernel_ulong_t relbit[REL_MAX/BITS_PER_LONG+1]; kernel_ulong_t absbit[ABS_MAX/BITS_PER_LONG+1]; kernel_ulong_t mscbit[MSC_MAX/BITS_PER_LONG+1]; kernel_ulong_t ledbit[LED_MAX/BITS_PER_LONG+1]; kernel_ulong_t sndbit[SND_MAX/BITS_PER_LONG+1]; kernel_ulong_t ffbit[FF_MAX/BITS_PER_LONG+1]; kernel_ulong_t swbit[SW_MAX/BITS_PER_LONG+1]; kernel_ulong_t driver_info;};/* * Structure for hotplug & device<->driver matching. */#define INPUT_DEVICE_ID_MATCH_BUS 1#define INPUT_DEVICE_ID_MATCH_VENDOR 2#define INPUT_DEVICE_ID_MATCH_PRODUCT 4#define INPUT_DEVICE_ID_MATCH_VERSION 8#define INPUT_DEVICE_ID_MATCH_EVBIT 0x010#define INPUT_DEVICE_ID_MATCH_KEYBIT 0x020#define INPUT_DEVICE_ID_MATCH_RELBIT 0x040#define INPUT_DEVICE_ID_MATCH_ABSBIT 0x080#define INPUT_DEVICE_ID_MATCH_MSCIT 0x100#define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200#define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400#define INPUT_DEVICE_ID_MATCH_FFBIT 0x800#define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000#ifdef __KERNEL__/* * In-kernel definitions. */#include <linux/fs.h>#include <linux/timer.h>#define NBITS(x) (((x)/BITS_PER_LONG)+1)#define BIT(x) (1UL<<((x)%BITS_PER_LONG))#define LONG(x) ((x)/BITS_PER_LONG)#define INPUT_KEYCODE(dev, scancode) ((dev->keycodesize == 1) ? ((u8*)dev->keycode)[scancode] : \ ((dev->keycodesize == 2) ? ((u16*)dev->keycode)[scancode] : (((u32*)dev->keycode)[scancode])))#define SET_INPUT_KEYCODE(dev, scancode, val) \ ({ unsigned __old; \ switch (dev->keycodesize) { \ case 1: { \ u8 *k = (u8 *)dev->keycode; \ __old = k[scancode]; \ k[scancode] = val; \ break; \ } \ case 2: { \ u16 *k = (u16 *)dev->keycode; \ __old = k[scancode]; \ k[scancode] = val; \ break; \ } \ default: { \ u32 *k = (u32 *)dev->keycode; \ __old = k[scancode]; \ k[scancode] = val; \ break; \ } \ } \ __old; })struct input_dev { void *private; const char *name; const char *phys; const char *uniq; struct input_id id; unsigned long evbit[NBITS(EV_MAX)]; unsigned long keybit[NBITS(KEY_MAX)]; unsigned long relbit[NBITS(REL_MAX)]; unsigned long absbit[NBITS(ABS_MAX)]; unsigned long mscbit[NBITS(MSC_MAX)]; unsigned long ledbit[NBITS(LED_MAX)]; unsigned long sndbit[NBITS(SND_MAX)]; unsigned long ffbit[NBITS(FF_MAX)]; unsigned long swbit[NBITS(SW_MAX)]; int ff_effects_max; unsigned int keycodemax; unsigned int keycodesize; void *keycode; unsigned int repeat_key; struct timer_list timer; struct pt_regs *regs; int state; int sync; int abs[ABS_MAX + 1]; int rep[REP_MAX + 1]; unsigned long key[NBITS(KEY_MAX)]; unsigned long led[NBITS(LED_MAX)]; unsigned long snd[NBITS(SND_MAX)]; unsigned long sw[NBITS(SW_MAX)]; int absmax[ABS_MAX + 1]; int absmin[ABS_MAX + 1]; int absfuzz[ABS_MAX + 1]; int absflat[ABS_MAX + 1]; int (*open)(struct input_dev *dev); void (*close)(struct input_dev *dev); int (*accept)(struct input_dev *dev, struct file *file); int (*flush)(struct input_dev *dev, struct file *file); int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect); int (*erase_effect)(struct input_dev *dev, int effect_id); struct input_handle *grab; struct semaphore sem; /* serializes open and close operations */ unsigned int users; struct class_device cdev; struct device *dev; /* will be removed soon */ int dynalloc; /* temporarily */ struct list_head h_list; struct list_head node;};#define to_input_dev(d) container_of(d, struct input_dev, cdev)#define INPUT_DEVICE_ID_MATCH_DEVICE\ (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT)#define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION\ (INPUT_DEVICE_ID_MATCH_DEVICE | INPUT_DEVICE_ID_MATCH_VERSION)struct input_handle;struct input_handler { void *private; void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id); void (*disconnect)(struct input_handle *handle); struct file_operations *fops; int minor; char *name; struct input_device_id *id_table; struct input_device_id *blacklist; struct list_head h_list; struct list_head node;};struct input_handle { void *private; int open; char *name; struct input_dev *dev; struct input_handler *handler; struct list_head d_node; struct list_head h_node;};#define to_dev(n) container_of(n,struct input_dev,node)#define to_handler(n) container_of(n,struct input_handler,node);#define to_handle(n) container_of(n,struct input_handle,d_node)#define to_handle_h(n) container_of(n,struct input_handle,h_node)static inline void init_input_dev(struct input_dev *dev){ INIT_LIST_HEAD(&dev->h_list); INIT_LIST_HEAD(&dev->node);}struct input_dev *input_allocate_device(void);static inline void input_free_device(struct input_dev *dev){ kfree(dev);}static inline struct input_dev *input_get_device(struct input_dev *dev){ return to_input_dev(class_device_get(&dev->cdev));}static inline void input_put_device(struct input_dev *dev){ class_device_put(&dev->cdev);}int input_register_device(struct input_dev *);void input_unregister_device(struct input_dev *);void input_register_handler(struct input_handler *);void input_unregister_handler(struct input_handler *);int input_grab_device(struct input_handle *);void input_release_device(struct input_handle *);int input_open_device(struct input_handle *);void input_close_device(struct input_handle *);int input_accept_process(struct input_handle *handle, struct file *file);int input_flush_device(struct input_handle* handle, struct file* file);void input_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);static inline void input_report_key(struct input_dev *dev, unsigned int code, int value){ input_event(dev, EV_KEY, code, !!value);}static inline void input_report_rel(struct input_dev *dev, unsigned int code, int value){ input_event(dev, EV_REL, code, value);}static inline void input_report_abs(struct input_dev *dev, unsigned int code, int value){ input_event(dev, EV_ABS, code, value);}static inline void input_report_ff(struct input_dev *dev, unsigned int code, int value){ input_event(dev, EV_FF, code, value);}static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value){ input_event(dev, EV_FF_STATUS, code, value);}static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value){ input_event(dev, EV_SW, code, !!value);}static inline void input_regs(struct input_dev *dev, struct pt_regs *regs){ dev->regs = regs;}static inline void input_sync(struct input_dev *dev){ input_event(dev, EV_SYN, SYN_REPORT, 0); dev->regs = NULL;}static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat){ dev->absmin[axis] = min; dev->absmax[axis] = max; dev->absfuzz[axis] = fuzz; dev->absflat[axis] = flat; dev->absbit[LONG(axis)] |= BIT(axis);}extern struct class input_class;#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -