Kivy 在我的应用程序中没有检测到触摸输入
Kivy is not detecting touch inputs in my application
我在 Raspberry Pi 上使用 Kivy,利用新的官方 7" 触摸屏。我正在尝试制作一个应用程序,利用触摸屏进行简单的 button/accordion 操作,但无法输入kivy 程序。我是否遗漏了以下代码中的重要内容?
触摸屏在 X 中工作正常,我还可以在进行多点触控手势时 cat /dev/input/event0 并查看缓冲区中的数据。
根据 Kivy 自己的说法,我在启动应用程序时肯定会初始化触摸屏:[=13=]
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_15-09-16_22.txt
[INFO ] [Kivy ] v1.9.1-dev
[INFO ] [Python ] v2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3]
[INFO ] [Factory ] 177 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] OpenGL version <OpenGL ES 2.0>
[INFO ] [GL ] OpenGL vendor <Broadcom>
[INFO ] [GL ] OpenGL renderer <VideoCore IV HW>
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[INFO ] [Shader ] fragment shader: <Compiled>
[INFO ] [Shader ] vertex shader: <Compiled>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Text ] Provider: pygame
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [HIDInput ] Read event from </dev/input/event0>
[INFO ] [Base ] Start application main loop
[INFO ] [HIDMotionEvent] using <FT5406 memory based driver>
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range ABS X position is 0 - 800
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range ABS Y position is 0 - 480
[INFO ] [GL ] NPOT texture support is available
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range position X is 0 - 800
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range position Y is 0 - 480
我的源码很初级:
import kivy
kivy.require('1.0.7')
from kivy.app import App
def button_pressed():
exit(0)
class CarInterfaceApp(App):
pass
if __name__ == '__main__':
CarInterfaceApp().run()
我的 kv 文件也很简单:
#:kivy 1.0
Accordion:
min_space: 60
orientation: 'vertical'
AccordionItem:
title: 'Car'
AccordionItem:
title: 'Music'
AccordionItem:
title: 'Messaging'
事实证明,kivy 的默认配置文件 config.ini 在 [input] 部分中有 provider=hidinput
。如果将其更改为 provider=mtdev
,FT5406 工作正常!
我有 2 个问题需要解决才能在 Arch Linux Arm 上运行。
第一个问题是 Peter 的回答所涵盖的问题 - 我的配置中没有 mtdev。我将 ~/.kivy/config.ini
的 [input]
部分设置为
[input]
mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput
第二个问题是 stderr
[INFO ] [ProbeSysfs ] unable to found provider mtdev
[INFO ] [ProbeSysfs ] fallback on hidinput
这里的解决方案是使用 pacman -S mtdev
安装 mtdev
我在 Raspberry Pi 上使用 Kivy,利用新的官方 7" 触摸屏。我正在尝试制作一个应用程序,利用触摸屏进行简单的 button/accordion 操作,但无法输入kivy 程序。我是否遗漏了以下代码中的重要内容?
触摸屏在 X 中工作正常,我还可以在进行多点触控手势时 cat /dev/input/event0 并查看缓冲区中的数据。
根据 Kivy 自己的说法,我在启动应用程序时肯定会初始化触摸屏:[=13=]
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_15-09-16_22.txt
[INFO ] [Kivy ] v1.9.1-dev
[INFO ] [Python ] v2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3]
[INFO ] [Factory ] 177 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] OpenGL version <OpenGL ES 2.0>
[INFO ] [GL ] OpenGL vendor <Broadcom>
[INFO ] [GL ] OpenGL renderer <VideoCore IV HW>
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[INFO ] [Shader ] fragment shader: <Compiled>
[INFO ] [Shader ] vertex shader: <Compiled>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [Text ] Provider: pygame
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [HIDInput ] Read event from </dev/input/event0>
[INFO ] [Base ] Start application main loop
[INFO ] [HIDMotionEvent] using <FT5406 memory based driver>
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range ABS X position is 0 - 800
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range ABS Y position is 0 - 480
[INFO ] [GL ] NPOT texture support is available
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range position X is 0 - 800
[INFO ] [HIDMotionEvent] <FT5406 memory based driver> range position Y is 0 - 480
我的源码很初级:
import kivy
kivy.require('1.0.7')
from kivy.app import App
def button_pressed():
exit(0)
class CarInterfaceApp(App):
pass
if __name__ == '__main__':
CarInterfaceApp().run()
我的 kv 文件也很简单:
#:kivy 1.0
Accordion:
min_space: 60
orientation: 'vertical'
AccordionItem:
title: 'Car'
AccordionItem:
title: 'Music'
AccordionItem:
title: 'Messaging'
事实证明,kivy 的默认配置文件 config.ini 在 [input] 部分中有 provider=hidinput
。如果将其更改为 provider=mtdev
,FT5406 工作正常!
我有 2 个问题需要解决才能在 Arch Linux Arm 上运行。
第一个问题是 Peter 的回答所涵盖的问题 - 我的配置中没有 mtdev。我将 ~/.kivy/config.ini
的 [input]
部分设置为
[input]
mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput
第二个问题是 stderr
[INFO ] [ProbeSysfs ] unable to found provider mtdev
[INFO ] [ProbeSysfs ] fallback on hidinput
这里的解决方案是使用 pacman -S mtdev