Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

accessibility: speakup: phonetic spelling while arrowing letter by letter

This patch includes an enhancement requested frequently on the mailing
list.[1][2] It adds a variable, cur_phonetic in the spk_vars, which can
be set as a module parameter, as well as in /sys/speakup/cur_phonetic.
This patch also documents cur_phonetic as a sysfs attribute in
sysfs-driver-speakup.

When cur_phonetic=1, it causes speakup to speak letters phonetically if
paused on the character while arrowing through a word.

When a user does not set cur_phonetic to any value, the default value
for it would be 0.

[1]: https://github.com/linux-speakup/speakup/issues/6
[2]: https://github.com/linux-speakup/speakup/issues/5

since V1:
- removed unnecessary lines

Signed-off-by: Mushahid Hussain<mushi.shar@gmail.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Link: https://lore.kernel.org/r/20221115100530.91174-3-mushi.shar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Mushahid Hussain and committed by
Greg Kroah-Hartman
72b8ec15 f43241aa

+26 -4
+9
Documentation/ABI/stable/sysfs-driver-speakup
··· 35 35 characters. Set this to a higher value to adjust for the delay 36 36 and better synchronisation between cursor position and speech. 37 37 38 + What: /sys/accessibility/speakup/cur_phonetic 39 + KernelVersion: 6.2 40 + Contact: speakup@linux-speakup.org 41 + Description: This allows speakup to speak letters phoneticaly when arrowing through 42 + a word letter by letter. This doesn't affect the spelling when typing 43 + the characters. When cur_phonetic=1, speakup will speak characters 44 + phoneticaly when arrowing over a letter. When cur_phonetic=0, speakup 45 + will speak letters as normally. 46 + 38 47 What: /sys/accessibility/speakup/delimiters 39 48 KernelVersion: 2.6 40 49 Contact: speakup@linux-speakup.org
+3
drivers/accessibility/speakup/kobjects.c
··· 914 914 __ATTR(say_word_ctl, 0644, spk_var_show, spk_var_store); 915 915 static struct kobj_attribute spell_delay_attribute = 916 916 __ATTR(spell_delay, 0644, spk_var_show, spk_var_store); 917 + static struct kobj_attribute cur_phonetic_attribute = 918 + __ATTR(cur_phonetic, 0644, spk_var_show, spk_var_store); 917 919 918 920 /* 919 921 * These attributes are i18n related. ··· 969 967 &say_control_attribute.attr, 970 968 &say_word_ctl_attribute.attr, 971 969 &spell_delay_attribute.attr, 970 + &cur_phonetic_attribute.attr, 972 971 NULL, 973 972 }; 974 973
+11 -3
drivers/accessibility/speakup/main.c
··· 65 65 int spk_say_ctrl, spk_bell_pos; 66 66 short spk_punc_mask; 67 67 int spk_punc_level, spk_reading_punc; 68 + int spk_cur_phonetic; 68 69 char spk_str_caps_start[MAXVARLEN + 1] = "\0"; 69 70 char spk_str_caps_stop[MAXVARLEN + 1] = "\0"; 70 71 char spk_str_pause[MAXVARLEN + 1] = "\0"; ··· 1274 1273 BLEEPS_ID, BLEEP_TIME_ID, PUNC_LEVEL_ID, 1275 1274 READING_PUNC_ID, CURSOR_TIME_ID, SAY_CONTROL_ID, 1276 1275 SAY_WORD_CTL_ID, NO_INTERRUPT_ID, KEY_ECHO_ID, 1277 - V_LAST_VAR_ID, NB_ID 1276 + CUR_PHONETIC_ID, V_LAST_VAR_ID, NB_ID 1278 1277 }; 1279 1278 1280 1279 static struct var_t spk_vars[NB_ID] = { ··· 1291 1290 [SAY_WORD_CTL_ID] = {SAY_WORD_CTL, TOGGLE_0}, 1292 1291 [NO_INTERRUPT_ID] = { NO_INTERRUPT, TOGGLE_0}, 1293 1292 [KEY_ECHO_ID] = { KEY_ECHO, .u.n = {NULL, 1, 0, 2, 0, 0, NULL} }, 1293 + [CUR_PHONETIC_ID] = { CUR_PHONETIC, .u.n = {NULL, 0, 0, 1, 0, 0, NULL} }, 1294 1294 V_LAST_VAR 1295 1295 }; 1296 1296 ··· 1722 1720 speakup_win_say(vc); 1723 1721 else if (is_cursor == 1 || is_cursor == 4) 1724 1722 say_line_from_to(vc, 0, vc->vc_cols, 0); 1725 - else 1726 - say_char(vc); 1723 + else { 1724 + if (spk_cur_phonetic == 1) 1725 + say_phonetic_char(vc); 1726 + else 1727 + say_char(vc); 1728 + } 1727 1729 spk_keydown = 0; 1728 1730 is_cursor = 0; 1729 1731 out: ··· 2479 2473 module_param_named(say_word_ctl, spk_vars[SAY_WORD_CTL_ID].u.n.default_val, int, 0444); 2480 2474 module_param_named(no_interrupt, spk_vars[NO_INTERRUPT_ID].u.n.default_val, int, 0444); 2481 2475 module_param_named(key_echo, spk_vars[KEY_ECHO_ID].u.n.default_val, int, 0444); 2476 + module_param_named(cur_phonetic, spk_vars[CUR_PHONETIC_ID].u.n.default_val, int, 0444); 2482 2477 2483 2478 MODULE_PARM_DESC(bell_pos, "This works much like a typewriter bell. If for example 72 is echoed to bell_pos, it will beep the PC speaker when typing on a line past character 72."); 2484 2479 MODULE_PARM_DESC(spell_delay, "This controls how fast a word is spelled when speakup's spell word review command is pressed."); ··· 2493 2486 MODULE_PARM_DESC(say_word_ctl, "Sets thw say_word_ctl on load."); 2494 2487 MODULE_PARM_DESC(no_interrupt, "Controls if typing interrupts output from speakup."); 2495 2488 MODULE_PARM_DESC(key_echo, "Controls if speakup speaks keys when they are typed. One = on zero = off or don't echo keys."); 2489 + MODULE_PARM_DESC(cur_phonetic, "Controls if speakup speaks letters phonetically during navigation. One = on zero = off or don't speak phonetically."); 2496 2490 2497 2491 module_init(speakup_init); 2498 2492 module_exit(speakup_exit);
+1
drivers/accessibility/speakup/speakup.h
··· 105 105 extern int spk_reading_punc, spk_attrib_bleep, spk_bleeps; 106 106 extern int spk_bleep_time, spk_bell_pos; 107 107 extern int spk_spell_delay, spk_key_echo; 108 + extern int spk_cur_phonetic; 108 109 extern short spk_punc_mask; 109 110 extern short spk_pitch_shift, synth_flags; 110 111 extern bool spk_quiet_boot;
+1 -1
drivers/accessibility/speakup/spk_types.h
··· 49 49 RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG, 50 50 DIRECT, PAUSE, 51 51 CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH, 52 - MAXVARS 52 + CUR_PHONETIC, MAXVARS 53 53 }; 54 54 55 55 typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch,
+1
drivers/accessibility/speakup/varhandlers.c
··· 48 48 { "chartab", CHARTAB, VAR_PROC, NULL, NULL }, 49 49 { "direct", DIRECT, VAR_NUM, NULL, NULL }, 50 50 { "pause", PAUSE, VAR_STRING, spk_str_pause, NULL }, 51 + { "cur_phonetic", CUR_PHONETIC, VAR_NUM, &spk_cur_phonetic, NULL }, 51 52 }; 52 53 53 54 static struct st_var_header *var_ptrs[MAXVARS] = { NULL, NULL, NULL };