Copyright (C) 2008 Dan Wilcox <danomatika@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
--------------------------------------------------------------------------------

rc-unitd: the robotcowboy unit daemon

a linux osc joystick and wiimote event deamon and associated tools

##### DESCRIPTION #####

The rc-unitd package contains the following parts:
1. rc-unitd - device event daemon
2. rc-unit-notifier - insert/removal notification tool, called by udev rules
3. lsjs - joystick info tool
4. libunit - rc-unitd class lib, installed to lib dir

Basically, this group of tools allows any osc-capable program to recieve joystick
event data aka button presses, axis movements, etc.  Specific joystick names, as reported
by the kernel, can be mapped to specific osc send addresses.  Using udev rules and
dbus communication, reading is started or stopped automatically.

These tools were originally developed for the robotcowboy project, a wearable computer
music system using Pure Data in linux. See http://robotcowboy.com.

##### REQUIREMENTS #####

udev, dbus, liblo, glib2.0, libcwiid(optional)


##### INSTALLATION #####
 
./configure
make
sudo make install

Configure flags: --with-cwiid, compile with experimental wiimote support
						             requires libcwiid to be installed

Config files are installed to /etc/rc-unitd
Udev rules are installed to /etc/udev/rules.d
A DBus configuration file is installed to /etc/dbus-1/system.d

You may need to force udev and dbus to reload their config directories for the
rules to be used.  The easiest way to do this is to reboot or if you are on a
Debian-based system try:
	%sudo /etc/init.d/udev reload
	%sudo /etc/init.d/dbus reload

NOTE: This readme and the example pd files are also installed to your
doc dir, something like prefix/share/doc/rc-unitd

##### USAGE #####

%rc-unitd
starts device daemon, config settings are stored in /etc/rc-unitd/unitd.conf
and joystick name mappings are kept in /etc/rc-unitd/joy_names.conf

The config formats is super simple right now: one key, one value per line separated by a
space.  There is little to none error checking on missing key/value pairs.

rc-unitd.conf contains the global osc send to address, ports, etc settings

The joy_names.conf file is where you map specific joystick names to osc send addresses. The lsjs
tool allows you to see the names of currently plugged in joysticks, which you can then use as a 
key in joy_names.conf.

rc-unitd sends all events over osc to a single global address which is by default
(for now) /pd/devices/.

There are a few extra specific functional addresses to control rc-unitd, but they
are subject to change for the forseable future.

Right now, wiimote support is limited to one wiimote buuuut it does work. Try
it out.  Pitch and roll are calculated.  You have to send an osc message to 
tell rc-unitd to try and connect to the wiimote whose address can be set in /etc/rc-unitd/unitd.conf.

See the pd patches in the pd folder on how to communicate with rc-unitd.

----

%lsjs
prints out currently connected joystick info, useful for retrieving joy names to use as matching
keys in the joy_names.conf file.  See above.

----

%rc-unit-notifier [OPTION...] devname (ie joystick device name "js*")
called by the rc-unitd udev rules in /etc/udev/rules.d/85-rc-unitd.rules to notifiy
rc-unitd over dbus of joystick insertions/removals

This does not need to be called manually if dbus and udev are working correctly.


##### FUTURE IDEAS/IMPROVEMENTS #####

Ok, lots of ideas to pursue ...

1. update the config format to xml
2. get wiimote support beyond experimental stages as well as multiple wiimote support
3. add HAL support so you can assign addresses based on joy name and usb port id
4. multiple osc send addresses for event forwarding between multiple machines
5. user based config settings as well as config "profiles"
6. make a systray applet for gui control of rc-unitd ala qtjackctl->jackd
7. add built in osc -> MIDI and other mapping capability aka a Linux version of STEIM's JunXion or osculator

