Thats what i did last time i flashed it, but the thing with heimdall is that i have to extract the ap then flash the files separately, it doesnt have the option to flash the packaged version of them, im wondering that maybe its because i didnt flash the full ap is why the touchscreen didnt work, by the way do you have to flash the fota.zipAfter it booted up without touchscreen, have you tried flashing unpatched stock files with Heimdall? Are you then back where you started, no Magisk but touchscreen works?
If so, I would say that shows you are using Heimdall correctly.
If you are using Heimdall, I would assume you are have a Samsung device. Have you read the Imstallation Notes sections about Samsung? I would expect you to have to install Magisk to recovery. There is some disagreement over whether you need to check the Recovery option in Magisk Manager before patching the AP.tar file, or whether Magisk Manager will always install to recovery when presented with an AP.tar file.