abstrakraft / cwiid Goto Github PK
View Code? Open in Web Editor NEWLinux Nintendo Wiimote interface
Home Page: cwiid.org
License: GNU General Public License v2.0
Linux Nintendo Wiimote interface
Home Page: cwiid.org
License: GNU General Public License v2.0
Hi,
when i do :
robert@laptop:~$ wmgui 00:17:AB:39:DB:90
the output is:
Invalid packet type
Unknown message type
any ideas?
it's not an original controller though.
From what I can tell it appears that the communications structures for the nunchuk is not fully implemented or has been broken with recent Bluetooth updates related to BTLE additions to the Bluetooth stack. During compilation it also appears that some of the python calls are deprecated.
This is on a pi zero w with the latest version of Raspbian.
For Python console these are the commands to pay attention to. They are not clearly documented anywhere:
You will need to pair the wiimote via the bluetooth console with these set of commands
bluetoothctl
scan on
(hit sync button on wiimote) once it shows up
pair mac_addr_of_wiimote
Note: do not trust or connect wiimote here as it will break cwiid, wminput as they use a separate authentication mechanism.
This step is only needed as the recent updates for Bluetooth Low Energy(BTLE) and hcitool scanning functionality slightly broke the existing library infrastructure in more modern versions of linux.
to conennect use this invocation set:
import cwiid
name = cwiid.Wiimote()
(at this point hit sync button on bottom of remote)
if no errors you are connected
rpt_modes are invoked to report with the following nomenclature
wm where wm is the name of your defined instance of the cwiid.Wiimote() invocation
RPT mode options are as follows:
RPT_STATUS minimal report
RPT_NUNCHUK report on the nunchuk
RPT_MOTIONPLUS report on the motionplus adapter
RPT_IR report on the IR function, requires bar accessory to work
RPT_EXT reports all readings on whatever connected device
RPT_CLASSIC report on the classic controller
RPT_BTN report on the wiimote controller
RPT_BALANCE report on the balance controller
RPT_ACC report on the wiimote accelerometer readings
so wm.rpt_mode= cwiid.RPT_BTN sets it to report wiimote button status information
wm.led=# where # equals a decimal value 1 - 15 noted here: https://github.com/abstrakraft/cwiid/blob/master/libcwiid/command.c
wm.rumble=# where # equals a uint8_t value noted here: https://github.com/abstrakraft/cwiid/blob/master/libcwiid/command.c
dir(cwiid) options are defined here: https://github.com/abstrakraft/cwiid/blob/master/python/cwiidmodule.c under cwiid constants
wm.state reports what the current readings are from the wiimote based upon the currently set report mode
Hi !
How can I see "Wii Motion Plus" in your interface ?
I'm trying to get my classic controller set up as an analog joystick/gamepad. If I set the directional pad as ABS_HAT0X and ABS_HAT0Y (as the obvious axises) and I configure the controller input in any of the various emulators available (snes9x, pcsx, mupen64plus), the application itself or the window crashes. Here is the file I'm using with it, if it makes a difference:
Classic.Dpad.X = ABS_HAT0X
Classic.Dpad.Y = ABS_HAT0Y
Classic.LStick.X = ABS_X
Classic.LStick.Y = ABS_Y
Classic.RStick.X = ABS_RX
Classic.RStick.Y = ABS_RY
Classic.A = BTN_A
Classic.B = BTN_B
Classic.X = BTN_X
Classic.Y = BTN_Y
Classic.Minus = BTN_SELECT
Classic.Plus = BTN_START
Classic.Home = BTN_MODE
Classic.L = BTN_TL
Classic.R = BTN_TR
Classic.ZL = BTN_TL2
Classic.ZR = BTN_TR2
What could be causing the problem?
When extension is plugged in the MotionPlus port it interleaves the data coming from the extension with data from MotionPlus. This can be distinguished by looking at 2nd byte in 5th byte.
This packet must then be changed to be seen as coming from Nun-chuck/Classic controller. I have done the first part in my forked repo, I have not yet found a way how to simply know what is plugged in.
Please have a look at http://github.com/robots/cwiid
Balance Board is identified as MotionPlus, because only one byte of the whole 6 bite long extension identifier is considered. Balance Board was working before MotionPlus-support, but because both extensions report 0x4 in 0xA400FE, Balance Board was incorrectly interpreted as MotionPlus.
See http://wiibrew.org/wiki/Wiimote#The_New_Way for more information on identifying extensions.
I have fixed the issue in my fork of the repository: http://github.com/tuos/cwiid
I am having the the same issue as #67 on the old Trac site:
import cwiid
Traceback (most recent call last):
File "", line 1, in
ImportError: /usr/local/lib/python2.6/dist-packages/cwiid.so: undefined symbol: cwiid_set_data
However I'm not using checkinstall, so the solution doesn't work for me. I am installing by
autoconf
./configure
make
sudo make install
cd python && sudo python setup.py install
The last line was needed as python couldn't find cwiid.so without it.
I am running Ubuntu Karmic and compiling from the latest git source.
Hi,
I've made a patch for the Gentoo ebuild in the layman overlay, that will check if the relevent kernel modules are enabled.
(I wonder how I can attach the patch to this issue?!)
I'm working on the logging feature, which is actually being used already for some high-school physics experiments.
I have an easy question: How do I get the menu item to be something other than CTRL-A? In the glade designer it says it will use the underline to pick which letter to use, and the underline is preceeding the L in Log, but it still comes up CTRL-A.
Thanks to everyone else for their work. Feel free to rip my stuff apart because I don't usually do C.
Hi, I'm using this library on a Raspberry PI with Python 2.7 to control a robot/car. This works brilliantly with a high range until the range is too far at which point I can't detect loss of signal/input and the car continues off into the distance etc.
Is there a way to resolve this?
Thanks
I have tried installing cwiid onto my computer and by using sudo apt-get install python-cwiid. which appears to come from debian I installed it on my computer's debian terminal that I downloaded. It successfully downloaded it but when I put import cwiid into python 3 on my computer it gave off the error No module named 'cwiid'. Then I tried using pip install cwiid on my command prompt and this MASSIVE error came up: (sorry about the format it is due to the ->""" <- . I think they sort of glitched by what format github thinks three speech marks is)
ERROR: Command errored out with exit status 1: 'c:\users\user\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\User\AppData\Local\Temp\pip-install-5u62qkij\cwiid\setup.py'"'"'; file='"'"'C:\Users\User\AppData\Local\Temp\pip-install-5u62qkij\cwiid\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\User\AppData\Local\Temp\pip-record-blsu2x3j\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
WARNING: You are using pip version 19.2.2, however version 19.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.`
the next key is to remap the accelerometer and stick values into values that the servos can use. There are two value options a pwm signal length (0ish to 2200ish), or an angular reading(0ish.
There is not a clean way to do this built into the library. Nor is there a good remap or constrain function I could easily locate for the need.
The basic remap formula is: new value = ((old value - old min)/(old max - old min))(new max-new min) + new min
The stick has a value range on the nunchuk of 28-220 and we are remapping to the typical servo range of 0-180 degrees. So the formula simplified is: new value = (( old value - 28)/(220-28))(180 - 0) + 0 = ((old value - 28)/(192))* 180
so if our nunchuk value is a neutral 124 for the x access and has a value name of nstickx and we are going to name the new remapped value as nstickxr, we would have something like this:
nstickr = ((nstickx -28)/(192))*180 (now in the next line lets substitute in the value of 124)
nstickr = ((124-28)/192))*180 = ((96)/192))*180 = 0.5 * 180 = 90 = nstickr
Now if you are not sure that you will always get a non integer value we will need to remap the number as an integer value. That is done with the int() function like so:
nstickri = int(nstickr)
but how can we simplify?
nstickr= int(((nstickx-28)/192))*180)
This works, but, can we simplify the equation and variables any more? Let us try to include the calculations into the readings we actually pull from the data array we are getting from the wiimote with minimal steps. for this case example lets pull the x axis reading on the nunchuk joystick
nunbut=wm.state['nunchuk']; nstick=nunbut['stick']; print(nstick); nstickx=int(((nstick[0]-28)/192)*180); print(nstickx);
that yields a result of (in neutral position):
(124, 129)
90
Now the wiimote accelerometer is a little bit different as it has a max value of 255 (range 0-255.) The accelerometer in it is a true accelerometer in purpose and design and was intended to be used with the IR pointer and a light bar to track cursor movements. Not a good reader of movement, though I might play with a motion plus once I get one to see if I can get better acceleration readings with it.
The wii nunchuk is a little bit different on its accelerometer readings as it is setup as more of a agyroscope position type sensor and as such is better at detecting yaw and pitch changes (x and z values.) the readings range on it seems to vary between 180 and 70
nunbut=wm.state['nunchuk']; nacc=nunbut['acc']; print(nstick); naccx=int(((nacc[0]-70)/110)*180); print(naccx);
And this yields:
(76, 104, 100)
9
And who thought that after highschool and college that they would no longer be doing polynomial math?
I am trying to use my classic controller's joystick as a mouse.
This works:
Classic.LStick.X = ABS_X
Classic.LStick.Y = ABS_Y
But it is not what I want.
When I try this:
Classic.LStick.X = REL_X
Classic.LStick.Y = REL_Y
Every key I press moves the cursor to the bottom left of the screen, which is quite odd.
Nuff said.
When I plus nunchuk into wiimote, and run wmdemo.py
the following comes up:
Report Mode: NUNCHUK CLASSIC
Active LEDs:
Rumble: Off
Battery: 74
No extension
wiimote.state is {'led': 0, 'rpt_mode': 48, 'ext_type': 0, 'rumble': 0, 'error': 0, 'battery': 154}
'ext_type' shows 0, I can't use nunchuk.
using wmgui gets the same result.
It would be nice if cwiid would automatically turn the wiimotes off to save power after a configurable length of inactivity. It's super easy to forget and have to swap battery packs daily.
Hi,
Great to see this project is maintained again, I pulled the latest version to see if a certain bug was fixed, sadly it wasn't.
What I do is this:
What I really wanted to do was make one of the analog sticks work as a mouse, but I couldn't get it to register anything at all. The moment I change anything in the config file, this happens.
Are the Wii drums supported?
I got the Wii remote buttons working but I don't see how I should read out the drum sensors.
If the drums are not supported, what would be needed to get this package to work with them?
Hello,
When I pair my my wiimote using the wminput command, in most cases the wiimote LEDs continue to blink, while the controller functions normally.
It is random, but it seems its in favor of blinking.
Is there a solution to this?
Using Debian Sid wminput 0.6
Guy
Hi, developers, thank you for your checking. It seems the lock wiimote->rpt_mutex
is not released correctly when !rpt_mode & CWIID_RPT_IR==1
and exec_write_seq(wiimote, seq_len, ir_enable_seq)==1
in the function update_rpt_mode
?
Line 144 in fadf11e
int update_rpt_mode(struct wiimote *wiimote, int8_t rpt_mode)
{
...;
/* rpt_mode = bitmask of requested report types */
/* rpt_type = report id sent to the wiimote */
if (pthread_mutex_lock(&wiimote->rpt_mutex)) {
cwiid_err(wiimote, "Mutex lock error (rpt mutex)");
return -1; // <====================lack an unlock statement
}
...;
...;
if ((rpt_mode & CWIID_RPT_IR)) {
if (exec_write_seq(wiimote, seq_len, ir_enable_seq)) {
cwiid_err(wiimote, "IR enable error");
return -1;
}
}
...;
if (pthread_mutex_unlock(&wiimote->rpt_mutex)) {
cwiid_err(wiimote, "Mutex unlock error (rpt mutex) - "
"deadlock warning");
return -1;
}
return 0;
}
Best,
Hi,
I know it's quite unlikely such a development will happen given the low activity on the project, but here's a suggestion : allow detecting and using Wiimotes through the HID API.
One of the most popular and simplest solution to handle Wiimotes in the Dolphin emulator is by using the Mayflash Dolphinbar.
The Dolphinbar handles the bluetooth connection and sync with the wiimotes, exposing them as generic USB devices that can be accessed through the HID API.
Thus, the wiimotes appear as USB devices with vendor ID 057e, and the product ID 306 (normal wiimote) or 330 (TR wiimote).
Dolphin then has fairly simple code to use these "USB wiimotes" : https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/HW/WiimoteReal/IOhidapi.cpp
Outside of the simplicity and stability, it has practical uses as well : because the Wiimotes are connected via a USB device, they can be shared over the network (via virtualhere or similar solutions), and thus work fine for playing via Moonlight or other things.
Unfortunately, CWiiD currently ignores these completely, since it only searches via actual bluetooth.
It would be pretty neat to adapt Dolphin's code into this project, to be able to use these Wiimotes in the OS just as well as in the emulator, without the need to add another bluetooth adapter and switch the sync from an adapter to the other.
Setting wiimote with this:
import cwiid
wm=cwiid.wiimote()
wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_ACC | cwiid.RPT_NUNCHUK
then running wm.state
yields:
{'rpt_mode' : 22, 'led' : 2, 'rumble' : 0, 'battery': 120, 'ext_type': 1, 'error': 0, 'buttons': 0, 'acc': (145, 128, 145), 'nunchuk': {'stick': (125, 129), 'acc': (171, 117, 132), 'buttons': 0}}
The problem is that there are two readings for:
acc, and buttons in the array. This creates errors with dictionaries in python as when you try to pull one of those duplicate keys out it errors out.
Hi,
I'm a distribution packager for Mageia ( http://www.mageia.org/ ) and i'm packager of cwiid.
The current released code is 3y old; while it seems there are still quite some development going on.
Since abstrakraft said himself that he didn't have much time for this, and he's not merging from any forks, i was looking on which fork that i can use as a release point.
However, there's too much forks, i cannot make head nor tails of which one i should have.
I would ask that any of you to continue and make a release and try to combine the existing forks back into one main thread. or perhaps have a fork/project where more than one developer can work on?
additionally, i would like for wminput -d to be forked into the background and sighup to reload. additionally, i can provide a systemd cwiid.service script for wminput -d.
another useful point would be to be able to hook up multiple wiimotes into extra uinput devices.
Perhaps if all of us have not that much time, perhaps if we work together, this would be resulting in a better project.
I would ask if anyone has a bit of time they can spare on this to answer here?
thanks in advance.
I can't find any way to make the nunchuck work. I made a modified test program that tested for the c button. I couldn't find any guides and so I made guesses with trial by looking at the modules. using the fallowing, it would work, but the 1 & 2 buttons acted as c & z respectively and I couldn't find a way to utilize the analog stick.
if (buttons & cwiid.NUNCHUK_BTN_C):
I am trying to control the mouse pointer using the nunchuk stick. I have done:
Nunchuk.Stick.X = ABS_X
Nunchuk.Stick.Y = ABS_Y
I have also tried for REL_X and REL_Y and have tried putting ~ in front of the ABS_X and ABS_Y. Still I am unable to control the mouse whatsoever. wmgui can definitely sense the nunchuk input, and things that aren't axes (for example, binding the nunchuk C button to the C key) work fine. The same general problem persists when I try to use a classic controller.
As described in the Debian bug tracker: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=669623
There is a proliferation of Wii Remote Plus which have a new device name and ID. The latest code in cwiid doesn't contemplate for these new IDs. But even changing these IDs is not enough to make the new devices work - apparently there is new reverse engineering to be done.
I would be happy to contribute the work to make this happen, but I would need some guidance on where to start.
This commit to xf86-input-libinput makes wminput's IR mouse mode not work (e.g., on Raspbian):
whot/xf86-input-libinput@3d6afca
I kludgily made it work again by changing one some REL to ABS ioctl calls in uinput, but I bet I broke some other functionality. Here's what I did: https://github.com/arpruss/cwiid/commit/4b3fda9a958fad74c2354b68c3f4389016d87b24
Can you please implement some kind of way to access raw message data in python? I'm attempting to write a python module for a custom wiimote accessory, but cwiid is improperly reading its data as being data from the classic controller. Because of this, many of the bits of the message are being split up when they are part of a group, and it is making it extraordinarily hard to figure out the protocols.
Perhaps this could be a flag you can set to simply cause all messages to be reported back as raw data? That, or just have a seperate way to get them as such, as well as a separate message callback.
Thank you.
It would be helpful sometimes to have access to the Wiimote's bluetooth address from the python interface.
project homepage redirects to http://abstrakraft.org/cwiid which is dead :(
I get error in https://github.com/abstrakraft/cwiid/blob/master/libcwiid/connect.c#L66 with a wiimote bought from China.
(it still connects to Wii but arrow buttons and 1 and 2 do not work)
Anyone having magic spell to make it sync with cwiid?
I know this repository is not in active development. However this library is used extensively by Raspberry Pi users for controlling robots. With the up coming PiWars (http://piwars.org) competition in the UK. It would be really great if someone could provide Python3 support.
Is anyone able to take up this challenge?
Hi
if i try to install cwiid i get this error:
` Running setup.py install for cwiid did not run successfully.
exit code: 1
[11 lines of output]
running install
running build
running build_ext
building 'cwiid' extension
creating build
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\pyCharm\projects\wiiremotegame\venv\include -IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\include -IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3312.0_x64__qbz5n2kfra8p0\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt /TcWiimote.c /Fobuild\temp.win-amd64-3.9\Release\Wiimote.obj
Wiimote.c
Wiimote.c(26): fatal error C1083: Cannot open include file: 'bluetooth/bluetooth.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX86\x64\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure
Encountered error while trying to install package.
cwiid
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.`
i think this is because it only installs the python folder and cant find the bluetooth.c in libcwiid
i tryd installing it manuali dosent work eather
app-misc/cwiid-0.6.00 ebuild needs net-wireless/bluez-libs and net-wireless/bluez-utils packages, which are hard-masked.
dependencies should be updated to net-wireless/bluez package.
this is a proposed ebuild, working for both cwiid-9999.ebuild (fetching sources from git) and cwiid-0.6.00.ebuild (working with USE="old-bluez-libs").
both tested for an x86 envinroment.
s939 cwiid # cat cwiid-9999.ebuild # Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="3" if [[ ${PV} == "9999" ]]; then EGIT_REPO_URI="git://github.com/abstrakraft/cwiid.git" SRC_URI="" KEYWORDS="" inherit git else SRC_URI="http://abstrakraft.org/cwiid/downloads/${P}.tgz" KEYWORDS="~x86" fi inherit eutils linux-mod autotools DESCRIPTION="Library, input driver, and utilities for the Nintendo Wiimote" HOMEPAGE="http://abstrakraft.org/cwiid" LICENSE="GPL-2" SLOT="0" IUSE="python -old-bluez-libs" DEPEND="sys-devel/bison >=sys-devel/flex-2.5.35 sys-apps/gawk" RDEPEND="=x11-libs/gtk+-2* >=sys-kernel/linux-headers-2.6 old-bluez-libs? ( net-wireless/bluez-libs net-wireless/bluez-utils ) !old-bluez-libs? ( net-wireless/bluez ) python? ( >=dev-lang/python-2.4 )" pkg_setup() { CONFIG_CHECK="BT_L2CAP INPUT_UINPUT" linux-mod_pkg_setup } src_unpack() { if [[ ${PV} == "9999" ]]; then git_src_unpack else unpack ${A} fi } src_prepare() { eautoreconf } src_configure() { econf $(use_with python) --disable-ldconfig || die "died running econf" } src_compile() { emake || die "died running emake" } src_install() { make DESTDIR="${D}" install || die "make install failed" }
s939 cwiid # cat metadata.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> <pkgmetadata> <herd></herd> <longdescription lang="en"> </longdescription> <use> <flag name="old-bluez-libs">Flag to build against hard masked bluez-libs. Needed for cwiid-0.6.00 </flag> </use> </pkgmetadata>
sudo wminput -w
gives me the following error message:
Put Wiimote in discoverable mode now (press 1+2)...
ValueError: PyCapsule_GetPointer called with incorrect name
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.