Draggable gearshifter for mobile game

I am trying to make a racing game but i need to add a gearstick. All i want is for the user to be able to drag the gearstick (the red thing in my screenshot) along the H pattern (the black thing) the gearstick should never leave the H pattern (it should always follow the H path, even when dragged). I also want the gearstick to snap to the closest gear/neutral when released; for example if you released the gearstick at the lower part of the 1st gear line, it would just snap back into neutral, or if you were near the bottom of the 4th gear line it would snap to 4th gear. I then need a way of the game knowing what gear it is in, which i do know how to do (by placing an object at each gear position and then checking collisions for the gearstick), but i want to see if anyone has a more efficient way of doing it. Thanks for any help!


i realised i forgot the screenshot lol so here it is