This repository has been archived by the owner on Sep 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
touchcontroloverlay.h
115 lines (94 loc) · 2.76 KB
/
touchcontroloverlay.h
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Copyright (c) 2011 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _TOUCHCONTROLOVERLAY_H_INCLUDED
#define _TOUCHCONTROLOVERLAY_H_INCLUDED
#include <sys/platform.h>
#include <screen/screen.h>
__BEGIN_DECLS
/**
* tco library functions that may fail
* return \c TCO_SUCCESS on success.
*/
#define TCO_SUCCESS (0)
/**
* tco library functions that may fail return
* \c TCO_FAILURE on error and
* may set errno.
*/
#define TCO_FAILURE (-1)
#define TCO_UNHANDLED (2)
/**
* File version number
*/
#define TCO_FILE_VERSION 1
struct tco_callbacks {
int (*handleKeyFunc)(int sym, int mod, int scancode, uint16_t unicode, int event);
int (*handleDPadFunc)(int angle, int event);
int (*handleTouchFunc)(int dx, int dy);
int (*handleMouseButtonFunc)(int button, int mask, int event); // TODO: Unify keyboard mod with mouse mask
int (*handleTapFunc)();
int (*handleTouchScreenFunc)(int x, int y, int tap, int hold);
};
enum EmuKeyButtonState {
TCO_KB_DOWN = 0,
TCO_KB_UP = 1
};
enum EmuMouseButton {
TCO_MOUSE_LEFT_BUTTON = 0,
TCO_MOUSE_RIGHT_BUTTON = 1,
TCO_MOUSE_MIDDLE_BUTTON = 2
};
enum EmuKeyMask {
TCO_SHIFT = 0x1,
TCO_CTRL = 0x2,
TCO_ALT = 0x4
};
enum EmuMouseButtonState {
TCO_MOUSE_BUTTON_DOWN = 0,
TCO_MOUSE_BUTTON_UP = 1
};
typedef void * tco_context_t;
/**
* Initialize the touch control overlay layer and context.
*/
int tco_initialize(tco_context_t *context, screen_context_t screenContext, struct tco_callbacks callbacks);
/**
* Load the controls from a file.
*/
int tco_loadcontrols(tco_context_t context, const char* filename);
/**
* Load default controls as a fallback.
*/
int tco_loadcontrols_default(tco_context_t context);
/**
* Show configuration window
* NOTE: the window MUST have a window group set already.
*/
int tco_swipedown(tco_context_t context, screen_window_t window);
/**
* Show overlay labels
*/
int tco_showlabels(tco_context_t context, screen_window_t window);
/**
* Provide touch events
*/
int tco_touch(tco_context_t context, screen_event_t event);
/**
* Cleanup and shutdown
*/
void tco_shutdown(tco_context_t context);
__END_DECLS
#endif /* _TOUCHCONTROLOVERLAY_H_INCLUDED */