An accused Baton Rouge cop shooter will be examined by two doctors to determine whether he was sane when he allegedly fired on relatives, a family friend and the officer last year, a state judge decided Thursday.

District Judge Mike Erwin made that decision at the request of Eugene Thomas Jr.'s attorney, Bruce Unangst. Prosecutors did not object. The judge scheduled a sanity hearing for Aug. 13.

Baton Rouge Police Cpl. Shane Totty, who was hit in the face by a bullet, shrapnel and glass when Thomas allegedly fired shots at his police car in February 2018, died this February when he was struck while escorting a funeral procession on his motorcycle along Jones Creek Road.

Thomas, 35, of Baton Rouge, has pleaded not guilty and not guilty by reason of insanity to one count of attempted first-degree murder of a peace officer and four counts of attempted first-degree murder in the shootings.

Unangst said after court Thursday that if the doctors appointed by Erwin find that Thomas was not sane at the time of the shootings, prosecutors could choose to forego a trial and agree to have Thomas confined to a state mental facility.

"We will wait to see what the doctors say before making any decisions," East Baton Rouge Parish District Attorney Hillar Moore III said.

Erwin last fall found Thomas, who has a long history of mental illness, competent to stand trial.

"We certainly believe he was not sane at the time of the offense based on his history," Unangst said Thursday, adding that Thomas was not taking his medication at the time of the shootings.

Thomas allegedly used a stolen handgun to shoot at three family members and a family friend on Thomas H. Delpit Drive. He then drove off and later fired shots at Totty on Lettsworth Street, authorities have said.

The shooting left three bullet holes in the windshield of Totty's police car.

Erwin sent Thomas back to a state psychiatric hospital in August after two doctors who examined him determined he wasn’t competent to go forward in his criminal case.

He was returned to East Baton Rouge Parish Prison in October after doctors at the state mental hospital found his competency had been restored. It was then that Thomas entered a dual plea of not guilty and not guilty by reason of insanity.

Thomas fatally shot a man in 2002 because, he claimed, the victim was wearing his shorts. He was charged with murder but found not guilty by reason of insanity and ordered to be treated at the state hospital in Jackson. He spent about five years there.

Then-state District Judge Tony Marabella terminated Thomas' probation in October 2017, and he was released completely from state supervision for the first time since his 2002 arrest.

Follow Joe Gyan Jr. on Twitter, @JoeGyanJr.