]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/linux/gamecontroller.cpp
Close the game controller device when deleting the object
[libs/gui.git] / source / input / linux / gamecontroller.cpp
index bf690494a91c76d08d71f10d2ad8a425cf56a2a8..7fc59ed6669d0f99f11758f352ac1a478550b570 100644 (file)
@@ -57,9 +57,14 @@ JsDevice::JsDevice(const string &fn)
                throw system_error(format("open(%s)", fn));
 }
 
+JsDevice::~JsDevice()
+{
+       sys_close(handle);
+}
+
 string JsDevice::get_name() const
 {
-       char buf[128];
+       char buf[128] = { 0 };
        int ret = ioctl(*handle, JSIOCGNAME(sizeof(buf)), buf);
        if(ret<0)
                throw system_error("ioctl(JSIOCGNAME)");