A police officer said he was ready to punch a man - who later died - while he was trying to restrain him.
Duncan Tomlin, 32, had epilepsy and died in July 2014 after being arrested in Haywards Heath, West Sussex.
PC Russell Watson told his inquest he grabbed Mr Tomlin and swore at him during the struggle and was surprised at Mr Tomlin's strength.
He told West Sussex Coroner's Court he used a "captor spray" on Mr Tomlin who grabbed it and sprayed him back.
The Sussex Police officer told the hearing he and a colleague arrived in Wood Ride and saw Mr Tomlin run off.
He said: "I turned to give chase. I took one or two steps and Duncan then turned round with his right-hand punches me to the left side of my face.
"It hurt and it shocked me because I wasn't expecting him to attack me."
PC Watson said: "It upset me . It made me a bit angry."
Sprayed in face
PC Watson grabbed him and swore at him before they fell to the floor and a struggle ensued, the officer told the court.
He then raised his fist and was ready to punch Mr Tomlin but instead sprayed him with his Parva incapacitant spray, formerly known as pepper spray.
He said this had no effect on Mr Tomlin, who grabbed the canister and sprayed the officer in the face.
PC Watson summoned help using his emergency button, and Mr Tomlin was detained and taken to a police van.
West Sussex Coroner Eizabeth Bussey-Jones heard Mr Tomlin had had a cardiac arrest and was given CPR on the street until an ambulance arrived. He died two days later.
The court was told previously a group of friends had spent the evening of 26 July 2014 at a friend's flat where Mr Tomlin and his girlfriend had taken "three or four" lines of cocaine and they had all been drinking.
The inquest continues.