[Simh] Adding USB game controller support
Lars Brinkhoff
lars at nocrew.org
Tue Feb 11 02:00:24 EST 2020
Hello,
I'm adding USB game controller support to SIMH. My primary motivation
is simulation of historical devices like Spacewar consoles, joysticks,
buttons, etc. I have updated the PDP-6/KA10 simulator to use this, and
I'm planning to do PDP-1 (Spacewar) and PDP-11 (Dazzle Dart) next.
I'm building on the APIs provided by the SDL2 library. In this API, a
game controller reports events for some number of axes and buttons. An
axis is an analog value, typically for a lever. Each joystick on a
device has two axes.
The API I added to sim_video.h looks like this:
typedef void (*VID_GAMEPAD_CALLBACK)(int, int, int);
t_stat vid_register_gamepad_motion_callback (VID_GAMEPAD_CALLBACK);
t_stat vid_register_gamepad_button_callback (VID_GAMEPAD_CALLBACK);
A SIMH simulator must first call vid_open, and can then register to
receive game controller events. When vid_close is called, all callbacks
are unregistered. More than one callback can be registered; the maximum
is currently 10.
When a game controller reports an event, the corresponding callback will
be called with three values. For a motion event, these are:
1. The device ID.
2. The axis on this device.
3. The value, from -32768 to 32767.
For a button event:
1. The device ID.
2. The button on this device.
3. The state, 0 for released and 1 for pressed.
The device ID, axis, and button are all enumerated starting from 0.
More information about the Simh
mailing list