Root/src/touchscreen.h

1/***************************************************************************
2 * Copyright (C) 2006 by Massimiliano Torromeo *
3 * massimiliano.torromeo@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#ifndef TOUCHSCREEN_H
22#define TOUCHSCREEN_H
23
24#include <SDL.h>
25
26#include <fcntl.h>
27#include <stdint.h>
28
29typedef struct {
30    uint16_t pressure;
31    uint16_t x;
32    uint16_t y;
33    uint16_t pad;
34    struct timeval stamp;
35} TS_EVENT;
36
37class Touchscreen {
38private:
39    int wm97xx;
40    bool calibrated, _handled;
41    TS_EVENT event;
42    int calibX, calibY;
43    int x, y, startX, startY;
44    bool wasPressed;
45
46    void calibrate(/*TS_EVENT event*/);
47
48public:
49    Touchscreen();
50    ~Touchscreen();
51
52    bool init();
53    bool initialized();
54    void deinit();
55
56    bool poll();
57    bool pressed();
58    bool released();
59
60    bool handled();
61    void setHandled();
62
63    bool inRect(SDL_Rect r);
64    bool inRect(int x, int y, int w, int h);
65    bool startedInRect(SDL_Rect r);
66    bool startedInRect(int x, int y, int w, int h);
67
68    int getX() { return x; }
69    int getY() { return y; }
70};
71
72#endif
73

Archive Download this file



interactive