Skip to content

Commit 421a423

Browse files
faxe1008nashif
authored andcommitted
drivers: input: Add input-touch assert for inversion without dimensions
Adds an assert to inform the user of possible coordinate wrap around due to missing screen dimension configurations. Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
1 parent e891ca6 commit 421a423

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/input/input_touch.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ void input_touchscreen_report_pos(const struct device *dev,
1010
k_timeout_t timeout)
1111
{
1212
const struct input_touchscreen_common_config *cfg = dev->config;
13+
__ASSERT(cfg->inverted_y == (cfg->screen_height > 0),
14+
"Y coordinate inversion requires screen-height");
15+
__ASSERT(cfg->inverted_x == (cfg->screen_width > 0),
16+
"X coordinate inversion requires screen-width");
1317
const uint32_t reported_x_code = cfg->swapped_x_y ? INPUT_ABS_Y : INPUT_ABS_X;
1418
const uint32_t reported_y_code = cfg->swapped_x_y ? INPUT_ABS_X : INPUT_ABS_Y;
1519
const uint32_t reported_x = cfg->inverted_x ? cfg->screen_width - x : x;

0 commit comments

Comments
 (0)