zynq_7010/Keyboard.h

44 lines
1006 B
C++

#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/input.h>
#include <sys/epoll.h>
#include <string.h>
#include <thread>
#include <time.h>
#include <condition_variable>
#include <functional>
#include "scanservices_utils.h"
static const char kDevInput[] = "/dev/input/event0";
#define MAX_EVENTS 10
namespace huagao
{
class Keyboard
{
public:
Keyboard(std::function<void(const int)> buttonevent);
~Keyboard();
void init();
private:
int mInputFd;
int mEpId;
struct epoll_event ev;
struct epoll_event events[MAX_EVENTS];
std::thread pollthread;
char buffer[sizeof(input_event)];
void poll();
void doInput(const epoll_event *ev);
bool b_run =false;
bool b_lowpwoer = false;
private:
std::function<void(const int)> m_event;
};
} // namespace huagao