From 0713819fd256bfdfcf241c71195b7e8c4e18c742 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 10 Apr 2015 09:40:53 -0700 Subject: Add ev_iterate_available_keys to minui. This lets us recognize whether we have up/down/power, say, and tailor the UI accordingly. Change-Id: If94e454f14243b59d2f473ac9a436bd60591da01 --- minui/minui.h | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'minui/minui.h') diff --git a/minui/minui.h b/minui/minui.h index 733b675f3..8f2ff1139 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -25,6 +25,10 @@ extern "C" { #endif +// +// Graphics. +// + typedef struct { int width; int height; @@ -56,30 +60,35 @@ void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); unsigned int gr_get_width(gr_surface surface); unsigned int gr_get_height(gr_surface surface); -// input event structure, include for the definition. -// see http://www.mjmwired.net/kernel/Documentation/input/ for info. +// +// Input events. +// + struct input_event; -typedef int (*ev_callback)(int fd, uint32_t epevents, void *data); -typedef int (*ev_set_key_callback)(int code, int value, void *data); +typedef int (*ev_callback)(int fd, uint32_t epevents, void* data); +typedef int (*ev_set_key_callback)(int code, int value, void* data); +typedef void (*ev_key_callback)(int code, void* data); -int ev_init(ev_callback input_cb, void *data); +int ev_init(ev_callback input_cb, void* data); void ev_exit(void); -int ev_add_fd(int fd, ev_callback cb, void *data); -int ev_sync_key_state(ev_set_key_callback set_key_cb, void *data); - -/* timeout has the same semantics as for poll - * 0 : don't block - * < 0 : block forever - * > 0 : block for 'timeout' milliseconds - */ +int ev_add_fd(int fd, ev_callback cb, void* data); +int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data); +void ev_iterate_available_keys(ev_key_callback cb, void* data); + +// 'timeout' has the same semantics as poll(2). +// 0 : don't block +// < 0 : block forever +// > 0 : block for 'timeout' milliseconds int ev_wait(int timeout); int ev_get_input(int fd, uint32_t epevents, struct input_event *ev); void ev_dispatch(void); int ev_get_epollfd(void); +// // Resources +// // res_create_*_surface() functions return 0 if no error, else // negative. -- cgit v1.2.3 From 642aaa7a3e11b2de719fc9decc45174bcc235c0c Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 10 Apr 2015 12:47:46 -0700 Subject: Fix ScreenRecoveryUI to handle devices without power/up/down. Currently fugu has a custom subclass to handle this. The default code supports devices with trackballs but not all shipping Nexus devices? That's just silly. Change-Id: Id2779c91284899a26b4bb1af41e7033aa889df10 --- minui/minui.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'minui/minui.h') diff --git a/minui/minui.h b/minui/minui.h index 8f2ff1139..82abb8a63 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -68,13 +68,11 @@ struct input_event; typedef int (*ev_callback)(int fd, uint32_t epevents, void* data); typedef int (*ev_set_key_callback)(int code, int value, void* data); -typedef void (*ev_key_callback)(int code, void* data); int ev_init(ev_callback input_cb, void* data); void ev_exit(void); int ev_add_fd(int fd, ev_callback cb, void* data); int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data); -void ev_iterate_available_keys(ev_key_callback cb, void* data); // 'timeout' has the same semantics as poll(2). // 0 : don't block @@ -130,4 +128,11 @@ void res_free_surface(gr_surface surface); } #endif +#ifdef __cplusplus + +#include +void ev_iterate_available_keys(std::function f); + +#endif + #endif -- cgit v1.2.3 From 07cfb8fe799901948afd6af05ef4674173713bcb Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 10 Apr 2015 13:12:05 -0700 Subject: Switch minui over to C++. Change-Id: I59e08a304ae514a3fdb6fab58721f11670bc1b01 --- minui/minui.h | 42 +++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 27 deletions(-) (limited to 'minui/minui.h') diff --git a/minui/minui.h b/minui/minui.h index 82abb8a63..eca3a5030 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -19,33 +19,30 @@ #include -#include - -#ifdef __cplusplus -extern "C" { -#endif +#include // // Graphics. // -typedef struct { +struct GRSurface { int width; int height; int row_bytes; int pixel_bytes; unsigned char* data; -} GRSurface; +}; +// TODO: remove this. typedef GRSurface* gr_surface; -int gr_init(void); -void gr_exit(void); +int gr_init(); +void gr_exit(); -int gr_fb_width(void); -int gr_fb_height(void); +int gr_fb_width(); +int gr_fb_height(); -void gr_flip(void); +void gr_flip(); void gr_fb_blank(bool blank); void gr_clear(); // clear entire surface to current color @@ -66,12 +63,14 @@ unsigned int gr_get_height(gr_surface surface); struct input_event; +// TODO: move these over to std::function. typedef int (*ev_callback)(int fd, uint32_t epevents, void* data); typedef int (*ev_set_key_callback)(int code, int value, void* data); int ev_init(ev_callback input_cb, void* data); -void ev_exit(void); +void ev_exit(); int ev_add_fd(int fd, ev_callback cb, void* data); +void ev_iterate_available_keys(std::function f); int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data); // 'timeout' has the same semantics as poll(2). @@ -80,9 +79,9 @@ int ev_sync_key_state(ev_set_key_callback set_key_cb, void* data); // > 0 : block for 'timeout' milliseconds int ev_wait(int timeout); -int ev_get_input(int fd, uint32_t epevents, struct input_event *ev); -void ev_dispatch(void); -int ev_get_epollfd(void); +int ev_get_input(int fd, uint32_t epevents, input_event* ev); +void ev_dispatch(); +int ev_get_epollfd(); // // Resources @@ -124,15 +123,4 @@ int res_create_localized_alpha_surface(const char* name, const char* locale, // functions. void res_free_surface(gr_surface surface); -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus - -#include -void ev_iterate_available_keys(std::function f); - -#endif - #endif -- cgit v1.2.3 From 8fd86d77f1a2f15c6fa95bc390bcbe646374873a Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 13 Apr 2015 14:36:02 -0700 Subject: Move the menu header out of the menu. This makes it easier for us to deal with arbitrary information at the top, and means that headers added by specific commands don't overwrite the default ones. Add the fingerprint back, but broken up so it fits even on sprout's display. Change-Id: Id71da79ab1aa455a611d72756a3100a97ceb4c1c --- minui/minui.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'minui/minui.h') diff --git a/minui/minui.h b/minui/minui.h index eca3a5030..936f7eec8 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -48,7 +48,7 @@ void gr_fb_blank(bool blank); void gr_clear(); // clear entire surface to current color void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); void gr_fill(int x1, int y1, int x2, int y2); -void gr_text(int x, int y, const char *s, int bold); +void gr_text(int x, int y, const char *s, bool bold); void gr_texticon(int x, int y, gr_surface icon); int gr_measure(const char *s); void gr_font_size(int *x, int *y); -- cgit v1.2.3 From 0a5cb0c7cd995ae0330a7d54a8d0db5d892a48a9 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 15 Apr 2015 10:58:56 -0700 Subject: Don't use typedefs that hide *s. gr_surface was causing confusion for no good reason. Change-Id: If7120187f9a00dd16297877fc49352185a4d4ea6 --- minui/minui.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'minui/minui.h') diff --git a/minui/minui.h b/minui/minui.h index 936f7eec8..bdde083f3 100644 --- a/minui/minui.h +++ b/minui/minui.h @@ -33,9 +33,6 @@ struct GRSurface { unsigned char* data; }; -// TODO: remove this. -typedef GRSurface* gr_surface; - int gr_init(); void gr_exit(); @@ -49,13 +46,13 @@ void gr_clear(); // clear entire surface to current color void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a); void gr_fill(int x1, int y1, int x2, int y2); void gr_text(int x, int y, const char *s, bool bold); -void gr_texticon(int x, int y, gr_surface icon); +void gr_texticon(int x, int y, GRSurface* icon); int gr_measure(const char *s); void gr_font_size(int *x, int *y); -void gr_blit(gr_surface source, int sx, int sy, int w, int h, int dx, int dy); -unsigned int gr_get_width(gr_surface surface); -unsigned int gr_get_height(gr_surface surface); +void gr_blit(GRSurface* source, int sx, int sy, int w, int h, int dx, int dy); +unsigned int gr_get_width(GRSurface* surface); +unsigned int gr_get_height(GRSurface* surface); // // Input events. @@ -98,17 +95,17 @@ int ev_get_epollfd(); // All these functions load PNG images from "/res/images/${name}.png". // Load a single display surface from a PNG image. -int res_create_display_surface(const char* name, gr_surface* pSurface); +int res_create_display_surface(const char* name, GRSurface** pSurface); // Load an array of display surfaces from a single PNG image. The PNG // should have a 'Frames' text chunk whose value is the number of // frames this image represents. The pixel data itself is interlaced // by row. int res_create_multi_display_surface(const char* name, - int* frames, gr_surface** pSurface); + int* frames, GRSurface*** pSurface); // Load a single alpha surface from a grayscale PNG image. -int res_create_alpha_surface(const char* name, gr_surface* pSurface); +int res_create_alpha_surface(const char* name, GRSurface** pSurface); // Load part of a grayscale PNG image that is the first match for the // given locale. The image is expected to be a composite of multiple @@ -117,10 +114,10 @@ int res_create_alpha_surface(const char* name, gr_surface* pSurface); // development/tools/recovery_l10n for an app that will generate these // specialized images from Android resources. int res_create_localized_alpha_surface(const char* name, const char* locale, - gr_surface* pSurface); + GRSurface** pSurface); // Free a surface allocated by any of the res_create_*_surface() // functions. -void res_free_surface(gr_surface surface); +void res_free_surface(GRSurface* surface); #endif -- cgit v1.2.3