• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_MULTITOUCH_SCREEN_H_
18 #define ANDROID_MULTITOUCH_SCREEN_H_
19 
20 #include "android/multitouch-port.h"
21 
22 /*
23  * Encapsulates functionality of multi-touch screen. Main task of this component
24  * is to report touch events to the emulated system via event device (see
25  * hw/goldfish_events_device.c) The source of touch events can be a mouse, or an
26  * actual android device that is used for multi-touch emulation. Note that since
27  * we need to simultaneousely support a mouse and a device as event source, we
28  * need to know which one has sent us a touch event. This is important for proper
29  * tracking of pointer IDs when multitouch is in play.
30  */
31 
32 /* Defines a source of multi-touch event. This is used to properly track
33  * pointer IDs.
34  */
35 typedef enum MTESource {
36     /* The event is associated with a mouse. */
37     MTES_MOUSE,
38     /* The event is associated with an actual android device. */
39     MTES_DEVICE,
40 } MTESource;
41 
42 /* Initializes MTSState instance.
43  * Param:
44  *  mtsp - Instance of the multi-touch port connected to the device.
45  */
46 extern void multitouch_init(AndroidMTSPort* mtsp);
47 
48 /* Handles a MT pointer event.
49  * Param:
50  *  source - Identifies the source of the event (mouse or a device).
51  *  tracking_id - Tracking ID of the pointer.
52  *  x, y - Pointer coordinates,
53  *  pressure - Pressure value for the pointer.
54  */
55 extern void multitouch_update_pointer(MTESource source,
56                                       int tracking_id,
57                                       int x,
58                                       int y,
59                                       int pressure);
60 
61 /* Gets maximum slot index available for the multi-touch emulation. */
62 extern int multitouch_get_max_slot();
63 
64 /* Saves screen size reported by the device that emulates multi-touch. */
65 extern void multitouch_set_device_screen_size(int width, int height);
66 
67 /* A callback set to monitor OpenGLES framebuffer updates.
68  * This callback is called by the renderer just before each new frame is
69  * displayed, providing a copy of the framebuffer contents.
70  * The callback will be called from one of the renderer's threads, so it may
71  * require synchronization on any data structures it modifies. The pixels buffer
72  * may be overwritten as soon as the callback returns.
73  * The pixels buffer is intentionally not const: the callback may modify the data
74  * without copying to another buffer if it wants, e.g. in-place RGBA to RGB
75  * conversion, or in-place y-inversion.
76  * Param:
77  *   context        The pointer optionally provided when the callback was
78  *                  registered. The client can use this to pass whatever
79  *                  information it wants to the callback.
80  *   width, height  Dimensions of the image, in pixels. Rows are tightly packed;
81  *                  there is no inter-row padding.
82  *   ydir           Indicates row order: 1 means top-to-bottom order, -1 means
83  *                  bottom-to-top order.
84  *   format, type   Format and type GL enums, as used in glTexImage2D() or
85  *                  glReadPixels(), describing the pixel format.
86  *   pixels         The framebuffer image.
87  *
88  * In the first implementation, ydir is always -1 (bottom to top), format and
89  * type are always GL_RGBA and GL_UNSIGNED_BYTE, and the width and height will
90  * always be the same as the ones passed to initOpenGLRenderer().
91  */
92 extern void multitouch_opengles_fb_update(void* context,
93                                           int width,
94                                           int height,
95                                           int ydir,
96                                           int format,
97                                           int type,
98                                           unsigned char* pixels);
99 
100 #endif  /* ANDROID_MULTITOUCH_SCREEN_H_ */
101