Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add buffer to screen edge for validation crosshair placement #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

slimdom
Copy link

@slimdom slimdom commented Apr 22, 2020

Adds an optional command line setting to configure buffer around screen perimeter in which crosshairs will not appear during validation. Useful for cases with bezels or screens with hard-to-reach corners.

@@ -160,6 +161,12 @@ static int ts_validate(struct tsdev *ts, int boundary, unsigned int loops, int t

if (loops == 0)
loops = VALIDATE_LOOPS_DEFAULT;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are spaces. please remove.

@@ -358,6 +369,16 @@ int main(int argc, char **argv)

validate_loops = atoi(optarg);
break;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spaces or tabs here. please remove.

Copy link
Member

@merge merge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than the spaces/tabs this looks really good! thanks.

@@ -160,6 +161,11 @@ static int ts_validate(struct tsdev *ts, int boundary, unsigned int loops, int t

if (loops == 0)
loops = VALIDATE_LOOPS_DEFAULT;
if ((edgebuf + 1) > ((int)xres/2) || (edgebuf + 1) > ((int)yres/2)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this should also do a lower bounds check in case EDGE_BUFFER_MIN changes in the future:

if (edgebuf < EDGE_BUFFER_MIN || (edgebuf + 1) > ((int)xres/2) || (edgebuf + 1) > ((int)yres/2)) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added lower bounds check for edgebuf

@@ -160,6 +161,11 @@ static int ts_validate(struct tsdev *ts, int boundary, unsigned int loops, int t

if (loops == 0)
loops = VALIDATE_LOOPS_DEFAULT;
if (edgebug < EDGE_BUFFER_MIN || (edgebuf + 1) > ((int)xres/2) || (edgebuf + 1) > ((int)yres/2)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo "edgebug". please test your changes! thanks, looks good otherwise.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo corrected.

edgebuf = EDGE_BUFFER_MIN;
fprintf(stderr, "Edge buffer out of range. Using %d\n",
edgebuf);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the cast to int here? anyways: gcc warns here, which we want to avoid:

ts_calibrate.c: In function ‘ts_validate’:
ts_calibrate.c:164:14: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]
  if (edgebuf < EDGE_BUFFER_MIN || (edgebuf + 1) > ((int)xres/2) || (edgebuf + 1) > ((int)yres/2)) {
              ^
ts_calibrate.c:164:49: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  if (edgebuf < EDGE_BUFFER_MIN || (edgebuf + 1) > ((int)xres/2) || (edgebuf + 1) > ((int)yres/2)) {
                                                 ^
ts_calibrate.c:164:82: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  if (edgebuf < EDGE_BUFFER_MIN || (edgebuf + 1) > ((int)xres/2) || (edgebuf + 1) > ((int)yres/2)) {

@slpn-lampe
Copy link
Contributor

I was about to open a similar pull request. An option to keep the validation crosses away from the screen edge would be useful.

With our typical screen resolutions, using int instead of unsigned int would be ok and not cause different signedness warnings, if that is the main objection.

@merge
Copy link
Member

merge commented Jan 23, 2024

does the now merged --border option cover this usecase too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants