------------------------
- DirectInput Joystick Driver for Allegro 4.x
--  by Marcello Basta-Forte (marcello@cellosoft.com)
-


1) introduction
Not much to say, I wanted to put force feedback support in my game,
so it just made sense to create a direct input joystick driver.

At the current version this is probably not super useful, the force
feedback routines are limited.

2) installing
Because I'm not sure how to create this driver as an addon, you will
have to manually hack your allegro to install this driver (scary!).

This is assuming you are using windows and successfully have compiled
and installed allegro already.  If you haven't, stop this now!

The unix utility 'sed' is required (in your path) for part of the 
installation.  Try http://unxutils.sourceforge.net/ if you don't have
sed.

So let's get down to business!

--- First you'll need to copy diutil.c, diutil.h, and wdijoy.c to your
allegro/src/win directory.

--- Second you'll need to edit the allegro/include/allegro/platform/alwin.h 
file. Open it up, then follow these steps:
a) look for this line near the end:
#define JOY_TYPE_WIN32           AL_ID('W','3','2',' ')


b) add these lines below it:
/* DirectInput Joystick driver Hack - variables */
#define JOY_DIRECTX              AL_ID('D','X',' ',' ')  
AL_VAR(JOYSTICK_DRIVER, joystick_directx);


c) then look at the following lines:
#define JOYSTICK_DRIVER_WIN32                                       \
      { JOY_TYPE_WIN32,          &joystick_win32,  TRUE  },


d) and change it to:
#define JOYSTICK_DRIVER_WIN32                                       \
/* DirectInput Joystick driver Hack - driver */                     \
      { JOY_DIRECTX,             &joystick_directx,    TRUE  },     \
      { JOY_TYPE_WIN32,          &joystick_win32,  TRUE  },


e) last of all, at the end of the file add these lines: (subject to change)
/* DirectInput Joystick driver Hack - FFEFFECT struct*/
typedef struct _FFEffectObject FFEFFECT;

/* DirectInput Joystick driver Hack - new functions */
AL_FUNC(int, ff_joystick_has, (int n));
AL_FUNC(FFEFFECT *, ff_create_effect, (void));
AL_FUNC(void, ff_destroy_effect, (FFEFFECT *));
AL_FUNC(int, ff_play_effect, (FFEFFECT *));
AL_FUNC(int, ff_play_dir_effect, (FFEFFECT *, long direction));
AL_FUNC(int, ff_make_periodic_effect, (int n, FFEFFECT *));
AL_FUNC(int, ff_make_constant_force_effect, (int n, FFEFFECT *, int fudge));
AL_FUNC(int, ff_make_fire_force_effect, (int n, FFEFFECT *));


f) ok that's it for this file!

--- Now open up allegro/makefile.lst.  Look for the ALLEGRO_SRC_WIN_FILES
listing, then add the following two lines (you can add after the 
src/win/wjoyw32.c \ line):
	src/win/wdijoy.c \
	src/win/diutil.c \

--- That should be all for the editing.  Now open up a dos prompt in the 
allegro directory.

--- Type the following from the allegro/ directory (NOTE: this will overwrite
your current dll/library with the hacked version, if you don't want that, just
'make' instead of 'make install'):
misc\fixdll
make depend
make install

--- If you want a static version, you'll have to compile that, too:
SET STATICLINK=1
make install

--- You should now be set!!!  You can run makeexample.bat in this zip
to see if the driver works right.  The main difference between the standard
driver and direct input driver is the button names are Button 1, Button 2,
etc, instead of B1, B2, etc.  Also, force feedback devices should be listed.

Press buttons 1/2/3 to try different force effects.


Special thanks (for helping get this to actually compile):
- matthew leverton / matthew@allegro.cc
- crew at #allegro EFNET