(MSVC) Fix warnings
Properly replace template.

Avoid having to assume a magic variable is present in scope.
Fallback if mouse or keyboard interface is not working.

Problems with tablets on Windows.
(D3D) Ifdefs for HAVE_CG (and miscellaneous)