blob: bbdfdfb50b6af7dd2f6f87b06cb4f01f38521aa0 [file] [log] [blame]
Dees_Troy51a0e822012-09-05 15:24:24 -04001/*
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
20typedef void* gr_surface;
21typedef unsigned short gr_pixel;
22
23int gr_init(void);
24void gr_exit(void);
25
26int gr_fb_width(void);
27int gr_fb_height(void);
28gr_pixel *gr_fb_data(void);
29void gr_flip(void);
Dees_Troy70237dc2013-02-28 21:31:48 +000030int gr_fb_blank(int blank);
Dees_Troy51a0e822012-09-05 15:24:24 -040031
32void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
33void gr_fill(int x, int y, int w, int h);
34
35int gr_textEx(int x, int y, const char *s, void* font);
36int gr_textExW(int x, int y, const char *s, void* font, int max_width);
37int gr_textExWH(int x, int y, const char *s, void* pFont, int max_width, int max_height);
38int twgr_text(int x, int y, const char *s);
39static inline int gr_text(int x, int y, const char *s) { return gr_textEx(x, y, s, NULL); }
40int gr_measureEx(const char *s, void* font);
41static inline int gr_measure(const char *s) { return gr_measureEx(s, NULL); }
42
43int gr_getFontDetails(void* font, unsigned* cheight, unsigned* maxwidth);
44static inline void gr_font_size(int *x, int *y) { gr_getFontDetails(NULL, (unsigned*) y, (unsigned*) x); }
45
46void* gr_loadFont(const char* fontName);
47
48void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
49unsigned int gr_get_width(gr_surface surface);
50unsigned int gr_get_height(gr_surface surface);
51int gr_get_surface(gr_surface* surface);
52int gr_free_surface(gr_surface surface);
53
54// input event structure, include <linux/input.h> for the definition.
55// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
56struct input_event;
57
58int ev_init(void);
59void ev_exit(void);
Dees_Troyb7ecc092013-08-24 12:15:41 +000060int ev_get(struct input_event *ev, unsigned dont_wait);
Vojtech Bocek1fc30fc2014-01-29 18:37:19 +010061int ev_has_mouse(void);
Dees_Troy51a0e822012-09-05 15:24:24 -040062
63// Resources
64
65// Returns 0 if no error, else negative.
66int res_create_surface(const char* name, gr_surface* pSurface);
67void res_free_surface(gr_surface surface);
68
69// Needed for AOSP:
70int ev_wait(int timeout);
71void ev_dispatch(void);
72int ev_get_input(int fd, short revents, struct input_event *ev);
73
Samer Diab (S.a.M.e.R_d)71e9b042014-01-07 20:18:47 +000074int vibrate(int timeout_ms);
75
Dees_Troy51a0e822012-09-05 15:24:24 -040076#endif