本文介绍了Sdl2 操纵杆不捕获“按下事件";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在 SDL(简单的直接媒体层)上运行的应用程序.我已将其移植到 SDL2.但是移植后,joystick(SDL_PollEvent) 只捕获了摇杆按钮的释放事件.有什么问题吗或者有什么设置可以在 SDL2 中捕获新闻事件?

I have an application which runs on SDL(simple directmedia layer). I've ported it to SDL2. But after porting, joystick(SDL_PollEvent) is only captures the release event of joysticks button.Is there anything wrong or is there any setting for capturing press events in SDL2?

推荐答案

我也有一个 loop 和 swich 语句.我只能通过这个循环获得操纵杆按钮的释放事件.

I have a loop and swich statement too.I could get only release events of joystick button by this loop.

我在几秒钟前找到了答案.如果我在 SDL_Init 语句之前调用 SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,"1") ,操纵杆按钮获取按下和释放事件,否则轮询无法捕获按下事件.

I found the answer a few seconds ago. If I call SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,"1") before SDL_Init statement, joystick button gets press and release events, otherwise polling can not capture press event.

这篇关于Sdl2 操纵杆不捕获“按下事件";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:52