| 1 |
| /---\ \ / /---\ | / /---- \ / |
| 2 |
| | | \ / | | / | \ / |
| 3 |
| | | | / |-- |--- | |
| 4 |
| | | | / | \ | | |
| 5 |
|___| \---/ | /____ | \ \---- | |
| 6 |
|
| 7 |
*1.6.1* |
| 8 |
Greetings! |
| 9 |
|
| 10 |
Ever had some awesome game that was great in every way, only to be |
| 11 |
spoiled by horrible keyboard controls? Wished you could pull out your |
| 12 |
trusty joystick or joypad and start blasting aliens in STYLE? Now you can! |
| 13 |
|
| 14 |
Joy2key will translate your joystick movements into the equivilent keystrokes |
| 15 |
and send them to your application or game! Works great, no muss, no fuss! |
| 16 |
|
| 17 |
Joy2key works both in X and at the console, (both raw and terminal modes.) |
| 18 |
|
| 19 |
WHAT YOU NEED |
| 20 |
------------- |
| 21 |
- Support for the /dev/js interface. You _must_ have version 1.0 (included |
| 22 |
since the 2.1.x kernel series) or later. All 2.0+ kernels theoretically |
| 23 |
will support version 1.2.1 and on of the joystick driver. The driver |
| 24 |
homepage is: |
| 25 |
http://atrey.karlin.mff.cuni.cz/~vojtech/joystick/ |
| 26 |
(if for some reason you can only use the joystick driver 0.8.0 or earlier, |
| 27 |
get joy2key 1.2 - however it lacks many features this version) |
| 28 |
- A desire to play games with the joystick :-) |
| 29 |
- The source code (joy2key-1.6.1.tar.gz) for joy2key, which you probably already |
| 30 |
have if you are reading this. |
| 31 |
|
| 32 |
|
| 33 |
COMPILING & INSTALLATION |
| 34 |
------------------------ |
| 35 |
(note: for the rest of this file, commands to be typed will be denoted '$ foo', |
| 36 |
where foo is to be typed in at the command and run) |
| 37 |
- edit the makefile to your satisfaction |
| 38 |
- type '$ make', (this will build the program) |
| 39 |
- type '$ make install' (optional, will put joy2key in /usr/local/bin and |
| 40 |
the joy2key man page in /usr/local/man/man1) |
| 41 |
|
| 42 |
That's it! EASY! |
| 43 |
|
| 44 |
USING JOY2KEY IN X |
| 45 |
------------------ |
| 46 |
In this example, I'll use the game xkobo, which is a great shoot 'em up game |
| 47 |
for X available here: |
| 48 |
ftp://uiarchive.cso.uiuc.edu/pub/systems/linux/sunsite/games/arcade/xkobo-1.9.tar.gz |
| 49 |
It is perfect to joy2key. |
| 50 |
|
| 51 |
Ok, assuming you have installed xkobo and all is good and well, |
| 52 |
playing it with your joystick is only moments away! |
| 53 |
Do this: |
| 54 |
|
| 55 |
start xkobo '$ xkobo' |
| 56 |
start joy2key '$ joy2key -X -buttons Shift_L s -axis Left Right Up Down' |
| 57 |
|
| 58 |
You will be prompted to calibrate the joystick. Center it, press a button, |
| 59 |
move to the low/high points, rinse and repeat, following the instructions. |
| 60 |
Make sure it doesn't display a '?' when you press the button (you may have |
| 61 |
to move the stick around a bit.) This calibrates joy2key to your stick. |
| 62 |
These settings are NOT saved - if you want to avoid going through the |
| 63 |
calibration each time, see "JOY2KEYRC" below. |
| 64 |
|
| 65 |
The mouse cursor will turn into a crosshair. Click on |
| 66 |
the xkobo window and joy2key will start. |
| 67 |
|
| 68 |
Here's the meaning of the options. |
| 69 |
-X means we're using X (as opposed to raw console or terminal mode.) |
| 70 |
-buttons sets buttons 0 and 1 (we programmers like to count from 0 you know) |
| 71 |
to Shift_L and s, which are shoot and pause in xkobo. |
| 72 |
-thresh sets the axis threshold for the X and Y axis. |
| 73 |
-axis sets the axis keys (what event to send when the joystick passes |
| 74 |
the previously specified threshold) |
| 75 |
|
| 76 |
See include/X11/keysymdef.h for the complete listing of key symbols in X. Don't |
| 77 |
include the "XK_" when passing to joy2key. You can also use the program 'xev' |
| 78 |
to catch keypresses and find out their key symbols. |
| 79 |
|
| 80 |
It's possible to supply the window name (joy2key "xkobo" -X ...) on |
| 81 |
the command line, then you will not be prompted with the crosshair to |
| 82 |
select the window. |
| 83 |
|
| 84 |
USING JOY2KEY IN TERMINAL MODE |
| 85 |
------------------------------ |
| 86 |
This is for ncurses applications and other programs that use the |
| 87 |
standard console interface. |
| 88 |
|
| 89 |
In this case, you need -terminal instead of -X, -buttons and -axis |
| 90 |
take either a) the ascii code of the character argument supplied (for |
| 91 |
example a or H) a decimal (example: 65), octal (example: 034), or |
| 92 |
hexidecimal (example: 0x60) number which is the ascii code you are |
| 93 |
intersted in. |
| 94 |
|
| 95 |
In terminal mode, the first argument may be the terminal that you want |
| 96 |
to send keys to. "/dev/tty" is automatically prepended to it, so |
| 97 |
"joy2key 3 -terminal ..." sends to /dev/tty3. You can also use |
| 98 |
the full /dev/whatever path. |
| 99 |
|
| 100 |
USING JOY2KEY IN RAW CONSOLE MODE |
| 101 |
------------------------------ |
| 102 |
Only for the brave! Lets you interface with SVGALIB applications like |
| 103 |
Doom and Quake. |
| 104 |
|
| 105 |
In this case, use -rawconsole. Look in the file "rawscancodes" and |
| 106 |
find the keys you want. You must supply these to -buttons and -axis. |
| 107 |
Note: single digits 0-9 are interpreted as ascii 0-9 (which is ascii |
| 108 |
40-49 or thereabouts) so you need to use hex notation (0x0 to 0x9) for |
| 109 |
SCANCODE_ESCAPE through SCANCODE_8. Other option are unaffected. |
| 110 |
|
| 111 |
The first argument on the command line works the same as in terminal mode. |
| 112 |
|
| 113 |
|
| 114 |
AUTOREPEAT |
| 115 |
---------- |
| 116 |
Thanks to Pierre Juhen, joy2key now has an autorepeat option. |
| 117 |
Simply put -autorepeat on the command line and joy2key will repeatedly send |
| 118 |
held down buttons at either the default or specified frequency. |
| 119 |
|
| 120 |
|
| 121 |
CALIBRATION (-deadzone) |
| 122 |
----------------------- |
| 123 |
|
| 124 |
Alright, automatic calibration is pretty straightforward. If you |
| 125 |
don't supply -thresh to the command line (as described below) you have |
| 126 |
to calibrate yourself. The only non-obvious part is the -deadzone |
| 127 |
option. Normally the threshold is set halfway in between the midpoint |
| 128 |
and maximum for each axis. -deadzone is a percentage of how far from |
| 129 |
the midpoint the threshold will be. |
| 130 |
threshold = middle + ((maximum - middle) * deadzone) |
| 131 |
1% is very sensitive (probably unplayable due to drift creating false events) |
| 132 |
50% is normal sensitivity (default, threshold halfway between midpoint & extreme) |
| 133 |
99% is very unsensitive (probably unplayable as well since nothing will register) |
| 134 |
Feel free to experiment. -deadzone does not affect the -thresh option in |
| 135 |
any way. |
| 136 |
|
| 137 |
|
| 138 |
AVOIDING CALIBRATION |
| 139 |
-------------------- |
| 140 |
Ok, earlier versions of joy2key required a clunky method of specifing |
| 141 |
at what point (the "threshold") a joystick axis move would trigger a |
| 142 |
key press/release event. New in this version you can calibrate |
| 143 |
automatically, but I'm sure that will get annoying quickly, and you |
| 144 |
will want to put you calibration in the below-mentioned joy2keyrc :) |
| 145 |
This is the -thresh option. Did you notice that when you were |
| 146 |
calibrating it spat out "Axis # low/high threshold set at #"? Those |
| 147 |
are the threshold values. Put '-thresh low high low high ...' on the |
| 148 |
command line where the first low is the low threshold for axis 0, high |
| 149 |
is the high threshold for axis 0, the next low is the low theshold for |
| 150 |
axis 1, etc. and you won't be bothered by the demand to calibrate |
| 151 |
manually. |
| 152 |
|
| 153 |
|
| 154 |
JOY2KEYRC (new in v1.4) |
| 155 |
--------- |
| 156 |
Now you can avoid typing long annoying command lines for joy2key! The |
| 157 |
new .joy2keyrc will store your configurations and let you use them |
| 158 |
with the -config command. For example, running xkobo is now a simple |
| 159 |
matter of: |
| 160 |
'$ joy2key -rcfile joy2keyrc.sample -config xkobo' |
| 161 |
|
| 162 |
However, if your rc file is in the default place ~/.joy2keyrc |
| 163 |
'$ joy2key -config xkobo' |
| 164 |
|
| 165 |
Neat, eh? |
| 166 |
|
| 167 |
The format of joy2keyrc is simple. It consists of two types of blocks, |
| 168 |
"COMMON" and "START" (case matters). |
| 169 |
|
| 170 |
START blocks are followed by the configuration name ('START xkobo' in |
| 171 |
this case) and then normal options as they would appear on the command |
| 172 |
line. In the case of xkobo, it looks something like this: |
| 173 |
START xkobo |
| 174 |
-X |
| 175 |
-buttons Shift_L s |
| 176 |
-axis Left Right Up Down |
| 177 |
|
| 178 |
COMMON blocks are always applied when the file is read in, so this |
| 179 |
will contain settings common to all configurations (like -thresh or |
| 180 |
-deadzone). Note that COMMON blocks are only read in when there is |
| 181 |
either a -rcfile or -config on the actual command line. |
| 182 |
|
| 183 |
Note you can include -rcfile and -config option in rc files themselves... |
| 184 |
... I think :) |
| 185 |
|
| 186 |
|
| 187 |
COPYING, LEGAL STUFF |
| 188 |
-------------------- |
| 189 |
This software is under the GNU general public license (see COPYING in |
| 190 |
this archive.) This basically means you can do whatever you want with |
| 191 |
it, and to it. Have fun. Send me mail if you make something cool. I |
| 192 |
CANNOT be held responsible for any damage, real or imagined, this |
| 193 |
program might wreak upon your system. In the words of one great |
| 194 |
hacker who escapes me at this moment: "If it breaks, you get to keep |
| 195 |
both pieces." |
| 196 |
|
| 197 |
That said, please mail me about your joy2key experiences! |
| 198 |
I can be reached at: |
| 199 |
[email protected] <Peter Amstutz> |
| 200 |
|
| 201 |
Also there is a web page that will always have the latest version of |
| 202 |
joy2key: |
| 203 |
http://interreality.org/~tetron/technology/joy2key/ |
| 204 |
|
| 205 |
Have fun. |
| 206 |
|
| 207 |
- Peter Amstutz |
| 208 |
15:43 27 January 2005 |