Re: Re: [AD] a small contribution

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


hi, here are some ideas to the keyboard accent problem...

What about adding a key_shifts flag to each ACCENT key? For example, on the
Slovak keyboard there are 3 accents on 2 keys. So ACCENT1 would have the 
normal KB_ACCENT1_FLAG and an additional flag, called KB_ACCENT1_ACTIVATE_FLAG
(the name is too long, I know :-) which would determine, what additional key
needs to be pressed to activate the ACCENT to wait for another keypress.
The KB_ACCENT_S_FLAG would be obsolete, because its function would take
(and improve :-) the new flag. That means, on our keyboard we would have the
first ACCENT mapped on the key KEY_EQUALS and the ACTIVATE_FLAG is 0 (which
means, activate it by pressing only KEY_EQUALS.) Then we would have a second
ACCENT, assigned to the same KEY_EQUALS, but the ACTIVATE FLAG would be
KB_SHIFT_FLAG. As the third ACCENT we would assign the KEY_TILDE (what it is
all about :-) and the ACTIVATE_FLAG would be KB_SHIFT_FLAG. On a normal press,
KEY_TILDE would print ';'.

In this case we would need more ACCENTS (I don't know what national
keyboard has the most accents, so I would suggest at least 3 (on our
keyboard there are 3 - our 2 and the Czech one.)

In PCKEYS.C, the defined KB_ACCENTS would be redefined into
(KB_ACCENT1_FLAG | KB_ACCENT2_FLAG | ... | KB_ACCENTx_FLAG), there would
be more than two 'int _key_accent*' and in the function _handle_pckey
the scanning for ACCENTS on the line 434 would look like this :
(of course, all tables would be modified

if ((((mycode==_key_accent1) && (_kb_shifts & KB_ACCENT1_ACTIVATE_FLAG)) ||      ((mycode==_key_accent2) && (_kb_shifts & KB_ACCENT2_ACTIVATE_FLAG)) ||
                                 ...
     ((mycode==_key_accent*) && (_kb_shifts & KB_ACCENT*_ACTIVATE_FLAG)))
     && (!_key_standard_kb)) {
        if (key_altgr) {
	   /* alt+gr overrides accent escapes */
	   _handle_key_press(_key_altgr_table[mycode], origcode);
	   return;            
        }
        else {
	   /* accent escape key */
	   if (mycode==_key_accent1) i = KB_ACCENT1_FLAG;
	   else if (mycode==_key_accent2) i = KB_ACCENT2_FLAG;
	                     ...
	   else if (mycode==_key_accent*) i = KB_ACCENT*_FLAG;
	   _key_shifts = i;
	   _handle_key_press(-1, origcode);
	   return;
        }
     }
     
     if (_key_shifts & KB_ACCENTS) {
        /* accented character input */
        if (((_key_shifts & KB_SHIFT_FLAG) != 0) ^ ((_key_shifts & KB_CAPSLOCK_FLAG) != 0)) {
  	 if (_key_shifts & KB_ACCENT1_FLAG)
  	    table = _key_accent1_upper_table;
  	 else if (_key_shifts & KB_ACCENT2_FLAG)
  	    table = _key_accent2_upper_table;
  		...
  	 else if (_key_shifts & KB_ACCENT*_FLAG)
  	    table = _key_accent*_upper_table;
  	 else
  	    table = NULL;
        }
        else {
  	 if (_key_shifts & KB_ACCENT1_FLAG)
  	    table = _key_accent1_lower_table;
  	 else if (_key_shifts & KB_ACCENT2_FLAG)
  	    table = _key_accent2_lower_table;
  		...
  	 else if (_key_shifts & KB_ACCENT*_FLAG)
  	    table = _key_accent*_lower_table;
  	 else
  	    table = NULL;
        }
  
        if (table[mycode]) {
  	 /* simple accented char */
  	 _key_shifts &= ~KB_ACCENTS;
  	 _handle_key_press(table[mycode], origcode);
  	 return;
        }
  /* now I've got a problem... see the bottom of this e-mail */      
        else {
  	 /* add the accent as an individual character */
  	 i = (_key_shifts & (KB_ACCENT1_FLAG | KB_ACCENT1_S_FLAG)) ? _key_accent1 : _key_accent2;
  	 _handle_key_press(_key_ascii_table[i], i);
  	 _key_shifts &= ~KB_ACCENTS;
        }
     }
     
There is only one thing that's not clear to me : when doing the /* add the
accent as an individual character */ (line 484 of pckeys.c), why isn't
there also the check for the KB_ACCENT2_FLAG ??? If I am right, it prints
the normal ASCII character (when its key is not mapped to an ACCENT), after
pressing an accent key and the next key. But where is the second accent ???

									Peter
-- 
-----------------------------------------------------------------------------
Mail: pavlovic@xxxxxxxxxx
WEB : http://redbull.dcs.fmph.uniba.sk/~pavlovic
-----------------------------------------------------------------------------



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/