Is there a way to convert analog joystick inputs to keypress outputs to the computer? For example, outputting arrow key codes for the directional inputs from the joystick?
Pretty sure you can't do that with any commercially-available encoder.
You're vaguely describing what appears to be an unusual edge-case so more details are needed to give more specific advice.
Theoretically, there are several ways to do what you describe. DISCLAIMER: I haven't tested these approaches.
1. Hardware: Wire the potentiometers differently so the analog stick behaves like an 8-way stick.
To understand how pots normally work and are wired, read
How a potentiometer provides the voltage for an analog encoder to measure.
Instead of the three tabs being 5v, wiper, and ground (or ground, wiper, and 5v), connect tab #2 (middle) to ground and tabs # 1 and 3 to the left and right input ports. (or right and left)
As long as the pot is a high enough resistance value, when it is centered, it will keep the input ports at a logic high level.
Center
Left port --------|-------- Right port
^
Ground
When you push the joystick lever left, the wiper will move closer to left input port decreasing the resistance between the left port/ground and increasing the resistance between right input port and ground. When you push the joystick lever far enough left, the left port is pulled down to logic low which triggers the output. The right port stays at logic high so it is not triggered.
Center
Left port --------|-------- Right port
^
Ground
2. Software/firmware: I can't help you much beyond the general info below.
The software/firmware approach is much more flexible than the hardware approach, but you need to have the programming skills to make it work.
- If you're good at C++, look into adapting the code that MAME uses to convert analog control inputs to "INC" and "DEC" keypresses.
Use software like an AHK script or firmware on an Arduino (32u4 or newer with analog inputs) to monitor the current X-axis and Y-axis positions and output the desired keystrokes.
In a 10 bit A/D setup, there are 1024 possible positions on each axis so a value of 512 would be centered.
If you divide that range into 8 parts, each part will be 128 wide so a value between 228 (512-64) and 576 (512+64) on the X-axis would be the center column of a 7x7 grid similar to a 49-way joystick. Values between 577 and 641 would be one column to the right of center. You can adjust the ranges as desired for a larger deadzone or more sensitivity.
You can write the code for absolute position or relative position.
Absolute position -- If you move from column 3-Right to 2-Right, it will send one left keystroke. This option is not usually used.
Relative position -- If you stay centered, no keystrokes are sent. If you move the stick to a non-centered column it starts sending the desired number and rate of keystrokes.
Scott