Merge branch 'Input' of https://github.com/dean11/Danbias into Input

This commit is contained in:
Dennis Andersen 2014-02-20 20:07:21 +01:00
commit a987c2e618
12 changed files with 167 additions and 32 deletions

View File

@ -5,17 +5,30 @@
#define INPUT_APPLICATION_KEBOARD_H #define INPUT_APPLICATION_KEBOARD_H
#include "InputObject.h" #include "InputObject.h"
#include <vector> #include <string>
namespace Input namespace Input
{ {
class AplicationKeyboard : public InputObject class ApplicationKeyboard : public InputObject
{ {
public: public:
bool IsActive() const;
void Activate();
void Deactivate();
void BindTextTarget( ::std::wstring *field );
void ReleaseTextTarget();
protected: protected:
AplicationKeyboard(); ::std::wstring *textTarget;
~AplicationKeyboard(); ::std::wstring::size_type writePos;
ApplicationKeyboard();
~ApplicationKeyboard();
private:
bool active;
}; };
} }

View File

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

View File

@ -68,10 +68,12 @@ namespace Input
public: public:
virtual bool IsBtnUp(Enum::SAMI key) = 0; virtual bool IsBtnUp(Enum::SAMI key) = 0;
virtual bool IsBtnDown(Enum::SAMI key) = 0; virtual bool IsBtnDown(Enum::SAMI key) = 0;
virtual int GetWheelDelta() = 0;
virtual Struct::SAIPoint2D GetPixelPosition(Struct::SAIPoint2D targetMem = Struct::SAIPoint2D()) = 0;
public: public:
int GetWheelDelta() const;
Struct::SAIPoint2D & GetPixelPosition( Struct::SAIPoint2D &targetMem = Struct::SAIPoint2D() ) const;
Struct::SAIPoint2D & GetDeltaPosition( Struct::SAIPoint2D &targetMem = Struct::SAIPoint2D() ) const;
void AddOnMousePressCallback( Typedefs::OnMousePressCallback func); void AddOnMousePressCallback( Typedefs::OnMousePressCallback func);
void AddOnMouseDownCallback( Typedefs::OnMouseDownCallback func ); void AddOnMouseDownCallback( Typedefs::OnMouseDownCallback func );
void AddOnMouseReleaseCallback( Typedefs::OnMouseReleaseCallback func ); void AddOnMouseReleaseCallback( Typedefs::OnMouseReleaseCallback func );
@ -135,7 +137,7 @@ namespace Input
protected: protected:
std::vector<MouseEvent*> mouseSubscribers; std::vector<MouseEvent*> mouseSubscribers;
MouseCallbackList* callbackList; MouseCallbackList* callbackList;
Struct::SAIPoint2D pixelPos; Struct::SAIPoint2D pixelPos, deltaPos;
bool isCurorLocked; bool isCurorLocked;
int wheelDelta; int wheelDelta;
}; };

View File

@ -4,20 +4,19 @@
#ifndef INPUT_WIN32_APPLICATION_KEBOARD_H #ifndef INPUT_WIN32_APPLICATION_KEBOARD_H
#define INPUT_WIN32_APPLICATION_KEBOARD_H #define INPUT_WIN32_APPLICATION_KEBOARD_H
#define NOMINMAX
#include <Windows.h>
#include "..\ApplicationKeyboard.h" #include "..\ApplicationKeyboard.h"
//#include <Windows.h>
namespace Input namespace Input
{ {
class Win32ApplicationKeyboard :public AplicationKeyboard class Win32ApplicationKeyboard : public ApplicationKeyboard
{ {
public: public:
Win32ApplicationKeyboard(); Win32ApplicationKeyboard();
~Win32ApplicationKeyboard(); ~Win32ApplicationKeyboard();
void CaptureText( UINT msg, WPARAM param );
private:
}; };
} }

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>
#include <Windows.h> #include <Windows.h>
#include <map> #include <map>

View File

@ -17,8 +17,6 @@ namespace Input
bool IsBtnUp(Enum::SAMI key) override; bool IsBtnUp(Enum::SAMI key) override;
bool IsBtnDown(Enum::SAMI key) override; bool IsBtnDown(Enum::SAMI key) override;
int GetWheelDelta() override;
Struct::SAIPoint2D GetPixelPosition(Struct::SAIPoint2D targetMem = Struct::SAIPoint2D()) override;
void ProccessMouseData (bool isDown, Enum::SAMI btn, int delta, Struct::SAIPoint2D velocity, unsigned int makeCode); void ProccessMouseData (bool isDown, Enum::SAMI btn, int delta, Struct::SAIPoint2D velocity, unsigned int makeCode);

View File

@ -20,9 +20,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="L_inputClass.cpp" /> <ClCompile Include="L_inputClass.cpp" />
<ClCompile Include="Source\ApplicationKeyboard.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" />
<ClCompile Include="Source\Win32\Win32ApplicationKeyboard.cpp" />
<ClCompile Include="Source\Win32\Win32Input.cpp" /> <ClCompile Include="Source\Win32\Win32Input.cpp" />
<ClCompile Include="Source\Win32\Win32Keyboard.cpp" /> <ClCompile Include="Source\Win32\Win32Keyboard.cpp" />
<ClCompile Include="Source\Win32\Win32Mouse.cpp" /> <ClCompile Include="Source\Win32\Win32Mouse.cpp" />
@ -42,6 +44,11 @@
<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="..\Utilities\Utilities.vcxproj">
<Project>{2ec4dded-8f75-4c86-a10b-e1e8eb29f3ee}</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>
@ -93,28 +100,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>
@ -125,7 +136,7 @@
<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>
@ -138,7 +149,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<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>
@ -153,7 +164,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<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

@ -81,6 +81,7 @@ Mouse::Mouse()
, wheelDelta(0) , wheelDelta(0)
, isCurorLocked(0) , isCurorLocked(0)
, pixelPos() , pixelPos()
, deltaPos()
{ {
} }
Mouse::~Mouse() Mouse::~Mouse()
@ -88,6 +89,25 @@ Mouse::~Mouse()
} }
int Mouse::GetWheelDelta() const
{
return this->wheelDelta;
}
SAIPoint2D & Mouse::GetPixelPosition( Struct::SAIPoint2D &targetMem ) const
{
targetMem.x = this->pixelPos.x;
targetMem.y = this->pixelPos.y;
return targetMem;
}
SAIPoint2D & Mouse::GetDeltaPosition( Struct::SAIPoint2D &targetMem ) const
{
targetMem.x = this->deltaPos.x;
targetMem.y = this->deltaPos.y;
return targetMem;
}
void Mouse::AddOnMousePressCallback( Typedefs::OnMousePressCallback func) void Mouse::AddOnMousePressCallback( Typedefs::OnMousePressCallback func)
{ {
MouseCallbackList::CallbackData d; MouseCallbackList::CallbackData d;

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

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

View File

@ -30,22 +30,13 @@ bool Win32Mouse::IsBtnDown(Enum::SAMI btn)
return this->buttons[btn].isDown; return this->buttons[btn].isDown;
} }
int Win32Mouse::GetWheelDelta()
{
return this->wheelDelta;
}
Struct::SAIPoint2D Win32Mouse::GetPixelPosition(Struct::SAIPoint2D targetMem)
{
targetMem = this->pixelPos;
return targetMem;
}
void Win32Mouse::ProccessMouseData (bool isUp, Enum::SAMI btn, int delta, Struct::SAIPoint2D velocity, unsigned int makeCode) void Win32Mouse::ProccessMouseData (bool isUp, Enum::SAMI btn, int delta, Struct::SAIPoint2D velocity, unsigned int makeCode)
{ {
if(velocity.Length() != 0) if(velocity.Length() != 0)
{ {
this->pixelPos.x += velocity.x; this->pixelPos.x += this->deltaPos.x = velocity.x;
this->pixelPos.y += velocity.y; this->pixelPos.y += this->deltaPos.y = velocity.y;
for (unsigned int i = 0; i < this->mouseSubscribers.size(); i++) for (unsigned int i = 0; i < this->mouseSubscribers.size(); i++)
{ {