diff options
-rw-r--r-- | apps/misc.c | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/apps/misc.c b/apps/misc.c index 1800342a50..bba3969e81 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -837,6 +837,56 @@ char *strip_extension(char* buffer, int buffer_size, const char *filename) | |||
837 | 837 | ||
838 | return buffer; | 838 | return buffer; |
839 | } | 839 | } |
840 | |||
841 | #if CONFIG_CODEC == SWCODEC | ||
842 | /* Play a standard sound */ | ||
843 | void system_sound_play(enum system_sound sound) | ||
844 | { | ||
845 | static const struct beep_params | ||
846 | { | ||
847 | int *setting; | ||
848 | unsigned short frequency; | ||
849 | unsigned short duration; | ||
850 | unsigned short amplitude; | ||
851 | } beep_params[] = | ||
852 | { | ||
853 | [SOUND_KEYCLICK] = | ||
854 | { &global_settings.keyclick, | ||
855 | 4000, KEYCLICK_DURATION, 2500 }, | ||
856 | [SOUND_TRACK_SKIP] = | ||
857 | { &global_settings.beep, | ||
858 | 2000, 100, 2500 }, | ||
859 | [SOUND_TRACK_NO_MORE] = | ||
860 | { &global_settings.beep, | ||
861 | 1000, 100, 1500 }, | ||
862 | }; | ||
863 | |||
864 | const struct beep_params *params = &beep_params[sound]; | ||
865 | |||
866 | if (*params->setting) | ||
867 | { | ||
868 | beep_play(params->frequency, params->duration, | ||
869 | params->amplitude * *params->setting); | ||
870 | } | ||
871 | } | ||
872 | |||
873 | /* Produce keyclick based upon button and global settings */ | ||
874 | void keyclick_click(int button) | ||
875 | { | ||
876 | /* Settings filters */ | ||
877 | if (global_settings.keyclick && | ||
878 | (global_settings.keyclick_repeats || !(button & BUTTON_REPEAT))) | ||
879 | { | ||
880 | /* Button filters */ | ||
881 | if (button != BUTTON_NONE && !(button & BUTTON_REL) | ||
882 | && !(button & (SYS_EVENT|BUTTON_MULTIMEDIA)) ) | ||
883 | { | ||
884 | system_sound_play(SOUND_KEYCLICK); | ||
885 | } | ||
886 | } | ||
887 | } | ||
888 | #endif /* CONFIG_CODEC == SWCODEC */ | ||
889 | |||
840 | #endif /* !defined(__PCTOOL__) */ | 890 | #endif /* !defined(__PCTOOL__) */ |
841 | 891 | ||
842 | /* Read (up to) a line of text from fd into buffer and return number of bytes | 892 | /* Read (up to) a line of text from fd into buffer and return number of bytes |
@@ -1036,52 +1086,3 @@ enum current_activity get_current_activity(void) | |||
1036 | { | 1086 | { |
1037 | return current_activity[current_activity_top?current_activity_top-1:0]; | 1087 | return current_activity[current_activity_top?current_activity_top-1:0]; |
1038 | } | 1088 | } |
1039 | |||
1040 | #if CONFIG_CODEC == SWCODEC | ||
1041 | /* Play a standard sound */ | ||
1042 | void system_sound_play(enum system_sound sound) | ||
1043 | { | ||
1044 | static const struct beep_params | ||
1045 | { | ||
1046 | int *setting; | ||
1047 | unsigned short frequency; | ||
1048 | unsigned short duration; | ||
1049 | unsigned short amplitude; | ||
1050 | } beep_params[] = | ||
1051 | { | ||
1052 | [SOUND_KEYCLICK] = | ||
1053 | { &global_settings.keyclick, | ||
1054 | 4000, KEYCLICK_DURATION, 2500 }, | ||
1055 | [SOUND_TRACK_SKIP] = | ||
1056 | { &global_settings.beep, | ||
1057 | 2000, 100, 2500 }, | ||
1058 | [SOUND_TRACK_NO_MORE] = | ||
1059 | { &global_settings.beep, | ||
1060 | 1000, 100, 1500 }, | ||
1061 | }; | ||
1062 | |||
1063 | const struct beep_params *params = &beep_params[sound]; | ||
1064 | |||
1065 | if (*params->setting) | ||
1066 | { | ||
1067 | beep_play(params->frequency, params->duration, | ||
1068 | params->amplitude * *params->setting); | ||
1069 | } | ||
1070 | } | ||
1071 | |||
1072 | /* Produce keyclick based upon button and global settings */ | ||
1073 | void keyclick_click(int button) | ||
1074 | { | ||
1075 | /* Settings filters */ | ||
1076 | if (global_settings.keyclick && | ||
1077 | (global_settings.keyclick_repeats || !(button & BUTTON_REPEAT))) | ||
1078 | { | ||
1079 | /* Button filters */ | ||
1080 | if (button != BUTTON_NONE && !(button & BUTTON_REL) | ||
1081 | && !(button & (SYS_EVENT|BUTTON_MULTIMEDIA)) ) | ||
1082 | { | ||
1083 | system_sound_play(SOUND_KEYCLICK); | ||
1084 | } | ||
1085 | } | ||
1086 | } | ||
1087 | #endif /* CONFIG_CODEC == SWCODEC */ | ||