b9f7c9347c
The runtime has always called fields on the table main.lua returns, but @lua-global declared them as loose functions, so the stubs type-checked something that does not exist and read as "define a global". Callbacks are now @lua-app blocks that generate a class: App for the core contract, TouchHandlers and ButtonHandlers beside the namespaces they belong to. An app composes what it implements: ---@class PaintApp : App, TouchHandlers Names follow the rest of the surface: onTouchDown rather than on_touch_down, with the field names the runtime looks up renamed to match. @lua-field carries the plain fields (home, data) that were prose in a preamble before.
40 lines
1.4 KiB
Lua
40 lines
1.4 KiB
Lua
---@meta
|
|
|
|
-- Generated from native/src/bindings/features/touch.cpp. Do not edit.
|
|
|
|
---@class TouchLib
|
|
touch = {}
|
|
|
|
---Returns the calibrated touch point, or nothing when the panel is not touched.
|
|
---@return integer? x
|
|
---@return integer? y
|
|
function touch.getPoint() end
|
|
|
|
---Returns the uncalibrated touch reading, or nothing when the panel is not touched.
|
|
---@return integer? x
|
|
---@return integer? y
|
|
function touch.getRawPoint() end
|
|
|
|
---Whether the panel is currently touched.
|
|
---@return boolean
|
|
function touch.isTouched() end
|
|
|
|
---Persists the panel's touch calibration.
|
|
---@param x0 integer Raw reading at the left edge.
|
|
---@param y0 integer Raw reading at the top edge.
|
|
---@param x1 integer Raw reading at the right edge.
|
|
---@param y1 integer Raw reading at the bottom edge.
|
|
---@return true? ok
|
|
---@return string? error
|
|
function touch.setCalibration(x0, y0, x1, y1) end
|
|
|
|
-- What an app implements to see raw touch, composed into its own class:
|
|
--
|
|
-- ---@class PaintApp : App, TouchHandlers
|
|
|
|
---@class TouchHandlers
|
|
---@field onTouchDown? fun(x: integer, y: integer) Fired when the finger lands.
|
|
---@field onTouchMove? fun(x: integer, y: integer) Fired when the finger moves while down, after the firmware's jitter filter.
|
|
---@field onTouchUp? fun(x: integer, y: integer) Fired when the finger lifts.
|
|
---@field onTouch? fun(x: integer, y: integer) Tap alias, fired on release like a click, after onTouchUp.
|