Fix output/input devices index bug