Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions components/drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,19 @@ config RT_USING_AUDIO
bool "Using Audio device drivers"
default n

menu "Using Input Device"
config RT_USING_INPUT
bool "Using Input devices"
default n

if RT_USING_INPUT
config INPUT_USING_TOUCH
bool "Enable TouchScren"
default n

endif
endmenu

menu "Using WiFi"
config RT_USING_WIFI
bool "Using Wi-Fi framework"
Expand Down
103 changes: 103 additions & 0 deletions components/drivers/include/drivers/input.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2006-2018, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*/

/*
* File : input.h
*
* Change Logs:
* Date Author Notes
2018-10-10 heyuanjie87 first version

*/

#ifndef __INPUT_H__
#define __INPUT_H__

#include <rtthread.h>
#include <stdint.h>

#include "input_ev_code.h"

typedef enum
{
INPUT_DEVTYPE_KBD = 1,
INPUT_DEVTYPE_TOUCH = 2,
} input_devtype_t;

struct input_event;
struct input_ops;
struct input_handler;

struct input_value
{
uint8_t type;
uint16_t code;
int value;
};

typedef struct input_dev
{
struct rt_device parent;
const struct input_ops *ops;

/* driver not touch */
uint8_t type; /* @input_devtype_t */
struct input_value *buf;
uint8_t wpos;
uint8_t numbuf;

struct input_handler *handler;
rt_list_t node;
} rt_input_t;

struct input_ops
{
int (*init)(rt_input_t *dev);
void (*deinit)(rt_input_t *dev);
};

#pragma pack(1)
struct input_event
{
uint16_t type;
uint16_t code;
int value;
uint32_t usec;
};
#pragma pack()

struct input_handler
{
struct rt_device parent;
uint8_t type; /* @input_devtype_t */
/* recv events from low driver */
void (*events)(struct input_handler *handler, struct input_dev *dev,
struct input_value *v, int cnt);
/* recv connection status from low driver */
void (*connect)(struct input_handler *handler, struct input_dev *dev,
int state);

rt_list_t node;
rt_list_t c_list; /* clients connect to this list */
rt_list_t d_list; /* input devices connect to this list */
};

int rt_input_device_register(rt_input_t *dev, int devtype, const char *name);
int rt_input_device_unregister(rt_input_t *dev);

int rt_input_handler_register(struct input_handler *handler);
int rt_input_device_open(struct input_handler *h);
int rt_input_device_close(struct input_handler *h);

int rt_input_report(rt_input_t *dev, int type, int code, int value);
int rt_input_rel_report(rt_input_t *dev, int code, int value);
int rt_input_abs_report(rt_input_t *dev, int code, int value);
int rt_input_key_report(rt_input_t *dev, int code, int value);
int rt_input_sync(rt_input_t *dev);

void _input_gettime(struct input_event *ev);

#endif
Loading