I fixed it by setting SELinux to permissive.Because
1. The android is not rooted.
2. This android does not have /dev/uinput (although rooted).
I am running today's nightly of CyanogenMod 14.1 for the Motorola Moto G 2014, which is Android 7.1.1 Nougat.