3

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
  • 1
    Even though your stuck using the keymapper, you can make your script much more efficient by using a macro to execute the relevant commands rather than all the gotos. There's also better options for effecting delays than a one second delay. – T3RR0R Feb 28 '21 at 01:33
  • Interesting, thank you. Do you think it would be better if I used an "if, else, else, else" kind of statement containing each of the "goto" options? – Pimpenstein McChickenLegs Feb 28 '21 at 18:47

1 Answers1

0

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.

SomethingDark
  • 13,229
  • 5
  • 50
  • 55