Add project files.

This commit is contained in:
2018-06-25 21:48:45 -04:00
parent b04a25689b
commit 3c1b7d28e8
425 changed files with 35333 additions and 0 deletions
@@ -0,0 +1,90 @@
#include "cTextInput.hpp"
using InputEngine::cTextInput;
cTextInput::cTextInput()
: cKeyboard("TextInput"), m_text(""), m_caps(false), m_shift(false), INTERNATIONAL_MASK(0xFF80), UNICODE_MASK(0x7F)
{
/*if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) {
SDL_EnableUNICODE(SDL_ENABLE);
}*/
}
cTextInput::cTextInput( const cTextInput& copy )
: cKeyboard(copy), m_text(copy.getText()), m_caps(false), m_shift(false), INTERNATIONAL_MASK(0xFF80), UNICODE_MASK(0x7F)
{
/*if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE) {
SDL_EnableUNICODE(SDL_ENABLE);
}*/
}
/*virtual*/ cTextInput::~cTextInput()
{}
///Functions
/* */
/*virtual*/ void cTextInput::KeyboardCheck( const SDL_Event& event )
{
switch(event.key.keysym.sym)
{
case SDLK_BACKSPACE:
case SDLK_DELETE:
if(m_text.size() == 0)
//m_text.erase(m_text.end() - 1);
break;
default:
{
char key = UnicodeValue(event);
if(key != 0)
m_text += key;
}
break;
}
}
/* Clears out the Text */
void cTextInput::ClearText()
{
m_text = "";
}
///Sets
void cTextInput::setText( const cString& text )
{
m_text = text;
}
///Gets
const cString& cTextInput::getText() const
{
return m_text;
}
//Private
const char cTextInput::UnicodeValue( const SDL_Event& event )
{
event;
/* if (SDL_EnableUNICODE(SDL_QUERY) != SDL_ENABLE)
return 0;
unsigned long int uni = event.key.keysym.unicode;
if( uni == 0 ) // not translatable key (like up or down arrows)
{
// probably not useful as string input
// we could optionally use this to get some value
// for it: SDL_GetKeyName( key );
return 0;
}
else if( ( uni & INTERNATIONAL_MASK ) == 0 )
{
return static_cast<char>(uni & UNICODE_MASK);
}
else // we have a funky international character. one we can't read :(
{
// we could do nothing, or we can just show some sign of input, like so:
return 0;
}*/
return 0;
}