xiaoliud commented on code in PR #4098:
URL: https://github.com/apache/nuttx-apps/pull/4098#discussion_r4661341220
##########
graphics/input/generator/input.c:
##########
@@ -259,6 +268,96 @@ static int input_button(input_gen_ctx_t ctx, int argc,
char **argv)
return result;
}
+/****************************************************************************
+ * Name: parse_scroll_value
+ ****************************************************************************/
+
+static int parse_scroll_value(int argc, char **argv, int16_t *value)
+{
+ int i;
+
+ *value = 0;
+
+ /* Simple form: scroll <value> */
+
+ if (argc >= 2 && strncmp(argv[1], "--", 2) != 0)
+ {
+ return parse_arg_to_int16(argv[1], value);
+ }
+
+ /* Android-style form: scroll --axis SCROLL,<value> */
+
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp(argv[i], "--axis") == 0 && i + 1 < argc)
+ {
+ FAR char *arg = argv[i + 1];
+ FAR char *comma = strchr(arg, ',');
+
+ if (comma == NULL)
+ {
+ return 1;
+ }
+
+ return parse_arg_to_int16(comma + 1, value);
+ }
+ }
+
+ return 1;
+}
+
+/****************************************************************************
+ * Name: input_scroll
+ ****************************************************************************/
+
+static int input_scroll(input_gen_ctx_t ctx, int argc, char **argv)
+{
+ int16_t value;
+ int16_t step;
+ int16_t sign;
+ int ret;
+
+ if (argc < 2)
+ {
+ return -EINVAL;
+ }
+
+ if (parse_scroll_value(argc, argv, &value))
Review Comment:
Done. The caller now stores the result in ret, checks ret < 0 and returns it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]