Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
TouchInput.h
Go to the documentation of this file.
1/* Copyright (C) 2012 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_TOUCHINPUT
19#define INCLUDED_TOUCHINPUT
20
21#include "lib/input.h"
22#include "maths/Vector2D.h"
23#include "maths/Vector3D.h"
24
25/**
26 * Maps touch events (e.g. on Android touchscreen devices) onto mouse events
27 * and camera movement.
28 */
30{
31public:
34
35 /**
36 * Returns whether the touch input mode is enabled for this device.
37 */
38 bool IsEnabled();
39
41
42 /**
43 * Should be called once per frame to perform updates.
44 */
45 void Frame();
46
47private:
48 void OnFingerDown(int id, int x, int y);
49 void OnFingerUp(int id, int x, int y);
50 void OnFingerMotion(int id, int x, int y);
51
52 // Mouse emulation state:
53 enum
54 {
59 };
60 static const size_t MAX_MOUSE = 2;
63
64 // Current finger state:
65 static const size_t MAX_FINGERS = 2;
69
70
71 enum
72 {
77 };
79
82
84 float m_PanDist;
85};
86
88
90
91#endif // INCLUDED_TOUCHINPUT
InReaction touch_input_handler(const SDL_Event_ *ev)
Definition: TouchInput.cpp:293
CTouchInput g_TouchInput
Definition: TouchInput.cpp:291
Maps touch events (e.g.
Definition: TouchInput.h:30
float m_PanDist
Definition: TouchInput.h:84
CVector2D m_MouseEmulateDownPos[MAX_MOUSE]
Definition: TouchInput.h:62
CTouchInput()
Definition: TouchInput.cpp:42
int m_State
Definition: TouchInput.h:78
static const size_t MAX_FINGERS
Definition: TouchInput.h:65
@ MOUSE_ACTIVE_DOWN
Definition: TouchInput.h:58
@ MOUSE_ACTIVE_UP
Definition: TouchInput.h:57
@ MOUSE_ACTIVATING
Definition: TouchInput.h:56
@ MOUSE_INACTIVE
Definition: TouchInput.h:55
InReaction HandleEvent(const SDL_Event_ *ev)
Definition: TouchInput.cpp:187
static const size_t MAX_MOUSE
Definition: TouchInput.h:60
CVector3D m_PanFocus
Definition: TouchInput.h:83
~CTouchInput()
Definition: TouchInput.cpp:52
double m_FirstTouchTime
Definition: TouchInput.h:80
void OnFingerUp(int id, int x, int y)
Definition: TouchInput.cpp:83
void OnFingerMotion(int id, int x, int y)
Definition: TouchInput.cpp:116
CVector2D m_Pos[MAX_FINGERS]
Definition: TouchInput.h:67
CVector2D m_FirstTouchPos
Definition: TouchInput.h:81
bool m_Down[MAX_FINGERS]
Definition: TouchInput.h:66
int m_MouseEmulateState[MAX_MOUSE]
Definition: TouchInput.h:61
void Frame()
Should be called once per frame to perform updates.
Definition: TouchInput.cpp:165
void OnFingerDown(int id, int x, int y)
Definition: TouchInput.cpp:65
@ STATE_FIRST_TOUCH
Definition: TouchInput.h:74
@ STATE_INACTIVE
Definition: TouchInput.h:73
@ STATE_ZOOMING
Definition: TouchInput.h:76
@ STATE_PANNING
Definition: TouchInput.h:75
bool IsEnabled()
Returns whether the touch input mode is enabled for this device.
Definition: TouchInput.cpp:56
CVector2D m_Prev[MAX_FINGERS]
Definition: TouchInput.h:68
Definition: Vector2D.h:32
Definition: Vector3D.h:31
InReaction
Definition: input.h:35
Definition: libsdl.h:53