Skip to content

Commit

Permalink
accessibility: speakup: phonetic spelling while arrowing letter by le…
Browse files Browse the repository at this point in the history
…tter

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]: linux-speakup/speakup#6
[2]: linux-speakup/speakup#5

since V1:
	- removed unnecessary lines

Signed-off-by: Mushahid Hussain<[email protected]>
Reviewed-by: Samuel Thibault <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
SikkiLadho authored and gregkh committed Nov 23, 2022
1 parent f43241a commit 72b8ec1
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Documentation/ABI/stable/sysfs-driver-speakup
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ Description: This controls cursor delay when using arrow keys. When a
characters. Set this to a higher value to adjust for the delay
and better synchronisation between cursor position and speech.

What: /sys/accessibility/speakup/cur_phonetic
KernelVersion: 6.2
Contact: [email protected]
Description: This allows speakup to speak letters phoneticaly when arrowing through
a word letter by letter. This doesn't affect the spelling when typing
the characters. When cur_phonetic=1, speakup will speak characters
phoneticaly when arrowing over a letter. When cur_phonetic=0, speakup
will speak letters as normally.

What: /sys/accessibility/speakup/delimiters
KernelVersion: 2.6
Contact: [email protected]
Expand Down
3 changes: 3 additions & 0 deletions drivers/accessibility/speakup/kobjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,8 @@ static struct kobj_attribute say_word_ctl_attribute =
__ATTR(say_word_ctl, 0644, spk_var_show, spk_var_store);
static struct kobj_attribute spell_delay_attribute =
__ATTR(spell_delay, 0644, spk_var_show, spk_var_store);
static struct kobj_attribute cur_phonetic_attribute =
__ATTR(cur_phonetic, 0644, spk_var_show, spk_var_store);

/*
* These attributes are i18n related.
Expand Down Expand Up @@ -967,6 +969,7 @@ static struct attribute *main_attrs[] = {
&say_control_attribute.attr,
&say_word_ctl_attribute.attr,
&spell_delay_attribute.attr,
&cur_phonetic_attribute.attr,
NULL,
};

Expand Down
14 changes: 11 additions & 3 deletions drivers/accessibility/speakup/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int spk_key_echo, spk_say_word_ctl;
int spk_say_ctrl, spk_bell_pos;
short spk_punc_mask;
int spk_punc_level, spk_reading_punc;
int spk_cur_phonetic;
char spk_str_caps_start[MAXVARLEN + 1] = "\0";
char spk_str_caps_stop[MAXVARLEN + 1] = "\0";
char spk_str_pause[MAXVARLEN + 1] = "\0";
Expand Down Expand Up @@ -1273,7 +1274,7 @@ enum spk_vars_id {
BLEEPS_ID, BLEEP_TIME_ID, PUNC_LEVEL_ID,
READING_PUNC_ID, CURSOR_TIME_ID, SAY_CONTROL_ID,
SAY_WORD_CTL_ID, NO_INTERRUPT_ID, KEY_ECHO_ID,
V_LAST_VAR_ID, NB_ID
CUR_PHONETIC_ID, V_LAST_VAR_ID, NB_ID
};

static struct var_t spk_vars[NB_ID] = {
Expand All @@ -1290,6 +1291,7 @@ static struct var_t spk_vars[NB_ID] = {
[SAY_WORD_CTL_ID] = {SAY_WORD_CTL, TOGGLE_0},
[NO_INTERRUPT_ID] = { NO_INTERRUPT, TOGGLE_0},
[KEY_ECHO_ID] = { KEY_ECHO, .u.n = {NULL, 1, 0, 2, 0, 0, NULL} },
[CUR_PHONETIC_ID] = { CUR_PHONETIC, .u.n = {NULL, 0, 0, 1, 0, 0, NULL} },
V_LAST_VAR
};

Expand Down Expand Up @@ -1720,8 +1722,12 @@ static void cursor_done(struct timer_list *unused)
speakup_win_say(vc);
else if (is_cursor == 1 || is_cursor == 4)
say_line_from_to(vc, 0, vc->vc_cols, 0);
else
say_char(vc);
else {
if (spk_cur_phonetic == 1)
say_phonetic_char(vc);
else
say_char(vc);
}
spk_keydown = 0;
is_cursor = 0;
out:
Expand Down Expand Up @@ -2473,6 +2479,7 @@ module_param_named(say_control, spk_vars[SAY_CONTROL_ID].u.n.default_val, int, 0
module_param_named(say_word_ctl, spk_vars[SAY_WORD_CTL_ID].u.n.default_val, int, 0444);
module_param_named(no_interrupt, spk_vars[NO_INTERRUPT_ID].u.n.default_val, int, 0444);
module_param_named(key_echo, spk_vars[KEY_ECHO_ID].u.n.default_val, int, 0444);
module_param_named(cur_phonetic, spk_vars[CUR_PHONETIC_ID].u.n.default_val, int, 0444);

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.");
MODULE_PARM_DESC(spell_delay, "This controls how fast a word is spelled when speakup's spell word review command is pressed.");
Expand All @@ -2486,6 +2493,7 @@ MODULE_PARM_DESC(say_control, "This controls if speakup speaks shift, alt and co
MODULE_PARM_DESC(say_word_ctl, "Sets thw say_word_ctl on load.");
MODULE_PARM_DESC(no_interrupt, "Controls if typing interrupts output from speakup.");
MODULE_PARM_DESC(key_echo, "Controls if speakup speaks keys when they are typed. One = on zero = off or don't echo keys.");
MODULE_PARM_DESC(cur_phonetic, "Controls if speakup speaks letters phonetically during navigation. One = on zero = off or don't speak phonetically.");

module_init(speakup_init);
module_exit(speakup_exit);
1 change: 1 addition & 0 deletions drivers/accessibility/speakup/speakup.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ extern int spk_no_intr, spk_say_ctrl, spk_say_word_ctl, spk_punc_level;
extern int spk_reading_punc, spk_attrib_bleep, spk_bleeps;
extern int spk_bleep_time, spk_bell_pos;
extern int spk_spell_delay, spk_key_echo;
extern int spk_cur_phonetic;
extern short spk_punc_mask;
extern short spk_pitch_shift, synth_flags;
extern bool spk_quiet_boot;
Expand Down
2 changes: 1 addition & 1 deletion drivers/accessibility/speakup/spk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ enum var_id_t {
RATE, PITCH, VOL, TONE, PUNCT, VOICE, FREQUENCY, LANG,
DIRECT, PAUSE,
CAPS_START, CAPS_STOP, CHARTAB, INFLECTION, FLUSH,
MAXVARS
CUR_PHONETIC, MAXVARS
};

typedef int (*special_func)(struct vc_data *vc, u_char type, u_char ch,
Expand Down
1 change: 1 addition & 0 deletions drivers/accessibility/speakup/varhandlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static struct st_var_header var_headers[] = {
{ "chartab", CHARTAB, VAR_PROC, NULL, NULL },
{ "direct", DIRECT, VAR_NUM, NULL, NULL },
{ "pause", PAUSE, VAR_STRING, spk_str_pause, NULL },
{ "cur_phonetic", CUR_PHONETIC, VAR_NUM, &spk_cur_phonetic, NULL },
};

static struct st_var_header *var_ptrs[MAXVARS] = { NULL, NULL, NULL };
Expand Down

0 comments on commit 72b8ec1

Please sign in to comment.