changeset 1780:fc9bea5ee079

Fix off-by-one error in evdev init code and allow ALSA device to be specified in config
author Michael Pavone <pavone@retrodev.com>
date Sun, 10 Mar 2019 22:11:32 -0700
parents 3a8c4ee68568
children 2b4d5cfec6d9
files render_fbdev.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/render_fbdev.c	Sun Mar 10 21:30:09 2019 -0700
+++ b/render_fbdev.c	Sun Mar 10 22:11:32 2019 -0700
@@ -943,7 +943,8 @@
 
 static void init_audio()
 {
-	int res = snd_pcm_open(&audio_handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
+	char *device_name = tern_find_path_default(config, "audio\0alsa_device\0", (tern_val){.ptrval="default"}, TVAL_PTR).ptrval;
+	int res = snd_pcm_open(&audio_handle, device_name, SND_PCM_STREAM_PLAYBACK, 0);
 	if (res < 0) {
 		fatal_error("Failed to open ALSA device: %s\n", snd_strerror(res));
 	}
@@ -1364,7 +1365,7 @@
 			}
 			int to_check[] = {KEY_ENTER, BTN_MOUSE, BTN_GAMEPAD};
 			device_type dtype = DEV_NONE;
-			for (int i = 0; i < 4; i++)
+			for (int i = 0; i < 3; i++)
 			{
 				if (1 & button_bits[to_check[i]/(8*sizeof(button_bits[0]))] >> to_check[i]%(8*sizeof(button_bits[0]))) {
 					dtype = i + 1;