3232#include "SDL_evdev.h"
3333#include "SDL_evdev_kbd.h"
3434
35- #include <sys/stat.h>
36- #include <unistd.h>
35+ #include <errno.h>
3736#include <fcntl.h>
37+ #include <unistd.h>
3838#include <sys/ioctl.h>
39+ #include <sys/stat.h>
3940#include <linux/input.h>
4041
4142#include "../../events/SDL_events_c.h"
@@ -674,7 +675,8 @@ static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
674675 ret = ioctl (item -> fd , EVIOCGNAME (sizeof (name )), name );
675676 if (ret < 0 ) {
676677 SDL_free (item -> touchscreen_data );
677- return SDL_SetError ("Failed to get evdev touchscreen name" );
678+ SDL_LogError (SDL_LOG_CATEGORY_INPUT , "Failed to get evdev touchscreen name" );
679+ return false;
678680 }
679681
680682 item -> touchscreen_data -> name = SDL_strdup (name );
@@ -687,7 +689,8 @@ static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
687689 if (ret < 0 ) {
688690 SDL_free (item -> touchscreen_data -> name );
689691 SDL_free (item -> touchscreen_data );
690- return SDL_SetError ("Failed to get evdev touchscreen limits" );
692+ SDL_LogError (SDL_LOG_CATEGORY_INPUT , "Failed to get evdev touchscreen limits" );
693+ return false;
691694 }
692695
693696 if (abs_info .maximum == 0 ) {
@@ -704,7 +707,8 @@ static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
704707 if (ret < 0 ) {
705708 SDL_free (item -> touchscreen_data -> name );
706709 SDL_free (item -> touchscreen_data );
707- return SDL_SetError ("Failed to get evdev touchscreen limits" );
710+ SDL_LogError (SDL_LOG_CATEGORY_INPUT , "Failed to get evdev touchscreen limits" );
711+ return false;
708712 }
709713 item -> touchscreen_data -> min_x = abs_info .minimum ;
710714 item -> touchscreen_data -> max_x = abs_info .maximum ;
@@ -714,7 +718,8 @@ static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
714718 if (ret < 0 ) {
715719 SDL_free (item -> touchscreen_data -> name );
716720 SDL_free (item -> touchscreen_data );
717- return SDL_SetError ("Failed to get evdev touchscreen limits" );
721+ SDL_LogError (SDL_LOG_CATEGORY_INPUT , "Failed to get evdev touchscreen limits" );
722+ return false;
718723 }
719724 item -> touchscreen_data -> min_y = abs_info .minimum ;
720725 item -> touchscreen_data -> max_y = abs_info .maximum ;
@@ -724,7 +729,8 @@ static bool SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
724729 if (ret < 0 ) {
725730 SDL_free (item -> touchscreen_data -> name );
726731 SDL_free (item -> touchscreen_data );
727- return SDL_SetError ("Failed to get evdev touchscreen limits" );
732+ SDL_LogError (SDL_LOG_CATEGORY_INPUT , "Failed to get evdev touchscreen limits" );
733+ return false;
728734 }
729735 item -> touchscreen_data -> min_pressure = abs_info .minimum ;
730736 item -> touchscreen_data -> max_pressure = abs_info .maximum ;
@@ -908,8 +914,9 @@ static bool SDL_EVDEV_device_added(const char *dev_path, int udev_class)
908914
909915 item -> fd = open (dev_path , O_RDONLY | O_NONBLOCK | O_CLOEXEC );
910916 if (item -> fd < 0 ) {
917+ SDL_LogError (SDL_LOG_CATEGORY_INPUT , "Couldn't open %s: %s" , dev_path , strerror (errno ));
911918 SDL_free (item );
912- return SDL_SetError ( "Unable to open %s" , dev_path ) ;
919+ return false ;
913920 }
914921
915922 item -> path = SDL_strdup (dev_path );
0 commit comments