/*---------------------------------------------------------------------------* Project: Horizon File: kbd.cpp Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 46365 $ *---------------------------------------------------------------------------*/ #include #include #include #include #include "kbd.h" u8 SwkbdDemo::m_KeyboardBuffer[KEYBOARD_BUFFER_SIZE] NN_ATTRIBUTE_ALIGN(4096); void SwkbdDemo::Initialize(demo::RenderSystemDrawing* p_RenderSystem) { Device::Initialize(p_RenderSystem); mp_RenderSystem = p_RenderSystem; memset( m_TextBuffer, 0, sizeof( m_TextBuffer ) ); // Initialize config nn::swkbd::InitializeConfig(&m_Param.config); m_Param.config.keyboardType = nn::swkbd::KEYBOARD_TYPE_QWERTY; m_Param.config.textLengthMax = 10; m_Param.config.lineFeed = false; m_Size = nn::swkbd::GetSharedMemorySize(&m_Param.config, NULL, NULL); NN_ASSERT( KEYBOARD_BUFFER_SIZE > m_Size ); } void SwkbdDemo::DrawFrame(void) { mp_RenderSystem->SetColor(1.0f, 1.0f, 1.0f, 1.0f); for(int i = 0; i < 10 ; i++) { mp_RenderSystem->DrawText(200 + 8 * i, 220, "%s", &m_TextBuffer[i]); } } bool SwkbdDemo::Exec(void) { wcsncpy( m_Param.config.guideText, m_TextBuffer, 11 ); // Start the software keyboard nn::swkbd::StartKeyboardApplet(&m_WakeupState, &m_Param, m_KeyboardBuffer, KEYBOARD_BUFFER_SIZE, NULL, NULL, NULL, NULL, NULL); // End determination if ( nn::applet::IsExpectedToCloseApplication() ) { return 1; } // Recover the GPU register settings nngxUpdateState(NN_GX_STATE_ALL); nngxValidateState(NN_GX_STATE_ALL,GL_TRUE); // Get the input string if( m_Param.config.inputText != -1 && !nn::applet::IsExpectedToProcessHomeButton() ) { u8* buf = m_KeyboardBuffer; memset( m_TextBuffer, 0, sizeof( m_TextBuffer ) ); memcpy( m_TextBuffer, &buf[m_Param.config.inputText], m_Param.config.inputTextLength * sizeof( wchar_t ) ); } return 0; } /*---------------------------------------------------------------------------* End of file *---------------------------------------------------------------------------*/