LinuxMCE Forums

General => Users => Topic started by: gazlang on September 10, 2007, 11:14:40 am

Title: wiimote almost sorted!
Post by: gazlang on September 10, 2007, 11:14:40 am
I have the wiimote working in LMCE now with full media button functionality using cwiid (follow this howto: http://ubuntuforums.org/showthread.php?t=535659) and altering the button config to incluse keys F3, F5, F6, F7, F8 and Esc as well as mouse left and right click (like the gyromouse, the power button doesn't work though). I installed this in KDE BEFORE installing LMCE, so anyone with LMCE already installed may have dependancy problems.

However I can't seem to find a way of making it start on boot, I have to manually start it by typing 'sudo wminput -c ir_ptr' in the terminal.
BIG problem, as I need a mouse and keyboard to do this, and I don't want them!

Anyone have any suggestions as to how I could make this command run on boot??
Title: Re: wiimote almost sorted!
Post by: Zaerc on September 10, 2007, 11:27:23 am
Cool, how did you set the button mappings?

Would be nice to run that command uppon the bluetooth discovery I reckon.
Title: Re: wiimote almost sorted!
Post by: gazlang on September 10, 2007, 12:24:50 pm
The button mappings are in the folder usr/local/etc/cwiid/wminput/buttons (when wminput is installed).
So just type sudo nano usr/local/etc/cwiid/wminput/buttons
Then I have this changed config:

Wiimote.A      = BTN_LEFT
Wiimote.B      = KEY_ESC
Wiimote.Up      = KEY_UP
Wiimote.Down   = KEY_DOWN
Wiimote.Left   = KEY_LEFT
Wiimote.Right   = KEY_RIGHT
Wiimote.Minus   = KEY_F6
Wiimote.Plus   = KEY_F8
Wiimote.Home   = KEY_F7
Wiimote.1      = KEY_F3
Wiimote.2      = KEY_F5

Set up for nice use!

As for starting on boot, the command 'wminput -w' should keep wminput in search mode untill a wiimote is found, but I had no luck putting this in as a cronjob.
(I tried-
sudo crontab -e
then entered
@reboot sudo wminput -w -c ir_ptr)

I think wminput starts up before the bluetooth adapter, and so fails and exits.
I'm going to keep working on this!
Title: Re: wiimote almost sorted!
Post by: gazlang on September 10, 2007, 01:38:15 pm
Oh, and for anyone who wants to install cwiid using the howto linked above, use this updated version of cwiid which seems to have improved ir following.

http://ftp.de.debian.org/debian/pool/main/c/cwiid/cwiid_0.6.00.orig.tar.gz
Title: Re: wiimote almost sorted!
Post by: gazlang on September 11, 2007, 11:41:18 am
Ok, I think the problem with getting to load the wiimote driver (wminput) on boot is due to a reliance on kbluetoothd.

The -w in the command wminput -w -c ir_ptr tells wminput to wait until a wiimote is found. But it appears to only wait so long as a bluetooth port is open, and that doesn't appear to happen until kbluetoothd has discovered a bluetooth device and started up.

If wminput -w -c ir_ptr is run before kbluetoothd has started (as a blue icon in the KDE tray) then it fails with an error.

So, I think to get it running on boot, the LMCE bluetooth manager (is there one??) needs to be disabled, and kbluetoothd started and put in discover mode on boot before wminput is started.

Any suggestions on this matter would be much appreciated!

Gareth
Title: Re: wiimote almost sorted!
Post by: sp00nhead on September 12, 2007, 10:16:12 pm
kbluetoothd ?? i didn't think that was used. I've just installed following the instructions at https://help.ubuntu.com/community/CWiiD but then remembered my bro "borrowed" my remote for some 4 player action on his wii :(

Title: Re: wiimote almost sorted!
Post by: Zaerc on September 12, 2007, 11:31:16 pm
I've just simply built and installed from the sources in that tarball, edited the buttons file like you said and it works like a charm after starting wminput. 

I think we should make it into a device that gets started when the media director is spawned.  I'm hoping that a simple script will suffice, just starting wminput in a loop, but maybe there has to be some sort of "locking" as well.
Title: Re: wiimote almost sorted!
Post by: RDAC on September 13, 2007, 12:09:33 am
This would be awesome! I'm so down for this...
Title: Re: wiimote almost sorted!
Post by: darrenmason on September 13, 2007, 01:24:26 am
I think we should make it into a device that gets started when the media director is spawned.  I'm hoping that a simple script will suffice, just starting wminput in a loop, but maybe there has to be some sort of "locking" as well.
I think that is probably the best idea actually. It only really needs the Startup/Shutdown events on the device to start/stop the appropriate wminput stuff.
Advantage would be timing should be better aligned with bluetooth stack loaded and "Quick Reload Router" should allow you to reinitialise it if needed. Scripted device should be fine.

Will have a go at this tonight... if noone beats me to it.

Regards Darren
Title: Re: wiimote almost sorted!
Post by: RDAC on September 13, 2007, 01:34:07 am
Go Darren, go!
Title: Re: wiimote almost sorted!
Post by: gazlang on September 13, 2007, 10:33:22 am
You are right, it's definately not kbluetoothd causing repeated failures in wminput! But possibly to do with pybluez. Further testing later....

Apparently, ubuntu users can get it started on boot by adding wminput -d (this just activated the gyro not the ir following, but i'm sure wminput -w -c ir_ptr works for them just the same) to the boot list under the sessions tab of the system settings.
Title: Re: wiimote almost sorted!
Post by: Zaerc on September 13, 2007, 09:46:06 pm
Well I had a stab at it, but got a bit confused when trying to set it up in the web-admin. 

To make a long story short, now I have to figure out why my development-setup fails to regenerate the orbiter (even after removing the devices I added)...  :-[
Title: Re: wiimote almost sorted!
Post by: darrenmason on September 14, 2007, 01:46:16 am
I was basically short on time last night so didn't get very far at all.

Got started though, setup wiimote on a different Media Director - as that one is easier for me to test things on. No major problems there except I did have problems discovering after a reboot.

Still undecided as to where the device should live in the heirarchy. At first I thought it would be a child of the MD Device but thinking about it a bit more it might be better under the Bluetooth dongle.

Did a couple of checks on the bluetooth dongle and it is receiving events on discover mode (1+2 buttons pressed). Therefore I think the following should be possible;
1. Walk into room with an existing MD running and Bluetooth dongle
2. Press discover (1+2)
3. Bluetooth dongle device recognises new device and matches MAC address range as wiimote presents option to winstall wiimote device (much like a new bluetooth phone does now)
4. Device is installed, with all dependent packages and parameter set to MAC address of wiimote. Maybe button/key mappings can be parameters as well
5. Device is started, starting wminput appropriately
6. On restart or reload router shtdown of device is called and stops the wminput

If device goes out of range then device would be stopped.

On an existing setup that has already got the device installed the same process would work (without having to do the package/device installs). You would still need to press 1+2 to use the wiimote (and start the device) - that is why I am think that it should live under bluetooth dongle???

All this seems quite straightforward to implement. Once the device is working then we just need to ensure all the dependencies are packaged up appropriately.

Some questions I still need answers to;
1. Can LMCE detect the wiimote and bind to it without 1+2 being pressed. This would enable the wiimote to be active on a restart without having to do anything.
2. Can wminput work with multiple wiimotes? Not a big issue or anything - just thinking ahead to the concept of it being like an ID for each family member. If they are using their wiimote then LMCE would recognise which user is controlling the orbiter. This makes cheking voicemail etc easier and can give them different UI.

There is also potential for Follow-me functionality to be tied to the wiimote. Basically, any of the mobile orbiter functionality could be contenders due to the use of bluettooth.

Anyway, first things first - need to get the device running with the basic wminput start/stop functionaility first. Job for the weekend now as that is the first chance I will get.

Regards
Darren
Title: Re: wiimote almost sorted!
Post by: RDAC on September 14, 2007, 03:10:21 am
Very logical. Follow me function would be key, as per this is toted as a big feature of the FiireChief remote (that, and the gyro).
Title: Re: wiimote almost sorted!
Post by: darrenmason on September 14, 2007, 04:36:55 am
It (followme) certainly wouldn't be as good as the fiirechief, but should be equivalent to the mobile orbiter follow-me which is what was originally built.

This is due to the fact that fiire have added hardware that more accurately advises signal strength to the device.
Title: Re: wiimote almost sorted!
Post by: sandos on September 14, 2007, 02:47:36 pm
I tried playing around with signal strength in ubuntu, but I was unable to get any readings even though my device supposedl  supports it! Does anybody know if there is a general problem of reading signal strength in BT ?

BTW nice work on the wiimote.
Title: Re: wiimote almost sorted!
Post by: RDAC on September 16, 2007, 07:03:22 am
Anybody had time to continue playing with this project? Wanted to see if you were workin' on it this weekend. I may start playing with it myself here soon.
Title: Re: wiimote almost sorted!
Post by: darrenmason on September 17, 2007, 01:41:31 am
Had a little bit of time to play with it, but not as much as I would have liked.

I am finding connection a little bit inconsistent at the moment - not sure if it is the bluetooth dongle as it is a real cheap one.

Created a C++ device to represent the wiimote. Have only got to the stage where the device is built and starts up in the MD. I havn't actually put any of the code in it yet.
Need to build myself a IR bar as well as sick of candles. Got all the bits just need to put them together.

Will look into signal stength when I get the thing connecting consistently.

Question for someone with a wii (I only have the wiimote), do you need to connect (press 1 +2) every time you use it? I have assumed that you don't, but I havn't used one so thought I better check.

I am trying to do a few things in parallel at the moment and the wiimote is lower on the priority list but hopefully will get more time on it this week.
Title: Re: wiimote almost sorted!
Post by: RDAC on September 17, 2007, 07:08:19 am
Don't have to press both buttons, normally any button on the remote will make it 'wake up'.
Title: Re: wiimote almost sorted!
Post by: gazlang on September 18, 2007, 09:07:55 am
Been playing around with wminput to get it sticking in search mode without a device enquiry error (so that it can be run auto at boot), but no luck yet.
I installed it on Kubuntu without Lmce, and wminput -w -c ir_ptr will hold forever untill you connect the wiimote (perfect for starting the command auto at boot).

Any suggestions why it fails with LMCE installed?? (or is it just a problem I have?) LMCE bluetooth override?

I have a feeling bluez-utils has something to do with it - I tried to re-compile it (on my LMCE machine) and it failed with errors.
Title: Re: wiimote almost sorted!
Post by: sandos on September 19, 2007, 08:35:25 am
With a Wii, the first thing you do is generally to press the red button in under the battery cover at the same time as pressing the red button under the front hinge on the Wii. This connects the wiimote and from then on it will automatically be detected by the Wii.


There is also the option of bringing your wiimote to a friends place and temporarily connect it to his Wii. I think this might be done with 1+2.
Title: Re: wiimote almost sorted!
Post by: darrenmason on September 19, 2007, 09:34:01 am
Sounds like it should be possible to (semi)permanently pair the wiimote with the bluetooth dongle then.
Will have to try stuff out and see what happens in terms of moving rooms etc.

I am starting to think that we might need a better solution than wminput. The things that bother me at the moment are;
* Intermitant connects - I am not getting a reliable connection
* Need to activate connection (1+2 button thing) each time.
* It seems to implement only one interface at a time, by default it is the accelerometer and with the -c ir_ptr option it is infrared. Originally, I had hoped it did both -ie used the acc. always and then enhanced it with IR positioning. The wiimote can obviously convey both, I guess the issue is with simulating mouse movements the two might conflict ???
Title: Re: wiimote almost sorted!
Post by: gazlang on September 19, 2007, 11:43:22 am
Well I decided to try out cwiid (wminput) because it allowed an easy button configuration, and also because the alternative 'wmd' didn't seem to have been met with much success (http://forum.linuxmce.org/index.php?topic=1246.0).

After using the wiimote under wminput for a while I have also decided that it is far from perfect for LMCE.
I don't mind having to connect by pressing 1+2 on boot, and once connected I don't have a problem with losing signal or connection. But I am finding a problem in the use of only one wiimote interface at a time (ir sensor or gyro).

The ir sensor doesn't seem to enable a good navigation of media (scrolling up and down pages in the LMCE TV guide / dvd chapter list etc). In fact, trying to scroll through pages accurately is useless, the wiimote completely overshoots page scrolling.

The gyro mode however, is perfect for up and down page scrolling in LMCE, but useless along the x (horizontal) axis, as this is controlled by roll motion of the wiimote rather than yaw (as when using the ir mode) and is extremely difficult to manipulate accurately.

Therefore, an integration of ir sensing and gyro control is a must really! I'm going to continue playing around with wminput for a while to see if I can at least get gyro for y axis movements and ir sensing for x axis movements, but i'll also be looking out for other wiimote drivers to check out.



Title: Re: wiimote almost sorted!
Post by: gazlang on September 19, 2007, 08:52:06 pm
Ok, got one little piggy sorted (I think):
to add gyro function to existing ir motion sensing simply:

sudo nano /usr/local/etc/cwiid/wminput/ir_ptr

and add

Plugin.acc.X    = REL_X
Plugin.acc.Y    = REL_Y

such that the page now looks like:

#ir_ptr

include buttons

Plugin.ir_ptr.X = ABS_X
Plugin.ir_ptr.Y = ABS_Y

Plugin.acc.X    = REL_X
Plugin.acc.Y    = REL_Y

Haven't tested how this works in LMCE for page scrolling yet - have it working on KDE (on my non LMCE PC).

Still trying to get it running auto on boot though.

Thinking that modding /etc/init.d/bluetooth to search for the wiimote using its mac address may work / help?? Or even adding wminput in there somewhere?? Not sure where.....hoping someone else can shed some light.

see here http://ubuntuforums.org/showthread.php?t=432013

Title: Re: wiimote almost sorted!
Post by: darrenmason on September 20, 2007, 01:14:26 am
Good stuff gazlang, hopefully I will be a ble to help you out a bit more soon. Struggling for any time this week.
Title: Re: wiimote almost sorted!
Post by: Stingly on September 27, 2007, 11:58:38 am
Has there been any further developments with this? I must admit that reading through the thread has made me rather excited by the prospect of using my wiimote to control LMCE!
Title: Re: wiimote almost sorted!
Post by: atreidae on October 06, 2007, 04:50:23 am
I got it working with gyro out of the box, cwiid is awesome, unfortunately my son and missus (as well as moving house0 is delaying development, you guys have flown straight past what i started, Whoa!

Ill see what i can do to get cwiid -w to run when a bt device is discovered.

something i noticed in the binaries i downloaded it helps ALOT if you specify the mac of the wiimote on the cwiid command line.

(all the commands escape me at the moment... im at work)
Title: Re: wiimote almost sorted!
Post by: atreidae on October 06, 2007, 04:53:35 am
of worthy note (i have checked the guides posted but most of them assumed uinput was running) the DVD install has uinput deactivated by default.

a "modprobe uinput" is required to get everything up and running PRIOR to cwiid.
can you CAN run cwiid as a normal user, you need to change the properties for uinput to all users (cant remember that one either)

Im sudoing because im slack.
Title: Re: wiimote almost sorted!
Post by: gazlang on October 06, 2007, 02:57:42 pm
I've been playing with it this morning, and kinda made some progress, while also taking a step back!

I have the wiimote kinda working on boot...

do hcitool scan in konsole and copy the mac address

then start wminput with the mac address. eg.

wminput -d -c ir_ptr 00:19:1D:84:CB:DD

the -d daemonises wminput and retries to connect after a disconnect.

THis is very stable in terms of maintaining a connection.

I then added:

@reboot /usr/local/bin/wminput -d -c /usr/local/etc/cwiid/wminput/ir_ptr 00:19:1D:84:CB:DD

to crontab -e

and the wiimote works at boot (of course you still have to press 1+2 to connect)
However, now it seems ir_ptr is ignored, as none of the configured buttons work, and neither does the ir sensing. Only the accelerometer motion and 'A' for enter!

I think something needs loading before wminput for this functionality. I don't know what though  :)

Title: Re: wiimote almost sorted!
Post by: atreidae on October 09, 2007, 08:41:42 am
sorry, can you go into this step in a little more detail..

Quote
I then added:

@reboot /usr/local/bin/wminput -d -c /usr/local/etc/cwiid/wminput/ir_ptr 00:19:1D:84:CB:DD

to crontab -e

never done it that way before, might be why i cant load stuff.

Check the permissions of the configuration file, try sticking your command in quotation marks

Im building a new machine tonight (MD) so ill have a play (moved my core to the cupboard when we moved.. the missus aint happy :D )

Title: Re: wiimote almost sorted!
Post by: gazlang on October 09, 2007, 11:00:10 am
Yes, sorry,

You can enter jobs to run at specific times in the crontab file (eg, you can run a command every hour or once a day or on every boot automatically (as the '@reboot' bit of my comand)) (http://ubuntuforums.org/showthread.php?t=102626 for examples)

it is a root job list, so I asume all commands are run as root anyway.

edit the file by:

sudo crontab -e

Specifying the locations of wminput and ir_ptr is probably overkill, but just wanted to make sure they were found (since kde isn't actually running while this command is run)

I have other commands running fine in crontab, like my lcdproc server and clients to display on a vfd screen.
Title: Re: wiimote almost sorted!
Post by: gazlang on November 01, 2007, 02:49:18 pm
After another long atempt at trying to get the ir and configured buttons to work on boot (and failing) I am starting to think that the xorg.conf (where the wiimote is listed as a input device - required for ir and configured button use) is being ignored by LMCE.

I did wonder as I have been trying to change my screen resolution via the xorg.conf file, with 0 effect.

Does anybody know whether LMCE does in fact ignore xorg.conf and read it's own version of xorg??
Title: Re: wiimote almost sorted!
Post by: Zaerc on November 01, 2007, 05:06:33 pm
see http://wiki.linuxmce.org/index.php/Display_Drivers#LinuxMCE_keeps_reconfiguring_my_display_settings maybe that helps a bit.
Title: Re: wiimote almost sorted!
Post by: gazlang on November 07, 2007, 11:35:09 am
Cheers Zaerc,
Thought it could have been the answer, but unfortunately did nothing for the wiimote.

Not giving up though  :)
Title: Re: wiimote almost sorted!
Post by: Ngiri on November 13, 2007, 10:51:00 pm
Hi, just thought I'd let everyone know that following the steps in this thread worked nicely for me to get the wiimote functioning and recognized easily on reboot.  Thanks for all the info.

I have to agree that using it isn't as nice as it could be.  Scrolling is nearly impossible.  Also, I seemed to burn through batteries within about 24 hours a set.  Like it keeps the connection live all the time.  I picked up a rechargeable battery pack and charger combo so that shouldn't be so bad now.

Keep up the good work.  If MCE would just included the ability to use the wiimote it would be a very nice "selling" feature.  Of course the average end-user might be at a loss about the whole sensor bar thing too.

Title: Re: wiimote almost sorted!
Post by: gazlang on November 15, 2007, 02:26:30 pm
Hi, just thought I'd let everyone know that following the steps in this thread worked nicely for me to get the wiimote functioning and recognized easily on reboot. 

Did you manage to get the ir sensing function working on boot?
Title: Re: wiimote almost sorted!
Post by: Ngiri on November 19, 2007, 06:58:09 pm
Yes I did.  I set up the cron settings outlined above and used the command line above for running the ir version in daemon mode (launched at boot).

If you'd like me to look up any of the specific settings I will.
Title: Re: wiimote almost sorted!
Post by: gazlang on November 19, 2007, 07:19:46 pm
Hmmm,
I was begining to wonder whether the problem was that the cronjob was starting up before xorg.conf was read (if I enter kde and connect the wiimote the ir function still does not work)

Exactly what do you have in your crontab file?
And also, have you edited any settings in LMCE to do with display / mice / keyboards (apart from during the A/V wizard)?

Cheers
Title: Re: wiimote almost sorted!
Post by: Ngiri on November 20, 2007, 09:43:13 pm
I know I made some changes to the Xorg.conf for the wiimote.  I don't think I made any others.

I can look up cron settings when I get home.
Title: Re: wiimote almost sorted!
Post by: gazlang on November 21, 2007, 09:17:55 pm
Were your xorg changes different to that described in the cwiid howto?

Cheers ngiri
Title: Re: wiimote almost sorted!
Post by: Ngiri on November 21, 2007, 10:49:50 pm
It's been some time, but I don't think they were.

I have a couple wiimotes and apparently I switched them so I've just updated the cron job with the address of the one I'm using and I'm checking to see if it's still working.
Title: Re: wiimote almost sorted!
Post by: Ngiri on November 21, 2007, 11:18:32 pm
The behavior I'm seeing is that although I just hit 1+2 on the wiimote to have it connect, the ir doesn't seem to be working.  I swear it was working before...  Did I confuse manually starting it with the boot connect?  I think I might have.