mirror of
https://github.com/Bloodysharp/Cheat-ImGui-Menu-Design.git
synced 2024-12-22 16:07:23 +08:00
Добавьте файлы проекта.
This commit is contained in:
parent
2401e4c4c5
commit
c14ce7bbd4
9
README.txt
Normal file
9
README.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
See BACKENDS and EXAMPLES files in the docs/ folder, or on the web at: https://github.com/ocornut/imgui/tree/master/docs
|
||||||
|
|
||||||
|
Backends = Helper code to facilitate integration with platforms/graphics api (used by Examples + should be used by your app).
|
||||||
|
Examples = Standalone applications showcasing integration with platforms/graphics api.
|
||||||
|
|
||||||
|
Some Examples have extra README files in their respective directory, please check them too!
|
||||||
|
|
||||||
|
Once Dear ImGui is running (in either examples or your own application/game/engine),
|
||||||
|
run and refer to ImGui::ShowDemoWindow() in imgui_demo.cpp for the end-user API.
|
9
example_win32_directx11/build_win32.bat
Normal file
9
example_win32_directx11/build_win32.bat
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler.
|
||||||
|
@set OUT_DIR=Debug
|
||||||
|
@set OUT_EXE=example_win32_directx11
|
||||||
|
@set INCLUDES=/I..\.. /I..\..\backends /I "%WindowsSdkDir%Include\um" /I "%WindowsSdkDir%Include\shared" /I "%DXSDK_DIR%Include"
|
||||||
|
@set SOURCES=main.cpp ..\..\backends\imgui_impl_dx11.cpp ..\..\backends\imgui_impl_win32.cpp ..\..\imgui*.cpp
|
||||||
|
@set LIBS=/LIBPATH:"%DXSDK_DIR%/Lib/x86" d3d11.lib d3dcompiler.lib
|
||||||
|
mkdir %OUT_DIR%
|
||||||
|
cl /nologo /Zi /MD /utf-8 %INCLUDES% /D UNICODE /D _UNICODE %SOURCES% /Fe%OUT_DIR%/%OUT_EXE%.exe /Fo%OUT_DIR%/ /link %LIBS%
|
||||||
|
|
190
example_win32_directx11/example_win32_directx11.vcxproj
Normal file
190
example_win32_directx11/example_win32_directx11.vcxproj
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{9F316E83-5AE5-4939-A723-305A94F48005}</ProjectGuid>
|
||||||
|
<RootNamespace>menu_win32_directx11</RootNamespace>
|
||||||
|
<WindowsTargetPlatformVersion>10.0.22621.0</WindowsTargetPlatformVersion>
|
||||||
|
<ProjectName>menu_win32_directx11</ProjectName>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>true</UseDebugLibraries>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v143</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||||
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
|
<PlatformToolset>v142</PlatformToolset>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
|
<ImportGroup Label="ExtensionSettings">
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<PropertyGroup Label="UserMacros" />
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
<ExecutablePath>C:\Users\racco\Desktop\imgui aternos\SDK\Lib;C:\Users\racco\Desktop\freetype\win64;C:\Users\racco\Desktop\freetype\include;C:\Users\racco\Desktop\imgui aternos\SDK\Include;$(ExecutablePath)</ExecutablePath>
|
||||||
|
<LibraryPath>C:\Users\racco\Desktop\imgui aternos\SDK\Include;C:\Users\racco\Desktop\freetype\win64;C:\Users\racco\Desktop\freetype\include;C:\Users\racco\Desktop\imgui aternos\SDK\Lib;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<OutDir>$(ProjectDir)$(Configuration)\</OutDir>
|
||||||
|
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||||
|
<IncludePath>C:\Users\Lycrus\Desktop\imgui aternos\SDK\Include;C:\Users\Lycrus\Desktop\imgui aternos\freetype\include;$(IncludePath)</IncludePath>
|
||||||
|
<LibraryPath>C:\Users\Lycrus\Desktop\imgui aternos\SDK\Lib\x64;C:\Users\Lycrus\Desktop\imgui aternos\freetype\win64;$(LibraryPath)</LibraryPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>Disabled</Optimization>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<ClCompile>
|
||||||
|
<WarningLevel>Level4</WarningLevel>
|
||||||
|
<Optimization>MaxSpeed</Optimization>
|
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
|
<AdditionalIncludeDirectories>..\..;..\..\backends;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
|
||||||
|
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||||
|
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
|
||||||
|
<LanguageStandard>stdcpp20</LanguageStandard>
|
||||||
|
</ClCompile>
|
||||||
|
<Link>
|
||||||
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
|
<AdditionalDependencies>d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
|
<AdditionalLibraryDirectories>$(DXSDK_DIR)/Lib/x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||||
|
<SubSystem>Console</SubSystem>
|
||||||
|
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||||
|
</Link>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\imconfig.h" />
|
||||||
|
<ClInclude Include="..\..\imgui.h" />
|
||||||
|
<ClInclude Include="..\..\imgui_edited.hpp" />
|
||||||
|
<ClInclude Include="..\..\imgui_internal.h" />
|
||||||
|
<ClInclude Include="..\..\backends\imgui_impl_dx11.h" />
|
||||||
|
<ClInclude Include="..\..\backends\imgui_impl_win32.h" />
|
||||||
|
<ClInclude Include="..\..\imgui_settings.h" />
|
||||||
|
<ClInclude Include="font.h" />
|
||||||
|
<ClInclude Include="texture.h" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\imgui.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_draw.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_edited.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_tables.cpp" />
|
||||||
|
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
||||||
|
<ClCompile Include="..\..\backends\imgui_impl_dx11.cpp" />
|
||||||
|
<ClCompile Include="..\..\backends\imgui_impl_win32.cpp" />
|
||||||
|
<ClCompile Include="main.cpp" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\..\misc\debuggers\imgui.natstepfilter" />
|
||||||
|
<None Include="..\..\misc\debuggers\imgui.natvis" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Library Include="..\..\freetype\win64\freetype.lib" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
<ImportGroup Label="ExtensionTargets">
|
||||||
|
</ImportGroup>
|
||||||
|
</Project>
|
@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ItemGroup>
|
||||||
|
<Filter Include="imgui">
|
||||||
|
<UniqueIdentifier>{0587d7a3-f2ce-4d56-b84f-a0005d3bfce6}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="sources">
|
||||||
|
<UniqueIdentifier>{08e36723-ce4f-4cff-9662-c40801cf1acf}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
<Filter Include="imgui\edited_elements">
|
||||||
|
<UniqueIdentifier>{aedf718d-cec7-4f6e-9aca-07394bb16e22}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\imconfig.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\imgui.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\imgui_internal.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\backends\imgui_impl_win32.h">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\backends\imgui_impl_dx11.h">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\imgui_settings.h">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="font.h">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="texture.h">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\imgui_edited.hpp">
|
||||||
|
<Filter>imgui\edited_elements</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\imgui.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="main.cpp">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_draw.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_widgets.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\backends\imgui_impl_win32.cpp">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\backends\imgui_impl_dx11.cpp">
|
||||||
|
<Filter>sources</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_tables.cpp">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\imgui_edited.cpp">
|
||||||
|
<Filter>imgui\edited_elements</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="..\..\misc\debuggers\imgui.natvis">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="..\..\misc\debuggers\imgui.natstepfilter">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Library Include="..\..\freetype\win64\freetype.lib">
|
||||||
|
<Filter>imgui</Filter>
|
||||||
|
</Library>
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
10172
example_win32_directx11/font.h
Normal file
10172
example_win32_directx11/font.h
Normal file
File diff suppressed because it is too large
Load Diff
144
example_win32_directx11/imgui.ini
Normal file
144
example_win32_directx11/imgui.ini
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
[Window][Debug##Default]
|
||||||
|
Pos=60,60
|
||||||
|
Size=400,400
|
||||||
|
|
||||||
|
[Window][IMGUI!]
|
||||||
|
Pos=323,541
|
||||||
|
Size=700,500
|
||||||
|
|
||||||
|
[Window][picker]
|
||||||
|
Pos=744,374
|
||||||
|
Size=259,285
|
||||||
|
|
||||||
|
[Window][info-bar]
|
||||||
|
Pos=1448,15
|
||||||
|
Size=457,45
|
||||||
|
|
||||||
|
[Window][ESP PREVIEW]
|
||||||
|
Pos=1100,253
|
||||||
|
Size=350,450
|
||||||
|
|
||||||
|
[Window][##Notification]
|
||||||
|
Pos=60,60
|
||||||
|
Size=190,18
|
||||||
|
|
||||||
|
[Window][##NOTIFY]
|
||||||
|
Pos=15,15
|
||||||
|
Size=322,102
|
||||||
|
|
||||||
|
[Window][##NOTIFY0]
|
||||||
|
Pos=15,15
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY1]
|
||||||
|
Pos=15,105
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY2]
|
||||||
|
Pos=15,195
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY3]
|
||||||
|
Pos=15,285
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY4]
|
||||||
|
Pos=15,375
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY5]
|
||||||
|
Pos=15,465
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY6]
|
||||||
|
Pos=1,555
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY7]
|
||||||
|
Pos=15,645
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY8]
|
||||||
|
Pos=15,735
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY9]
|
||||||
|
Pos=15,825
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY10]
|
||||||
|
Pos=15,915
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY11]
|
||||||
|
Pos=15,1005
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY12]
|
||||||
|
Pos=15,1095
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY13]
|
||||||
|
Pos=15,1185
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY14]
|
||||||
|
Pos=15,1275
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY15]
|
||||||
|
Pos=32,1365
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY16]
|
||||||
|
Pos=15,1455
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY17]
|
||||||
|
Pos=15,1545
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY18]
|
||||||
|
Pos=15,1635
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY19]
|
||||||
|
Pos=15,1725
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY20]
|
||||||
|
Pos=15,1815
|
||||||
|
Size=396,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY21]
|
||||||
|
Pos=15,1905
|
||||||
|
Size=362,79
|
||||||
|
|
||||||
|
[Window][##NOTIFY22]
|
||||||
|
Pos=15,1335
|
||||||
|
Size=291,49
|
||||||
|
|
||||||
|
[Window][##NOTIFY23]
|
||||||
|
Pos=15,1395
|
||||||
|
Size=291,49
|
||||||
|
|
||||||
|
[Window][##NOTIFY24]
|
||||||
|
Pos=15,1455
|
||||||
|
Size=291,49
|
||||||
|
|
||||||
|
[Window][##NOTIFY25]
|
||||||
|
Pos=15,1515
|
||||||
|
Size=291,49
|
||||||
|
|
||||||
|
[Window][##NOTIFY26]
|
||||||
|
Pos=15,1575
|
||||||
|
Size=291,49
|
||||||
|
|
||||||
|
[Window][Draggable Text]
|
||||||
|
Pos=381,429
|
||||||
|
Size=69,18
|
||||||
|
|
||||||
|
[Window][Dear ImGui]
|
||||||
|
Pos=139,222
|
||||||
|
Size=780,500
|
||||||
|
|
767
example_win32_directx11/main.cpp
Normal file
767
example_win32_directx11/main.cpp
Normal file
@ -0,0 +1,767 @@
|
|||||||
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
||||||
|
|
||||||
|
#include "imgui_impl_win32.h"
|
||||||
|
#include "imgui_impl_dx11.h"
|
||||||
|
|
||||||
|
#include "imgui_edited.hpp"
|
||||||
|
|
||||||
|
#include "imgui_freetype.h"
|
||||||
|
#include <d3d11.h>
|
||||||
|
#include <tchar.h>
|
||||||
|
|
||||||
|
#include "font.h"
|
||||||
|
#include "texture.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
#include <chrono>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
#include <SDK/Include/D3DX11tex.h>
|
||||||
|
#pragma comment(lib, "D3DX11.lib")
|
||||||
|
|
||||||
|
#pragma comment(lib, "d3d11.lib")
|
||||||
|
#pragma comment(lib, "D3DCompiler.lib")
|
||||||
|
|
||||||
|
static ID3D11Device* g_pd3dDevice = nullptr;
|
||||||
|
static ID3D11DeviceContext* g_pd3dDeviceContext = nullptr;
|
||||||
|
static IDXGISwapChain* g_pSwapChain = nullptr;
|
||||||
|
static UINT g_ResizeWidth = 0, g_ResizeHeight = 0;
|
||||||
|
static ID3D11RenderTargetView* g_mainRenderTargetView = nullptr;
|
||||||
|
|
||||||
|
bool CreateDeviceD3D(HWND hWnd);
|
||||||
|
void CleanupDeviceD3D();
|
||||||
|
void CreateRenderTarget();
|
||||||
|
void CleanupRenderTarget();
|
||||||
|
|
||||||
|
namespace texture
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* logo = nullptr;
|
||||||
|
ID3D11ShaderResourceView* foto = nullptr;
|
||||||
|
ID3D11ShaderResourceView* esp_preview = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool enable_preview = true;
|
||||||
|
int page;
|
||||||
|
int page_s;
|
||||||
|
|
||||||
|
DWORD picker_flags = ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreview;
|
||||||
|
|
||||||
|
namespace io
|
||||||
|
{
|
||||||
|
void CricleProgress(const char* name, float progress, float max, float radius, const ImVec2& size)
|
||||||
|
{
|
||||||
|
const float tickness = 3.f;
|
||||||
|
static float position = 0.f;
|
||||||
|
|
||||||
|
position = progress / max * 6.28f;
|
||||||
|
|
||||||
|
ImGui::GetForegroundDrawList()->PathClear();
|
||||||
|
ImGui::GetForegroundDrawList()->PathArcTo(ImGui::GetCursorScreenPos() + size, radius, 0.f, 2.f * IM_PI, 120.f);
|
||||||
|
ImGui::GetForegroundDrawList()->PathStroke(ImGui::GetColorU32(c::elements::background_widget), 0, tickness);
|
||||||
|
|
||||||
|
ImGui::GetForegroundDrawList()->PathClear();
|
||||||
|
ImGui::GetForegroundDrawList()->PathArcTo(ImGui::GetCursorScreenPos() + size, radius, IM_PI * 1.5f, IM_PI * 1.5f + position, 120.f);
|
||||||
|
ImGui::GetForegroundDrawList()->PathStroke(ImGui::GetColorU32(c::accent), 0, tickness);
|
||||||
|
|
||||||
|
int procent = progress / (int)max * 100;
|
||||||
|
|
||||||
|
std::string procent_str = std::to_string(procent) + "%";
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Notification
|
||||||
|
{
|
||||||
|
int id;
|
||||||
|
std::string message;
|
||||||
|
std::chrono::steady_clock::time_point startTime;
|
||||||
|
std::chrono::steady_clock::time_point endTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
class NotificationSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NotificationSystem() : notificationIdCounter(0) {}
|
||||||
|
|
||||||
|
void AddNotification(const std::string& message, int durationMs)
|
||||||
|
{
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
auto endTime = now + std::chrono::milliseconds(durationMs);
|
||||||
|
notifications.push_back({ notificationIdCounter++, message, now, endTime });
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawNotifications() {
|
||||||
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
|
std::sort(notifications.begin(), notifications.end(),
|
||||||
|
[now](const Notification& a, const Notification& b) -> bool
|
||||||
|
{
|
||||||
|
float durationA = std::chrono::duration_cast<std::chrono::milliseconds>(a.endTime - a.startTime).count();
|
||||||
|
float elapsedA = std::chrono::duration_cast<std::chrono::milliseconds>(now - a.startTime).count();
|
||||||
|
float percentageA = (durationA - elapsedA) / durationA;
|
||||||
|
|
||||||
|
float durationB = std::chrono::duration_cast<std::chrono::milliseconds>(b.endTime - b.startTime).count();
|
||||||
|
float elapsedB = std::chrono::duration_cast<std::chrono::milliseconds>(now - b.startTime).count();
|
||||||
|
float percentageB = (durationB - elapsedB) / durationB;
|
||||||
|
|
||||||
|
return percentageA < percentageB;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
int currentNotificationPosition = 0;
|
||||||
|
|
||||||
|
for (auto& notification : notifications)
|
||||||
|
{
|
||||||
|
if (now < notification.endTime)
|
||||||
|
{
|
||||||
|
float duration = std::chrono::duration_cast<std::chrono::milliseconds>(notification.endTime - notification.startTime).count();
|
||||||
|
float elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(now - notification.startTime).count();
|
||||||
|
float percentage = (duration - elapsed) / duration * 100.0f;
|
||||||
|
|
||||||
|
ShowNotification(currentNotificationPosition, notification.message, percentage);
|
||||||
|
currentNotificationPosition++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notifications.erase(std::remove_if(notifications.begin(), notifications.end(),
|
||||||
|
[now](const Notification& notification) { return now >= notification.endTime; }),
|
||||||
|
notifications.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<Notification> notifications;
|
||||||
|
int notificationIdCounter;
|
||||||
|
|
||||||
|
void ShowNotification(int position, const std::string& message, float percentage) {
|
||||||
|
|
||||||
|
float duePercentage = 100.0f - percentage;
|
||||||
|
float alpha = percentage > 10.0f ? 1.0f : percentage / 10.0f;
|
||||||
|
ImGui::GetStyle().WindowPadding = ImVec2(15, 10);
|
||||||
|
|
||||||
|
ImGui::SetNextWindowPos(ImVec2(duePercentage < 15.f ? duePercentage : 15.f, 15 + position * 90));
|
||||||
|
|
||||||
|
ImGui::Begin(("##NOTIFY" + std::to_string(position)).c_str(), nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
|
||||||
|
ImVec2 pos = ImGui::GetWindowPos(), spacing = ImGui::GetStyle().ItemSpacing, region = ImGui::GetContentRegionMax();
|
||||||
|
|
||||||
|
ImGui::GetBackgroundDrawList()->AddRectFilledMultiColor(pos, pos + region, ImGui::GetColorU32(c::background::filling, alpha), ImGui::GetColorU32(c::accent, 0.01f), ImGui::GetColorU32(c::accent, 0.01f), ImGui::GetColorU32(c::background::filling, alpha), c::elements::rounding);
|
||||||
|
ImGui::GetBackgroundDrawList()->AddRectFilled(pos, pos + region, ImGui::GetColorU32(c::background::filling, 0.4f), c::elements::rounding);
|
||||||
|
ImGui::GetBackgroundDrawList()->AddRect(pos, pos + region, ImGui::GetColorU32(c::background::stroke, alpha), c::elements::rounding);
|
||||||
|
|
||||||
|
if (c::other::notify_select == 0)
|
||||||
|
CricleProgress("##NOTIFY", percentage, 100, 7.f, ImVec2(ImGui::GetContentRegionMax().x - 40, 11));
|
||||||
|
if (c::other::notify_select == 1)
|
||||||
|
ImGui::GetBackgroundDrawList()->AddRectFilled(pos + ImVec2(0, region.y - 3), pos + ImVec2(region.x * (duePercentage / 100.0f), region.y), ImGui::GetColorU32(c::accent, alpha), c::elements::rounding);
|
||||||
|
|
||||||
|
ImGui::PushFont(font::lexend_bold);
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::accent, alpha)), "%s", "[Notification]");
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text_active, alpha)), "%s", message.c_str());
|
||||||
|
ImGui::Dummy(ImVec2(ImGui::CalcTextSize(message.c_str()).x + 15, 5));
|
||||||
|
ImGui::PopFont();
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
io::NotificationSystem notificationSystem;
|
||||||
|
|
||||||
|
namespace esp_preview
|
||||||
|
{
|
||||||
|
bool money = true;
|
||||||
|
bool nickname = true;
|
||||||
|
bool weapon = true;
|
||||||
|
bool zoom = true;
|
||||||
|
|
||||||
|
bool c4 = true;
|
||||||
|
bool HP_line = true;
|
||||||
|
bool hit = true;
|
||||||
|
bool box = true;
|
||||||
|
bool bomb = true;
|
||||||
|
|
||||||
|
static float box_color[4] = { 37 / 255.f, 37 / 255.f, 47 / 255.f, 1.f };
|
||||||
|
static float nick_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float money_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float zoom_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float c4_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float bomb_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float hp_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float hp_line_color[4] = { 112 / 255.f, 109 / 255.f, 214 / 255.f, 1.f };
|
||||||
|
static float weapon_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
static float hit_color[4] = { 255 / 255.f, 255 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
|
||||||
|
int hp = 85;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace render_ui
|
||||||
|
{
|
||||||
|
|
||||||
|
void Particles()
|
||||||
|
{
|
||||||
|
ImVec2 screen_size = { (float)GetSystemMetrics(SM_CXSCREEN), (float)GetSystemMetrics(SM_CYSCREEN) };
|
||||||
|
|
||||||
|
static ImVec2 partile_pos[100];
|
||||||
|
static ImVec2 partile_target_pos[100];
|
||||||
|
static float partile_speed[100];
|
||||||
|
static float partile_radius[100];
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 1; i < 50; i++)
|
||||||
|
{
|
||||||
|
if (partile_pos[i].x == 0 || partile_pos[i].y == 0)
|
||||||
|
{
|
||||||
|
partile_pos[i].x = rand() % (int)screen_size.x + 1;
|
||||||
|
partile_pos[i].y = 15.f;
|
||||||
|
partile_speed[i] = 1 + rand() % 25;
|
||||||
|
partile_radius[i] = rand() % 4;
|
||||||
|
|
||||||
|
partile_target_pos[i].x = rand() % (int)screen_size.x;
|
||||||
|
partile_target_pos[i].y = screen_size.y * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
partile_pos[i] = ImLerp(partile_pos[i], partile_target_pos[i], ImGui::GetIO().DeltaTime * (partile_speed[i] / 60));
|
||||||
|
|
||||||
|
if (partile_pos[i].y > screen_size.y)
|
||||||
|
{
|
||||||
|
partile_pos[i].x = 0;
|
||||||
|
partile_pos[i].y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::GetWindowDrawList()->AddCircleFilled(partile_pos[i], partile_radius[i], ImColor(114, 149, 255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_function()
|
||||||
|
{
|
||||||
|
static float color[4] = { 114 / 255.f, 149 / 255.f, 255 / 255.f, 1.f };
|
||||||
|
c::accent = { color[0], color[1], color[2], 1.f };
|
||||||
|
|
||||||
|
ImGui::Begin("Dear ImGui", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus);
|
||||||
|
{
|
||||||
|
ImGui::SetCursorPos(ImVec2(70, 120));
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, c::tab::tab_alpha);
|
||||||
|
{
|
||||||
|
if (c::tab::active_tab == 0)
|
||||||
|
{
|
||||||
|
edited::BeginChild("##Container0", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Weapons");
|
||||||
|
|
||||||
|
static int select = 0;
|
||||||
|
const char* items[3]{ "One", "Two", "Three" };
|
||||||
|
edited::Combo("Select Weapon", "Select a weapon to customize", &select, items, IM_ARRAYSIZE(items), 3);
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "General");
|
||||||
|
|
||||||
|
static bool enabled = true;
|
||||||
|
edited::Checkbox("Enabled", "Activate ragebot [AWP]", &enabled);
|
||||||
|
if (ImGui::IsItemClicked() && ImGui::IsItemHovered()) notificationSystem.AddNotification("You clicked on the check box, the notification is here!", 4000);
|
||||||
|
|
||||||
|
static bool pick = true;
|
||||||
|
edited::Checkbox("Peek Assist", "Returns you to the previous point after peek", &pick);
|
||||||
|
if (ImGui::IsItemClicked() && ImGui::IsItemHovered()) notificationSystem.AddNotification("I'm going to be a hell of a long time, no offense.", 10500);
|
||||||
|
|
||||||
|
static bool shots = true;
|
||||||
|
edited::Checkbox("Hide Shots", "Doesn't turn your head forward after a shot is fired", &shots);
|
||||||
|
|
||||||
|
static bool dtap = true;
|
||||||
|
edited::Checkbox("Double Tap", "Fires 2 rounds per round on some weapons", &dtap);
|
||||||
|
|
||||||
|
static int field = 90;
|
||||||
|
edited::SliderInt("Field of View", "The range of the ragebot", &field, -180, 180, "%d\xC2\xB0");
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Accuracy");
|
||||||
|
|
||||||
|
static bool scope = true;
|
||||||
|
edited::Checkbox("Auto Scope", "Automatically scope when a target is seen", &scope);
|
||||||
|
|
||||||
|
static bool stope = true;
|
||||||
|
edited::Checkbox("Auto Stope", "Automatically stops when a target is seen", &stope);
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
|
||||||
|
ImGui::SameLine(0, 0);
|
||||||
|
|
||||||
|
edited::BeginChild("##Container1", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Selection");
|
||||||
|
|
||||||
|
static bool multi_num[5] = { false, true, true, false, true };
|
||||||
|
const char* multi_items[5] = { "Head", "Chest", "Stromatch", "Body", "Legs" };
|
||||||
|
edited::MultiCombo("Hitboxes", "What body parts will the ragebot shoot at?", multi_num, multi_items, 5);
|
||||||
|
|
||||||
|
static bool multi_num1[5] = { true, true, false, false, false };
|
||||||
|
const char* multi_items1[5] = { "Head", "Chest", "Stromatch", "Body", "Legs" };
|
||||||
|
edited::MultiCombo("Multipoints", "Point of impact calculation in hitboxes", multi_num1, multi_items1, 5);
|
||||||
|
|
||||||
|
static float hit1, hit2;
|
||||||
|
edited::RangeSliderFloat("Hit Chance", "The chance of hitting the enemy", &hit1, &hit2, 0, 100, "%.1f, %.1f");
|
||||||
|
|
||||||
|
static float dmg1, dmg2;
|
||||||
|
edited::RangeSliderFloat("Min. Damage", "Minimum damage to enemy hit", &dmg1, &dmg2, 0, 100, "%.0fHP, %.0fHP");
|
||||||
|
|
||||||
|
static bool penetrate = true;
|
||||||
|
edited::Checkbox("Penetrate Walls", "Shoot through walls", &penetrate);
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Safety");
|
||||||
|
|
||||||
|
static int body_select = 0;
|
||||||
|
const char* body_items[3]{ "Default", "Prefer", "Force" };
|
||||||
|
edited::Combo("Body Aim", "Will shoot more often at the body", &body_select, body_items, IM_ARRAYSIZE(body_items), 3);
|
||||||
|
|
||||||
|
static int safe_select = 0;
|
||||||
|
const char* safe_items[3]{ "Default", "Prefer", "Force" };
|
||||||
|
edited::Combo("Safe Points", "Will only shoot at points the cheat is sure of.", &safe_select, safe_items, IM_ARRAYSIZE(safe_items), 3);
|
||||||
|
|
||||||
|
static int ensure_select = 0;
|
||||||
|
const char* ensure_items[3]{ "Default", "Prefer", "Force" };
|
||||||
|
edited::Combo("Ensure Hitbox Safety", "I don't know what the fuck that function is.", &ensure_select, ensure_items, IM_ARRAYSIZE(ensure_items), 3);
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Keybinds");
|
||||||
|
|
||||||
|
static int key = 0;
|
||||||
|
edited::Keybind("Aimbot Active", "Activate all parts of these parameters.", &key);
|
||||||
|
|
||||||
|
static int key1 = 0;
|
||||||
|
edited::Keybind("Penetrate Active", "Activates this function by holding or pressing a key.", &key1);
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
}
|
||||||
|
else if (c::tab::active_tab == 1)
|
||||||
|
{
|
||||||
|
edited::BeginChild("##Container0", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Select");
|
||||||
|
|
||||||
|
static int select = 0;
|
||||||
|
const char* items[1]{ "Enemy" };
|
||||||
|
edited::Combo("Type", "Select type", &select, items, IM_ARRAYSIZE(items), 1);
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "General");
|
||||||
|
|
||||||
|
static bool enable = true;
|
||||||
|
edited::Checkbox("Enabled", "Active visuals", &enable);
|
||||||
|
|
||||||
|
static int select1 = 0;
|
||||||
|
const char* items1[2]{ "Health", "Armor" };
|
||||||
|
edited::Combo("Select Weapon", "Select a weapon to customize", &select1, items1, IM_ARRAYSIZE(items1), 2);
|
||||||
|
|
||||||
|
static float health_color[4] = { 0.f, 0.f, 1.f, 0.5f };
|
||||||
|
edited::ColorEdit4("Health Color", "The color of the 'Health' element", health_color, picker_flags);
|
||||||
|
|
||||||
|
static float armor_color[4] = { 0.f, 0.f, 1.f, 0.5f };
|
||||||
|
edited::ColorEdit4("Armor Color", "The color of the ‘Armor’ element", armor_color, picker_flags);
|
||||||
|
|
||||||
|
static int line_ticknes = 50;
|
||||||
|
edited::SliderInt("Line Thickness", "The range of the ragebot", &line_ticknes, 0, 100, "%d%%");
|
||||||
|
|
||||||
|
static int x_pos0 = (1920 / 2), x_pos1 = (1080 / 2);
|
||||||
|
edited::QuandInt("Quand Integer", "ESP Preview exact position.", &x_pos0, &x_pos1, 0, 1920, 0, 1080);
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
|
||||||
|
ImGui::SameLine(0, 0);
|
||||||
|
|
||||||
|
edited::BeginChild("##Container1", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Chams");
|
||||||
|
|
||||||
|
static int select1 = 0;
|
||||||
|
const char* items1[2]{ "Visibility", "Invisibility" };
|
||||||
|
edited::Combo("Style", "Select a style to customize", &select1, items1, IM_ARRAYSIZE(items1), 2);
|
||||||
|
|
||||||
|
static bool enabled = true;
|
||||||
|
edited::Checkbox("Enabled", "Activate ‘Visibility’", &enabled);
|
||||||
|
|
||||||
|
static int select2 = 0;
|
||||||
|
const char* items2[2]{ "Flat", "Blyat" };
|
||||||
|
edited::Combo("Material", "Select material for ‘Visibility’", &select1, items2, IM_ARRAYSIZE(items2), 2);
|
||||||
|
|
||||||
|
static float color[4] = { 0.f, 0.f, 1.f, 0.5f };
|
||||||
|
edited::ColorEdit4("Color", "Color to material", color, picker_flags);
|
||||||
|
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Glow");
|
||||||
|
|
||||||
|
static bool enabled_glow = true;
|
||||||
|
edited::Checkbox("Enabled ", "Activate glow", &enabled_glow);
|
||||||
|
|
||||||
|
static float color_glow[4] = { 0.9f, 0.3f, 0.5f, 0.5f };
|
||||||
|
edited::ColorEdit4("Color ", "Select a color for the glow", color_glow, picker_flags);
|
||||||
|
|
||||||
|
static int ticknes = 50;
|
||||||
|
edited::SliderInt("Thickness", "Luminescence thickness", &ticknes, 0, 100, "%d%%");
|
||||||
|
|
||||||
|
static char text[65] = { "" };
|
||||||
|
ImGui::InputTextEx("v", "Enter your text here", text, 65, ImVec2(ImGui::GetContentRegionMax().x - 10, 40), NULL);
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
}
|
||||||
|
else if (c::tab::active_tab == 2)
|
||||||
|
{
|
||||||
|
edited::BeginChild("##Container0", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
ImGui::TextColored(ImColor(ImGui::GetColorU32(c::elements::text)), "Create");
|
||||||
|
|
||||||
|
static char name[65] = { "" };
|
||||||
|
ImGui::InputTextEx("v", "Config name", name, 65, ImVec2(ImGui::GetContentRegionMax().x - 10, 40), NULL);
|
||||||
|
|
||||||
|
static char desc[65] = { "" };
|
||||||
|
ImGui::InputTextEx("v", "Config description", desc, 65, ImVec2(ImGui::GetContentRegionMax().x - 10, 40), NULL);
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
|
||||||
|
ImGui::SameLine(0, 0);
|
||||||
|
edited::BeginChild("##Container1", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
}
|
||||||
|
else if (c::tab::active_tab == 5)
|
||||||
|
{
|
||||||
|
edited::BeginChild("##Container0", ImVec2(290, 320), NULL);
|
||||||
|
{
|
||||||
|
edited::ColorEdit4("Accented Color", "Setting the main color of the menu.", color, picker_flags);
|
||||||
|
edited::Checkbox("ESP Preview", "Activate ESP Preview for settings", &enable_preview);
|
||||||
|
}
|
||||||
|
edited::EndChild();
|
||||||
|
}
|
||||||
|
ImGui::PopStyleVar();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
|
||||||
|
if (enable_preview)
|
||||||
|
{
|
||||||
|
ImGui::SetNextWindowSize(ImVec2(350, 450));
|
||||||
|
ImGui::Begin("ESP PREVIEW", nullptr, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration);
|
||||||
|
{
|
||||||
|
Particles();
|
||||||
|
|
||||||
|
const ImVec2& pos = ImGui::GetWindowPos(), spacing = ImVec2(10,10), region = ImGui::GetContentRegionMax();
|
||||||
|
|
||||||
|
ImGui::GetBackgroundDrawList()->AddRectFilled(pos, pos + region, ImColor(15, 17, 16), 10);
|
||||||
|
ImGui::GetBackgroundDrawList()->AddRect(pos, pos + region, ImColor(32, 35, 34), 10, NULL, 1.5);
|
||||||
|
|
||||||
|
ImGui::GetWindowDrawList()->AddText(pos + ImVec2(15, 15), ImGui::GetColorU32(c::elements::text_active), "ESP PREVIEW");
|
||||||
|
|
||||||
|
ImGui::SetCursorPosY(55);
|
||||||
|
edited::esp_preview(texture::esp_preview, &esp_preview::hp, esp_preview::hp_color, &esp_preview::box, esp_preview::box_color, &esp_preview::HP_line, esp_preview::hp_line_color);
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(20, 415));
|
||||||
|
ImGui::BeginGroup();
|
||||||
|
{
|
||||||
|
edited::checkboxP("HP", &esp_preview::HP_line, ImVec2(ImGui::CalcTextSize("HP").x + 5, 23));
|
||||||
|
ImGui::SameLine();
|
||||||
|
edited::checkboxP("Box", &esp_preview::box, ImVec2(ImGui::CalcTextSize("Box").x + 5, 23));
|
||||||
|
}
|
||||||
|
ImGui::EndGroup();
|
||||||
|
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderTab()
|
||||||
|
{
|
||||||
|
ImGui::SetCursorPos(ImVec2(17, 85));
|
||||||
|
ImGui::BeginGroup();
|
||||||
|
{
|
||||||
|
std::vector<std::vector<std::string>> tab_columns =
|
||||||
|
{
|
||||||
|
{ "c", "b", "f", "o"}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < tab_columns[0].size(); ++i)
|
||||||
|
{
|
||||||
|
if (edited::Tab(page == i, tab_columns[0][i].c_str(), ImVec2(35, 35)))
|
||||||
|
{
|
||||||
|
page = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(17, 340));
|
||||||
|
if (edited::Tab(page == 5, "e", ImVec2(35, 35)))
|
||||||
|
{
|
||||||
|
page = 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndGroup();
|
||||||
|
|
||||||
|
c::tab::tab_alpha = ImLerp(c::tab::tab_alpha, (page == c::tab::active_tab) ? 1.f : 0.f, 15.f * ImGui::GetIO().DeltaTime);
|
||||||
|
if (c::tab::tab_alpha < 0.01f && c::tab::tab_add < 0.01f) c::tab::active_tab = page;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Render_Sub()
|
||||||
|
{
|
||||||
|
ImVec2 pos = ImGui::GetWindowPos();
|
||||||
|
|
||||||
|
//if (page == 0)
|
||||||
|
// {
|
||||||
|
ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(pos.x + 105, pos.y + 40), 20, ImColor(26, 30, 29), 100);
|
||||||
|
|
||||||
|
ImGui::GetWindowDrawList()->AddText(font::lexend_regular, 16, ImVec2(pos.x + 135, pos.y + 25), ImColor(255, 255, 255), "Visual");
|
||||||
|
ImGui::GetWindowDrawList()->AddText(font::icomoon, 20, ImVec2(pos.x + 95, pos.y + 30), ImColor(107, 107, 107), "c");
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(135, 30));
|
||||||
|
ImGui::BeginGroup();
|
||||||
|
{
|
||||||
|
std::vector<std::vector<std::string>> sub_tab_columns =
|
||||||
|
{
|
||||||
|
{ "Enemy", "Ally", "World" }
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < sub_tab_columns[0].size(); ++i)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (edited::SubTab(page_s == i, sub_tab_columns[0][i].c_str(), ImVec2(40, 40)))
|
||||||
|
{
|
||||||
|
page_s = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndGroup();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
void Byte()
|
||||||
|
{
|
||||||
|
ImGui::SetCursorPos(ImVec2(13, 20));
|
||||||
|
ImGui::Image(texture::logo, ImVec2(45, 50));
|
||||||
|
|
||||||
|
ImGui::SetCursorPos(ImVec2(18, 390));
|
||||||
|
ImGui::Image(texture::foto, ImVec2(35, 35));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Search()
|
||||||
|
{
|
||||||
|
static char text[65] = { "" };
|
||||||
|
ImGui::SetCursorPos(ImVec2(82, 65));
|
||||||
|
ImGui::InputTextEx("v", "Search", text, 65, ImVec2(550, 40), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Decoration()
|
||||||
|
{
|
||||||
|
auto draw = ImGui::GetWindowDrawList();
|
||||||
|
ImVec2 pos = ImGui::GetWindowPos();
|
||||||
|
|
||||||
|
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x, pos.y), ImVec2(pos.x + 650, pos.y + 450), ImColor(15, 17, 16), 10);
|
||||||
|
ImGui::GetWindowDrawList()->AddRect(ImVec2(pos.x, pos.y), ImVec2(pos.x + 650, pos.y + 450), ImColor(32, 35, 34), 10, NULL, 1.5);
|
||||||
|
|
||||||
|
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + 10, pos.y + 10), ImVec2(pos.x + 60, pos.y + 440), ImColor(23, 25, 24), 5);
|
||||||
|
ImGui::GetWindowDrawList()->AddRect(ImVec2(pos.x + 10, pos.y + 10), ImVec2(pos.x + 60, pos.y + 440), ImColor(32, 35, 34), 5, NULL, 1.3f);
|
||||||
|
|
||||||
|
ImGui::GetWindowDrawList()->AddRectFilled(ImVec2(pos.x + 71, pos.y + 10), ImVec2(pos.x + 641, pos.y + 115), ImColor(23, 25, 24), 5);
|
||||||
|
ImGui::GetWindowDrawList()->AddRect(ImVec2(pos.x + 71, pos.y + 10), ImVec2(pos.x + 641, pos.y + 115), ImColor(32, 35, 34), 5, NULL, 1.3f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Render()
|
||||||
|
{
|
||||||
|
ImGuiStyle* style = &ImGui::GetStyle();
|
||||||
|
|
||||||
|
style->WindowPadding = ImVec2(0, 0);
|
||||||
|
style->ItemSpacing = ImVec2(10, 10);
|
||||||
|
style->WindowBorderSize = 0;
|
||||||
|
style->ScrollbarSize = 8.f;
|
||||||
|
|
||||||
|
ImGui::SetNextWindowSize(c::background::size);
|
||||||
|
ImGui::Begin("Dear ImGui", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoBackground);
|
||||||
|
{
|
||||||
|
Decoration();
|
||||||
|
Particles();
|
||||||
|
|
||||||
|
RenderTab();
|
||||||
|
Render_Sub();
|
||||||
|
|
||||||
|
render_function();
|
||||||
|
|
||||||
|
Byte();
|
||||||
|
Search();
|
||||||
|
}
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr };
|
||||||
|
::RegisterClassExW(&wc);
|
||||||
|
HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX11 Example", WS_POPUP, 0, 0, 1920, 1080, nullptr, nullptr, wc.hInstance, nullptr);
|
||||||
|
|
||||||
|
if (!CreateDeviceD3D(hwnd))
|
||||||
|
{
|
||||||
|
CleanupDeviceD3D();
|
||||||
|
::UnregisterClassW(wc.lpszClassName, wc.hInstance);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
::ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||||
|
::UpdateWindow(hwnd);
|
||||||
|
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
|
||||||
|
//Font
|
||||||
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
|
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;
|
||||||
|
|
||||||
|
ImFontConfig cfg;
|
||||||
|
cfg.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_ForceAutoHint | ImGuiFreeTypeBuilderFlags_LightHinting | ImGuiFreeTypeBuilderFlags_LoadColor;
|
||||||
|
|
||||||
|
font::lexend_general_bold = io.Fonts->AddFontFromMemoryTTF(lexend_bold, sizeof(lexend_bold), 18.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||||
|
font::lexend_bold = io.Fonts->AddFontFromMemoryTTF(lexend_regular, sizeof(lexend_regular), 17.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||||
|
font::lexend_regular = io.Fonts->AddFontFromMemoryTTF(lexend_regular, sizeof(lexend_regular), 14.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||||
|
font::icomoon = io.Fonts->AddFontFromMemoryTTF(icomoon, sizeof(icomoon), 20.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||||
|
|
||||||
|
font::icomoon_widget = io.Fonts->AddFontFromMemoryTTF(icomoon_widget, sizeof(icomoon_widget), 15.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||||
|
font::icomoon_widget2 = io.Fonts->AddFontFromMemoryTTF(icomoon, sizeof(icomoon), 16.f, &cfg, io.Fonts->GetGlyphRangesCyrillic());
|
||||||
|
|
||||||
|
//Byte
|
||||||
|
D3DX11_IMAGE_LOAD_INFO info; ID3DX11ThreadPump* pump{ nullptr };
|
||||||
|
if (texture::logo == nullptr)
|
||||||
|
D3DX11CreateShaderResourceViewFromMemory(g_pd3dDevice, logo_type, sizeof(logo_type), &info, pump, &texture::logo, 0);
|
||||||
|
if (texture::foto == nullptr)
|
||||||
|
D3DX11CreateShaderResourceViewFromMemory(g_pd3dDevice, foto_type, sizeof(foto_type), &info, pump, &texture::foto, 0);
|
||||||
|
|
||||||
|
if (texture::esp_preview == nullptr)
|
||||||
|
D3DX11CreateShaderResourceViewFromMemory(g_pd3dDevice, esp_preview1, sizeof(esp_preview1), &info, pump, &texture::esp_preview, 0);
|
||||||
|
|
||||||
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
|
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||||
|
|
||||||
|
bool done = false;
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
MSG msg;
|
||||||
|
while (::PeekMessage(&msg, nullptr, 0U, 0U, PM_REMOVE))
|
||||||
|
{
|
||||||
|
::TranslateMessage(&msg);
|
||||||
|
::DispatchMessage(&msg);
|
||||||
|
if (msg.message == WM_QUIT)
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
if (done) break;
|
||||||
|
|
||||||
|
if (g_ResizeWidth != 0 && g_ResizeHeight != 0)
|
||||||
|
{
|
||||||
|
CleanupRenderTarget();
|
||||||
|
g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0);
|
||||||
|
g_ResizeWidth = g_ResizeHeight = 0;
|
||||||
|
CreateRenderTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplDX11_NewFrame();
|
||||||
|
ImGui_ImplWin32_NewFrame();
|
||||||
|
|
||||||
|
ImGui::NewFrame();
|
||||||
|
{
|
||||||
|
render_ui::Render();
|
||||||
|
notificationSystem.DrawNotifications();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Render();
|
||||||
|
const float clear_color_with_alpha[4] = { 0.f };
|
||||||
|
|
||||||
|
g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, nullptr);
|
||||||
|
g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
|
||||||
|
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
|
||||||
|
|
||||||
|
g_pSwapChain->Present(1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui_ImplDX11_Shutdown();
|
||||||
|
ImGui_ImplWin32_Shutdown();
|
||||||
|
ImGui::DestroyContext();
|
||||||
|
|
||||||
|
CleanupDeviceD3D();
|
||||||
|
::DestroyWindow(hwnd);
|
||||||
|
::UnregisterClassW(wc.lpszClassName, wc.hInstance);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateDeviceD3D(HWND hWnd)
|
||||||
|
{
|
||||||
|
// Setup swap chain
|
||||||
|
DXGI_SWAP_CHAIN_DESC sd;
|
||||||
|
ZeroMemory(&sd, sizeof(sd));
|
||||||
|
sd.BufferCount = 2;
|
||||||
|
sd.BufferDesc.Width = 0;
|
||||||
|
sd.BufferDesc.Height = 0;
|
||||||
|
sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||||
|
sd.BufferDesc.RefreshRate.Numerator = 60;
|
||||||
|
sd.BufferDesc.RefreshRate.Denominator = 1;
|
||||||
|
sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
|
||||||
|
sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||||
|
sd.OutputWindow = hWnd;
|
||||||
|
sd.SampleDesc.Count = 1;
|
||||||
|
sd.SampleDesc.Quality = 0;
|
||||||
|
sd.Windowed = TRUE;
|
||||||
|
sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||||
|
|
||||||
|
UINT createDeviceFlags = 0;
|
||||||
|
|
||||||
|
D3D_FEATURE_LEVEL featureLevel;
|
||||||
|
const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, };
|
||||||
|
HRESULT res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext);
|
||||||
|
if (res == DXGI_ERROR_UNSUPPORTED)
|
||||||
|
res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_WARP, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext);
|
||||||
|
if (res != S_OK) return false;
|
||||||
|
|
||||||
|
CreateRenderTarget();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanupDeviceD3D()
|
||||||
|
{
|
||||||
|
CleanupRenderTarget();
|
||||||
|
if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = nullptr; }
|
||||||
|
if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = nullptr; }
|
||||||
|
if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = nullptr; }
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateRenderTarget()
|
||||||
|
{
|
||||||
|
ID3D11Texture2D* pBackBuffer;
|
||||||
|
g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer));
|
||||||
|
g_pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &g_mainRenderTargetView);
|
||||||
|
pBackBuffer->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CleanupRenderTarget()
|
||||||
|
{
|
||||||
|
if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; }
|
||||||
|
}
|
||||||
|
|
||||||
|
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
||||||
|
|
||||||
|
LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
switch (msg)
|
||||||
|
{
|
||||||
|
case WM_SIZE:
|
||||||
|
if (wParam == SIZE_MINIMIZED)
|
||||||
|
return 0;
|
||||||
|
g_ResizeWidth = (UINT)LOWORD(lParam);
|
||||||
|
g_ResizeHeight = (UINT)HIWORD(lParam);
|
||||||
|
return 0;
|
||||||
|
case WM_SYSCOMMAND:
|
||||||
|
if ((wParam & 0xfff0) == SC_KEYMENU)
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
case WM_DESTROY:
|
||||||
|
::PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return ::DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
|
}
|
4736
example_win32_directx11/texture.h
Normal file
4736
example_win32_directx11/texture.h
Normal file
File diff suppressed because it is too large
Load Diff
31
imgui_menu.sln
Normal file
31
imgui_menu.sln
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio Version 17
|
||||||
|
VisualStudioVersion = 17.2.32616.157
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_win32_directx11", "example_win32_directx11\example_win32_directx11.vcxproj", "{9F316E83-5AE5-4939-A723-305A94F48005}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Win32 = Debug|Win32
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Release|Win32 = Release|Win32
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|Win32.Build.0 = Debug|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.ActiveCfg = Release|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|Win32.Build.0 = Release|Win32
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{9F316E83-5AE5-4939-A723-305A94F48005}.Release|x64.Build.0 = Release|x64
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {B1ACFD20-A0A9-4A4C-ADBA-E7608F0E2BEE}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
37
libs/emscripten/emscripten_mainloop_stub.h
Normal file
37
libs/emscripten/emscripten_mainloop_stub.h
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// What does this file solves?
|
||||||
|
// - Since Dear ImGui 1.00 we took pride that most of our examples applications had their entire
|
||||||
|
// main-loop inside the main() function. That's because:
|
||||||
|
// - It makes the examples easier to read, keeping the code sequential.
|
||||||
|
// - It permit the use of local variables, making it easier to try things and perform quick
|
||||||
|
// changes when someone needs to quickly test something (vs having to structure the example
|
||||||
|
// in order to pass data around). This is very important because people use those examples
|
||||||
|
// to craft easy-to-past repro when they want to discuss features or report issues.
|
||||||
|
// - It conveys at a glance that this is a no-BS framework, it won't take your main loop away from you.
|
||||||
|
// - It is generally nice and elegant.
|
||||||
|
// - However, comes Emscripten... it is a wonderful and magical tech but it requires a "main loop" function.
|
||||||
|
// - Only some of our examples would run on Emscripten. Typically the ones rendering with GL or WGPU ones.
|
||||||
|
// - I tried to refactor those examples but felt it was problematic that other examples didn't follow the
|
||||||
|
// same layout. Why would the SDL+GL example be structured one way and the SGL+DX11 be structured differently?
|
||||||
|
// Especially as we are trying hard to convey that using a Dear ImGui backend in an *existing application*
|
||||||
|
// should requires only a few dozens lines of code, and this should be consistent and symmetrical for all backends.
|
||||||
|
// - So the next logical step was to refactor all examples to follow that layout of using a "main loop" function.
|
||||||
|
// This worked, but it made us lose all the nice things we had...
|
||||||
|
|
||||||
|
// Since only about 3 examples really need to run with Emscripten, here's our solution:
|
||||||
|
// - Use some weird macros and capturing lambda to turn a loop in main() into a function.
|
||||||
|
// - Hide all that crap in this file so it doesn't make our examples unusually ugly.
|
||||||
|
// As a stance and principle of Dear ImGui development we don't use C++ headers and we don't
|
||||||
|
// want to suggest to the newcomer that we would ever use C++ headers as this would affect
|
||||||
|
// the initial judgment of many of our target audience.
|
||||||
|
// - Technique is based on this idea: https://github.com/ocornut/imgui/pull/2492/
|
||||||
|
#ifdef __EMSCRIPTEN__
|
||||||
|
#include <emscripten.h>
|
||||||
|
#include <functional>
|
||||||
|
static std::function<void()> MainLoopForEmscriptenP;
|
||||||
|
static void MainLoopForEmscripten() { MainLoopForEmscriptenP(); }
|
||||||
|
#define EMSCRIPTEN_MAINLOOP_BEGIN MainLoopForEmscriptenP = [&]()
|
||||||
|
#define EMSCRIPTEN_MAINLOOP_END ; emscripten_set_main_loop(MainLoopForEmscripten, 0, true)
|
||||||
|
#else
|
||||||
|
#define EMSCRIPTEN_MAINLOOP_BEGIN
|
||||||
|
#define EMSCRIPTEN_MAINLOOP_END
|
||||||
|
#endif
|
65
libs/emscripten/shell_minimal.html
Normal file
65
libs/emscripten/shell_minimal.html
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en-us">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
|
||||||
|
<title>Dear ImGui Emscripten example</title>
|
||||||
|
<style>
|
||||||
|
body { margin: 0; background-color: black }
|
||||||
|
/* FIXME: with our GLFW example this block seems to break resizing and io.DisplaySize gets stuck */
|
||||||
|
.emscripten {
|
||||||
|
position: absolute;
|
||||||
|
top: 0px;
|
||||||
|
left: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
border: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
display: block;
|
||||||
|
image-rendering: optimizeSpeed;
|
||||||
|
image-rendering: -moz-crisp-edges;
|
||||||
|
image-rendering: -o-crisp-edges;
|
||||||
|
image-rendering: -webkit-optimize-contrast;
|
||||||
|
image-rendering: optimize-contrast;
|
||||||
|
image-rendering: crisp-edges;
|
||||||
|
image-rendering: pixelated;
|
||||||
|
-ms-interpolation-mode: nearest-neighbor;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
|
||||||
|
<script type='text/javascript'>
|
||||||
|
var Module = {
|
||||||
|
preRun: [],
|
||||||
|
postRun: [],
|
||||||
|
print: (function() {
|
||||||
|
return function(text) {
|
||||||
|
text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
console.log(text);
|
||||||
|
};
|
||||||
|
})(),
|
||||||
|
printErr: function(text) {
|
||||||
|
text = Array.prototype.slice.call(arguments).join(' ');
|
||||||
|
console.error(text);
|
||||||
|
},
|
||||||
|
canvas: (function() {
|
||||||
|
var canvas = document.getElementById('canvas');
|
||||||
|
//canvas.addEventListener("webglcontextlost", function(e) { alert('FIXME: WebGL context lost, please reload the page'); e.preventDefault(); }, false);
|
||||||
|
return canvas;
|
||||||
|
})(),
|
||||||
|
setStatus: function(text) {
|
||||||
|
console.log("status: " + text);
|
||||||
|
},
|
||||||
|
monitorRunDependencies: function(left) {
|
||||||
|
// no run dependencies to log
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.onerror = function() {
|
||||||
|
console.log("onerror: " + event);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
{{{ SCRIPT }}}
|
||||||
|
</body>
|
||||||
|
</html>
|
22
libs/glfw/COPYING.txt
Normal file
22
libs/glfw/COPYING.txt
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
|
Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would
|
||||||
|
be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
|
4227
libs/glfw/include/GLFW/glfw3.h
Normal file
4227
libs/glfw/include/GLFW/glfw3.h
Normal file
File diff suppressed because it is too large
Load Diff
456
libs/glfw/include/GLFW/glfw3native.h
Normal file
456
libs/glfw/include/GLFW/glfw3native.h
Normal file
@ -0,0 +1,456 @@
|
|||||||
|
/*************************************************************************
|
||||||
|
* GLFW 3.2 - www.glfw.org
|
||||||
|
* A library for OpenGL, window and input
|
||||||
|
*------------------------------------------------------------------------
|
||||||
|
* Copyright (c) 2002-2006 Marcus Geelnard
|
||||||
|
* Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would
|
||||||
|
* be appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not
|
||||||
|
* be misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#ifndef _glfw3_native_h_
|
||||||
|
#define _glfw3_native_h_
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* Doxygen documentation
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
/*! @file glfw3native.h
|
||||||
|
* @brief The header of the native access functions.
|
||||||
|
*
|
||||||
|
* This is the header file of the native access functions. See @ref native for
|
||||||
|
* more information.
|
||||||
|
*/
|
||||||
|
/*! @defgroup native Native access
|
||||||
|
*
|
||||||
|
* **By using the native access functions you assert that you know what you're
|
||||||
|
* doing and how to fix problems caused by using them. If you don't, you
|
||||||
|
* shouldn't be using them.**
|
||||||
|
*
|
||||||
|
* Before the inclusion of @ref glfw3native.h, you may define exactly one
|
||||||
|
* window system API macro and zero or more context creation API macros.
|
||||||
|
*
|
||||||
|
* The chosen backends must match those the library was compiled for. Failure
|
||||||
|
* to do this will cause a link-time error.
|
||||||
|
*
|
||||||
|
* The available window API macros are:
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_WIN32`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_COCOA`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_X11`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_WAYLAND`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_MIR`
|
||||||
|
*
|
||||||
|
* The available context API macros are:
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_WGL`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_NSGL`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_GLX`
|
||||||
|
* * `GLFW_EXPOSE_NATIVE_EGL`
|
||||||
|
*
|
||||||
|
* These macros select which of the native access functions that are declared
|
||||||
|
* and which platform-specific headers to include. It is then up your (by
|
||||||
|
* definition platform-specific) code to handle which of these should be
|
||||||
|
* defined.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* System headers and types
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||||
|
// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
|
||||||
|
// example to allow applications to correctly declare a GL_ARB_debug_output
|
||||||
|
// callback) but windows.h assumes no one will define APIENTRY before it does
|
||||||
|
#undef APIENTRY
|
||||||
|
#include <windows.h>
|
||||||
|
#elif defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||||
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
#if defined(__OBJC__)
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
#else
|
||||||
|
typedef void* id;
|
||||||
|
#endif
|
||||||
|
#elif defined(GLFW_EXPOSE_NATIVE_X11)
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
#elif defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
||||||
|
#include <wayland-client.h>
|
||||||
|
#elif defined(GLFW_EXPOSE_NATIVE_MIR)
|
||||||
|
#include <mir_toolkit/mir_client_library.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
|
/* WGL is declared by windows.h */
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
|
/* NSGL is declared by Cocoa.h */
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
|
#include <GL/glx.h>
|
||||||
|
#endif
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* Functions
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_WIN32)
|
||||||
|
/*! @brief Returns the adapter device name of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The UTF-8 encoded adapter device name (for example `\\.\DISPLAY1`)
|
||||||
|
* of the specified monitor, or `NULL` if an [error](@ref error_handling)
|
||||||
|
* occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI const char* glfwGetWin32Adapter(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the display device name of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The UTF-8 encoded display device name (for example
|
||||||
|
* `\\.\DISPLAY1\Monitor0`) of the specified monitor, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI const char* glfwGetWin32Monitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the `HWND` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `HWND` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_WGL)
|
||||||
|
/*! @brief Returns the `HGLRC` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `HGLRC` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI HGLRC glfwGetWGLContext(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_COCOA)
|
||||||
|
/*! @brief Returns the `CGDirectDisplayID` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `CGDirectDisplayID` of the specified monitor, or
|
||||||
|
* `kCGNullDirectDisplay` if an [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI CGDirectDisplayID glfwGetCocoaMonitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the `NSWindow` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `NSWindow` of the specified window, or `nil` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI id glfwGetCocoaWindow(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_NSGL)
|
||||||
|
/*! @brief Returns the `NSOpenGLContext` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `NSOpenGLContext` of the specified window, or `nil` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI id glfwGetNSGLContext(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_X11)
|
||||||
|
/*! @brief Returns the `Display` used by GLFW.
|
||||||
|
*
|
||||||
|
* @return The `Display` used by GLFW, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI Display* glfwGetX11Display(void);
|
||||||
|
|
||||||
|
/*! @brief Returns the `RRCrtc` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `RRCrtc` of the specified monitor, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI RRCrtc glfwGetX11Adapter(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the `RROutput` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `RROutput` of the specified monitor, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.1.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI RROutput glfwGetX11Monitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the `Window` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `Window` of the specified window, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI Window glfwGetX11Window(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_GLX)
|
||||||
|
/*! @brief Returns the `GLXContext` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `GLXContext` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Returns the `GLXWindow` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `GLXWindow` of the specified window, or `None` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_WAYLAND)
|
||||||
|
/*! @brief Returns the `struct wl_display*` used by GLFW.
|
||||||
|
*
|
||||||
|
* @return The `struct wl_display*` used by GLFW, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI struct wl_display* glfwGetWaylandDisplay(void);
|
||||||
|
|
||||||
|
/*! @brief Returns the `struct wl_output*` of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The `struct wl_output*` of the specified monitor, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI struct wl_output* glfwGetWaylandMonitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the main `struct wl_surface*` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The main `struct wl_surface*` of the specified window, or `NULL` if
|
||||||
|
* an [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI struct wl_surface* glfwGetWaylandWindow(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_MIR)
|
||||||
|
/*! @brief Returns the `MirConnection*` used by GLFW.
|
||||||
|
*
|
||||||
|
* @return The `MirConnection*` used by GLFW, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI MirConnection* glfwGetMirDisplay(void);
|
||||||
|
|
||||||
|
/*! @brief Returns the Mir output ID of the specified monitor.
|
||||||
|
*
|
||||||
|
* @return The Mir output ID of the specified monitor, or zero if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI int glfwGetMirMonitor(GLFWmonitor* monitor);
|
||||||
|
|
||||||
|
/*! @brief Returns the `MirSurface*` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `MirSurface*` of the specified window, or `NULL` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.2.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI MirSurface* glfwGetMirWindow(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(GLFW_EXPOSE_NATIVE_EGL)
|
||||||
|
/*! @brief Returns the `EGLDisplay` used by GLFW.
|
||||||
|
*
|
||||||
|
* @return The `EGLDisplay` used by GLFW, or `EGL_NO_DISPLAY` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI EGLDisplay glfwGetEGLDisplay(void);
|
||||||
|
|
||||||
|
/*! @brief Returns the `EGLContext` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `EGLContext` of the specified window, or `EGL_NO_CONTEXT` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI EGLContext glfwGetEGLContext(GLFWwindow* window);
|
||||||
|
|
||||||
|
/*! @brief Returns the `EGLSurface` of the specified window.
|
||||||
|
*
|
||||||
|
* @return The `EGLSurface` of the specified window, or `EGL_NO_SURFACE` if an
|
||||||
|
* [error](@ref error_handling) occurred.
|
||||||
|
*
|
||||||
|
* @thread_safety This function may be called from any thread. Access is not
|
||||||
|
* synchronized.
|
||||||
|
*
|
||||||
|
* @since Added in version 3.0.
|
||||||
|
*
|
||||||
|
* @ingroup native
|
||||||
|
*/
|
||||||
|
GLFWAPI EGLSurface glfwGetEGLSurface(GLFWwindow* window);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _glfw3_native_h_ */
|
||||||
|
|
BIN
libs/glfw/lib-vc2010-32/glfw3.lib
Normal file
BIN
libs/glfw/lib-vc2010-32/glfw3.lib
Normal file
Binary file not shown.
BIN
libs/glfw/lib-vc2010-64/glfw3.lib
Normal file
BIN
libs/glfw/lib-vc2010-64/glfw3.lib
Normal file
Binary file not shown.
8
libs/usynergy/README.txt
Normal file
8
libs/usynergy/README.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
uSynergy client -- Implementation for the embedded Synergy client library
|
||||||
|
version 1.0.0, July 7th, 2012
|
||||||
|
Copyright (c) 2012 Alex Evans
|
||||||
|
|
||||||
|
This is a copy of the files once found at:
|
||||||
|
https://github.com/symless/synergy-core/tree/790d108a56ada9caad8e56ff777d444485a69da9/src/micro
|
||||||
|
|
636
libs/usynergy/uSynergy.c
Normal file
636
libs/usynergy/uSynergy.c
Normal file
@ -0,0 +1,636 @@
|
|||||||
|
/*
|
||||||
|
uSynergy client -- Implementation for the embedded Synergy client library
|
||||||
|
version 1.0.0, July 7th, 2012
|
||||||
|
|
||||||
|
Copyright (c) 2012 Alex Evans
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
#include "uSynergy.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Internal helpers
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Read 16 bit integer in network byte order and convert to native byte order
|
||||||
|
**/
|
||||||
|
static int16_t sNetToNative16(const unsigned char *value)
|
||||||
|
{
|
||||||
|
#ifdef USYNERGY_LITTLE_ENDIAN
|
||||||
|
return value[1] | (value[0] << 8);
|
||||||
|
#else
|
||||||
|
return value[0] | (value[1] << 8);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Read 32 bit integer in network byte order and convert to native byte order
|
||||||
|
**/
|
||||||
|
static int32_t sNetToNative32(const unsigned char *value)
|
||||||
|
{
|
||||||
|
#ifdef USYNERGY_LITTLE_ENDIAN
|
||||||
|
return value[3] | (value[2] << 8) | (value[1] << 16) | (value[0] << 24);
|
||||||
|
#else
|
||||||
|
return value[0] | (value[1] << 8) | (value[2] << 16) | (value[3] << 24);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Trace text to client
|
||||||
|
**/
|
||||||
|
static void sTrace(uSynergyContext *context, const char* text)
|
||||||
|
{
|
||||||
|
// Don't trace if we don't have a trace function
|
||||||
|
if (context->m_traceFunc != 0L)
|
||||||
|
context->m_traceFunc(context->m_cookie, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Add string to reply packet
|
||||||
|
**/
|
||||||
|
static void sAddString(uSynergyContext *context, const char *string)
|
||||||
|
{
|
||||||
|
size_t len = strlen(string);
|
||||||
|
memcpy(context->m_replyCur, string, len);
|
||||||
|
context->m_replyCur += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Add uint8 to reply packet
|
||||||
|
**/
|
||||||
|
static void sAddUInt8(uSynergyContext *context, uint8_t value)
|
||||||
|
{
|
||||||
|
*context->m_replyCur++ = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Add uint16 to reply packet
|
||||||
|
**/
|
||||||
|
static void sAddUInt16(uSynergyContext *context, uint16_t value)
|
||||||
|
{
|
||||||
|
uint8_t *reply = context->m_replyCur;
|
||||||
|
*reply++ = (uint8_t)(value >> 8);
|
||||||
|
*reply++ = (uint8_t)value;
|
||||||
|
context->m_replyCur = reply;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Add uint32 to reply packet
|
||||||
|
**/
|
||||||
|
static void sAddUInt32(uSynergyContext *context, uint32_t value)
|
||||||
|
{
|
||||||
|
uint8_t *reply = context->m_replyCur;
|
||||||
|
*reply++ = (uint8_t)(value >> 24);
|
||||||
|
*reply++ = (uint8_t)(value >> 16);
|
||||||
|
*reply++ = (uint8_t)(value >> 8);
|
||||||
|
*reply++ = (uint8_t)value;
|
||||||
|
context->m_replyCur = reply;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Send reply packet
|
||||||
|
**/
|
||||||
|
static uSynergyBool sSendReply(uSynergyContext *context)
|
||||||
|
{
|
||||||
|
// Set header size
|
||||||
|
uint8_t *reply_buf = context->m_replyBuffer;
|
||||||
|
uint32_t reply_len = (uint32_t)(context->m_replyCur - reply_buf); /* Total size of reply */
|
||||||
|
uint32_t body_len = reply_len - 4; /* Size of body */
|
||||||
|
uSynergyBool ret;
|
||||||
|
reply_buf[0] = (uint8_t)(body_len >> 24);
|
||||||
|
reply_buf[1] = (uint8_t)(body_len >> 16);
|
||||||
|
reply_buf[2] = (uint8_t)(body_len >> 8);
|
||||||
|
reply_buf[3] = (uint8_t)body_len;
|
||||||
|
|
||||||
|
// Send reply
|
||||||
|
ret = context->m_sendFunc(context->m_cookie, context->m_replyBuffer, reply_len);
|
||||||
|
|
||||||
|
// Reset reply buffer write pointer
|
||||||
|
context->m_replyCur = context->m_replyBuffer+4;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Call mouse callback after a mouse event
|
||||||
|
**/
|
||||||
|
static void sSendMouseCallback(uSynergyContext *context)
|
||||||
|
{
|
||||||
|
// Skip if no callback is installed
|
||||||
|
if (context->m_mouseCallback == 0L)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Send callback
|
||||||
|
context->m_mouseCallback(context->m_cookie, context->m_mouseX, context->m_mouseY, context->m_mouseWheelX,
|
||||||
|
context->m_mouseWheelY, context->m_mouseButtonLeft, context->m_mouseButtonRight, context->m_mouseButtonMiddle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Send keyboard callback when a key has been pressed or released
|
||||||
|
**/
|
||||||
|
static void sSendKeyboardCallback(uSynergyContext *context, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)
|
||||||
|
{
|
||||||
|
// Skip if no callback is installed
|
||||||
|
if (context->m_keyboardCallback == 0L)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Send callback
|
||||||
|
context->m_keyboardCallback(context->m_cookie, key, modifiers, down, repeat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Send joystick callback
|
||||||
|
**/
|
||||||
|
static void sSendJoystickCallback(uSynergyContext *context, uint8_t joyNum)
|
||||||
|
{
|
||||||
|
int8_t *sticks;
|
||||||
|
|
||||||
|
// Skip if no callback is installed
|
||||||
|
if (context->m_joystickCallback == 0L)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Send callback
|
||||||
|
sticks = context->m_joystickSticks[joyNum];
|
||||||
|
context->m_joystickCallback(context->m_cookie, joyNum, context->m_joystickButtons[joyNum], sticks[0], sticks[1], sticks[2], sticks[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Parse a single client message, update state, send callbacks and send replies
|
||||||
|
**/
|
||||||
|
#define USYNERGY_IS_PACKET(pkt_id) memcmp(message+4, pkt_id, 4)==0
|
||||||
|
static void sProcessMessage(uSynergyContext *context, const uint8_t *message)
|
||||||
|
{
|
||||||
|
// We have a packet!
|
||||||
|
if (memcmp(message+4, "Synergy", 7)==0)
|
||||||
|
{
|
||||||
|
// Welcome message
|
||||||
|
// kMsgHello = "Synergy%2i%2i"
|
||||||
|
// kMsgHelloBack = "Synergy%2i%2i%s"
|
||||||
|
sAddString(context, "Synergy");
|
||||||
|
sAddUInt16(context, USYNERGY_PROTOCOL_MAJOR);
|
||||||
|
sAddUInt16(context, USYNERGY_PROTOCOL_MINOR);
|
||||||
|
sAddUInt32(context, (uint32_t)strlen(context->m_clientName));
|
||||||
|
sAddString(context, context->m_clientName);
|
||||||
|
if (!sSendReply(context))
|
||||||
|
{
|
||||||
|
// Send reply failed, let's try to reconnect
|
||||||
|
sTrace(context, "SendReply failed, trying to reconnect in a second");
|
||||||
|
context->m_connected = USYNERGY_FALSE;
|
||||||
|
context->m_sleepFunc(context->m_cookie, 1000);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Let's assume we're connected
|
||||||
|
char buffer[256+1];
|
||||||
|
sprintf(buffer, "Connected as client \"%s\"", context->m_clientName);
|
||||||
|
sTrace(context, buffer);
|
||||||
|
context->m_hasReceivedHello = USYNERGY_TRUE;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("QINF"))
|
||||||
|
{
|
||||||
|
// Screen info. Reply with DINF
|
||||||
|
// kMsgQInfo = "QINF"
|
||||||
|
// kMsgDInfo = "DINF%2i%2i%2i%2i%2i%2i%2i"
|
||||||
|
uint16_t x = 0, y = 0, warp = 0;
|
||||||
|
sAddString(context, "DINF");
|
||||||
|
sAddUInt16(context, x);
|
||||||
|
sAddUInt16(context, y);
|
||||||
|
sAddUInt16(context, context->m_clientWidth);
|
||||||
|
sAddUInt16(context, context->m_clientHeight);
|
||||||
|
sAddUInt16(context, warp);
|
||||||
|
sAddUInt16(context, 0); // mx?
|
||||||
|
sAddUInt16(context, 0); // my?
|
||||||
|
sSendReply(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("CIAK"))
|
||||||
|
{
|
||||||
|
// Do nothing?
|
||||||
|
// kMsgCInfoAck = "CIAK"
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("CROP"))
|
||||||
|
{
|
||||||
|
// Do nothing?
|
||||||
|
// kMsgCResetOptions = "CROP"
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("CINN"))
|
||||||
|
{
|
||||||
|
// Screen enter. Reply with CNOP
|
||||||
|
// kMsgCEnter = "CINN%2i%2i%4i%2i"
|
||||||
|
|
||||||
|
// Obtain the Synergy sequence number
|
||||||
|
context->m_sequenceNumber = sNetToNative32(message + 12);
|
||||||
|
context->m_isCaptured = USYNERGY_TRUE;
|
||||||
|
|
||||||
|
// Call callback
|
||||||
|
if (context->m_screenActiveCallback != 0L)
|
||||||
|
context->m_screenActiveCallback(context->m_cookie, USYNERGY_TRUE);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("COUT"))
|
||||||
|
{
|
||||||
|
// Screen leave
|
||||||
|
// kMsgCLeave = "COUT"
|
||||||
|
context->m_isCaptured = USYNERGY_FALSE;
|
||||||
|
|
||||||
|
// Call callback
|
||||||
|
if (context->m_screenActiveCallback != 0L)
|
||||||
|
context->m_screenActiveCallback(context->m_cookie, USYNERGY_FALSE);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DMDN"))
|
||||||
|
{
|
||||||
|
// Mouse down
|
||||||
|
// kMsgDMouseDown = "DMDN%1i"
|
||||||
|
char btn = message[8]-1;
|
||||||
|
if (btn==2)
|
||||||
|
context->m_mouseButtonRight = USYNERGY_TRUE;
|
||||||
|
else if (btn==1)
|
||||||
|
context->m_mouseButtonMiddle = USYNERGY_TRUE;
|
||||||
|
else
|
||||||
|
context->m_mouseButtonLeft = USYNERGY_TRUE;
|
||||||
|
sSendMouseCallback(context);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DMUP"))
|
||||||
|
{
|
||||||
|
// Mouse up
|
||||||
|
// kMsgDMouseUp = "DMUP%1i"
|
||||||
|
char btn = message[8]-1;
|
||||||
|
if (btn==2)
|
||||||
|
context->m_mouseButtonRight = USYNERGY_FALSE;
|
||||||
|
else if (btn==1)
|
||||||
|
context->m_mouseButtonMiddle = USYNERGY_FALSE;
|
||||||
|
else
|
||||||
|
context->m_mouseButtonLeft = USYNERGY_FALSE;
|
||||||
|
sSendMouseCallback(context);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DMMV"))
|
||||||
|
{
|
||||||
|
// Mouse move. Reply with CNOP
|
||||||
|
// kMsgDMouseMove = "DMMV%2i%2i"
|
||||||
|
context->m_mouseX = sNetToNative16(message+8);
|
||||||
|
context->m_mouseY = sNetToNative16(message+10);
|
||||||
|
sSendMouseCallback(context);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DMWM"))
|
||||||
|
{
|
||||||
|
// Mouse wheel
|
||||||
|
// kMsgDMouseWheel = "DMWM%2i%2i"
|
||||||
|
// kMsgDMouseWheel1_0 = "DMWM%2i"
|
||||||
|
context->m_mouseWheelX += sNetToNative16(message+8);
|
||||||
|
context->m_mouseWheelY += sNetToNative16(message+10);
|
||||||
|
sSendMouseCallback(context);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DKDN"))
|
||||||
|
{
|
||||||
|
// Key down
|
||||||
|
// kMsgDKeyDown = "DKDN%2i%2i%2i"
|
||||||
|
// kMsgDKeyDown1_0 = "DKDN%2i%2i"
|
||||||
|
//uint16_t id = sNetToNative16(message+8);
|
||||||
|
uint16_t mod = sNetToNative16(message+10);
|
||||||
|
uint16_t key = sNetToNative16(message+12);
|
||||||
|
sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_FALSE);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DKRP"))
|
||||||
|
{
|
||||||
|
// Key repeat
|
||||||
|
// kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
|
||||||
|
// kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
|
||||||
|
uint16_t mod = sNetToNative16(message+10);
|
||||||
|
// uint16_t count = sNetToNative16(message+12);
|
||||||
|
uint16_t key = sNetToNative16(message+14);
|
||||||
|
sSendKeyboardCallback(context, key, mod, USYNERGY_TRUE, USYNERGY_TRUE);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DKUP"))
|
||||||
|
{
|
||||||
|
// Key up
|
||||||
|
// kMsgDKeyUp = "DKUP%2i%2i%2i"
|
||||||
|
// kMsgDKeyUp1_0 = "DKUP%2i%2i"
|
||||||
|
//uint16 id=Endian::sNetToNative(sbuf[4]);
|
||||||
|
uint16_t mod = sNetToNative16(message+10);
|
||||||
|
uint16_t key = sNetToNative16(message+12);
|
||||||
|
sSendKeyboardCallback(context, key, mod, USYNERGY_FALSE, USYNERGY_FALSE);
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DGBT"))
|
||||||
|
{
|
||||||
|
// Joystick buttons
|
||||||
|
// kMsgDGameButtons = "DGBT%1i%2i";
|
||||||
|
uint8_t joy_num = message[8];
|
||||||
|
if (joy_num<USYNERGY_NUM_JOYSTICKS)
|
||||||
|
{
|
||||||
|
// Copy button state, then send callback
|
||||||
|
context->m_joystickButtons[joy_num] = (message[9] << 8) | message[10];
|
||||||
|
sSendJoystickCallback(context, joy_num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DGST"))
|
||||||
|
{
|
||||||
|
// Joystick sticks
|
||||||
|
// kMsgDGameSticks = "DGST%1i%1i%1i%1i%1i";
|
||||||
|
uint8_t joy_num = message[8];
|
||||||
|
if (joy_num<USYNERGY_NUM_JOYSTICKS)
|
||||||
|
{
|
||||||
|
// Copy stick state, then send callback
|
||||||
|
memcpy(context->m_joystickSticks[joy_num], message+9, 4);
|
||||||
|
sSendJoystickCallback(context, joy_num);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DSOP"))
|
||||||
|
{
|
||||||
|
// Set options
|
||||||
|
// kMsgDSetOptions = "DSOP%4I"
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("CALV"))
|
||||||
|
{
|
||||||
|
// Keepalive, reply with CALV and then CNOP
|
||||||
|
// kMsgCKeepAlive = "CALV"
|
||||||
|
sAddString(context, "CALV");
|
||||||
|
sSendReply(context);
|
||||||
|
// now reply with CNOP
|
||||||
|
}
|
||||||
|
else if (USYNERGY_IS_PACKET("DCLP"))
|
||||||
|
{
|
||||||
|
// Clipboard message
|
||||||
|
// kMsgDClipboard = "DCLP%1i%4i%s"
|
||||||
|
//
|
||||||
|
// The clipboard message contains:
|
||||||
|
// 1 uint32: The size of the message
|
||||||
|
// 4 chars: The identifier ("DCLP")
|
||||||
|
// 1 uint8: The clipboard index
|
||||||
|
// 1 uint32: The sequence number. It's zero, because this message is always coming from the server?
|
||||||
|
// 1 uint32: The total size of the remaining 'string' (as per the Synergy %s string format (which is 1 uint32 for size followed by a char buffer (not necessarily null terminated)).
|
||||||
|
// 1 uint32: The number of formats present in the message
|
||||||
|
// And then 'number of formats' times the following:
|
||||||
|
// 1 uint32: The format of the clipboard data
|
||||||
|
// 1 uint32: The size n of the clipboard data
|
||||||
|
// n uint8: The clipboard data
|
||||||
|
const uint8_t * parse_msg = message+17;
|
||||||
|
uint32_t num_formats = sNetToNative32(parse_msg);
|
||||||
|
parse_msg += 4;
|
||||||
|
for (; num_formats; num_formats--)
|
||||||
|
{
|
||||||
|
// Parse clipboard format header
|
||||||
|
uint32_t format = sNetToNative32(parse_msg);
|
||||||
|
uint32_t size = sNetToNative32(parse_msg+4);
|
||||||
|
parse_msg += 8;
|
||||||
|
|
||||||
|
// Call callback
|
||||||
|
if (context->m_clipboardCallback)
|
||||||
|
context->m_clipboardCallback(context->m_cookie, format, parse_msg, size);
|
||||||
|
|
||||||
|
parse_msg += size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Unknown packet, could be any of these
|
||||||
|
// kMsgCNoop = "CNOP"
|
||||||
|
// kMsgCClose = "CBYE"
|
||||||
|
// kMsgCClipboard = "CCLP%1i%4i"
|
||||||
|
// kMsgCScreenSaver = "CSEC%1i"
|
||||||
|
// kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
|
||||||
|
// kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
|
||||||
|
// kMsgDMouseRelMove = "DMRM%2i%2i"
|
||||||
|
// kMsgEIncompatible = "EICV%2i%2i"
|
||||||
|
// kMsgEBusy = "EBSY"
|
||||||
|
// kMsgEUnknown = "EUNK"
|
||||||
|
// kMsgEBad = "EBAD"
|
||||||
|
char buffer[64];
|
||||||
|
sprintf(buffer, "Unknown packet '%c%c%c%c'", message[4], message[5], message[6], message[7]);
|
||||||
|
sTrace(context, buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reply with CNOP maybe?
|
||||||
|
sAddString(context, "CNOP");
|
||||||
|
sSendReply(context);
|
||||||
|
}
|
||||||
|
#undef USYNERGY_IS_PACKET
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Mark context as being disconnected
|
||||||
|
**/
|
||||||
|
static void sSetDisconnected(uSynergyContext *context)
|
||||||
|
{
|
||||||
|
context->m_connected = USYNERGY_FALSE;
|
||||||
|
context->m_hasReceivedHello = USYNERGY_FALSE;
|
||||||
|
context->m_isCaptured = USYNERGY_FALSE;
|
||||||
|
context->m_replyCur = context->m_replyBuffer + 4;
|
||||||
|
context->m_sequenceNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Update a connected context
|
||||||
|
**/
|
||||||
|
static void sUpdateContext(uSynergyContext *context)
|
||||||
|
{
|
||||||
|
/* Receive data (blocking) */
|
||||||
|
int receive_size = USYNERGY_RECEIVE_BUFFER_SIZE - context->m_receiveOfs;
|
||||||
|
int num_received = 0;
|
||||||
|
int packlen = 0;
|
||||||
|
if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer + context->m_receiveOfs, receive_size, &num_received) == USYNERGY_FALSE)
|
||||||
|
{
|
||||||
|
/* Receive failed, let's try to reconnect */
|
||||||
|
char buffer[128];
|
||||||
|
sprintf(buffer, "Receive failed (%d bytes asked, %d bytes received), trying to reconnect in a second", receive_size, num_received);
|
||||||
|
sTrace(context, buffer);
|
||||||
|
sSetDisconnected(context);
|
||||||
|
context->m_sleepFunc(context->m_cookie, 1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context->m_receiveOfs += num_received;
|
||||||
|
|
||||||
|
/* If we didn't receive any data then we're probably still polling to get connected and
|
||||||
|
therefore not getting any data back. To avoid overloading the system with a Synergy
|
||||||
|
thread that would hammer on polling, we let it rest for a bit if there's no data. */
|
||||||
|
if (num_received == 0)
|
||||||
|
context->m_sleepFunc(context->m_cookie, 500);
|
||||||
|
|
||||||
|
/* Check for timeouts */
|
||||||
|
if (context->m_hasReceivedHello)
|
||||||
|
{
|
||||||
|
uint32_t cur_time = context->m_getTimeFunc();
|
||||||
|
if (num_received == 0)
|
||||||
|
{
|
||||||
|
/* Timeout after 2 secs of inactivity (we received no CALV) */
|
||||||
|
if ((cur_time - context->m_lastMessageTime) > USYNERGY_IDLE_TIMEOUT)
|
||||||
|
sSetDisconnected(context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
context->m_lastMessageTime = cur_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Eat packets */
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
/* Grab packet length and bail out if the packet goes beyond the end of the buffer */
|
||||||
|
packlen = sNetToNative32(context->m_receiveBuffer);
|
||||||
|
if (packlen+4 > context->m_receiveOfs)
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* Process message */
|
||||||
|
sProcessMessage(context, context->m_receiveBuffer);
|
||||||
|
|
||||||
|
/* Move packet to front of buffer */
|
||||||
|
memmove(context->m_receiveBuffer, context->m_receiveBuffer+packlen+4, context->m_receiveOfs-packlen-4);
|
||||||
|
context->m_receiveOfs -= packlen+4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Throw away over-sized packets */
|
||||||
|
if (packlen > USYNERGY_RECEIVE_BUFFER_SIZE)
|
||||||
|
{
|
||||||
|
/* Oversized packet, ditch tail end */
|
||||||
|
char buffer[128];
|
||||||
|
sprintf(buffer, "Oversized packet: '%c%c%c%c' (length %d)", context->m_receiveBuffer[4], context->m_receiveBuffer[5], context->m_receiveBuffer[6], context->m_receiveBuffer[7], packlen);
|
||||||
|
sTrace(context, buffer);
|
||||||
|
num_received = context->m_receiveOfs-4; // 4 bytes for the size field
|
||||||
|
while (num_received != packlen)
|
||||||
|
{
|
||||||
|
int buffer_left = packlen - num_received;
|
||||||
|
int to_receive = buffer_left < USYNERGY_RECEIVE_BUFFER_SIZE ? buffer_left : USYNERGY_RECEIVE_BUFFER_SIZE;
|
||||||
|
int ditch_received = 0;
|
||||||
|
if (context->m_receiveFunc(context->m_cookie, context->m_receiveBuffer, to_receive, &ditch_received) == USYNERGY_FALSE)
|
||||||
|
{
|
||||||
|
/* Receive failed, let's try to reconnect */
|
||||||
|
sTrace(context, "Receive failed, trying to reconnect in a second");
|
||||||
|
sSetDisconnected(context);
|
||||||
|
context->m_sleepFunc(context->m_cookie, 1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
num_received += ditch_received;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
context->m_receiveOfs = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Public interface
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize uSynergy context
|
||||||
|
**/
|
||||||
|
void uSynergyInit(uSynergyContext *context)
|
||||||
|
{
|
||||||
|
/* Zero memory */
|
||||||
|
memset(context, 0, sizeof(uSynergyContext));
|
||||||
|
|
||||||
|
/* Initialize to default state */
|
||||||
|
sSetDisconnected(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Update uSynergy
|
||||||
|
**/
|
||||||
|
void uSynergyUpdate(uSynergyContext *context)
|
||||||
|
{
|
||||||
|
if (context->m_connected)
|
||||||
|
{
|
||||||
|
/* Update context, receive data, call callbacks */
|
||||||
|
sUpdateContext(context);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Try to connect */
|
||||||
|
if (context->m_connectFunc(context->m_cookie))
|
||||||
|
context->m_connected = USYNERGY_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Send clipboard data
|
||||||
|
**/
|
||||||
|
void uSynergySendClipboard(uSynergyContext *context, const char *text)
|
||||||
|
{
|
||||||
|
// Calculate maximum size that will fit in a reply packet
|
||||||
|
uint32_t overhead_size = 4 + /* Message size */
|
||||||
|
4 + /* Message ID */
|
||||||
|
1 + /* Clipboard index */
|
||||||
|
4 + /* Sequence number */
|
||||||
|
4 + /* Rest of message size (because it's a Synergy string from here on) */
|
||||||
|
4 + /* Number of clipboard formats */
|
||||||
|
4 + /* Clipboard format */
|
||||||
|
4; /* Clipboard data length */
|
||||||
|
uint32_t max_length = USYNERGY_REPLY_BUFFER_SIZE - overhead_size;
|
||||||
|
|
||||||
|
// Clip text to max length
|
||||||
|
uint32_t text_length = (uint32_t)strlen(text);
|
||||||
|
if (text_length > max_length)
|
||||||
|
{
|
||||||
|
char buffer[128];
|
||||||
|
sprintf(buffer, "Clipboard buffer too small, clipboard truncated at %d characters", max_length);
|
||||||
|
sTrace(context, buffer);
|
||||||
|
text_length = max_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assemble packet
|
||||||
|
sAddString(context, "DCLP");
|
||||||
|
sAddUInt8(context, 0); /* Clipboard index */
|
||||||
|
sAddUInt32(context, context->m_sequenceNumber);
|
||||||
|
sAddUInt32(context, 4+4+4+text_length); /* Rest of message size: numFormats, format, length, data */
|
||||||
|
sAddUInt32(context, 1); /* Number of formats (only text for now) */
|
||||||
|
sAddUInt32(context, USYNERGY_CLIPBOARD_FORMAT_TEXT);
|
||||||
|
sAddUInt32(context, text_length);
|
||||||
|
sAddString(context, text);
|
||||||
|
sSendReply(context);
|
||||||
|
}
|
420
libs/usynergy/uSynergy.h
Normal file
420
libs/usynergy/uSynergy.h
Normal file
@ -0,0 +1,420 @@
|
|||||||
|
/*
|
||||||
|
uSynergy client -- Interface for the embedded Synergy client library
|
||||||
|
version 1.0.0, July 7th, 2012
|
||||||
|
|
||||||
|
Copyright (C) 2012 Synergy Si Ltd.
|
||||||
|
Copyright (c) 2012 Alex Evans
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Configuration
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Determine endianness
|
||||||
|
**/
|
||||||
|
#if defined(USYNERGY_LITTLE_ENDIAN) && defined(USYNERGY_BIG_ENDIAN)
|
||||||
|
/* Ambiguous: both endians specified */
|
||||||
|
#error "Can't define both USYNERGY_LITTLE_ENDIAN and USYNERGY_BIG_ENDIAN"
|
||||||
|
#elif !defined(USYNERGY_LITTLE_ENDIAN) && !defined(USYNERGY_BIG_ENDIAN)
|
||||||
|
/* Attempt to auto detect */
|
||||||
|
#if defined(__LITTLE_ENDIAN__) || defined(LITTLE_ENDIAN) || (_BYTE_ORDER == _LITTLE_ENDIAN)
|
||||||
|
#define USYNERGY_LITTLE_ENDIAN
|
||||||
|
#elif defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN) || (_BYTE_ORDER == _BIG_ENDIAN)
|
||||||
|
#define USYNERGY_BIG_ENDIAN
|
||||||
|
#else
|
||||||
|
#error "Can't detect endian-nes, please defined either USYNERGY_LITTLE_ENDIAN or USYNERGY_BIG_ENDIAN";
|
||||||
|
#endif
|
||||||
|
#else
|
||||||
|
/* User-specified endian-nes, nothing to do for us */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Types and Constants
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Boolean type
|
||||||
|
**/
|
||||||
|
typedef int uSynergyBool;
|
||||||
|
#define USYNERGY_FALSE 0 /* False value */
|
||||||
|
#define USYNERGY_TRUE 1 /* True value */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief User context type
|
||||||
|
|
||||||
|
The uSynergyCookie type is an opaque type that is used by uSynergy to communicate to the client. It is passed along to
|
||||||
|
callback functions as context.
|
||||||
|
**/
|
||||||
|
typedef struct { int ignored; } * uSynergyCookie;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Clipboard types
|
||||||
|
**/
|
||||||
|
enum uSynergyClipboardFormat
|
||||||
|
{
|
||||||
|
USYNERGY_CLIPBOARD_FORMAT_TEXT = 0, /* Text format, UTF-8, newline is LF */
|
||||||
|
USYNERGY_CLIPBOARD_FORMAT_BITMAP = 1, /* Bitmap format, BMP 24/32bpp, BI_RGB */
|
||||||
|
USYNERGY_CLIPBOARD_FORMAT_HTML = 2, /* HTML format, HTML fragment, UTF-8, newline is LF */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Constants and limits
|
||||||
|
**/
|
||||||
|
#define USYNERGY_NUM_JOYSTICKS 4 /* Maximum number of supported joysticks */
|
||||||
|
|
||||||
|
#define USYNERGY_PROTOCOL_MAJOR 1 /* Major protocol version */
|
||||||
|
#define USYNERGY_PROTOCOL_MINOR 4 /* Minor protocol version */
|
||||||
|
|
||||||
|
#define USYNERGY_IDLE_TIMEOUT 2000 /* Timeout in milliseconds before reconnecting */
|
||||||
|
|
||||||
|
#define USYNERGY_TRACE_BUFFER_SIZE 1024 /* Maximum length of traced message */
|
||||||
|
#define USYNERGY_REPLY_BUFFER_SIZE 1024 /* Maximum size of a reply packet */
|
||||||
|
#define USYNERGY_RECEIVE_BUFFER_SIZE 4096 /* Maximum size of an incoming packet */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Keyboard constants
|
||||||
|
**/
|
||||||
|
#define USYNERGY_MODIFIER_SHIFT 0x0001 /* Shift key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_CTRL 0x0002 /* Ctrl key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_ALT 0x0004 /* Alt key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_META 0x0008 /* Meta key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_WIN 0x0010 /* Windows key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_ALT_GR 0x0020 /* AltGr key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_LEVEL5LOCK 0x0040 /* Level5Lock key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_CAPSLOCK 0x1000 /* CapsLock key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_NUMLOCK 0x2000 /* NumLock key modifier */
|
||||||
|
#define USYNERGY_MODIFIER_SCROLLOCK 0x4000 /* ScrollLock key modifier */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Functions and Callbacks
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Connect function
|
||||||
|
|
||||||
|
This function is called when uSynergy needs to connect to the host. It doesn't imply a network implementation or
|
||||||
|
destination address, that must all be handled on the user side. The function should return USYNERGY_TRUE if a
|
||||||
|
connection was established or USYNERGY_FALSE if it could not connect.
|
||||||
|
|
||||||
|
When network errors occur (e.g. uSynergySend or uSynergyReceive fail) then the connect call will be called again
|
||||||
|
so the implementation of the function must close any old connections and clean up resources before retrying.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
**/
|
||||||
|
typedef uSynergyBool (*uSynergyConnectFunc)(uSynergyCookie cookie);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Send function
|
||||||
|
|
||||||
|
This function is called when uSynergy needs to send something over the default connection. It should return
|
||||||
|
USYNERGY_TRUE if sending succeeded and USYNERGY_FALSE otherwise. This function should block until the send
|
||||||
|
operation is completed.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param buffer Address of buffer to send
|
||||||
|
@param length Length of buffer to send
|
||||||
|
**/
|
||||||
|
typedef uSynergyBool (*uSynergySendFunc)(uSynergyCookie cookie, const uint8_t *buffer, int length);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Receive function
|
||||||
|
|
||||||
|
This function is called when uSynergy needs to receive data from the default connection. It should return
|
||||||
|
USYNERGY_TRUE if receiving data succeeded and USYNERGY_FALSE otherwise. This function should block until data
|
||||||
|
has been received and wait for data to become available. If @a outLength is set to 0 upon completion it is
|
||||||
|
assumed that the connection is alive, but still in a connecting state and needs time to settle.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param buffer Address of buffer to receive data into
|
||||||
|
@param maxLength Maximum amount of bytes to write into the receive buffer
|
||||||
|
@param outLength Address of integer that receives the actual amount of bytes written into @a buffer
|
||||||
|
**/
|
||||||
|
typedef uSynergyBool (*uSynergyReceiveFunc)(uSynergyCookie cookie, uint8_t *buffer, int maxLength, int* outLength);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Thread sleep function
|
||||||
|
|
||||||
|
This function is called when uSynergy wants to suspend operation for a while before retrying an operation. It
|
||||||
|
is mostly used when a socket times out or disconnect occurs to prevent uSynergy from continuously hammering a
|
||||||
|
network connection in case the network is down.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param timeMs Time to sleep the current thread (in milliseconds)
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergySleepFunc)(uSynergyCookie cookie, int timeMs);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Get time function
|
||||||
|
|
||||||
|
This function is called when uSynergy needs to know the current time. This is used to determine when timeouts
|
||||||
|
have occured. The time base should be a cyclic millisecond time value.
|
||||||
|
|
||||||
|
@returns Time value in milliseconds
|
||||||
|
**/
|
||||||
|
typedef uint32_t (*uSynergyGetTimeFunc)();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Trace function
|
||||||
|
|
||||||
|
This function is called when uSynergy wants to trace something. It is optional to show these messages, but they
|
||||||
|
are often useful when debugging. uSynergy only traces major events like connecting and disconnecting. Usually
|
||||||
|
only a single trace is shown when the connection is established and no more trace are called.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param text Text to be traced
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergyTraceFunc)(uSynergyCookie cookie, const char *text);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Screen active callback
|
||||||
|
|
||||||
|
This callback is called when Synergy makes the screen active or inactive. This
|
||||||
|
callback is usually sent when the mouse enters or leaves the screen.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param active Activation flag, 1 if the screen has become active, 0 if the screen has become inactive
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergyScreenActiveCallback)(uSynergyCookie cookie, uSynergyBool active);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Mouse callback
|
||||||
|
|
||||||
|
This callback is called when a mouse events happens. The mouse X and Y position,
|
||||||
|
wheel and button state is communicated in the message. It's up to the user to
|
||||||
|
interpret if this is a mouse up, down, double-click or other message.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param x Mouse X position
|
||||||
|
@param y Mouse Y position
|
||||||
|
@param wheelX Mouse wheel X position
|
||||||
|
@param wheelY Mouse wheel Y position
|
||||||
|
@param buttonLeft Left button pressed status, 0 for released, 1 for pressed
|
||||||
|
@param buttonMiddle Middle button pressed status, 0 for released, 1 for pressed
|
||||||
|
@param buttonRight Right button pressed status, 0 for released, 1 for pressed
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergyMouseCallback)(uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Key event callback
|
||||||
|
|
||||||
|
This callback is called when a key is pressed or released.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param key Key code of key that was pressed or released
|
||||||
|
@param modifiers Status of modifier keys (alt, shift, etc.)
|
||||||
|
@param down Down or up status, 1 is key is pressed down, 0 if key is released (up)
|
||||||
|
@param repeat Repeat flag, 1 if the key is down because the key is repeating, 0 if the key is initially pressed by the user
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergyKeyboardCallback)(uSynergyCookie cookie, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Joystick event callback
|
||||||
|
|
||||||
|
This callback is called when a joystick stick or button changes. It is possible that multiple callbacks are
|
||||||
|
fired when different sticks or buttons change as these are individual messages in the packet stream. Each
|
||||||
|
callback will contain all the valid state for the different axes and buttons. The last callback received will
|
||||||
|
represent the most current joystick state.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param joyNum Joystick number, always in the range [0 ... USYNERGY_NUM_JOYSTICKS>
|
||||||
|
@param buttons Button pressed mask
|
||||||
|
@param leftStickX Left stick X position, in range [-127 ... 127]
|
||||||
|
@param leftStickY Left stick Y position, in range [-127 ... 127]
|
||||||
|
@param rightStickX Right stick X position, in range [-127 ... 127]
|
||||||
|
@param rightStickY Right stick Y position, in range [-127 ... 127]
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergyJoystickCallback)(uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Clipboard event callback
|
||||||
|
|
||||||
|
This callback is called when something is placed on the clipboard. Multiple callbacks may be fired for
|
||||||
|
multiple clipboard formats if they are supported. The data provided is read-only and may not be modified
|
||||||
|
by the application.
|
||||||
|
|
||||||
|
@param cookie Cookie supplied in the Synergy context
|
||||||
|
@param format Clipboard format
|
||||||
|
@param data Memory area containing the clipboard raw data
|
||||||
|
@param size Size of clipboard data
|
||||||
|
**/
|
||||||
|
typedef void (*uSynergyClipboardCallback)(uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Context
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief uSynergy context
|
||||||
|
**/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
/* Mandatory configuration data, filled in by client */
|
||||||
|
uSynergyConnectFunc m_connectFunc; /* Connect function */
|
||||||
|
uSynergySendFunc m_sendFunc; /* Send data function */
|
||||||
|
uSynergyReceiveFunc m_receiveFunc; /* Receive data function */
|
||||||
|
uSynergySleepFunc m_sleepFunc; /* Thread sleep function */
|
||||||
|
uSynergyGetTimeFunc m_getTimeFunc; /* Get current time function */
|
||||||
|
const char* m_clientName; /* Name of Synergy Screen / Client */
|
||||||
|
uint16_t m_clientWidth; /* Width of screen */
|
||||||
|
uint16_t m_clientHeight; /* Height of screen */
|
||||||
|
|
||||||
|
/* Optional configuration data, filled in by client */
|
||||||
|
uSynergyCookie m_cookie; /* Cookie pointer passed to callback functions (can be NULL) */
|
||||||
|
uSynergyTraceFunc m_traceFunc; /* Function for tracing status (can be NULL) */
|
||||||
|
uSynergyScreenActiveCallback m_screenActiveCallback; /* Callback for entering and leaving screen */
|
||||||
|
uSynergyMouseCallback m_mouseCallback; /* Callback for mouse events */
|
||||||
|
uSynergyKeyboardCallback m_keyboardCallback; /* Callback for keyboard events */
|
||||||
|
uSynergyJoystickCallback m_joystickCallback; /* Callback for joystick events */
|
||||||
|
uSynergyClipboardCallback m_clipboardCallback; /* Callback for clipboard events */
|
||||||
|
|
||||||
|
/* State data, used internall by client, initialized by uSynergyInit() */
|
||||||
|
uSynergyBool m_connected; /* Is our socket connected? */
|
||||||
|
uSynergyBool m_hasReceivedHello; /* Have we received a 'Hello' from the server? */
|
||||||
|
uSynergyBool m_isCaptured; /* Is Synergy active (i.e. this client is receiving input messages?) */
|
||||||
|
uint32_t m_lastMessageTime; /* Time at which last message was received */
|
||||||
|
uint32_t m_sequenceNumber; /* Packet sequence number */
|
||||||
|
uint8_t m_receiveBuffer[USYNERGY_RECEIVE_BUFFER_SIZE]; /* Receive buffer */
|
||||||
|
int m_receiveOfs; /* Receive buffer offset */
|
||||||
|
uint8_t m_replyBuffer[USYNERGY_REPLY_BUFFER_SIZE]; /* Reply buffer */
|
||||||
|
uint8_t* m_replyCur; /* Write offset into reply buffer */
|
||||||
|
uint16_t m_mouseX; /* Mouse X position */
|
||||||
|
uint16_t m_mouseY; /* Mouse Y position */
|
||||||
|
int16_t m_mouseWheelX; /* Mouse wheel X position */
|
||||||
|
int16_t m_mouseWheelY; /* Mouse wheel Y position */
|
||||||
|
uSynergyBool m_mouseButtonLeft; /* Mouse left button */
|
||||||
|
uSynergyBool m_mouseButtonRight; /* Mouse right button */
|
||||||
|
uSynergyBool m_mouseButtonMiddle; /* Mouse middle button */
|
||||||
|
int8_t m_joystickSticks[USYNERGY_NUM_JOYSTICKS][4]; /* Joystick stick position in 2 axes for 2 sticks */
|
||||||
|
uint16_t m_joystickButtons[USYNERGY_NUM_JOYSTICKS]; /* Joystick button state */
|
||||||
|
} uSynergyContext;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
// Interface
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Initialize uSynergy context
|
||||||
|
|
||||||
|
This function initializes @a context for use. Call this function directly after
|
||||||
|
creating the context, before filling in any configuration data in it. Not calling
|
||||||
|
this function will cause undefined behavior.
|
||||||
|
|
||||||
|
@param context Context to be initialized
|
||||||
|
**/
|
||||||
|
extern void uSynergyInit(uSynergyContext *context);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Update uSynergy
|
||||||
|
|
||||||
|
This function updates uSynergy and does the bulk of the work. It does connection management,
|
||||||
|
receiving data, reconnecting after errors or timeouts and so on. It assumes that networking
|
||||||
|
operations are blocking and it can suspend the current thread if it needs to wait. It is
|
||||||
|
best practice to call uSynergyUpdate from a background thread so it is responsive.
|
||||||
|
|
||||||
|
Because uSynergy relies mostly on blocking calls it will mostly stay in thread sleep state
|
||||||
|
waiting for system mutexes and won't eat much memory.
|
||||||
|
|
||||||
|
uSynergyUpdate doesn't do any memory allocations or have any side effects beyond those of
|
||||||
|
the callbacks it calls.
|
||||||
|
|
||||||
|
@param context Context to be updated
|
||||||
|
**/
|
||||||
|
extern void uSynergyUpdate(uSynergyContext *context);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief Send clipboard data
|
||||||
|
|
||||||
|
This function sets new clipboard data and sends it to the server. Use this function if
|
||||||
|
your client cuts or copies data onto the clipboard that it needs to share with the
|
||||||
|
server.
|
||||||
|
|
||||||
|
Currently there is only support for plaintext, but HTML and image data could be
|
||||||
|
supported with some effort.
|
||||||
|
|
||||||
|
@param context Context to send clipboard data to
|
||||||
|
@param text Text to set to the clipboard
|
||||||
|
**/
|
||||||
|
extern void uSynergySendClipboard(uSynergyContext *context, const char *text);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
};
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user