blob: 74da4e9c0661c5546cf6ca775e2e320a58b56095 [file] [log] [blame]
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -08001/*
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
Dima Zavin4daf48a2011-08-30 11:59:20 -070020#include <stdbool.h>
21
Doug Zongker28ce47c2011-10-28 10:33:05 -070022#ifdef __cplusplus
23extern "C" {
24#endif
25
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080026typedef void* gr_surface;
27typedef unsigned short gr_pixel;
28
29int gr_init(void);
30void gr_exit(void);
31
32int gr_fb_width(void);
33int gr_fb_height(void);
34gr_pixel *gr_fb_data(void);
35void gr_flip(void);
Dima Zavin4daf48a2011-08-30 11:59:20 -070036void gr_fb_blank(bool blank);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080037
38void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
39void gr_fill(int x, int y, int w, int h);
40int gr_text(int x, int y, const char *s);
41int gr_measure(const char *s);
Dima Zavin3c7f00e2011-08-30 11:58:24 -070042void gr_font_size(int *x, int *y);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080043
44void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy);
45unsigned int gr_get_width(gr_surface surface);
46unsigned int gr_get_height(gr_surface surface);
47
48// input event structure, include <linux/input.h> for the definition.
49// see http://www.mjmwired.net/kernel/Documentation/input/ for info.
50struct input_event;
51
Dima Zavinbc290632011-08-30 11:59:45 -070052typedef int (*ev_callback)(int fd, short revents, void *data);
Dima Zavin441031d2011-10-12 15:53:29 -070053typedef int (*ev_set_key_callback)(int code, int value, void *data);
Dima Zavinbc290632011-08-30 11:59:45 -070054
55int ev_init(ev_callback input_cb, void *data);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080056void ev_exit(void);
Dima Zavin36583672011-09-02 11:51:31 -070057int ev_add_fd(int fd, ev_callback cb, void *data);
Dima Zavin441031d2011-10-12 15:53:29 -070058int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data);
Dima Zavinbc290632011-08-30 11:59:45 -070059
60/* timeout has the same semantics as for poll
61 * 0 : don't block
62 * < 0 : block forever
63 * > 0 : block for 'timeout' milliseconds
64 */
65int ev_wait(int timeout);
66
67int ev_get_input(int fd, short revents, struct input_event *ev);
68void ev_dispatch(void);
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080069
70// Resources
71
72// Returns 0 if no error, else negative.
73int res_create_surface(const char* name, gr_surface* pSurface);
74void res_free_surface(gr_surface surface);
75
Doug Zongker28ce47c2011-10-28 10:33:05 -070076#ifdef __cplusplus
77}
78#endif
79
The Android Open Source Projectc24a8e62009-03-03 19:28:42 -080080#endif