Skip Menu |

This queue is for tickets about the Text-TypingEffort CPAN distribution.

Report information
The Basics
Id: 13399
Status: new
Priority: 0/
Queue: Text-TypingEffort

People
Owner: Nobody in particular
Requestors: michael [...] palmcluster.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.01
Fixed in: (no value)



Subject: Additional keyboard layouts
Some additional keyboard layouts should be added to the 'layout' option. Two that come to mind are the XPeRT layout (http://www.xpertkeyboard.com) and the Maltron layout (http://www.ergo-comp.com/ergomatic/layout.html) Since the XPeRT layout is designed for hunt-and-peck typists, a new keyboard design may be needed to indicate the distances a two-finger typist would move his fingers when typing. Another difficulty with the XPeRT layout is that it contains two E keys. That could be hard to incorporate with current design. The Maltron layout is designed for the special Maltron keyboard. To truly incorporate the Maltron layout, a Maltron keyboard design would need to be created.
[MNDRIX - Thu Jun 23 23:38:48 2005]: Show quoted text
> Another difficulty with the XPeRT layout is that it contains two E > keys. That could be hard to incorporate with current design.
This can pry be handled by simply ignoring the E that isn't on the home row. A typist may be able to alternate hands better by selectively using the two E keys, but our current metrics wouldn't pick up on this.
From: rjbs
[MNDRIX - Thu Jun 23 23:38:48 2005]: Show quoted text
> Some additional keyboard layouts should be added to the 'layout' > option.
I have attached a patch which will make it easier to register new layouts without changes to the source. This isn't a cure-all by any means, but it should be a big improvement. -- rjbs
--- Text-TypingEffort-0.20/lib/Text/TypingEffort.pm 2005-06-26 00:34:36.000000000 -0400 +++ tte/lib/Text/TypingEffort.pm 2005-07-02 16:58:12.000000000 -0400 @@ -62,7 +62,7 @@ layout => 'qwerty' # keyboard layout | 'dvorak' | 'aset', - unknowns => 0 | 1, # tally unknown chars? + unknowns => 2 | 1, # tally unknown chars? initial => \%metrics, # set initial values ); @@ -375,7 +375,7 @@ ############### subroutines to help with the calculations ################ sub _basis { - my ($desired) = @_; + my $desired = shift || 'qwerty'; my %basis; $basis{LAYOUT} = $desired; @@ -384,10 +384,7 @@ my @keyboard = &us_104; # get the layout - my @layout; - if( $desired =~ /^dvorak$/i ) { @layout = &dvorak } - elsif( $desired =~ /^aset$/i ) { @layout = &aset } - else { @layout = &qwerty } + my @layout = @{ layout($desired) }; # get some keyboard characteristics my($lshift,$rshift) = splice(@keyboard, 0, 2); @@ -522,12 +519,16 @@ ################### subroutines for keyboard layouts #################### -sub qwerty { - no warnings 'qw'; # stop warnings about the '#' and ',' characters - return ( - # the first value is the character generated by pressing the key - # without any modifier. The second value is the character generated - # when pressing the key along with the SHIFT key. + +my %layout; +{ no warnings qw(qw); # stop warnings about the '#' and ',' characters + + # the first value is the character generated by pressing the key + # without any modifier. The second value is the character generated + # when pressing the key along with the SHIFT key. + # define the 12345 row + + $layout{qwerty} = [ # define the 12345 row qw{ ` ~ @@ -590,12 +591,9 @@ . > / ? } - ); -} + ]; -sub dvorak { - no warnings 'qw'; # stop warnings about the '#' and ',' characters - return ( + $layout{dvorak} = [ # define the 12345 row qw/ ` ~ @@ -655,15 +653,9 @@ v V z Z }, - ); -} + ]; -sub aset { - no warnings 'qw'; # stop warnings about the '#' and ',' characters - return ( - # the first value is the character generated by pressing the key - # without any modifier. The second value is the character generated - # when pressing the key along with the SHIFT key. + $layout{aset} = [ # define the 12345 row qw{ ` ~ @@ -726,9 +718,34 @@ . > / ? } - ); + ]; } +=head2 register_layout($layout_name, $layout) + +This routine will register a new layout, using the given name. The layout +itself should be an arrayref containing each key's character and its shifted +version. (Consult the source for examples.) + +=cut + +sub register_layout { + my ($layout_name, $layout) = @_; + $layout{$layout_name} = $layout; +} + +=head2 layout($layout_name) + +This routine returns the arrayref representing the requested layout, or the +QWERTY layout if the given name is unknown. + +=cut + +sub layout { + my ($layout_name) = @_; + return $layout{$layout_name} if exists $layout{$layout_name}; + return $layout{qwerty}; +} 1; __END__