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.
Yes, I’m still waking up. I should have said before modern firearms.
Lancers were still very effective against unformed infantry through the Napoleonic period. It took rifled weapons and the Minié ball to give infantry firearms the range to really make themselves almost impossible for cavalry to deal with. And then the lever-action repeater really was the death knell for cavalry in other than a dragoon (mounted infantry) and scouting role.