PERFORCE change 214580 for review
Brooks Davis
brooks at FreeBSD.org
Wed Jul 18 22:39:46 UTC 2012
http://p4web.freebsd.org/@@214580?ac=10
Change 214580 by brooks at brooks_ecr_current on 2012/07/18 22:39:42
Sort argument processing.
Add a vstripes subcommand to draw black and white stripes on
the screen.
Affected files ...
.. //depot/projects/ctsrd/beribsd/src/ctsrd/mtlctl/mtlctl.c#2 edit
Differences ...
==== //depot/projects/ctsrd/beribsd/src/ctsrd/mtlctl/mtlctl.c#2 (text+ko) ====
@@ -81,10 +81,12 @@
usage(void)
{
- printf("usage: mtlclt gesture\n");
- printf(" mtlclt gestures\n");
+ printf("usage: \n");
printf(" mtlclt fbdump <file>\n");
printf(" mtlclt fbloaddump <file>\n");
+ printf(" mtlclt gesture\n");
+ printf(" mtlclt gestures\n");
+ printf(" mtlclt vstripes <width>\n");
exit(1);
}
@@ -166,7 +168,7 @@
int
main(int argc, char *argv[] __unused)
{
- int b, fd, i;
+ int b, fd, i, j;
u_int32_t *image;
if (argc < 2)
@@ -174,12 +176,7 @@
fb_init();
- if (strcmp(argv[1], "gesture") == 0)
- print_gesture();
- else if (strcmp(argv[1], "gestures") == 0)
- for (;;)
- print_gesture();
- else if (strcmp(argv[1], "fbdump") == 0) {
+ if (strcmp(argv[1], "fbdump") == 0) {
if (argc != 3)
usage();
image = malloc(fb_width * fb_height * 4);
@@ -187,8 +184,7 @@
err(1, "malloc");
if ((fd = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC)) == -1)
err(1, "open");
- for (i = 0; i < fb_width * fb_height; i++)
- image[i] = pfbp[i];
+ fb_save(image);
for (i = 0; i < fb_width * fb_height * 4; i += b) {
b = write(fd, image, fb_width * fb_height * 4 - i);
if (b == -1)
@@ -199,7 +195,7 @@
usage();
image = malloc(fb_width * fb_height * 4);
if (image == NULL)
- err(1, "malloc");
+ err(1, "malloc image buf");
if ((fd = open(argv[2], O_RDONLY)) == -1)
err(1, "open");
for (i = 0; i < fb_width * fb_height * 4; i += b) {
@@ -208,7 +204,34 @@
err(1, "read");
}
fb_post(image);
- }
+ } else if (strcmp(argv[1], "gesture") == 0) {
+ print_gesture();
+ } else if (strcmp(argv[1], "gestures") == 0) {
+ for (;;)
+ print_gesture();
+ } else if (strcmp(argv[1], "vstripes") == 0) {
+ int width;
+ char *endp;
+ if (argc != 3)
+ usage();
+ width = strtoul(argv[2], &endp, 0);
+ if (*endp != '\0' || width > fb_width) {
+ warnx("Invalid width '%s'", argv[2]);
+ usage();
+ }
+
+ image = malloc(fb_width * fb_height * 4);
+ if (image == NULL)
+ err(1, "malloc image buf");
+ for (i = 0; i < fb_width; i++)
+ for (j = 0; j < fb_height; j++)
+ image[i + j * fb_width] =
+ (((i / width) & 0x1) == 1) ?
+ fb_colour(0xff, 0xff, 0xff) :
+ fb_colour(0, 0, 0);
+ fb_post(image);
+ } else
+ usage();
return (0);
}
More information about the p4-projects
mailing list