Win32ApplicationKeyboard fully implemented

ApplicationKeyboard, Win32ApplicationKeyboard & implemented into the
CreateDevice function
This commit is contained in:
Dander7BD 2014-02-20 14:39:12 +01:00
parent 2c8b52e0fa
commit 8993241408
7 changed files with 83 additions and 28 deletions

View File

@ -17,10 +17,12 @@ namespace Input
void Activate();
void Deactivate();
void SetTargetText( ::std::wstring *field );
void BindTextTarget( ::std::wstring *field );
void ReleaseTextTarget();
protected:
::std::wstring *targetText;
::std::wstring *textTarget;
::std::wstring::size_type writePos;
ApplicationKeyboard();
~ApplicationKeyboard();

View File

@ -16,10 +16,7 @@ namespace Input
Win32ApplicationKeyboard();
~Win32ApplicationKeyboard();
LRESULT CALLBACK WindowCallback( HWND h, UINT m, WPARAM w, LPARAM l );
private:
void CaptureText( UINT msg, WPARAM param );
};
}

View File

@ -8,6 +8,7 @@
#include "..\InputManager.h"
#include "Win32Keyboard.h"
#include "Win32Mouse.h"
#include "Win32ApplicationKeyboard.h"
#include <vector>
#include <Windows.h>
#include <map>

View File

@ -44,6 +44,11 @@
<ClInclude Include="Include\Win32\Win32Mouse.h" />
<ClInclude Include="L_inputClass.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Utilities\Utilities.vcxproj">
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}</ProjectGuid>
<RootNamespace>Input</RootNamespace>
@ -95,28 +100,32 @@
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -127,7 +136,7 @@
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -140,7 +149,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -155,7 +164,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -5,7 +5,8 @@ using namespace ::Input;
ApplicationKeyboard::ApplicationKeyboard() :
InputObject( Enum::SAIType_ApplicationKeyboard )
{
this->targetText = nullptr;
this->textTarget = nullptr;
this->writePos = 0;
this->isEnabled = true;
}
@ -27,7 +28,17 @@ void ApplicationKeyboard::Deactivate()
this->isEnabled = false;
}
void ApplicationKeyboard::SetTargetText( ::std::wstring *field )
void ApplicationKeyboard::BindTextTarget( ::std::wstring *field )
{
this->targetText = field;
this->textTarget = field;
if( field )
{
this->writePos = field->size();
}
}
void ApplicationKeyboard::ReleaseTextTarget( )
{
this->BindTextTarget( nullptr );
}

View File

@ -1,20 +1,51 @@
#include "../../Include/Win32/Win32ApplicationKeyboard.h"
#include "Utilities.h"
using namespace ::Input;
using namespace ::Utility::Value;
using ::std::wstring;
Win32ApplicationKeyboard::Win32ApplicationKeyboard() : ApplicationKeyboard() { /* DO nothing */ }
//{
// class Win32ApplicationKeyboard : public ApplicationKeyboard
// {
// public:
// Win32ApplicationKeyboard();
// ~Win32ApplicationKeyboard();
//
// LRESULT CALLBACK WindowCallback( HWND h, UINT m, WPARAM w, LPARAM l );
//
// private:
//
// };
//}
//
//#endif // !INPUT_WIN32_APPLICATION_KEBOARD_H
Win32ApplicationKeyboard::~Win32ApplicationKeyboard() { /* DO nothing */ }
void Win32ApplicationKeyboard::CaptureText( UINT msg, WPARAM param )
{
if( !this->textTarget | !this->isEnabled )
return;
switch( msg )
{
case WM_CHAR:
this->textTarget->insert( this->writePos, 1, (wchar_t)param );
++this->writePos;
break;
case WM_KEYDOWN:
{
switch( param )
{
case VK_BACK:
if( this->writePos > 0 )
{
--this->writePos;
this->textTarget->erase( this->writePos, 1 );
}
break;
case VK_DELETE:
if( this->writePos < this->textTarget->size() )
{
this->textTarget->erase( this->writePos, 1 );
}
break;
case VK_LEFT:
this->writePos = Max( this->writePos - 1, (wstring::size_type)0 );
break;
case VK_RIGHT:
this->writePos = Min( this->writePos + 1, this->textTarget->size() );
break;
default: break;
}
}
default: break;
}
}

View File

@ -775,6 +775,10 @@ InputObject* Win32Input::CreateDevice(const SAIType inputType, Typedefs::WindowH
}
}
break;
case SAIType_ApplicationKeyboard:
val = new Win32ApplicationKeyboard();
break;
}
return val;