Integrating Microsystems With Metamaterials Towards Thz And Infrared Metadevices