comparison render_fbdev.c @ 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
comparison
equal deleted inserted replaced
1779:3a8c4ee68568 1780:fc9bea5ee079
941 941
942 static char *vid_std_names[NUM_VID_STD] = {"ntsc", "pal"}; 942 static char *vid_std_names[NUM_VID_STD] = {"ntsc", "pal"};
943 943
944 static void init_audio() 944 static void init_audio()
945 { 945 {
946 int res = snd_pcm_open(&audio_handle, "default", SND_PCM_STREAM_PLAYBACK, 0); 946 char *device_name = tern_find_path_default(config, "audio\0alsa_device\0", (tern_val){.ptrval="default"}, TVAL_PTR).ptrval;
947 int res = snd_pcm_open(&audio_handle, device_name, SND_PCM_STREAM_PLAYBACK, 0);
947 if (res < 0) { 948 if (res < 0) {
948 fatal_error("Failed to open ALSA device: %s\n", snd_strerror(res)); 949 fatal_error("Failed to open ALSA device: %s\n", snd_strerror(res));
949 } 950 }
950 951
951 snd_pcm_hw_params_t *params; 952 snd_pcm_hw_params_t *params;
1362 close(fd); 1363 close(fd);
1363 continue; 1364 continue;
1364 } 1365 }
1365 int to_check[] = {KEY_ENTER, BTN_MOUSE, BTN_GAMEPAD}; 1366 int to_check[] = {KEY_ENTER, BTN_MOUSE, BTN_GAMEPAD};
1366 device_type dtype = DEV_NONE; 1367 device_type dtype = DEV_NONE;
1367 for (int i = 0; i < 4; i++) 1368 for (int i = 0; i < 3; i++)
1368 { 1369 {
1369 if (1 & button_bits[to_check[i]/(8*sizeof(button_bits[0]))] >> to_check[i]%(8*sizeof(button_bits[0]))) { 1370 if (1 & button_bits[to_check[i]/(8*sizeof(button_bits[0]))] >> to_check[i]%(8*sizeof(button_bits[0]))) {
1370 dtype = i + 1; 1371 dtype = i + 1;
1371 } 1372 }
1372 } 1373 }