52 lines
1.9 KiB
C
52 lines
1.9 KiB
C
/* probe_input.c — 读 goodix-ts 触摸 ABS 范围 + fb0 分辨率。
|
|
* 用于确认「歌单列表触摸坐标有偏差/串行」是否由触摸面板分辨率与帧缓冲不一致引起。
|
|
* 本地设备操作,零 NCM 请求。 */
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <linux/input.h>
|
|
#include <linux/fb.h>
|
|
#include <sys/ioctl.h>
|
|
|
|
static const char *axis_name(int code)
|
|
{
|
|
switch (code) {
|
|
case ABS_X: return "ABS_X";
|
|
case ABS_Y: return "ABS_Y";
|
|
case ABS_MT_POSITION_X: return "ABS_MT_POSITION_X";
|
|
case ABS_MT_POSITION_Y: return "ABS_MT_POSITION_Y";
|
|
default: return "?";
|
|
}
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int fd = open("/dev/input/event1", O_RDONLY | O_NONBLOCK);
|
|
if (fd < 0) { printf("open event1 failed: %s\n", strerror(errno)); return 1; }
|
|
int codes[] = { ABS_X, ABS_Y, ABS_MT_POSITION_X, ABS_MT_POSITION_Y };
|
|
for (unsigned i = 0; i < sizeof codes / sizeof codes[0]; i++) {
|
|
struct input_absinfo ab; memset(&ab, 0, sizeof ab);
|
|
if (ioctl(fd, EVIOCGABS(codes[i]), &ab) == 0)
|
|
printf("%-22s min=%d max=%d value=%d flat=%d fuzz=%d res=%d\n",
|
|
axis_name(codes[i]), ab.minimum, ab.maximum, ab.value,
|
|
ab.flat, ab.fuzz, ab.resolution);
|
|
else
|
|
printf("%-22s ioctl failed: %s\n", axis_name(codes[i]), strerror(errno));
|
|
}
|
|
close(fd);
|
|
|
|
/* fb0 分辨率 */
|
|
fd = open("/dev/fb0", O_RDWR);
|
|
if (fd >= 0) {
|
|
struct fb_var_screeninfo vs; memset(&vs, 0, sizeof vs);
|
|
if (ioctl(fd, FBIOGET_VSCREENINFO, &vs) == 0)
|
|
printf("fb0 xres=%u yres=%u xres_virtual=%u yres_virtual=%u bpp=%u\n",
|
|
vs.xres, vs.yres, vs.xres_virtual, vs.yres_virtual, vs.bits_per_pixel);
|
|
else printf("fb0 vinfo failed: %s\n", strerror(errno));
|
|
close(fd);
|
|
} else printf("open fb0 failed: %s\n", strerror(errno));
|
|
return 0;
|
|
}
|