Home

Resume

Blog

Teikitu


/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
/*  »Project«   Teikitu Gaming System (TgS) (∂)
    »File«      TgS (WIN) Input - GUI Keyboard.c
    »Author«    Andrew Aye (EMail: mailto:andrew.aye@gmail.com, Web: http://www.andrewaye.com)
    »Version«   4.51 / »GUID« A9981407-3EC9-42AF-8B6F-8BE6DD919615                                                                                                        */
/*   -------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
/*  Copyright: © 2002-2017, Andrew Aye.  All Rights Reserved.
    This software is free for non-commercial use.  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
      following conditions are met:
        Redistribution of source code must retain this copyright notice, this list of conditions and the following disclaimers.
        Redistribution in binary form must reproduce this copyright notice, this list of conditions and the following disclaimers in the documentation and other materials
          provided with the distribution.
    The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
    The intellectual property rights of the algorithms used reside with Andrew Aye.
    You may not use this software, in whole or in part, in support of any commercial product without the express written consent of the author.
    There is no warranty or other guarantee of fitness of this software for any purpose. It is provided solely "as is".                                                   */
/* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */

#pragma warning( push, 3 )
#include <winuser.rh>
#pragma warning( pop )




/* == Input ============================================================================================================================================================= */

/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions and Data                                                                                                                                         */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

static TgVOID                               tgIN_PM_Update_GUI_Keyboard_Callback( TgMS_HWND, TgUINT32, TgUINTPTR, TgSINTPTR );
static TgUINT32                             tgIN_PM_Query_Code_Page( TgVOID );

static TgUINT32                             s_uiInput_Code_Page = 0;




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  Internal Functions                                                                                                                                                    */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgIN_PM_Init_GUI_Keyboard --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgIN_PM_Init_GUI_Keyboard( TgVOID )
{
    return (KTgS_OK);
}


/* ---- tgIN_PM_Boot_GUI_Keyboard --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgIN_PM_Boot_GUI_Keyboard( TgVOID )
{
    tgKN_Set_GUI_Keyboard_Callback( tgIN_PM_Update_GUI_Keyboard_Callback );
    return (KTgS_OK);
}


/* ---- tgIN_PM_Stop_GUI_Keyboard --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgIN_PM_Stop_GUI_Keyboard( TgVOID )
{
    tgKN_Set_GUI_Keyboard_Callback( nullptr );
    return (KTgS_OK);
}


/* ---- tgIN_PM_Free_GUI_Keyboard --------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgRESULT tgIN_PM_Free_GUI_Keyboard( TgVOID )
{
    return (KTgS_OK);
}


/* ---- tgIN_PM_Update_GUI_Keyboard ------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgVOID tgIN_PM_Update_GUI_Keyboard( C_ETgCONTROLLER UNUSED_PARAM enController )
{
}


/* ---- tgIN_PM_Query_Fixed_Memory_GUI_Keyboard ------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
TgSIZE tgIN_PM_Query_Fixed_Memory_GUI_Keyboard( TgVOID )
{
    return (0
    );
}




/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */
/*  File Local Functions                                                                                                                                                  */
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. */

/* ---- tgIN_PM_Query_Code_Page ----------------------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgUINT32 tgIN_PM_Query_Code_Page( TgVOID )
{
#if !defined(TgCOMPILE_PLATFORM_UWP)
    return (g_pfnGetACP());
#else
    return (0);
#endif
}


/* ---- tgIN_PM_Update_GUI_Keyboard_Callback ---------------------------------------------------------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- */
static TgVOID tgIN_PM_Update_GUI_Keyboard_Callback( TgMS_HWND UNUSED_PARAM hWnd, TgUINT32 uiMsg, TgUINTPTR wParam, TgSINTPTR UNUSED_PARAM lParam )
{
    static TgBOOL                       bIsInit = TgFALSE;
    TgUINT32                            uiState;
    TgUINT32                            uiEvent;

    if ((TgTRUE != bIsInit) || 0 == s_uiInput_Code_Page)
    {
        s_uiInput_Code_Page = tgIN_PM_Query_Code_Page();
        bIsInit = TgTRUE;
    };

    uiState = ETgSTATE_KEYBOARD_VALID;

    switch (uiMsg)
    {
        case WM_INPUTLANGCHANGE:
            s_uiInput_Code_Page = tgIN_PM_Query_Code_Page();
            break;

        case WM_UNICHAR:
            break;

        case WM_IME_CHAR:
            break;

        case WM_CHAR:
            break;

        case WM_SYSKEYDOWN:
        case WM_KEYDOWN:
        case WM_IME_KEYDOWN:
            break;

        case WM_SYSKEYUP:
        case WM_KEYUP:
        case WM_IME_KEYUP:
            break;
    };

    while (0 == tgCM_UTM_LA_RB_SRSW__Query_Free_Size( &g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_sLA_RB_SRSW ))
    {
        tgTR_Yield();
    };

    uiEvent = (TgUINT32)tgCM_UTM_LA_RB_SRSW__Push_Next_Index( &g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_sLA_RB_SRSW );

    g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_asEvent[uiEvent].m_enController = ETgCONTROLLER_GUI_KEYBOARD;
    g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_asEvent[uiEvent].m_uiState.GUI_Keyboard = uiState;
    g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_asEvent[uiEvent].m_enProp.GUI_Keyboard = ETgPROP_GUI_KEY_MAX;
    g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_asEvent[uiEvent].m_uiUTF32 = (TgUINT32)wParam;
    g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_asEvent[uiEvent].m_fValue = 0.0F;
    g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_asEvent[uiEvent].m_fDiff = 0.0F;

    tgCM_UTM_LA_RB_SRSW__Push_Commit( &g_asController_Active[ETgCONTROLLER_GUI_KEYBOARD].m_sLA_RB_SRSW );
}