Pyrogenesis
13997
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
source
ps
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
*/
29
class
CTouchInput
30
{
31
public
:
32
CTouchInput
();
33
~CTouchInput
();
34
35
/**
36
* Returns whether the touch input mode is enabled for this device.
37
*/
38
bool
IsEnabled
();
39
40
InReaction
HandleEvent
(
const
SDL_Event_
* ev);
41
42
/**
43
* Should be called once per frame to perform updates.
44
*/
45
void
Frame
();
46
47
private
:
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
{
55
MOUSE_INACTIVE
,
56
MOUSE_ACTIVATING
,
57
MOUSE_ACTIVE_UP
,
58
MOUSE_ACTIVE_DOWN
59
};
60
static
const
size_t
MAX_MOUSE
= 2;
61
int
m_MouseEmulateState
[
MAX_MOUSE
];
62
CVector2D
m_MouseEmulateDownPos
[
MAX_MOUSE
];
63
64
// Current finger state:
65
static
const
size_t
MAX_FINGERS
= 2;
66
bool
m_Down
[
MAX_FINGERS
];
67
CVector2D
m_Pos
[
MAX_FINGERS
];
68
CVector2D
m_Prev
[
MAX_FINGERS
];
69
70
71
enum
72
{
73
STATE_INACTIVE
,
74
STATE_FIRST_TOUCH
,
75
STATE_PANNING
,
76
STATE_ZOOMING
77
};
78
int
m_State
;
79
80
double
m_FirstTouchTime
;
81
CVector2D
m_FirstTouchPos
;
82
83
CVector3D
m_PanFocus
;
84
float
m_PanDist
;
85
};
86
87
extern
CTouchInput
g_TouchInput
;
88
89
extern
InReaction
touch_input_handler
(
const
SDL_Event_
* ev);
90
91
#endif // INCLUDED_TOUCHINPUT
CTouchInput::HandleEvent
InReaction HandleEvent(const SDL_Event_ *ev)
Definition:
TouchInput.cpp:185
CTouchInput::m_MouseEmulateState
int m_MouseEmulateState[MAX_MOUSE]
Definition:
TouchInput.h:61
CTouchInput::STATE_PANNING
Definition:
TouchInput.h:75
CTouchInput::IsEnabled
bool IsEnabled()
Returns whether the touch input mode is enabled for this device.
Definition:
TouchInput.cpp:54
input.h
CTouchInput::m_Prev
CVector2D m_Prev[MAX_FINGERS]
Definition:
TouchInput.h:68
CTouchInput::MAX_FINGERS
static const size_t MAX_FINGERS
Definition:
TouchInput.h:65
CTouchInput::STATE_ZOOMING
Definition:
TouchInput.h:76
Vector2D.h
CTouchInput::MOUSE_INACTIVE
Definition:
TouchInput.h:55
CVector3D
Definition:
Vector3D.h:28
CTouchInput::m_Down
bool m_Down[MAX_FINGERS]
Definition:
TouchInput.h:66
CTouchInput
Maps touch events (e.g.
Definition:
TouchInput.h:29
touch_input_handler
InReaction touch_input_handler(const SDL_Event_ *ev)
Definition:
TouchInput.cpp:293
CTouchInput::~CTouchInput
~CTouchInput()
Definition:
TouchInput.cpp:50
CTouchInput::MAX_MOUSE
static const size_t MAX_MOUSE
Definition:
TouchInput.h:60
SDL_Event_
Definition:
libsdl.h:54
CTouchInput::OnFingerDown
void OnFingerDown(int id, int x, int y)
Definition:
TouchInput.cpp:63
CTouchInput::m_FirstTouchPos
CVector2D m_FirstTouchPos
Definition:
TouchInput.h:81
CTouchInput::MOUSE_ACTIVE_UP
Definition:
TouchInput.h:57
g_TouchInput
CTouchInput g_TouchInput
Definition:
TouchInput.cpp:291
InReaction
InReaction
Definition:
input.h:34
CTouchInput::STATE_FIRST_TOUCH
Definition:
TouchInput.h:74
CTouchInput::MOUSE_ACTIVE_DOWN
Definition:
TouchInput.h:58
CTouchInput::OnFingerUp
void OnFingerUp(int id, int x, int y)
Definition:
TouchInput.cpp:81
CTouchInput::m_Pos
CVector2D m_Pos[MAX_FINGERS]
Definition:
TouchInput.h:67
CTouchInput::m_FirstTouchTime
double m_FirstTouchTime
Definition:
TouchInput.h:80
CVector2D
Definition:
Vector2D.h:31
CTouchInput::m_PanFocus
CVector3D m_PanFocus
Definition:
TouchInput.h:83
CTouchInput::STATE_INACTIVE
Definition:
TouchInput.h:73
Vector3D.h
CTouchInput::CTouchInput
CTouchInput()
Definition:
TouchInput.cpp:40
CTouchInput::Frame
void Frame()
Should be called once per frame to perform updates.
Definition:
TouchInput.cpp:163
CTouchInput::OnFingerMotion
void OnFingerMotion(int id, int x, int y)
Definition:
TouchInput.cpp:114
CTouchInput::m_State
int m_State
Definition:
TouchInput.h:78
CTouchInput::m_MouseEmulateDownPos
CVector2D m_MouseEmulateDownPos[MAX_MOUSE]
Definition:
TouchInput.h:62
CTouchInput::MOUSE_ACTIVATING
Definition:
TouchInput.h:56
CTouchInput::m_PanDist
float m_PanDist
Definition:
TouchInput.h:84
Generated on Mon Oct 14 2013 00:58:08 for Pyrogenesis by
1.8.5