Files
MeowOS-For-R3P2/patch_v2/meow_launcherd/fbpan.c
T
MeowOS Dev 245bee2946 MeowOS for HiBy R3 Pro II — 公共发布版本(历史已重置)
• 全新单提交:清除含敏感信息的旧历史(sudo 口令、内网 IP、SSH 密钥路径、热点 SSID、设备 MAC)
• 本地开发文档/测试记录/构建脚本全部移入 gitignored 的 devdocs/ 与 scripts/build/(不入库)
• 保留:MeowOS 源码(launcher/watchdog/bootmenu/meow_svcd/SDK)、项目规范文档、mips-repo
增补组件:SDK 统一日志+通知 API、meow_svcd 服务管理器、mips-repo 软件仓库
2026-08-30 01:12:34 +08:00

35 lines
1.1 KiB
C

/* fbpan — set /dev/fb0 yoffset (pan) to argv[1] and print the result. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <stdint.h>
#define GETV 0x4600
#define PAN 0x4606
int main(int argc, char **argv) {
int fd = open("/dev/fb0", O_RDWR);
if (fd < 0) { perror("open"); return 1; }
unsigned char v[160]; memset(v,0,sizeof v);
if (ioctl(fd, GETV, v) < 0) { perror("getvar"); return 1; }
uint32_t orig = *(uint32_t*)(v+20);
uint32_t yres = *(uint32_t*)(v+4);
uint32_t target = argc > 1 ? (uint32_t)atoi(argv[1]) : 0;
if (yres) target = (target / yres) * yres; /* snap to whole-screen offset */
*(uint32_t*)(v+16) = 0;
*(uint32_t*)(v+20) = target;
errno = 0;
int r = ioctl(fd, PAN, v);
int e = errno;
unsigned char w[160]; memset(w,0,sizeof w);
ioctl(fd, GETV, w);
printf("pan(%u): r=%d errno=%d(%s) yoffset %u -> %u (yres=%u)\n",
target, r, e, strerror(e), orig, *(uint32_t*)(w+20), yres);
close(fd);
return 0;
}