Skip to content

Commit

Permalink
(distr) inputanalog_query to wmsupport.lua for touchscreen range
Browse files Browse the repository at this point in the history
If possible, will use information returned by inputanalog_query to calibrate touch input range.
Otherwise will fallback to display dimensions as it was done before.
Autorange algorithm is kept just in case the touchscreen doesn't provide it's range and does not match the display dimensions.
  • Loading branch information
cipharius committed May 11, 2023
1 parent 42ec5d8 commit be2ee43
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions data/scripts/builtin/wmsupport.lua
Expand Up @@ -133,13 +133,18 @@ if not wm_touch_normalize then
local rangetbl = {}
wm_touch_normalize =
function(io)
-- there is no support script for touch- ranging yet as the scripts in durden
-- are not mature enough (and no input platform that does the job) - assume
-- values are ranged to the display, then autorange as needed.
local rt, w, h, _, _ = wm_active_display()
local range = rangetbl[io.devid]
if not range then
range = {w, h}
local x_axis = inputanalog_query(io.devid, 0);
local y_axis = inputanalog_query(io.devid, 1);

if (x_axis and y_axis) then
range = {x_axis.upper_bound, y_axis.upper_bound}
else
range = {w, h}
end

rangetbl[io.devid] = range
end

Expand Down

0 comments on commit be2ee43

Please sign in to comment.