summaryrefslogtreecommitdiff
path: root/touchthread.h
blob: 8c247112ccccd6bf22aa684faac5509f8dfc3053 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * touchthread.h: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *  (c) 2007-2008 Jörg Wendel
 *
 * Date: 14.11.2008
 *
 * The touch device driver is taken from the 
 *     touchTFT plugin written by (c) Frank Simon
 *
 */

#ifndef _TOUCHTHREAD_H_
#define _TOUCHTHREAD_H_

#include <vdr/thread.h>

#include <common.h>

//***************************************************************************
// Class Touch Thread
//***************************************************************************

class cTouchThread : public cThread
{
   public:
  
      // definitions

      enum Misc
      {
         sizeBuffer = 32,
         bounceTime = 30,      // milli Seconds (0.03 sec)
         doubleClickTime = 500 // milli Seconds (0.5 sec)
      };

      struct CalibrationSetting
      {
         int swapXY;
         double scaleX;
         double scaleY;
         int offsetX;
         int offsetY;
         int scaleWidth;
         int scaleHeight;
      };

      // object

      cTouchThread(void* aDisplay);
      virtual ~cTouchThread();

      // frame

      void Stop();
      void Action(void);

      // interface

      void setCalibrate(int state)              { calibrate = state; }
      int getCalibrate()                        { return calibrate; }
      void setSetting(CalibrationSetting* aSet) { settings = *aSet; }
      void resetSetting(int swap = no);
      CalibrationSetting* getSettings()         { return &settings; }
      void setDevice(const char* aDevice, int doOpen = no);

      int open();
      int close();
      int isOpen()    { return handle > 0; }

   protected:

      void processEvent(bool touch, int x, int y);
      void rescale();

      // data

      CalibrationSetting settings;
      int handle;
      void* display;
      int calibrate;
      char* touchDevice;
};

//***************************************************************************
#endif // _TOUCHTHREAD_H_