Db9

Modified db9 driver

This is a quick and dirty hack I made to connect a "piso-pad" to my parallel port, using the db9 driver from the linux kernel. As I don't know of any laptops witch have game ports built-in, I figured this could be pretty useful for those who do not really feel the need to buy and vandalize an USB controller.

In order to avoid any axes problems, all input ports are defined as buttons.

At least you should have some experience building a linux kernel and a little C knowledge would be good, too.


Editing the driver

This has been tested under kernel 2.6.14.

Using your favourite editor, open up ${KERNEL_SOURCE}/drivers/input/joystick/db9.c and do the following:

1) Replace

#define DB9_MAX_PAD          0x0D

with

#define DB9_DANCE_PAD           0x0D
#define DB9_MAX_PAD             0x0E


2) Add a new list with the driver's buttons, ie, all 8 parport inputs.

static short db9_multi_btn[] = { BTN_TRIGGER, BTN_THUMB };
static short db9_genesis_btn[] = { BTN_START, BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_MODE };
static short db9_cd32_btn[] = { BTN_A, BTN_B, BTN_C, BTN_X, BTN_Y, BTN_Z, BTN_TL, BTN_TR, BTN_START };
static short db9_dancepad_btn[] = { BTN_0, BTN_1, BTN_2, BTN_3,
                                   BTN_4, BTN_5, BTN_6, BTN_7 };

(By the way, BTN_* have already been defined in an input include, just in case you were wondering).


3) Now modify the rest of the arrays which include information about the drivers, adding a last entry to them, which will be our driver:

static char db9_buttons[DB9_MAX_PAD] = { 0, 1, 2, 4, 0, 6, 8, 9, 1, 1, 7, 9, 9, 8 };
static short *db9_btn[DB9_MAX_PAD] = { NULL, db9_multi_btn, db9_multi_btn, db9_genesis_btn, NULL, db9_genesis_btn,
                                       db9_genesis_btn, db9_cd32_btn, db9_multi_btn, db9_multi_btn, db9_cd32_btn,
                                       db9_cd32_btn, db9_cd32_btn, db9_dancepad_btn };
static char *db9_name[DB9_MAX_PAD] = { NULL, "Multisystem joystick", "Multisystem joystick (2 fire)", "Genesis pad",
                                     NULL, "Genesis 5 pad", "Genesis 6 pad", "Saturn pad", "Multisystem (0.8.0.2) joystick",
                                    "Multisystem (0.8.0.2-dual) joystick", "Amiga CD-32 pad", "Saturn dpp", "Saturn dpp dual", "Dance Pad 8-Button" };
static const int db9_max_pads[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 6, 1, 2, 1, 6, 12, 1 };
static const int db9_num_axis[DB9_MAX_PAD] = { 0, 2, 2, 2, 0, 2, 2, 7, 2, 2, 2 ,7, 7, 1 };

And also:

static const int db9_bidirectional[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1 };
static const int db9_reverse[DB9_MAX_PAD] = { 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1 };


(Notice I've set a "1" on our driver's db9_num_axis[] entry just in case; since we won't define any axis-related buttons, the application will probably see the axis, avoiding eventual crashes, but will never receive any input from it)


4) Finally, check function db9_timer. There is a switch(db9->mode) inside; after the last case break (case DB9_C32_PAD), add the following:

          case DB9_DANCE_PAD:
                  data = parport_read_data(port);
                  input_report_key(dev, BTN_0, ~data & DB9_FIRE1);
                  input_report_key(dev, BTN_1, ~data & DB9_FIRE2);
                  input_report_key(dev, BTN_2, ~data & DB9_FIRE3);
                  input_report_key(dev, BTN_3, ~data & DB9_FIRE4);
                  input_report_key(dev, BTN_4, ~data & DB9_UP);
                  input_report_key(dev, BTN_5, ~data & DB9_DOWN);
                  input_report_key(dev, BTN_6, ~data & DB9_LEFT);
                  input_report_key(dev, BTN_7, ~data & DB9_RIGHT);
                  break;


5) That's it. You're ready to do a make modules; make modules_install and load the driver using

modprobe db9 dev=0,0xD

Then do

modprobe joydev

and use jstest /dev/js0 to check that everything is allright. You should now have an 8-button-joystick connected to your parallel port :-). To turn one of the switches on, you only have to drive pins 2-9 of the DB25 parallel port to the ground (for example, pin 18).


In case you have any problems, read the following docs at the kernel source:

${KERNEL_SOURCE}/Documentation/input/joystick.txt ${KERNEL_SOURCE}/Documentation/input/joystick-parport.txt


Good luck!

-- Aleix


PS.- If you're lazy, you can also get the patched db9.c here: Espelt.net

Article -  Edit -  History - 
Hover for description
News
FAQ Tutorials Docs
Downloads
Songs
StepMix 1 Songs
StepMix 1 Songs (2)
StepMix 2 Songs
StepMix 2 Songs (2)
StepMix 3 Songs
StepMix 3 Songs (2)
StepMix 4 Songs
User Songs
Song Download Sites
Themes
Announcers
Backgrounds
Other Downloads
ITG Downloads
Message Boards

Dance Pads

Dance Pad Info
Dance Pads
Other Controllers
USB Adapters

Cool Stuff

StepMix 4 Contest
StepMania CD-ROM
StepMania Scores
In The Groove
StepMania Online
Movies
Pictures
Products
Links
Other Simulators
Frappr,MySpace,Facebook
Dance Dance Revolution
Pump It Up

Other StepMania

Documentation
Help/Support
Create & Share
Video Cards
Video Drivers
Spread StepMania
Developers
RSS Feeds
Contact Us

Search

Thanks to

SourceForge.net Logo

Site Stats

73486.76 GB of free downloads served since July 28, 2006.

Translate

Random Pictures