# 离线只读验证：不访问网络、不操作设备，只读取同目录合成输入。
import json, math, struct, statistics
from pathlib import Path
def check(d):
 out=[]
 for h in d['reports']:
  b=bytes.fromhex(h)
  if len(b)!=3: out.append('长度错误'); continue
  if b[0]!=1: out.append('未知报告ID'); continue
  v=int.from_bytes(b[1:],'little')
  out.append(dict(buttons=[v&1,(v>>1)&1],axis=(v>>2)&0xfff,padding=v>>14))
 assert Path(__file__).with_name('report.bin').read_bytes()==bytes.fromhex(d['reports'][0])
 return out

if __name__=='__main__':
 fixture=json.loads(Path(__file__).with_name('fixture.json').read_text(encoding='utf-8'))
 actual=check(fixture['input'])
 assert actual==fixture['expected'], {'实际':actual,'预期':fixture['expected']}
 print(json.dumps({'状态':'通过','实际':actual,'边界':'仅离线合成样例，现场未测'},ensure_ascii=False))
