When Mark Ronson and Bruno Mars accepted the Grammy Award for Record of the Year for “Uptown Funk” in 2016, Ronson made a point of thanking producers and songwriters Jimmy Jam and Terry Lewis during his speech.

But they had no direct connection to the song. Ronson was simply acknowledging them for being a primary influence, and for helping define funk, R&B and soul during the last 35 years.

Together, the Minneapolis duo have crafted dozens of hits, some sung by Janet Jackson, Michael Jackson, George Michael and Boyz II Men, among many others.

Next Thursday, Jam, 58, and Lewis, 60, will be inducted into the Songwriters Hall of Fame in New York, alongside Kenneth “Babyface” Edmonds, Berry Gordy, Robert Lamm and James Pankow (from Chicago), Max Martin and Jay Z. Here’s a brief history of their career and collaborations.

To and ’fro with Prince

Prince performing in NYC in 1980.Getty Images

In the early ’80s, Jam and Lewis were members of the Time — the group masterminded by Prince in order to act as his personal side project.

But Jam’s connection to the funk legend goes way back to when they went to junior high school together.

“He had the biggest afro of all time, which was great because back in those days, the biggest afro was definitely the best,” he tells The Post. “He had good hair genes, and the girls loved it! And yes, he really was that good at basketball. He was like Steph Curry.”

As Jam and Lewis went on to produce and write their own hits, Lewis remembers Prince having mixed feelings.

“In the beginning, it probably wasn’t that easy for him. It might have shook him for a minute. It’s kind of hard for a parent to see a child to grow up.”

Taking “Control” with Janet Jackson

Jam and Lewis began to have major success with a reluctant Janet Jackson on her breakout third album, “Control” (1986).

“I talked to her the other day and we were watching an old clip of her singing as a kid on the Jacksons’ variety show,” says Jam. “She said, ‘I hated singing, but in my family, everyone’s got to sing!’ Her first two albums were more about ‘Here are some songs, go and sing them.’ I don’t think that was really her passion. When we did ‘Control’ together, we concentrated on her needs, and she grew to love it.”

But her father Joe was initially less pleased with the idea of his daughter working with the former Prince collaborators.

“Prince was fairly controversial and provocative at that time,” says Jam. “So I think it was a dad looking at his daughter and thinking, ‘Don’t turn her into that.’”

The “Optimistic” challenge

Earlier this year, Chance the Rapper recorded a video of himself and friends dancing to the 1991 Sounds of Blackness track “Optimistic” — intended to inspire fans to positive thoughts and actions to counter the postelection gloom. It spread like wildfire, creating the viral Optimistic Challenge.

The song itself was another Jam and Lewis classic. “We ran into him at the Grammys and he said he did it because people needed something to help them get through a moment of darkness,” says Jam. “But he had no idea we wrote that record!”