Author Topic: wiimote almost sorted!  (Read 28667 times)

gazlang

  • Guru
  • ****
  • Posts: 210
    • View Profile
wiimote almost sorted!
« 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??
AMD Athlon 5800+ X2
Asus M2N-SLI-Deluxe
2x Corsair XMS6400 DDR2 512mb
Samsung 400GB SATA + 500GB SATA
nVidia GeForce 7300GT
Hauppauge Nova-T 500
Hauppauge PVR-500
Thermaltake low-noise 450w PSU
Thermaltake Bach Case w/ imon vfd
Fiire Remote
UIRT

Zaerc

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 2256
  • Department of Redundancy Department.
    • View Profile
Re: wiimote almost sorted!
« Reply #1 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.
"Change is inevitable. Progress is optional."
-- Anonymous


gazlang

  • Guru
  • ****
  • Posts: 210
    • View Profile
Re: wiimote almost sorted!
« Reply #2 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!
AMD Athlon 5800+ X2
Asus M2N-SLI-Deluxe
2x Corsair XMS6400 DDR2 512mb
Samsung 400GB SATA + 500GB SATA
nVidia GeForce 7300GT
Hauppauge Nova-T 500
Hauppauge PVR-500
Thermaltake low-noise 450w PSU
Thermaltake Bach Case w/ imon vfd
Fiire Remote
UIRT

gazlang

  • Guru
  • ****
  • Posts: 210
    • View Profile
Re: wiimote almost sorted!
« Reply #3 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
AMD Athlon 5800+ X2
Asus M2N-SLI-Deluxe
2x Corsair XMS6400 DDR2 512mb
Samsung 400GB SATA + 500GB SATA
nVidia GeForce 7300GT
Hauppauge Nova-T 500
Hauppauge PVR-500
Thermaltake low-noise 450w PSU
Thermaltake Bach Case w/ imon vfd
Fiire Remote
UIRT

gazlang

  • Guru
  • ****
  • Posts: 210
    • View Profile
Re: wiimote almost sorted!
« Reply #4 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
AMD Athlon 5800+ X2
Asus M2N-SLI-Deluxe
2x Corsair XMS6400 DDR2 512mb
Samsung 400GB SATA + 500GB SATA
nVidia GeForce 7300GT
Hauppauge Nova-T 500
Hauppauge PVR-500
Thermaltake low-noise 450w PSU
Thermaltake Bach Case w/ imon vfd
Fiire Remote
UIRT

sp00nhead

  • Veteran
  • ***
  • Posts: 69
    • View Profile
Re: wiimote almost sorted!
« Reply #5 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 :(


Zaerc

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 2256
  • Department of Redundancy Department.
    • View Profile
Re: wiimote almost sorted!
« Reply #6 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.
"Change is inevitable. Progress is optional."
-- Anonymous


RDAC

  • Veteran
  • ***
  • Posts: 55
    • View Profile
Re: wiimote almost sorted!
« Reply #7 on: September 13, 2007, 12:09:33 am »
This would be awesome! I'm so down for this...

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: wiimote almost sorted!
« Reply #8 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

RDAC

  • Veteran
  • ***
  • Posts: 55
    • View Profile
Re: wiimote almost sorted!
« Reply #9 on: September 13, 2007, 01:34:07 am »
Go Darren, go!

gazlang

  • Guru
  • ****
  • Posts: 210
    • View Profile
Re: wiimote almost sorted!
« Reply #10 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.
AMD Athlon 5800+ X2
Asus M2N-SLI-Deluxe
2x Corsair XMS6400 DDR2 512mb
Samsung 400GB SATA + 500GB SATA
nVidia GeForce 7300GT
Hauppauge Nova-T 500
Hauppauge PVR-500
Thermaltake low-noise 450w PSU
Thermaltake Bach Case w/ imon vfd
Fiire Remote
UIRT

Zaerc

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 2256
  • Department of Redundancy Department.
    • View Profile
Re: wiimote almost sorted!
« Reply #11 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)...  :-[
"Change is inevitable. Progress is optional."
-- Anonymous


darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: wiimote almost sorted!
« Reply #12 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

RDAC

  • Veteran
  • ***
  • Posts: 55
    • View Profile
Re: wiimote almost sorted!
« Reply #13 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).

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: wiimote almost sorted!
« Reply #14 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.