(Input drivers) Cleanups

This commit is contained in:
twinaphex 2015-06-03 18:12:06 +02:00
parent 4cfe960bf3
commit bafda714a1
2 changed files with 20 additions and 21 deletions

View File

@ -14,20 +14,19 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../../driver.h"
#include <sys/ioctl.h>
#include <linux/input.h>
#include <linux/kd.h>
#include <termios.h>
#include <unistd.h>
#include <signal.h>
#include "../../general.h"
#include "../input_keymaps.h"
#include "../input_common.h"
#include "../input_joypad.h"
static long oldKbmd = 0xffff;
static long oldKbmd = 0xffff;
static bool linuxraw_stdin_claimed = false;
static struct termios oldTerm, newTerm;
@ -80,11 +79,11 @@ static void *linuxraw_input_init(void)
if (oldKbmd == 0xffff)
{
tcgetattr(0, &oldTerm);
newTerm = oldTerm;
newTerm.c_lflag &= ~(ECHO | ICANON | ISIG);
newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
newTerm.c_cc[VMIN] = 0;
newTerm.c_cc[VTIME] = 0;
newTerm = oldTerm;
newTerm.c_lflag &= ~(ECHO | ICANON | ISIG);
newTerm.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
newTerm.c_cc[VMIN] = 0;
newTerm.c_cc[VTIME] = 0;
if (ioctl(0, KDGKBMODE, &oldKbmd) != 0)
{
@ -109,9 +108,9 @@ static void *linuxraw_input_init(void)
/* Trap some standard termination codes so we
* can restore the keyboard before we lose control. */
sigaction(SIGABRT, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
sigaction(SIGFPE, &sa, NULL);
sigaction(SIGILL, &sa, NULL);
sigaction(SIGQUIT, &sa, NULL);
sigaction(SIGSEGV, &sa, NULL);

View File

@ -273,8 +273,8 @@ static bool add_device(udev_input_t *udev,
{
int fd;
struct input_device **tmp;
struct stat st = {0};
struct input_device *device = NULL;
struct stat st = {0};
struct epoll_event event = {0};
if (stat(devnode, &st) < 0)
@ -337,14 +337,14 @@ static void udev_input_remove_device(udev_input_t *udev, const char *devnode)
for (i = 0; i < udev->num_devices; i++)
{
if (!strcmp(devnode, udev->devices[i]->devnode))
{
close(udev->devices[i]->fd);
free(udev->devices[i]);
memmove(udev->devices + i, udev->devices + i + 1,
(udev->num_devices - (i + 1)) * sizeof(*udev->devices));
udev->num_devices--;
}
if (strcmp(devnode, udev->devices[i]->devnode) != 0)
continue;
close(udev->devices[i]->fd);
free(udev->devices[i]);
memmove(udev->devices + i, udev->devices + i + 1,
(udev->num_devices - (i + 1)) * sizeof(*udev->devices));
udev->num_devices--;
}
}