C Language Development Kit/Functions/SetShiftTimer

From OptiWiki

Jump to: navigation, search
Description Sets the time it takes for a shifted key to be accepted as an entered character after

the key has not been pressed anymore.

Syntax
unsigned int setshifttimer(unsigned int shifttimer);
Arguments
unsigned int shifttimer
The time it takes for a shifted key to be accepted as an entered character after the key has not been pressed anymore. The value is given in steps of 20 milliseconds.

When the value (unsigned int) (~0) is entered, shifttimer is not set, only the current value of shifttimer will be returned.

Returns The value of shifttimer after the call to setshifttimer().
Remarks This function is used when entering alpha characters with the SHIFT key. When you press a key, for example 'A' and you wait for 10 seconds (the default time for shifttimer PHL1700/2700), the PHL accept 'A' as a complete character, so this will then be returned by getchar().

When after pressing the SHIFT key, you press the 'A' key twice, the character 'B' will be returned by getchar() when you wait the time indicated by shifttimer. Each time a key is pressed, the waiting time is reset. When you press another key, the previous key is accepted as a completed character, and the waiting time for the new key is reset to the value of shifttimer. The default time for the PHL1300 is set to one second.

Example
#include "lib.h"
#include <stdio.h>
 
void main( void )
{
    int key;
 
    setecho( ON );        // Shows intermediate value of key
    setshifttimer( 50 );  // 20*50 ms = 1 second
    resetkey();
 
    printf("\fType\nsomething:\n");
    while( 1 )
    {
        if( (key = getchar()) != EOF)
        {
            resetkey();
            sound( TSTANDARD, VHIGH, SHIGH, 0);
            printf("\fYou typed\n%c",(char)key);
            delay( 50*2 ); // wait 2 seconds
            sound( TCLICK, VHIGH, SMEDIUM, 0);
            printf("\fType\nsomething:\n");
        }
        idle();
    }
}


Views
Personal tools