void ipod_init_volume_control() { ipod_init_sound(); ipod_init_input(); ipod_init_backlight(); int input, exit; exit = 0; while (exit != 1) { input = ipod_get_keypress(); if (!KEYSTATE(input)) { // Pressed input = KEYCODE(input); switch (input) { case SCROLL_R: if (SCROLL_MOD(SCROLL_MOD_NUM)) { ipod_volume++; if (ipod_volume > 70) ipod_volume = 70; // To be safe - 70 is VERY loud ipod_update_volume(); } break; case KEY_ACTION: ipod_toggle_backlight(); break; case SCROLL_L: if (SCROLL_MOD(SCROLL_MOD_NUM)) { ipod_volume--; if (ipod_volume < 0) ipod_volume = 0; // Negative volume DNE! ipod_update_volume(); } break; case KEY_MENU: exit = 1; break; default: break; } } } printf("Exiting...\n"); ipod_exit_sound(); ipod_exit_input(); }
void ipod_init_sound() { sound_fd = open("/dev/dsp", O_WRONLY); ipod_mixer = open("/dev/mixer", O_RDWR); ipod_update_volume(); int channels; channels = 1; // Mono MUCH better and smoother than stereo! ioctl(sound_fd, SNDCTL_DSP_CHANNELS, &channels); ioctl(sound_fd, SNDCTL_DSP_SPEED, &sound_frequency); }
static void ipod_init_sound() { ipod_mixer = open("/dev/mixer", O_RDWR); ipod_volume = 50; // Good default ipod_update_volume(); }