Lancers against unformed infantry was a bad, bad deal for infantry, before firearms.
Well.......
The Siege of Vienna was not before firearms. Matchlock guns and cannon had been in use for over two centuries, and the flintlock had been invented about sixty years earlier. And the Turks went in for firearms in a big way.
However, I don’t think the Turks had ever taken up the pike-and-musket square which most European powers in that era had used to nullify the advantage of cavalry (hedgehog of pikes pointing outward with musketeers firing outward from between the pikemen), and Sobieski had the advantage of attacking an army engaged in a siege, rather than drawn up for battle.