树莓派支持鼠标和LCD(TODO)
创始人
2024-11-14 13:34:25
0

这个工作量比较大,估计要晚一些搞了。。。

安装树莓派 Pico 的 C/C++ SDK

git clone https://github.com/hathach/tinyusb.git

CMakeList.txt

 

cmake_minimum_required(VERSION 3.13)

include(pico_sdk_import.cmake)

project(usb_host_mouse_example)

pico_sdk_init()

add_executable(usb_host_mouse_example

main.c

)

# 添加对 TinyUSB 的支持

add_subdirectory(tinyusb)

target_link_libraries(usb_host_mouse_example pico_stdlib tinyusb_host)

pico_add_extra_outputs(usb_host_mouse_example)

main.c

#include "pico/stdlib.h"
#include "bsp/board.h"
#include "tusb.h"
// USB HID 鼠标回调函数
void tuh_hid_mouse_mounted_cb(uint8_t dev_addr) {
    printf("A USB mouse is mounted.\n");
}
void tuh_hid_mouse_unmounted_cb(uint8_t dev_addr) {
    printf("A USB mouse is unmounted.\n");
}
void tuh_hid_mouse_isr(uint8_t dev_addr, uint8_t instance, const uint8_t* report, uint16_t len) {
    // 解析鼠标报告
    int8_t x = report[1];
    int8_t y = report[2];
    int8_t wheel = report[3];
    printf("Mouse movement: x=%d, y=%d, wheel=%d\n", x, y, wheel);
}
int main() {
    // 初始化板子和 USB 主机
    board_init();
    tusb_init();
    while (true) {
        // 处理 USB 事件
        tuh_task();
    }
    return 0;
}

 

mkdir build

cd build

cmake ..

make

生成的 usb_host_mouse_example.uf2 文件拖放到树莓派 Pico 的 USB 驱动器中,完成固件上传。

相关内容

热门资讯

第三方技巧!hhpoker软件... 您好,hhpoker可以控制吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
最终!德普之星透视软件免费入口... 最终!德普之星透视软件免费入口官网,aapoker透视脚本,切实存在有挂(今日头条)1、下载好德普之...
日前!模拟器打开hhpoker... 日前!模拟器打开hhpoker,德普辅助软件,总是确实有挂(有挂解惑)1、进入到模拟器打开hhpok...
2026版总结!werplan... 2026版总结!werplan免费挂下载,德州圈脚本,好像真的有挂(有挂技巧)一、werplan免费...
反观!wpk真吗,hhpoke... 反观!wpk真吗,hhpoker破解工具,都是真的有挂(证实有挂)运hhpoker破解工具辅助工具,...
在玩家背景下!hhpoker透... 在玩家背景下!hhpoker透视脚本下载,hhpoker辅助挂,一直确实有挂(有挂详情)1、让任何用...
黑科技辅助挂!fishpoke... 黑科技辅助挂!fishpoker透视底牌,hhpoker有没有作弊挂,一直真的是有挂(真的有挂)1、...
今天上午!aapoker怎么选... 今天上午!aapoker怎么选牌,wepoker私人辅助器,都是是真的有挂(有挂实锤)1、不需要AI...
据目击者称!wpk德州局透视,... 据目击者称!wpk德州局透视,wpk是真的还是假的,真是存在有挂(有挂规律)1、玩家可以在wpk是真...
第三方技巧!xpoker辅助工... 第三方技巧!xpoker辅助工具,wpk俱乐部怎么作弊,一直是有挂(有挂透明挂)1、上手简单,内置详...