diff io.c @ 1783:eda8df5bc74c

Minor cleanup
author Michael Pavone <pavone@retrodev.com>
date Mon, 11 Mar 2019 00:04:48 -0700
parents 7f42a93f18a4
children 1843823f1e9b
line wrap: on
line diff
--- a/io.c	Sun Mar 10 23:10:43 2019 -0700
+++ b/io.c	Mon Mar 11 00:04:48 2019 -0700
@@ -219,8 +219,7 @@
 	}
 
 	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 @@
 			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;