Tiny6410 觸控驅動輸出為單一 32-bit 整數 (jjts) 封裝 X/Y/壓力,非標準 input_event 結構。需修改 plugins/input-raw.c 中的 ts_input_read。
static int ts_input_read(struct tslib_module_info *inf,
struct ts_sample *samp, int nr) {
struct tslib_input *i = (struct tslib_input*)inf;
struct tsdev *ts = inf->dev;
struct input_event ev;
int ret = nr, total = 0;
while (total < nr) {
ret = read(ts->fd, &ev, sizeof(ev));
if (ret != sizeof(ev)) return -1;
// 標準事件解析...
}
return total;
}
static int ts_input_read(struct tslib_module_info *inf,
struct ts_sample *samp, int nr) {
struct tslib_input *i = (struct tslib_input*)inf;
struct tsdev *ts = inf->dev;
int ret = nr, total = 0;
unsigned long jjts;
while (total < nr) {
ret = read(ts->fd, &jjts, sizeof(jjts));
if (ret == -1) return 0; // 關鍵:非 continue,避免 Qt 點擊無效
samp->pressure = (jjts >> 31) & 0x01;
samp->x = (jjts >> 16) & 0xFFFF;
samp->y = jjts & 0xFFFF;
samp++;
total++;
}
return total;
}
關鍵點:ret == -1 時 return 0 而非 continue,否則 Qt 程式雖能移動游標但點擊無回應。
# 1. 解壓並進入目錄
tar xf tslib-1.4.tar.gz
cd tslib-1.4
# 2. 安裝建構依賴
sudo apt-get install autoconf automake libtool
# 3. 設定安裝前綴
export PREFIX=/opt/tslib
# 4. 生成 configure 腳本
./autogen.sh
# 5. 建立交叉編譯快取 (欺騙 configure)
echo "ac_cv_func_malloc_0_nonnull=yes" > arm-linux.cache
# 6. 配置 (指定 host、prefix、cache)
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=$PREFIX --cache-file=arm-linux.cache
# 7. 編譯安裝
make
make install
成功後 /opt/tslib 下生成 bin/、etc/、include/、lib/ 四目錄。
/opt/tslib/etc/ts.confmodule_raw input
module pthres pmin=1
module variance delta=30
module dejitter delta=100
module linear
模組說明:
input:從 Linux input 子系統讀取原始資料pthres:壓力閾值濾波variance:方差濾波平滑抖動dejitter:去抖動linear:線性校正 (依據 pointercal 校準參數)# 宿主機打包
tar czf tslib.tar.gz -C /opt tslib
# 目標板解壓
tar xzf tslib.tar.gz -C /opt
tslib.sh#!/bin/sh
export TSLIB_ROOT=/opt/tslib
export TSLIB_TSDEVICE=/dev/touchscreen-1wire # 依實際裝置節點調整
export TSLIB_CALIBFILE=$TSLIB_ROOT/etc/pointercal
export TSLIB_CONFFILE=$TSLIB_ROOT/etc/ts.conf
export TSLIB_PLUGINDIR=$TSLIB_ROOT/lib/ts
export TSLIB_CONSOLEDEVICE=/dev/tty
export TSLIB_FBDEVICE=/dev/fb0
# 目標板執行
source tslib.sh
cd /opt/tslib/bin
./ts_calibrate
# 依畫面十字準星點擊 5 點,生成 pointercal
# 讓 pointercal 系統可見
ln -s /opt/tslib/etc/pointercal /etc/pointercal
# 可將 source tslib.sh 加入 /etc/profile 或啟動腳本
# 測試原始讀取
./ts_test
# 測試校準效果
./ts_calibrate
# Qt 程式測試
export QWS_MOUSE_PROTO=Tslib:/dev/touchscreen-1wire
./your_qt_app -qws
ts.conf 中 module_raw 為 input,且裝置節點正確TSLIB_PLUGINDIR 指向 lib/ts,且 libts-*.so 存在