问题描述
我想用我的 ps4 控制器移动鼠标光标,所以我使用了 pygame 和 win32api
我想出了这个问题的解决方案,但它没有按我的预期工作,因为它非常滞后
for event in pygame.event.get():
if event.type == pygame.JOYAXISMOTION:
if event.value > self.threshold :
if event.axis == 2:
win32api.SetCursorPos([win32api.GetCursorPos()[0] + self.sensitivity,win32api.GetCursorPos()[1]])
if event.axis == 3:
win32api.SetCursorPos([win32api.GetCursorPos()[0],win32api.GetCursorPos()[1] + self.sensitivity])
if event.value < -self.threshold :
if event.axis == 2:
win32api.SetCursorPos([win32api.GetCursorPos()[0] - self.sensitivity,win32api.GetCursorPos()[1] - self.sensitivity])
这只是检查操纵杆是否在运动,然后通过将相同的值添加到当前位置,将此运动转换为具有给定灵敏度的光标:
win32api.SetCursorPos([win32api.GetCursorPos()[0] + self.sensitivity,win32api.GetCursorPos()[1]])
有没有其他有效的解决方案不会让我的电脑滞后?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)