From e2281e5a19682d44435b1015c4ce4a64b7e3b586 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Mon, 11 Mar 2019 00:04:48 -0700 Subject: Minor cleanup --- io.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'io.c') diff --git a/io.c b/io.c index ac30c56..4b571b0 100644 --- a/io.c +++ b/io.c @@ -219,8 +219,7 @@ void process_device(char * device_type, io_port * port) } const int gamepad_len = strlen("gamepad"); - const int mouse_len = strlen("mouse"); - if (!strncmp(device_type, "gamepad", gamepad_len)) + if (startswith(device_type, "gamepad")) { if ( (device_type[gamepad_len] != '3' && device_type[gamepad_len] != '6' && device_type[gamepad_len] != '2') @@ -236,10 +235,10 @@ void process_device(char * device_type, io_port * port) port->device_type = IO_GAMEPAD6; } port->device.pad.gamepad_num = device_type[gamepad_len+2] - '0'; - } else if(!strncmp(device_type, "mouse", mouse_len)) { + } else if(startswith(device_type, "mouse")) { if (port->device_type != IO_MOUSE) { port->device_type = IO_MOUSE; - port->device.mouse.mouse_num = device_type[mouse_len+1] - '0'; + port->device.mouse.mouse_num = device_type[strlen("mouse")+1] - '0'; port->device.mouse.last_read_x = 0; port->device.mouse.last_read_y = 0; port->device.mouse.cur_x = 0; -- cgit v1.2.3