Search code examples
batch-filecmdcontrollerjoystickgamepad

is it possible to use a joystick/game controller input in cmd?


As the title says, I would like to use Joystick buttons for input in this simple batch I am writing. Is it even possible?

I know I can use a Joy to Keyboard mapper program to emulate keystrokes, but I would like to avoid this extra layer if possible.

EDIT: Code updated, as per advice in comments.

set /a "PC=0"
set DELAY=20

:START

CHOICE /C ABCD /M "Select [A]Channel Up [B]Channel Down [C]Program Change Up [D]Program Change Down"
IF %ERRORLEVEL% EQU 1 goto INCCH
IF %ERRORLEVEL% EQU 2 goto DECCH
IF %ERRORLEVEL% EQU 3 goto INCPC
IF %ERRORLEVEL% EQU 4 goto DECPC

goto START

:INCCH
if %CH% EQU 8 (set /a "CH=1") else (set /a "CH+=1")
goto SEND

:INCPC
if %PC% EQU 7 (set /a "PC=0") else (set /a "PC+=1")
goto SEND

:DECCH
if %CH% EQU 1 (set /a "CH=8") else (set /a "CH-=1")
goto SEND

:DECPC
if %PC% EQU 0 (set /a "PC=7") else (set /a "PC-=1")
goto SEND

:SEND
echo SEND MIDI program-change %CH% %PC%
sendmidi --out <port> --program-change %CH% %PC%
for /L %%a In (0 1 %DELAY%) do (ping -n 1 -w 99.99.99.99 > nul)
goto START

Solution

  • The command prompt is unaware of any type of input other than the keyboard - it doesn't even have mouse support.

    Your best bet is to keep using the joystick-to-keyboard emulator that you're currently using.