@rukawakaede xboxdrv has a --four-way-restrictor flag which removes diagonal inputs. More info at: https://retropie.org.uk/docs/Universal-Controller-Calibration-&-Mapping-Using-xboxdrv/

Section 2D is the relevant section on restricting directional control to four ways.