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/sdk-controller-socket.h" 21 #include "android/multitouch-port.h" 22 23 /* 24 * Encapsulates functionality of multi-touch screen. Main task of this component 25 * is to report touch events to the emulated system via event device (see 26 * hw/goldfish_events_device.c) The source of touch events can be a mouse, or an 27 * actual android device that is used for multi-touch emulation. Note that since 28 * we need to simultaneousely support a mouse and a device as event source, we 29 * need to know which one has sent us a touch event. This is important for proper 30 * tracking of pointer IDs when multitouch is in play. 31 */ 32 33 /* Defines a source of multi-touch event. This is used to properly track 34 * pointer IDs. 35 */ 36 typedef enum MTESource { 37 /* The event is associated with a mouse. */ 38 MTES_MOUSE, 39 /* The event is associated with an actual android device. */ 40 MTES_DEVICE, 41 } MTESource; 42 43 /* Initializes MTSState instance. 44 * Param: 45 * mtsp - Instance of the multi-touch port connected to the device. 46 */ 47 extern void multitouch_init(AndroidMTSPort* mtsp); 48 49 /* Handles a MT pointer event. 50 * Param: 51 * source - Identifies the source of the event (mouse or a device). 52 * tracking_id - Tracking ID of the pointer. 53 * x, y - Pointer coordinates, 54 * pressure - Pressure value for the pointer. 55 */ 56 extern void multitouch_update_pointer(MTESource source, 57 int tracking_id, 58 int x, 59 int y, 60 int pressure); 61 62 /* Gets maximum slot index available for the multi-touch emulation. */ 63 extern int multitouch_get_max_slot(); 64 65 /* A callback set to monitor OpenGLES framebuffer updates. 66 * This callback is called by the renderer just before each new frame is 67 * displayed, providing a copy of the framebuffer contents. 68 * The callback will be called from one of the renderer's threads, so it may 69 * require synchronization on any data structures it modifies. The pixels buffer 70 * may be overwritten as soon as the callback returns. 71 * The pixels buffer is intentionally not const: the callback may modify the data 72 * without copying to another buffer if it wants, e.g. in-place RGBA to RGB 73 * conversion, or in-place y-inversion. 74 * Param: 75 * context The pointer optionally provided when the callback was 76 * registered. The client can use this to pass whatever 77 * information it wants to the callback. 78 * width, height Dimensions of the image, in pixels. Rows are tightly packed; 79 * there is no inter-row padding. 80 * ydir Indicates row order: 1 means top-to-bottom order, -1 means 81 * bottom-to-top order. 82 * format, type Format and type GL enums, as used in glTexImage2D() or 83 * glReadPixels(), describing the pixel format. 84 * pixels The framebuffer image. 85 * 86 * In the first implementation, ydir is always -1 (bottom to top), format and 87 * type are always GL_RGBA and GL_UNSIGNED_BYTE, and the width and height will 88 * always be the same as the ones passed to initOpenGLRenderer(). 89 */ 90 extern void multitouch_opengles_fb_update(void* context, 91 int width, 92 int height, 93 int ydir, 94 int format, 95 int type, 96 unsigned char* pixels); 97 98 /* Pushes the entire framebuffer to the device. This will force the device to 99 * refresh the entire screen. 100 */ 101 extern void multitouch_refresh_screen(void); 102 103 /* Framebuffer update has been handled by the device. */ 104 extern void multitouch_fb_updated(void); 105 106 #endif /* ANDROID_MULTITOUCH_SCREEN_H_ */ 107