问题描述
所以我正在开发a set of wrapping utilities for SDL2,但遇到了一个奇怪的问题。每当在帧末尾使用SDL_GetError
轮询错误时,如果我触摸触控板,都会收到以下奇怪的错误消息:UnkNown touch device id -1,cannot reset
。用引号引起的错误仅显示one result on google,这似乎是macOS的问题,尽管只有一种情况很难确定。
这是一个最小的可重现示例:
#include <SDL2/SDL.h>
#include <stdio.h>
int main() {
SDL_Init(SDL_INIT_VIDEO);
SDL_Window* window = SDL_CreateWindow("Window",SDL_WINDOWPOS_UNDEFINED,100,SDL_WINDOW_SHOWN);
while(1) {
SDL_Event e;
while(SDL_PollEvent(&e))
switch(e.type) {
case SDL_QUIT: {
SDL_DestroyWindow(window);
SDL_Quit();
exit(0);
break;
}
}
const char* err = SDL_GetError();
if(err[0]) {
printf("%s",err);
exit(-1);
}
}
}
我知道这是一个奇怪的问题(并且可能是无法解决的问题),因此,我非常感谢您提供任何答案或建议。
我正在使用运行macOS Catalina(10.15.6)的MacBook Pro 13英寸Mid 2012。使用clang 12.0.0编译
编辑:我已经下载了SDL2源代码以查找错误,并且根本原因似乎是此功能:
static int
SDL_GetTouchIndex(SDL_TouchID id)
{
int index;
SDL_Touch *touch;
for (index = 0; index < SDL_num_touch; ++index) {
touch = SDL_touchDevices[index];
if (touch->id == id) {
return index;
}
}
return -1;
}
我正在寻找导致此错误的确切原因,并将为以后遇到此错误的任何人更新此帖子,并向SDL开发人员团队提交错误报告
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)