TouchCPLib  1.0.0
A touch-enabled GUI interface based on SDL and libTS. It provides a simple desktop-free UI for your embedded Raspberry projects.
TouchInput.h
Go to the documentation of this file.
1 #pragma once
2 
13 #include <string>
14 #include <tslib.h>
15 #include <vector>
16 #include <functional>
17 
18 #include "TouchInputException.h"
19 
20 #define TS_SETENV(x) setenv(#x, x, false);
21 
22 using TouchEventCallback = std::function<void(ts_sample_mt)>; // void(*)(ts_sample_mt);
23 
28 {
29 public:
37  TouchInput(const std::string &device_name, TouchEventCallback callback, int samples, int slots);
38  ~TouchInput();
40  void poll();
41 
42 private:
43  std::string device_name;
44  struct tsdev *ts;
45  ts_sample_mt **samp_mt;
46  int samples, slots, ret;
47  TouchEventCallback event_callback;
48 
49  const char *TSLIB_CALIBFILE = "/etc/pointercal.tslib";
50  const char *TSLIB_CONFFILE = "/etc/ts.conf";
51  const char *TSLIB_TSDEVICE = "/dev/input/event0";
52 };
TouchInput(const std::string &device_name, TouchEventCallback callback, int samples, int slots)
Creates an instance of TouchInput.
Definition: TouchInput.cpp:3
void setTouchEventCallback(TouchEventCallback callback)
Definition: TouchInput.cpp:39
Object that gathers the touch events from the underlying device.
Definition: TouchInput.h:27
void poll()
Definition: TouchInput.cpp:44
std::function< void(ts_sample_mt)> TouchEventCallback
Definition: TouchInput.h:22
~TouchInput()
Definition: TouchInput.cpp:24