Ejemplo n.º 1
0
HB_SIZE hb_inkeyKeyString( int iKey, char * buffer, HB_SIZE nSize )
{
   HB_SIZE nLen = 0;

   HB_TRACE( HB_TR_DEBUG, ( "hb_inkeyKeyString(%d,%p, %" HB_PFS "u)", iKey, buffer, nSize ) );

   if( HB_INKEY_ISUNICODE( iKey ) )
   {
      nLen = hb_cdpTextPutU16( hb_vmCDP(), buffer, nSize, HB_INKEY_VALUE( iKey ) );
   }
   else
   {
      if( HB_INKEY_ISCHAR( iKey ) )
         iKey = HB_INKEY_VALUE( iKey );
      else if( HB_INKEY_ISKEY( iKey ) )
      {
         int iFlags = HB_INKEY_FLAGS( iKey );

         iKey = HB_INKEY_VALUE( iKey );

         if( iKey > 0 && iKey <= ( int ) HB_SIZEOFARRAY( s_transKeyFun ) )
            iKey = s_inkeyTransChar( iKey, iFlags, &s_transKeyFun[ iKey - 1 ] );
         else if( iKey >= 32 && iKey <= 127 )
            iKey = s_inkeyTransChar( iKey, iFlags, &s_transKeyStd[ iKey - 32 ] );
      }
      if( iKey >= 32 && iKey <= 255 && iKey != 127 )
      {
         PHB_CODEPAGE cdp = hb_vmCDP();
         nLen = hb_cdpTextPutU16( cdp, buffer, nSize,
                                  hb_cdpGetU16( cdp, ( HB_UCHAR ) iKey ) );
      }
   }
   return nLen;
}
Ejemplo n.º 2
0
int hb_inkeyKeyStd( int iKey )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_inkeyKeyStd(%d)", iKey ) );

   if( HB_INKEY_ISEXT( iKey ) )
   {
      int iFlags = HB_INKEY_FLAGS( iKey );

      if( HB_INKEY_ISMOUSEPOS( iKey ) )
         iKey = K_MOUSEMOVE;
      else if( HB_INKEY_ISKEY( iKey ) )
      {
         iKey = HB_INKEY_VALUE( iKey );

         if( iKey > 0 && iKey <= ( int ) HB_SIZEOFARRAY( s_transKeyFun ) )
            iKey = s_inkeyTransChar( iKey, iFlags, &s_transKeyFun[ iKey - 1 ] );
         else if( iKey >= 32 && iKey <= 127 )
            iKey = s_inkeyTransChar( iKey, iFlags, &s_transKeyStd[ iKey - 32 ] );
      }
      else if( HB_INKEY_ISCHAR( iKey ) || HB_INKEY_ISUNICODE( iKey ) )
      {
         int iVal = HB_INKEY_VALUE( iKey );

         if( iVal >= 32 && iVal <= 127 &&
             ( iFlags & ( HB_KF_ALT | HB_KF_CTRL ) ) != 0 )
            iKey = s_inkeyTransChar( iVal, iFlags, &s_transKeyStd[ iVal - 32 ] );
         else if( HB_INKEY_ISUNICODE( iKey ) )
         {
            HB_WCHAR wc = ( HB_WCHAR ) iVal;
            if( wc )
            {
               HB_UCHAR uc = hb_cdpGetUC( hb_vmCDP(), wc, 0 );
               if( uc != 0 )
                  iKey = uc;
            }
            else
               iKey = 0;
         }
         else
            iKey = iVal;
      }
      else /* HB_INKEY_ISMOUSEKEY | HB_INKEY_ISEVENT */
         iKey = HB_INKEY_VALUE( iKey );
   }
   return iKey;
}