Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos SDL2未在OSX上发送输入事件_Macos_Rendering_Sdl_Sdl 2_Ogre - Fatal编程技术网

Macos SDL2未在OSX上发送输入事件

Macos SDL2未在OSX上发送输入事件,macos,rendering,sdl,sdl-2,ogre,Macos,Rendering,Sdl,Sdl 2,Ogre,我尝试在OSX上使用SDL2和Ogre,渲染效果很好,但我没有收到任何键盘和鼠标事件 对于渲染循环,我使用间隔为0.001s的NSTimer。 如果我做了一个SDL_PumpEvents()或SDL\u PollEvent(&event)在我的循环中,我得到一些键盘事件,但并不完美,鼠标工作正常 是什么导致了这种奇怪的行为 谢谢 self.timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:

我尝试在OSX上使用SDL2和Ogre,渲染效果很好,但我没有收到任何键盘和鼠标事件

对于渲染循环,我使用间隔为
0.001s的
NSTimer
。 如果我做了一个
SDL_PumpEvents()
SDL\u PollEvent(&event)
在我的循环中,我得到一些键盘事件,但并不完美,鼠标工作正常

是什么导致了这种奇怪的行为

谢谢

self.timer = [NSTimer scheduledTimerWithTimeInterval:0.001
  target:self
  selector:@selector(step)
  userInfo:NULL repeats:YES];
[self.timer fire];

...

-(void) step {
  renderOneFrame();
  SDL_GL_SwapWindow(sdlWindow);

  SDL_PumpEvents();
  // or
  SDL_Event event;
  while (SDL_PollEvent(&event)) { }
}
更新 如果我添加
SDL\u AddEventWatch(\u eventFilter,this)
侦听事件鼠标和其他事件(例如退出)可以在不进行轮询或其他操作的情况下工作!
但是仍然没有接收到键盘事件。

可能您的检查不正确。如果您使用GetKeyboardState并比较按键,会发生什么情况?首先,我在原始问题中添加了一些更新,并使用GetKeyboardState进行了检查,没有轮询,任何按键都不会被识别为按下。可能您的检查不正确。如果您使用GetKeyboardState并比较按键,会发生什么情况?首先,我对原始问题添加了一些更新,并使用GetKeyboardState进行了检查,没有轮询,任何按键都不会被识别为按下。