There is Touch.X and Touch.Y
you could set a global variable called something like aim or target and update it every tick with
if mouse mode aim = angle(gun.X,gun.Y,Mouse.X,Mouse.Y)
if touch mode aim = angle(gun.X,gun.Y,Touch.X,Touch.Y)
Then fire in that direction ( aim )