这是一台运行Gentoo Linux的笔记本电脑,amd64。问题是某些东西会自动生成以下类型的按键事件(使用 int main()
{
int size, x, y, test = 1;
printf("How big is your map? ");
scanf("%d", &size);
char map[size][size], move;
int row = size/2, col = size/2;
for(x = 0; x < size; x++)
{ //gives null value to everything in the board except for the player
for(y = 0; y < size; y++)
{
map[x][y] = 'X';
}
}
while(test != 0)
{
scanf("%d", &test);
for(x = 0; x < size; x++)
{
for(y = 0; y < size; y++)
if (x == row && y == col)
{
printf("O");
map[row][col] = 'O';
}
else
printf("%c", map[x][y]);
printf("\n");
}
//
// Everything runs completely fine until this point,
// after I type either W, A, S, or D, the program crashes
// and gives me an insanely high return value.
// I have no idea what I did wrong, and any insight would be extremely appreciated.
//
printf("Use W, A, S, D to move around.");
map[row][col] = 'X'; //set the old player location to null.
while(x != 0)
{
scanf(" %c", move);
switch(move)
{
case 'w':
case 'W': row -= 1; x = 0; break;
case 's':
case 'S': row += 1; x = 0; break;
case 'a':
case 'A': col -= 1; x = 0; break;
case 'd':
case 'D': col += 1; x = 0; break;
default: printf("Invalid input, try again.");
}
}
map[row][col] = 'O';
}
return 0;
}
实用程序捕获):
xev
这特别导致终端窗口中的烦人问题,其中自动滚动配置为在按键上运行 - 它在15秒后向下滚动到命令提示符。
我想找到此事件的来源,然后将其禁用。
内核配置:https://drive.google.com/file/d/0B4T1g89tYDs0UkhSX1ZmMW5ZeXc/view?usp=sharing
答案 0 :(得分:0)
使用
xinput list
确定系统中存在的输入设备。接下来,使用
xinput test
或xinput test-xi2
来监控来自任何输入设备的各个事件。
查看此answer了解详情。