Please do not post a support request without first reading and following the advice in https://retropie.org.uk/forum/topic/3/read-this-first

Assigning jstest output to a variable from a shell script



  • I tried using this to assign the output of jstest to a variable, but it seems like jstest just opens and the script does not continue.

    JSTEST_OUTPUT_2=$(jstest /dev/input/js1)

    This is the command and the output I am trying to capture:

    jstest /dev/input/js1

    Driver version is 2.1.0.
    Joystick (Twin USB Joystick) has 6 axes (X, Y, Z, Rz, Hat0X, Hat0Y)
    and 12 buttons (Trigger, ThumbBtn, ThumbBtn2, TopBtn, TopBtn2, PinkieBtn, BaseBtn, BaseBtn2, BaseBtn3, BaseBtn4, BaseBtn5, BaseBtn6).
    Testing ... (interrupt to exit)
    Axes: 0: 0 1: 0 2: 0 3: 0 4: 0 5: 0 Buttons: 0:off 1:off 2:on 3:off 4:off 5:on 6:off 7:off 8:off 9:on 10:off 11:off

    I also tried using grep (jstest --normal /dev/input/js1 | grep ".*") just to see what would show up and it would only return:
    Driver version is 2.1.0.
    Joystick (Twin USB Joystick) has 6 axes (X, Y, Z, Rz, Hat0X, Hat0Y)
    and 12 buttons (Trigger, ThumbBtn, ThumbBtn2, TopBtn, TopBtn2, PinkieBtn, BaseBtn, BaseBtn2, BaseBtn3, BaseBtn4, BaseBtn5, BaseBtn6).
    Testing ... (interrupt to exit)

    I am not sure why it wouldnt capture the button/stick data (maybe because it's values are constantly being updated?)

    I dont care about the other information i just want this:
    Axes: 0: 0 1: 0 2: 0 3: 0 4: 0 5: 0 Buttons: 0:off 1:off 2:on 3:off 4:off 5:on 6:off 7:off 8:off 9:on 10:off 11:off

    I will keep searching the internet for an answer and I will update this post if I find one.

    Thanks guys!



Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.

Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.