This is how I do it using an X52 PRO
To change weapon rails assign a hat to the DMS ( Data Management Switch )
DMS Left Short and DMS Right Short ( quick press and release ) will then cycle thru the weapon rails.
Two things to note:
1) The HUD is the SOI ( Sensor of Interest )
2) If you are in GUNS mode this key will instead cycle thru the 4 different gunsights. If you are in any of the other modes NAV, CCIP, CCRP, etc it will cycle the weapon rails.
As to putting the command on a slider or rotary I would highly recommend not doing that but it could be possible if you assigned bands to the axis.
Hope this helps.