dev: implement input event hooks

This commit is contained in:
2023-06-11 16:46:58 +01:00
parent 3cc72f1f24
commit 7308fd98fb
3 changed files with 90 additions and 1 deletions

View File

@@ -11,6 +11,7 @@
struct device;
struct input_event;
struct input_event_hook;
struct tty_device;
#define DEV_NAME_MAX OBJECT_NAME_MAX
@@ -94,6 +95,7 @@ struct input_device {
struct input_device_ops *i_ops;
unsigned int i_id;
struct ringbuffer i_events;
struct queue i_hooks;
};
struct bus_device {
@@ -232,10 +234,42 @@ static inline struct device *framebuffer_device_base(struct framebuffer_device *
return (struct device *)((char *)dev - offsetof(struct device, fb));
}
static inline struct object *char_device_object(struct char_device *dev)
{
return &char_device_base(dev)->dev_base;
}
static inline struct object *block_device_object(struct block_device *dev)
{
return &block_device_base(dev)->dev_base;
}
static inline struct object *net_device_object(struct net_device *dev)
{
return &net_device_base(dev)->dev_base;
}
static inline struct object *input_device_object(struct input_device *dev)
{
return &input_device_base(dev)->dev_base;
}
static inline struct object *bus_device_object(struct bus_device *dev)
{
return &bus_device_base(dev)->dev_base;
}
static inline struct object *framebuffer_device_object(struct framebuffer_device *dev)
{
return &framebuffer_device_base(dev)->dev_base;
}
extern kern_status_t device_register(struct device *dev, struct driver *owner, struct device *parent);
extern kern_status_t input_device_report_event(struct input_device *dev, const struct input_event *ev, bool noblock);
extern kern_status_t input_device_read(struct device *dev, void *buf, size_t size, size_t *bytes_read, socks_flags_t flags);
extern kern_status_t input_device_add_hook(struct device *dev, struct input_event_hook *hook);
extern kern_status_t input_device_remove_hook(struct device *dev, struct input_event_hook *hook);
extern struct driver *driver_create(struct kext *self, const char *name);
extern kern_status_t driver_destroy(struct driver *driver);

View File

@@ -2,6 +2,14 @@
#define SOCKS_INPUT_H_
#include <stdint.h>
#include <socks/queue.h>
#include <socks/status.h>
enum input_event_hook_flags {
INPUT_HOOK_SQUASH_EVENT = 0x01u,
};
struct device;
enum input_event_type {
INPUT_TYPE_UNKNOWN = 0x00u,
@@ -167,4 +175,10 @@ struct input_event {
};
};
struct input_event_hook {
void(*hook_callback)(struct device *, struct input_event *, enum input_event_hook_flags *, void *);
void *hook_arg;
struct queue_entry hook_head;
};
#endif