Both solutions can work. For the 5 pin "digital" variant, you need a means to isolate the switches in normal operation, at least serious resistors, diodes or a multiplexer ic. The feasibility depends much on the regular function of the respective pins. It's probably more easy for pins that are used as outputs later.
The "analog" solution needs a sixth pull-down resistor, forming a voltage divider. The threshold voltages for the 5 bit decoder need to be calculated and e.g. placed in a ROM table.