Custody is either done by agreement or decided by the court. Your prior offense will be one of many factors the court will consider. You need a lawyer who will address this and makes sure the court hears about any other issues you have in the case. Since this involves your child, this may be the most important case you ever have. Make sure it gets done right the first time. You need to get your evidence on the record and keep out stuff that may factor against you. It can be very difficult to change something later if it is not done right the first time.