Misc - Merged with Input

This commit is contained in:
dean11 2014-02-21 11:52:48 +01:00
commit c04ef3a425
9 changed files with 171 additions and 13 deletions

View File

@ -166,6 +166,7 @@ namespace DanBias
DanBiasGame::Result DanBiasGame::Update(float deltaTime) DanBiasGame::Result DanBiasGame::Update(float deltaTime)
{ {
{ // updating mouse input { // updating mouse input
// TODO: Is obosolete when Dennis's input system is wired in
POINT mousePos; POINT mousePos;
GetCursorPos( &mousePos ); GetCursorPos( &mousePos );

View File

@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dan Andersson] [2014]
/////////////////////////////////////////////////////////////////////
#ifndef INPUT_APPLICATION_KEBOARD_H
#define INPUT_APPLICATION_KEBOARD_H
#include "InputObject.h"
#include <string>
namespace Input
{
class ApplicationKeyboard : public InputObject
{
public:
bool IsActive() const;
void Activate();
void Deactivate();
void BindTextTarget( ::std::wstring *field );
void ReleaseTextTarget();
protected:
::std::wstring *textTarget;
::std::wstring::size_type writePos;
ApplicationKeyboard();
~ApplicationKeyboard();
private:
bool active;
};
}
#endif // !INPUT_KEBOARD_H

View File

@ -21,7 +21,7 @@ namespace Input
{ {
SAIType_Keyboard, SAIType_Keyboard,
SAIType_Mouse, SAIType_Mouse,
SAIType_ApplicationKeyboard, //SAIType_ApplicationKeyboard,
SAIType_futureExample1, SAIType_futureExample1,
SAIType_futureExample2, SAIType_futureExample2,
SAIType_futureExample3, SAIType_futureExample3,

View File

@ -0,0 +1,23 @@
/////////////////////////////////////////////////////////////////////
// Created by [Dan Andersson] [2014]
/////////////////////////////////////////////////////////////////////
#ifndef INPUT_WIN32_APPLICATION_KEBOARD_H
#define INPUT_WIN32_APPLICATION_KEBOARD_H
#define NOMINMAX
#include <Windows.h>
#include "..\ApplicationKeyboard.h"
namespace Input
{
class Win32ApplicationKeyboard : public ApplicationKeyboard
{
public:
Win32ApplicationKeyboard();
~Win32ApplicationKeyboard();
void CaptureText( UINT msg, WPARAM param );
};
}
#endif // !INPUT_WIN32_APPLICATION_KEBOARD_H

View File

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

View File

@ -20,7 +20,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="L_inputClass.cpp" /> <ClCompile Include="L_inputClass.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="Source\InputManager.cpp" /> <ClCompile Include="Source\InputManager.cpp" />
<ClCompile Include="Source\Keyboard.cpp" /> <ClCompile Include="Source\Keyboard.cpp" />
<ClCompile Include="Source\Mouse.cpp" /> <ClCompile Include="Source\Mouse.cpp" />
@ -36,41 +35,37 @@
<ClInclude Include="Include\Keyboard.h" /> <ClInclude Include="Include\Keyboard.h" />
<ClInclude Include="Include\Mouse.h" /> <ClInclude Include="Include\Mouse.h" />
<ClInclude Include="Include\PreReq.h" /> <ClInclude Include="Include\PreReq.h" />
<ClInclude Include="Include\Win32\Win32Input.h" />
<ClInclude Include="Include\Win32\Win32Keyboard.h" /> <ClInclude Include="Include\Win32\Win32Keyboard.h" />
<ClInclude Include="Include\Win32\Win32Mouse.h" /> <ClInclude Include="Include\Win32\Win32Mouse.h" />
<ClInclude Include="L_inputClass.h" /> <ClInclude Include="L_inputClass.h" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WindowManager\WindowManager.vcxproj">
<Project>{35aea3c0-e0a7-4e1e-88cd-514aa5a442b1}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}</ProjectGuid> <ProjectGuid>{7E3990D2-3D94-465C-B58D-64A74B3ECF9B}</ProjectGuid>
<RootNamespace>Input</RootNamespace> <RootNamespace>Input</RootNamespace>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset> <PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset> <PlatformToolset>v110</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset> <PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset> <PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
@ -96,28 +91,32 @@
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)D</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir> <OutDir>$(SolutionDir)..\External\Lib\$(ProjectName)\</OutDir>
<IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir> <IntDir>$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\</IntDir>
<TargetName>$(ProjectName)_$(PlatformShortName)</TargetName> <TargetName>$(ProjectName)_$(PlatformShortName)</TargetName>
<IncludePath>$(IncludePath)</IncludePath>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(SolutionDir)Misc\Utilities;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>

View File

@ -0,0 +1,44 @@
#include "../Include/ApplicationKeyboard.h"
using namespace ::Input;
ApplicationKeyboard::ApplicationKeyboard() :
InputObject( Enum::SAIType_ApplicationKeyboard )
{
this->textTarget = nullptr;
this->writePos = 0;
this->isEnabled = true;
}
ApplicationKeyboard::~ApplicationKeyboard()
{ /* DO nothing */ }
bool ApplicationKeyboard::IsActive() const
{
return this->isEnabled;
}
void ApplicationKeyboard::Activate()
{
this->isEnabled = true;
}
void ApplicationKeyboard::Deactivate()
{
this->isEnabled = false;
}
void ApplicationKeyboard::BindTextTarget( ::std::wstring *field )
{
this->textTarget = field;
if( field )
{
this->writePos = field->size();
}
}
void ApplicationKeyboard::ReleaseTextTarget( )
{
this->BindTextTarget( nullptr );
}

View File

@ -0,0 +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 */ }
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

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