个人工具
119.28.94.63
该IP地址的讨论
登录
查看“UbuntuHelp:CWiiD”的源代码 - Ubuntu中文
UbuntuHelp
讨论
查看源代码
历史
搜索
导航
首页
最近更改
随机页面
页面分类
帮助
编辑
编辑指南
沙盒
新闻动态
字词处理
工具
链入页面
相关更改
特殊页面
页面信息
查看“UbuntuHelp:CWiiD”的源代码
来自Ubuntu中文
←
UbuntuHelp:CWiiD
跳转至:
导航
,
搜索
因为以下原因,你没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{From|https://help.ubuntu.com/community/CWiiD}} {{Languages|UbuntuHelp:CWiiD}} == Introduction == Since the Wii Remote uses bluetooth to communicate with the console, it's relatively straightforward to use it to control a computer. The most obvious way is similar to the main menu on the Wii console - point the remote where you want the cursor to go, and press A and B to left and right click. There are also options for tilting the Wiimote to move the cursor around, which is useful if you don't have a sensor bar available. The Feisty instructions are from a mash up of other howtos, man pages and help from forum posts, culminating in the forum's howto by leffect (thanks to Babazoid for pointing out a couple of things that should've been obvious, and Rycuda for showing me where I was going wrong with Autoconf) I've got my Wii remotes working nicely as mice in Ubuntu. The Gutsy/Hardy tutorials are pulled almost verbatim from Rhubarb's post on the Forum. So, without further ado: == Installation == === Hardy Heron (8.04) === Just install the packages <pre><nowiki> sudo apt-get install libcwiid1 lswm wmgui wminput </nowiki></pre> === Gutsy Gibbon (7.10) === Just install the packages <pre><nowiki> sudo apt-get install libcwiid0 lswm wmgui wminput </nowiki></pre> === Before Gutsy Gibbon (7.10) === First things first, there are a handful of packages that need installing: <pre><nowiki> sudo apt-get install libbluetooth2 bluez-utils original-awk bison flex libbluetooth2-dev autoconf mouseemu libgtk2.0-dev </nowiki></pre> At this point, you can (optionally!) turn on the Wii remote to scan by pressing 1 and 2 simultaneously (all the lights will flash) then running: <pre><nowiki> hcitool scan </nowiki></pre> If the remote is picked up, something like the following will be displayed: <pre><nowiki> Scanning ... 00:19:1D:A8:44:AB Nintendo RVL-CNT-01</nowiki></pre> Next, downloading and installing the Wii remote library: <pre><nowiki> mkdir Wii cd Wii/ wget "http://downloads.sourceforge.net/libwiimote/libwiimote-0.4.tgz?modtime=1173542681&big_mirror=0" tar -zxvf libwiimote-0.4.tgz cd libwiimote-0.4/ autoconf ./configure make sudo make install </nowiki></pre> https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=info.png It is not ideal to use make install on a package managed distribution like Ubuntu, so you might like to take a look at [[UbuntuHelp:CheckInstall|CheckInstall]]. If you are using checkinstall, just replace <code><nowiki>sudo make install</nowiki></code> with <code><nowiki>sudo checkinstall</nowiki></code> throughout this howto. And CWiiD - the program for actually using the library: <pre><nowiki> wget http://abstrakraft.org/cwiid/downloads/cwiid-0.5.03.tgz tar -zxvf cwiid-0.5.03.tgz cd cwiid-0.5.03/ ./configure make sudo make install sudo ldconfig /usr/local/lib/ </nowiki></pre> At this point, ensure that the local libraries are recognised by configuring the runtime linker to check in <code><nowiki>/usr/local/lib</nowiki></code> and update the cache. <pre><nowiki> sudo sh -c "echo /usr/local/lib > /etc/ld.so.conf.d/locallib.conf" sudo ldconfig </nowiki></pre> https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=info.png You might find your local libraries are already defined, so you can just run ldconfig and skip the ld.so.conf. Check <code><nowiki>/etc/ld.so.conf.d</nowiki></code> for files already containing <code><nowiki>/usr/local/lib</nowiki></code> == Controlling the Wii Remote == Now it's possible to load a gui which shows what the Wiimote is doing: <pre><nowiki> wmgui </nowiki></pre> Select "connect" from the file menu, press 1+2 when prompted then OK. Lights and rumble can be turned on and off from the controls menu, and which inputs are displayed from the settings menu. Using this, you can test the IR camera, the accelerometers and check the inputs from the Nunchuck or Classic Controller. Next up is the mouse "emulator" which allows you to control the mouse with the Wiimote. At this point, it can be run with default settings (tilting the Wiimote moves the pointer, A and B work as left and right click). The uinput module needs to be loaded into the kernal first. This can either be done manually after every reboot: <pre><nowiki> sudo modprobe uinput </nowiki></pre> or it can be put into /etc/rc.local: <pre><nowiki> gksudo gedit /etc/rc.local </nowiki></pre> and add the line "modprobe uinput" before "exit 0". The default is shown below: <pre><nowiki> #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. modprobe uinput exit 0 </nowiki></pre> === Gutsy Gibbon or Hardy Heron (7.10 or 8.04) === Now, we can start using the Wiimote to control the mouse. First, find the address of the Wiimote (this is optional, but speeds up connecting). Press 1+2 on the Wiimote and run: <pre><nowiki> lswm </nowiki></pre> This should return the address of the Wiimote (something like 00:1F:32:95:EF:B0). This will be different for each Wiimote. If it doesn't work, try again, ensuring the lights on the Wiimote are still flashing when you run lswm. ==== Moving the mouse by tilting the Wiimote ==== Press the 1+2 buttons on the Wiimote and run: <pre><nowiki> wminput 00:1F:32:95:EF:B0 </nowiki></pre> replacing 00:1F:32:95:EF:B0 with the address of your Wiimote. This can be run without the address, but will take longer to connect. ==== Moving the mouse by pointing the Wiimote at an IR source ==== <code><nowiki>gksudo gedit /etc/cwiid/wminput/ir_ptr</nowiki></code> Find these lines: <pre><nowiki> Plugin.ir_ptr.X = ~ABS_X Plugin.ir_ptr.Y = ~ABS_Y </nowiki></pre> and replace them with: <pre><nowiki> Plugin.ir_ptr.X = ABS_X Plugin.ir_ptr.Y = ABS_Y </nowiki></pre> Press 1+2 on the Wiimote and from a terminal run this: <pre><nowiki> wminput -c ir_ptr 00:1F:32:95:EF:B0 </nowiki></pre> === Feisty Fawn (7.04) === Press 1 and 2 to enter discoverable mode then type: <pre><nowiki> sudo wminput </nowiki></pre> At this point, I think wminput is using one of ubuntu's default configurations in xorg.conf, so if it does not work for you, include the xorg.conf configuration in the following section "Using the Sensor Bar" https://help.ubuntu.com/community/IconsPage?action=AttachFile&do=get&target=info.png It is not wise to run wminput as superuser, so when you have finished testing change your udev rules to allow access to <code><nowiki>/dev/input/uinput</nowiki></code>. I'm going to assume you are a member of the admin group but you can always create a dedicated group for uinput users and use that instead. <pre><nowiki> sudo sh -c 'echo "KERNEL==\"uinput\", GROUP=\"admin\"" > /etc/udev/rules.d/50-cwiid-input.rules' sudo /etc/init.d/udev restart </nowiki></pre> ==== Using the Sensor Bar (Feisty Fawn) ==== In order to get it working with the sensor bar, and to get the buttons to emulate keyboard functions, a couple of bits need to be added to xorg.conf. Open xorg.conf in your favourite text editor (eg: <code><nowiki>sudo gedit /etc/X11/xorg.conf</nowiki></code> - don't forget the sudo! ) then add the following section after the last <code><nowiki>InputDevice</nowiki></code> section: <pre><nowiki> Section "InputDevice" Identifier "Wiimote" Driver "evdev" Option "Name" "Nintendo Wiimote" EndSection </nowiki></pre> and the following at the end of the <code><nowiki>ServerLayout</nowiki></code> section: <pre><nowiki> InputDevice "Wiimote" "AlwaysCore" </nowiki></pre> Now to reload xorg.conf by restarting X. (if there's a better way to reload it, I'd appreciate it if someone told me!) Make sure you haven't got anything unsaved, then press ctrl+alt+backspace. This will drop you back at a login screen, so make sure you know how to get back to this page! Now you can reload wminput with the IR settings. Press 1 and 2 on the Wiimote to enter discoverable mode and type: <pre><nowiki> wminput -c ir_ptr </nowiki></pre> Note: If you have not changed your udev rules, don't forget to sudo this wminput! Now waving the Wiimote at your sensor bar will move the mouse around the screen! A and B still act as left and right click - just like in the Wii menus! == Other notes == It's worth noting that if the Wii is turned off, so is the sensor bar, so you have to have it turned on. This means that if your Wiimotes are paired with your console, when you press 1 and 2, they'll automatically link to the console, rather than your computer. I'm currently working round this by pressing the red button under the battery cover instead of 1 and 2 to enter discoverable mode. I'm planning to go and pair one of my Wiimotes with someone else's console, so I won't have to do that. == Sensor bar alternatives == Since the sensor bar consists of a number of IR LEDs (in two groups, one at each end of the bar), which the Wii remote detects as two dots, it's relatively easy to make an alternative sensor bar for use away from the Wii. Ideally, you want two IR point sources, such as IR LEDs, however candles, lighters, light bulbs etc will work as well. Also, CWiiD only actually requires a single point to track, so it is possible to just point the remote at a room light, and track from that. There are a number of companies selling various Wii accessories, such as replacement sensor bars, which could be used, however I plan to buy some IR LEDs and mount them on my laptop, and connect them to a USB port. == Config files == If you want to change the config files, they're in <code><nowiki>/usr/local/etc/cwiid/wminput</nowiki></code> - it'll load <code><nowiki>default</nowiki></code> unless something else is specified. After install, default is linked to <code><nowiki>acc_ptr</nowiki></code>, so the acclerometers control the pointer. buttons contains the mappings for the buttons to keys, and is linked by the other config files. I've made a new config file, which is basically a copy/paste from <code><nowiki>buttons</nowiki></code> and <code><nowiki>ir_ptr</nowiki></code>: <pre><nowiki> #IR pointer Plugin.ir_ptr.X = ~ABS_X Plugin.ir_ptr.Y = ~ABS_Y #buttons Wiimote.A = BTN_LEFT Wiimote.B = BTN_RIGHT Wiimote.Up = KEY_KATAKANA Wiimote.Down = KEY_KPENTER Wiimote.Left = KEY_HENKAN Wiimote.Right = KEY_MUHENKAN Wiimote.Minus = KEY_BACK Wiimote.Plus = KEY_FORWARD Wiimote.Home = KEY_HOME Wiimote.1 = KEY_SLASH Wiimote.2 = KEY_SPACE #Nunchuk.C = BTN_LEFT #Nunchuk.Z = BTN_RIGHT # #Classic.Up = KEY_UP #Classic.Down = KEY_DOWN #Classic.Left = KEY_LEFT #Classic.Right = KEY_RIGHT #Classic.Minus = KEY_BACK #Classic.Plus = KEY_FORWARD #Classic.Home = KEY_HOME #Classic.A = BTN_LEFT #Classic.B = BTN_RIGHT #Classic.X = #Classic.Y = #Classic.ZL = #Classic.ZR = #Classic.L = #Classic.R = </nowiki></pre> But I'm currently having a few problems with it. The up/down/left/right maps aren't assigned sensibly - hence the rather odd bindings, however these values seem to work. The right click has also stopped working, despite not changing anything relating to it in the config file. There is a file in with the source <code><nowiki>~/Wii/cwiid-0.5.03/wminput/action_enum.txt</nowiki></code> which should contain all the codes for keys, however it seems to be significantly out - at least for a GB keyboard. == Problems == There are a few things I'm not quite happy with here. I'd like to find a way to disassociate my controllers from my console, so that they don't automatically link to it whenever it's on. I'd like to have a better way to reload xorg.conf than restarting X - especially for a howto that's being followed from a webpage! The keymappings in the config file don't work sensibly. The key mappings given don't map to the keys they claim to. If anyone has any ideas for fixing any of these, I would be very happy to hear from them! (user leffect on the Ubuntu forums) There is a discussion thread for Feisty Fawn based on this howto at http://ubuntuforums.org/showthread.php?p=3258659 and a more recent one for Hardy Heron at http://ubuntuforums.org/showthread.php?t=836231 ---- [[category:CategoryDocumentation]] [[category:CategoryHardware]] [[category:UbuntuHelp]]
该页面使用的模板:
模板:From
(
查看源代码
)
模板:Languages
(
查看源代码
)(受保护)
模板:Languages/Lang
(
查看源代码
)(受保护)
返回至
UbuntuHelp:CWiiD
。