ftp.nice.ch/pub/next/system/driver/joystick/joystick.0.0.README

This is the README for joystick.0.0.I.s.tar.gz [Download] [Browse] [Up]

Greetings,

Here's the source code for an Intel joystick driver I ported over from
Linux.  This driver allows you to create /dev/js[01] devices and
then open/read from the devices for Joystick input.  It only works
on Intel hardware with a standard joystick.  This driver was written
and tested on an Intel Nextstep 3.3 system.

I've had no formal training on writing device drivers, so use this
code at your own risk.  Most packages people make available say this,
but as this is a device driver, this is a lot more risky than
most packages.  This driver runs at kernel level, and could easily
destroy all data on any accessible IO device. It's possible (although
unlikely) it could even damage your hardware.

In addition to that, I've done very little hardware/assembly-level
programming for Intel systems, and that which I did was all based
on 8088 chips several years ago.  What can I say?  I'm an Apple II
hacker, and my primary purpose in creating this was to get joystick
support into the Apple II emulator :)

I haven't had time to work on this project for awhile now, so I've
decided to just make the source code available.  Please feel free to
improve it and post newer versions.

I've tried to clean it up a bit today.  I've rewritten some
of the Makefiles and performed minimal testing.  It still appears
to work. I'm 99% certain the project should compile and work on
other systems. 

The project actually consists of three areas:
    - The original linux joystick driver project,
    - An Intel generic-unix-like device driver (works),
    - and the start of a DriverKit device driver.

I made almost no progress on writing a DriverKit driver, so there's
probably little of value in that area.

I'm not completely certain the linux code is unmodified.
I could only find a file-by-file web page from which to
download it, and I don't appear to have backed up that
source.   In fact, I'm pretty sure that I commented out the
following line and added the other one.  I also don't
appear to have recorded where I got the original code.
Try searching for linux joystick.

// #define JOYSTICK_MAJOR		15
#define JOYSTICK_MAJOR		113
 
This driver installs as major device 32.   This conflicts with the
BPF (berkeley packet filter) device [distributed with ppp, but
generally unused], but I was unsuccessful in my attempts to get
any other device number to work.  I have no idea why this was the
case.  It doesn't appear to be anything in the joystick driver code
as the original code didn't even use 32.  I got 32 from BPF.  Since
I do automatically load ppp when I boot, maybe something in ppp or
bpf performs some missing initialization for using device 32.

Using this driver has occasionally caused my clock to jump forward
several minutes.   I'm not familiar enough with Intel hardware to
know why this happens.  Probably either due to wrong handling of
interrupts or due to conflicts with the timer that the joystick
uses.

Along those same lines, the code for CLI_STI (interrupts) is mostly
guesswork.  Heck, most of the code was guesswork derived from
various other driver source code.  However, I don't have a good
feeling for the interrupt stuff.  It seems to work both with and
without the cli/sti calls.  I can't remember, but I think I also
tried spl calls at one point.

I have done no or almost-no testing on joystick ioctl options.
They may not work at all.

I no longer remember what joystick_loadable does.  The project seems to work
equally well without it.  By default, it's not installed.
I've renamed the only copy of it I've found (from an old production
directory to joystick_loadable.dist).

I have successfully used this driver with a couple of test programs
(included) as well as with a modified version of the a2 apple
emulator (not included) to play some old Apple games.

I'll try to find the time to upload the a2 emulator later.
Joystick code is #ifdef'd with JOYSTICK_SUPPORT.

Please feel free to contact me if you have any questions/comments.
I'd really like to see this project become more usable.

Things that really need done:
	- convert to DriverKit
	
	or
	
	- clean up interrupt code
	- chose (and get working) different major device number
	- make this "non-hacker" useable.
	- merge this into the windowserver so that joystick events
		are created rather than reading the devices in loops.
	- (try to keep it as compatible with linux driver as possible)
	- make setting absolute path to LIBDIR in Makefile unnecessary
	- make setting absolute major device in Makefile unnecessary

To build this driver,
	cd joystick/joystick.next
	edit Makefile to set absolute path for LIBDIR.  This points
		to the "production copy" of the driver.  This copy is
		never modified except during "make install." Make clean
		won't delete this copy.  Eventually, you'd probably
		want to put this production copy in /usr/local/etc
		or somewhere similar.
	edit Makefile and joystick_kernel.h to change major device number if
		necessary.  See above caveats.
	make

To install the driver (does not install/build test programs)
	make install
	
To use the driver (this must be done as root)
	make install_driver		# creates device files/loads driver
	make deinstall_driver		# deletes device files/unloads driver

It's probably safe to leave the /dev/js* entries around if you want.

-Mike Kienenberger
 mkienenb@alaska.net
 November 3, 1997

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.