Index: apps/action.c =================================================================== --- apps/action.c (révision 27409) +++ apps/action.c (copie de travail) @@ -149,6 +149,34 @@ CONTEXT_STD : items[i].action_code; } + +#ifdef IPOD_COLOR +//Code only valid for ipod hw_ver >=4 +#define inl(a) (*(volatile unsigned long *) (a)) +#define outl(a,b) (*(volatile unsigned long *) (b) = (a)) +void ipod_beep_on(int duration_ms, int period); +void ipod_beep_off(void); +void ipod_beep_on(int duration_ms, int period) + // period: 40=2286Hz, 30=3024Hz, 20=4465Hz, 10=8547Hz +{ + if (duration_ms == 0 && period == 0) { + // both values 0 -> make a click + duration_ms = 1; + period = 20; + } + if (period < 0) duration_ms = 30; // default period + if (duration_ms < 0) duration_ms = 50; // default duration + if (duration_ms > 1000) duration_ms = 1000; // max beep duration is 1s + outl(inl(0x70000010) & ~0xc, 0x70000010); + outl(inl(0x6000600c) | 0x20000, 0x6000600c); // enable device + outl(0x80000000 | 0x800000 | (period & 0xffff), 0x7000a000); // set pitch +} +void ipod_beep_off() +{ + outl(0x0, 0x7000a000); // piezo off +} +#endif + /* * int get_action_worker(int context, struct button_mapping *user_mappings, int timeout) @@ -201,8 +229,16 @@ /* Produce keyclick */ if (global_settings.keyclick && !(button & BUTTON_REL)) if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats) + { +#ifdef IPOD_COLOR + ipod_beep_on(0,0); +#endif pcmbuf_beep(4000, KEYCLICK_DURATION, 2500*global_settings.keyclick); +#ifdef IPOD_COLOR + ipod_beep_off(); #endif + } +#endif if ((context != last_context) && ((last_button & BUTTON_REL) == 0)) {