done = false;
do {
struct expo_action act;
- int ichar, key;
- ret = expo_render(exp);
- if (ret)
- break;
-
- ichar = cli_ch_process(&exp->cch, 0);
- if (!ichar) {
- while (!ichar && !tstc()) {
- schedule();
- mdelay(2);
- ichar = cli_ch_process(&exp->cch, -ETIMEDOUT);
- }
- if (!ichar) {
- ichar = getchar();
- ichar = cli_ch_process(&exp->cch, ichar);
- }
- }
-
- key = 0;
- if (ichar) {
- key = bootmenu_conv_key(ichar);
- if (key == BKEY_NONE)
- key = ichar;
- }
- if (!key)
- continue;
-
- ret = expo_send_key(exp, key);
- if (ret)
- break;
-
- ret = expo_action_get(exp, &act);
+ ret = expo_poll(exp, &act);
if (!ret) {
switch (act.type) {
case EXPOACT_SELECT:
done = true;
break;
case EXPOACT_QUIT:
- done = true;
- break;
+ return -EPIPE;
default:
break;
}
+ } else if (ret != -EPIPE && ret != -EAGAIN) {
+ return log_msg_ret("bmr", ret);
}
} while (!done);
- if (ret)
- return log_msg_ret("end", ret);
-
if (sel_id) {
struct bootflow *bflow;
int i;
save = false;
do {
struct expo_action act;
- int ichar, key;
- ret = expo_render(exp);
- if (ret)
- break;
-
- ichar = cli_ch_process(&exp->cch, 0);
- if (!ichar) {
- while (!ichar && !tstc()) {
- schedule();
- mdelay(2);
- ichar = cli_ch_process(&exp->cch, -ETIMEDOUT);
- }
- if (!ichar) {
- ichar = getchar();
- ichar = cli_ch_process(&exp->cch, ichar);
- }
- }
-
- key = 0;
- if (ichar) {
- key = bootmenu_conv_key(ichar);
- if (key == BKEY_NONE || key >= BKEY_FIRST_EXTRA)
- key = ichar;
- }
- if (!key)
- continue;
-
- ret = expo_send_key(exp, key);
- if (ret)
- break;
-
- ret = expo_action_get(exp, &act);
+ ret = expo_poll(exp, &act);
if (!ret) {
switch (act.type) {
case EXPOACT_POINT_OBJ:
default:
break;
}
+ } else if (ret != -EAGAIN) {
+ return log_msg_ret("cep", ret);
}
} while (!done);
#include <dm.h>
#include <expo.h>
+#include <log.h>
#include <malloc.h>
+#include <menu.h>
#include <video.h>
+#include <watchdog.h>
+#include <linux/delay.h>
#include "scene_internal.h"
int expo_new(const char *name, void *priv, struct expo **expp)
return 0;
}
+
+int expo_poll(struct expo *exp, struct expo_action *act)
+{
+ int ichar, key, ret;
+
+ ret = expo_render(exp);
+ if (ret)
+ return log_msg_ret("ere", ret);
+
+ ichar = cli_ch_process(&exp->cch, 0);
+ if (!ichar) {
+ while (!ichar && !tstc()) {
+ schedule();
+ mdelay(2);
+ ichar = cli_ch_process(&exp->cch, -ETIMEDOUT);
+ }
+ if (!ichar) {
+ ichar = getchar();
+ ichar = cli_ch_process(&exp->cch, ichar);
+ }
+ }
+
+ key = 0;
+ if (ichar) {
+ key = bootmenu_conv_key(ichar);
+ if (key == BKEY_NONE || key >= BKEY_FIRST_EXTRA)
+ key = ichar;
+ }
+ if (!key)
+ return -EAGAIN;
+
+ ret = expo_send_key(exp, key);
+ if (ret)
+ return log_msg_ret("epk", ret);
+ ret = expo_action_get(exp, act);
+ if (ret)
+ return log_msg_ret("eag", ret);
+
+ return 0;
+}
ret = bootflow_menu_run(std, text_mode, &bflow);
if (ret) {
- if (ret == -EAGAIN) {
+ if (ret == -EPIPE) {
printf("Nothing chosen\n");
std->cur_bootflow = NULL;
} else {
* @std: Bootstd information
* @text_mode: Uses a text-based menu suitable for a serial port
* @bflowp: Returns chosen bootflow (set to NULL if nothing is chosen)
- * @return 0 if an option was chosen, -EAGAIN if nothing was chosen, -ve on
+ * @return 0 if an option was chosen, -EPIPE if nothing was chosen, -ve on
* error
*/
int bootflow_menu_run(struct bootstd_priv *std, bool text_mode,
*/
int cb_expo_build(struct expo **expp);
+/**
+ * expo_poll() - render an expo and see if the user takes an action
+ *
+ * Thsi calls expo_render() and then checks for a keypress. If there is one, it
+ * is processed and the resulting action returned, if any
+ *
+ * @exp: Expo to poll
+ * @act: Returns action on success
+ * Return: 0 if an action was obtained, -EAGAIN if not, other error if something
+ * went wrong
+ */
+int expo_poll(struct expo *exp, struct expo_action *act);
+
#endif /*__EXPO_H */