HOUSTON, Texas — The man charged in the shooting of a Houston sheriff’s deputy was found three years ago to be mentally unfit to stand trial on a separate case, and was ordered committed for evaluation, according to court documents.

Shannon Miles, who faces capital murder charges in the deadly shooting last week at a suburban gas station, was charged in 2012 with felony aggravated assault following a fight inside a Salvation Army facility in Austin, Texas. According to documents, Miles beat the other man unconscious as the result of an argument over a television remote control. Miles was indicted by a grand jury, but, according to documents, was deemed incompetent and was ordered to an Austin mental hospital for evaluation.

Documents related to the case show that Miles spent about four months in treatment, before being deemed fit for trial — but charges were dropped when authorities could not find the victim who was beaten.

The court documents surfaced on the same day the troubled 30-year-old made his first appearance in court on the shooting that has gripped this city and drawn national attention.

Related: Motive still undetermined in murder of Deputy

During a brief hearing Monday, Miles listened impassively as Harris County District Attorney Devon Anderson told a judge that Miles fired at the deputy 15 times, striking him in the head and back. Anderson said Miles unloaded every bullet in his gun.

Miles was walked into court Monday morning wearing a pale yellow prisoner’s jumpsuit. As he stood before a judge he said very little and spoke softly.

“Mr. Miles, is that correct?” the judge said.

“Yes, I am,” Miles said.

The brief hearing established cause to hold Miles after his arrest Saturday on capital murder charges. A Grand Jury is expected to be convened during the next week or two.

Anderson, the district attorney, said that Miles snuck up behind Deputy Sheriff Darren Goforth on Aug. 28 and leveled his gun at the officer’s head. Surveillance video showed Miles, wearing a white shirt, red shorts and sneakers, continuing to unload his gun even as Goforth fell forward onto the pavement.

A call about an officer-involved shooting went out around 8:20 p.m., Anderson said. Deputies responded to find their colleague face down near his patrol car, 15 40-caliber Aguilla-brand shell casings near his body.

An eyewitness who pulled up to the Chevron station just as shots were ringing out spotted a black male firing a pistol, Anderson said. The witness saw the man walking to a red pickup truck afterward and then driving off.

Deputies arriving at the scene noted the gas station’s security cameras, and upon studying the footage were able to match the red pickup truck to an address in the neighborhood.

Anderson said that when deputies arrived at the house, they found what appeared to be the same red truck with the same after-market trailer hitch visible in the video. A man who answered the door said the car belonged to his brother — and as the man let deputies inside the house, Shannon Miles and his mother pulled up in another car.

Anderson said the deputies asked Miles if he owned any guns, and that Miles said he owned a 40-caliber pistol. Deputies got a search warrant, and inside a baseball bag in the garage deputies found a pistol and a box of Aguila-brand 40-caliber ammunition. Anderson said ballistic tests tied the Smith and Wesson brand gun to the shooting.

Court was adjourned shortly afterward, and Miles was led from the courtroom, walking just past a row of deputies and police officers standing near a far wall.

Deputy Goforth’s violent death in a suburban community here in Houston has thrown the city into shock and grief. There was an outpouring of support over the weekend, as a thousand people came out on Saturday night for a vigil at the Chevron station, and on Sunday more than a thousand gathered for a neighborhood walk to support law enforcement and commemorate Goforth.

At least two fundraising drives have sprung up to support Goforth’s wife and children. An online fund has surpassed $75,000 dollars, and organizers of a separate cash drive say they’ve raised more than $85,000.

Late Monday, President Obama said he called Goforth’s widow.

“On behalf of the American people, I offered Mrs. Goforth my condolences, and told her that Michelle and I would keep her and her family in our prayers,” Obama said in a statement.

The president called the targeting of police officers “an affront to civilized society.”

Obama’s statement comes after three days of renewed national focus on the state of the relationship between police and the black community.

During a press conference on Saturday, the Harris County Sheriff said a “dangerous rhetoric” is putting police officers at risk.

“We’ve heard black lives matter — all lives matter,” Sheriff Ron Hickman said, referring to the protest movement that became prominent after the 2014 police shooting death of an unarmed black teenager in Ferguson, Missouri. Anderson earlier in that same press conference said it is time “for a silent majority in this country to support law enforcement.”

On Monday, authorities were still searching for a motive. But, speaking with reporters after court adjourned, Anderson said motive is not required. “It’s just beginning,” Anderson said of the investigation.

Asked if she still believed there is a tie between Goforth’s shooting and broader tensions among the public and police, Anderson would not say.

“I want to accentuate the positive here,” Anderson said. ”This crime is not going to divide us,” she said.

Funeral services for deputy Goforth are planned for Friday, at a Houston church.