Custody of child by father

I have a daughter of 5 n half yrs, from last 2 yrs there were arguments n small fights going on between me and my wife. One day last year she moved to some other area near her work place she works in a bank and our daughter was with me and my parents. My parents have raised our daughter since my wife started going to work after 3 months of my daughters birth. One weekend she visited to met our daughter and left early saying they have some work in bank on weekends bt she was with some other person in hotel. I found my wife had extra marital affair and i have proof of them staying together in hotel for few days. She confessed and said that she was sorry and wanted another chance, i trusted her and we started stating together but in between we used to have small fights on the same topic. Bt from last few days she started acting very different and said she dsnt want to stay with me n want to get separated. I said i dnt want to give u divorce and want this to work out for iur daughter, if u want we can leave my parents house and dtay sumwere near ur office place to which she rplyed that i want to stay alone with my daughter. Fre days back i was at work n she told everyone at home that she is going to her parents place for few days mext day she called me n said that she will be shifting sumwere else with our daughter n her parents will move with her n she doesn’t want to come back. I still want this relationship to work n want to stay with my daughter. Im sure that my wife is having affair with same person. How can i keep my daughter if i agree for divorce she will most probably get her custody and if i try to stay with her she can file false case against me and my family. What should i do to get my daughters custody before divorce or even if she wants divorce after that also. Pls suggest