在看到wiimotes的能力和漏洞后,我真的很想在我的“编程入门”期末考试中使用它。每个人都必须制作一个python程序,并将其呈现给班级。
我想用pygame做一个包含wiimote的游戏。我发现了pywiiuse,它是使用c类型的wiiuse库的一个非常基本的包装器。
我不能得到任何东西以外的LED和振动工作。按钮,红外线,动作感应,什么都没有。我尝试过wiiuse,pywiiuse,甚至python的不同版本。我甚至不能运行它附带的示例。以下是我作为简单测试编写的代码。我复制了一些示例C++代码。
from pywiiuse import *
from time import sleep
#Init
wiimotes = wiiuse_init()
#Find and start the wiimote
found = wiiuse_find(wiimotes,1,5)
#Make the variable wiimote to the first wiimote init() found
wiimote = wiimotes.contents
#Set Leds
wiiuse_set_leds(wiimote,WIIMOTE_LED_1)
#Rumble for 1 second
wiiuse_rumble(wiimote,1)
sleep(1)
wiiuse_rumble(wiimote,0)
#Turn motion sensing on(supposedly)
wiiuse_motion_sensing(wiimote,1)
while 1:
#Poll the wiimotes to get the status like pitch or roll
if(wiiuse_poll(wiimote,1)):
print 'EVENT'这是我运行它时的输出。
wiiuse version 0.9
wiiuse api version 8
[INFO] Found wiimote [assigned wiimote id 1].
EVENT
EVENT
Traceback (most recent call last):
File "C:\Documents and Settings\Nick\Desktop\wiimotetext.py", line 26, in <mod
ule>
if(wiiuse_poll(wiimote,1)):
WindowsError: exception: access violation reading 0x00000004似乎每次我运行它,它都会打印事件2-5次,直到回溯。在这一点上我不知道该怎么做,我在过去的两天里一直在尝试让它工作。
谢谢!
发布于 2010-10-23 11:23:02
我更新了pywiiuse包装器。它似乎不是为最新版本的wiiuse (在本文回答时为0.12)制作的,因为它的大部分内容在当前的迭代中都不能工作。
我在这里发布了这个包和一些示例脚本:http://code.google.com/p/pywiiuse/downloads/list
你也应该能够做到
easy_install wiiuse因为我也把它放在了pypi上。
发布于 2009-03-24 19:49:06
近两天来我一直在寻找Wiimote的一组Python包装器,以下是我对最新技术的总结:
pywiimote (来自谷歌):大约完成了一半,当我下载最新版本(r52)时还没有编译,有一些很好的想法,但需要大量的投资才能开始工作。
pywiiuse (上图):理论上不错,
cwiid:未积极开发,仅适用于Linux (不能在Cygwin下编译)。
总之--现在还没有现成的东西(3/24/2009)。将会继续测量。
--布莱恩
发布于 2009-12-04 11:25:11
我知道你的课程现在已经结束了,但是对于其他人来说,cwiid真的很好。安装在Ubuntu中如下所示:
apt-get install libcwiimote-dev python-cwiid或者从github获取最新版本。
读取wiimote传感器(比如从加速计读取音调)非常简单:
import cwiid
print 'place wiimote in discoverable mode (press 1 and 2)...'
wiimote = cwiid.Wiimote()
wiimote.rpt_mode = cwiid.RPT_ACC
#wiimote.state dict now has an acc key with a three-element tuple
print 'pitch: %d' % (wiimote.state['acc'][cwiid.Y])https://stackoverflow.com/questions/481943
复制相似问题