examples/touchscreen/tc_main.c: Appease nxstyle
This commit is contained in:
parent
89a4d02fce
commit
c8f2f0f262
@ -109,6 +109,7 @@ int main(int argc, FAR char *argv[])
|
||||
{
|
||||
nsamples = strtol(argv[1], NULL, 10);
|
||||
}
|
||||
|
||||
printf("tc_main: nsamples: %d\n", nsamples);
|
||||
|
||||
/* Open the touchscreen device for reading */
|
||||
@ -127,104 +128,105 @@ int main(int argc, FAR char *argv[])
|
||||
* touchscreen samples.
|
||||
*/
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Flush any output before the loop entered or from the previous pass
|
||||
* through the loop.
|
||||
*/
|
||||
for (; ; )
|
||||
{
|
||||
/* Flush any output before the loop entered or from the previous pass
|
||||
* through the loop.
|
||||
*/
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stdout);
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_TOUCHSCREEN_MOUSE
|
||||
/* Read one sample */
|
||||
/* Read one sample */
|
||||
|
||||
iinfo("Reading...\n");
|
||||
nbytes = read(fd, &sample, sizeof(struct mouse_report_s));
|
||||
iinfo("Bytes read: %d\n", nbytes);
|
||||
iinfo("Reading...\n");
|
||||
nbytes = read(fd, &sample, sizeof(struct mouse_report_s));
|
||||
iinfo("Bytes read: %d\n", nbytes);
|
||||
|
||||
/* Handle unexpected return values */
|
||||
/* Handle unexpected return values */
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
errval = errno;
|
||||
if (errval != EINTR)
|
||||
{
|
||||
printf("tc_main: read %s failed: %d\n",
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval);
|
||||
errval = 3;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
if (nbytes < 0)
|
||||
{
|
||||
errval = errno;
|
||||
if (errval != EINTR)
|
||||
{
|
||||
printf("tc_main: read %s failed: %d\n",
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval);
|
||||
errval = 3;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
printf("tc_main: Interrupted read...\n");
|
||||
}
|
||||
else if (nbytes != sizeof(struct mouse_report_s))
|
||||
{
|
||||
printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n",
|
||||
nbytes, sizeof(struct mouse_report_s));
|
||||
}
|
||||
printf("tc_main: Interrupted read...\n");
|
||||
}
|
||||
else if (nbytes != sizeof(struct mouse_report_s))
|
||||
{
|
||||
printf("tc_main: Unexpected read size=%d, expected=%d, Ignoring\n",
|
||||
nbytes, sizeof(struct mouse_report_s));
|
||||
}
|
||||
|
||||
/* Print the sample data on successful return */
|
||||
/* Print the sample data on successful return */
|
||||
|
||||
else
|
||||
{
|
||||
printf("Sample :\n");
|
||||
printf(" buttons : %02x\n", sample.buttons);
|
||||
printf(" x : %d\n", sample.x);
|
||||
printf(" y : %d\n", sample.y);
|
||||
else
|
||||
{
|
||||
printf("Sample :\n");
|
||||
printf(" buttons : %02x\n", sample.buttons);
|
||||
printf(" x : %d\n", sample.x);
|
||||
printf(" y : %d\n", sample.y);
|
||||
#ifdef CONFIG_MOUSE_WHEEL
|
||||
printf(" wheel : %d\n", sample.wheel);
|
||||
printf(" wheel : %d\n", sample.wheel);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* Read one sample */
|
||||
/* Read one sample */
|
||||
|
||||
iinfo("Reading...\n");
|
||||
nbytes = read(fd, &sample, sizeof(struct touch_sample_s));
|
||||
iinfo("Bytes read: %d\n", nbytes);
|
||||
iinfo("Reading...\n");
|
||||
nbytes = read(fd, &sample, sizeof(struct touch_sample_s));
|
||||
iinfo("Bytes read: %d\n", nbytes);
|
||||
|
||||
/* Handle unexpected return values */
|
||||
/* Handle unexpected return values */
|
||||
|
||||
if (nbytes < 0)
|
||||
{
|
||||
errval = errno;
|
||||
if (errval != EINTR)
|
||||
{
|
||||
printf("tc_main: read %s failed: %d\n",
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval);
|
||||
errval = 3;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
if (nbytes < 0)
|
||||
{
|
||||
errval = errno;
|
||||
if (errval != EINTR)
|
||||
{
|
||||
printf("tc_main: read %s failed: %d\n",
|
||||
CONFIG_EXAMPLES_TOUCHSCREEN_DEVPATH, errval);
|
||||
errval = 3;
|
||||
goto errout_with_dev;
|
||||
}
|
||||
|
||||
printf("tc_main: Interrupted read...\n");
|
||||
}
|
||||
else if (nbytes != sizeof(struct touch_sample_s))
|
||||
{
|
||||
printf("tc_main: Unexpected read size=%ld, expected=%d, Ignoring\n",
|
||||
(long)nbytes, sizeof(struct touch_sample_s));
|
||||
}
|
||||
printf("tc_main: Interrupted read...\n");
|
||||
}
|
||||
else if (nbytes != sizeof(struct touch_sample_s))
|
||||
{
|
||||
printf("tc_main: Unexpected read size=%ld, expected=%d, "
|
||||
"Ignoring\n",
|
||||
(long)nbytes, sizeof(struct touch_sample_s));
|
||||
}
|
||||
|
||||
/* Print the sample data on successful return */
|
||||
/* Print the sample data on successful return */
|
||||
|
||||
else
|
||||
{
|
||||
printf("Sample :\n");
|
||||
printf(" npoints : %d\n", sample.npoints);
|
||||
printf("Point 1 :\n");
|
||||
printf(" id : %d\n", sample.point[0].id);
|
||||
printf(" flags : %02x\n", sample.point[0].flags);
|
||||
printf(" x : %d\n", sample.point[0].x);
|
||||
printf(" y : %d\n", sample.point[0].y);
|
||||
printf(" h : %d\n", sample.point[0].h);
|
||||
printf(" w : %d\n", sample.point[0].w);
|
||||
printf(" pressure : %d\n", sample.point[0].pressure);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Sample :\n");
|
||||
printf(" npoints : %d\n", sample.npoints);
|
||||
printf("Point 1 :\n");
|
||||
printf(" id : %d\n", sample.point[0].id);
|
||||
printf(" flags : %02x\n", sample.point[0].flags);
|
||||
printf(" x : %d\n", sample.point[0].x);
|
||||
printf(" y : %d\n", sample.point[0].y);
|
||||
printf(" h : %d\n", sample.point[0].h);
|
||||
printf(" w : %d\n", sample.point[0].w);
|
||||
printf(" pressure : %d\n", sample.point[0].pressure);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (nsamples && --nsamples <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nsamples && --nsamples <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
errout_with_dev:
|
||||
close(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user