1 /* 2 * Copyright (C) 2007 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 _MINUI_H_ 18 #define _MINUI_H_ 19 20 #include <stdbool.h> 21 22 typedef void* gr_surface; 23 typedef unsigned short gr_pixel; 24 25 int gr_init(void); 26 void gr_exit(void); 27 28 int gr_fb_width(void); 29 int gr_fb_height(void); 30 gr_pixel *gr_fb_data(void); 31 void gr_flip(void); 32 void gr_fb_blank(bool blank); 33 34 void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); 35 void gr_fill(int x, int y, int w, int h); 36 int gr_text(int x, int y, const char *s); 37 int gr_measure(const char *s); 38 void gr_font_size(int *x, int *y); 39 40 void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); 41 unsigned int gr_get_width(gr_surface surface); 42 unsigned int gr_get_height(gr_surface surface); 43 44 // input event structure, include <linux/input.h> for the definition. 45 // see http://www.mjmwired.net/kernel/Documentation/input/ for info. 46 struct input_event; 47 48 typedef int (*ev_callback)(int fd, short revents, void *data); 49 typedef int (*ev_set_key_callback)(int code, int value, void *data); 50 51 int ev_init(ev_callback input_cb, void *data); 52 void ev_exit(void); 53 int ev_add_fd(int fd, ev_callback cb, void *data); 54 int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data); 55 56 /* timeout has the same semantics as for poll 57 * 0 : don't block 58 * < 0 : block forever 59 * > 0 : block for 'timeout' milliseconds 60 */ 61 int ev_wait(int timeout); 62 63 int ev_get_input(int fd, short revents, struct input_event *ev); 64 void ev_dispatch(void); 65 66 // Resources 67 68 // Returns 0 if no error, else negative. 69 int res_create_surface(const char* name, gr_surface* pSurface); 70 void res_free_surface(gr_surface surface); 71 72 #endif 73