Fixed segment fault when having a controller connected

Revision of b4c03b992cb6ccd2380b726dcc0e7dfb145bdb64
I tested this on mavericks and kept getting errors when trying to start a glfw window and a gamepad connected.