├── res ├── resource.h ├── resource.rc ├── resource.rc2 ├── shader_copy_ps.hlsl ├── shader_fullscreen_vs.hlsl ├── shader_imgui_ps.hlsl ├── shader_mipmap_cs.hlsl └── shader_imgui_vs.hlsl ├── tools ├── 7za.exe ├── verbuild.exe └── fxc.cpp ├── source ├── input.cpp ├── resource_loading.hpp ├── d3d9 │ ├── state_block.hpp │ ├── d3d9_profiling.cpp │ ├── state_block.cpp │ ├── d3d9_swapchain.hpp │ ├── runtime_d3d9.hpp │ └── d3d9_swapchain.cpp ├── moving_average.hpp ├── resource_loading.cpp ├── opengl │ ├── state_block.hpp │ ├── runtime_opengl.hpp │ └── state_block.cpp ├── gui_widgets.hpp ├── dxgi │ ├── dxgi_d3d10.cpp │ ├── dxgi_device.hpp │ ├── format_utils.hpp │ ├── dxgi_swapchain.hpp │ └── dxgi_device.cpp ├── hook.cpp ├── log.cpp ├── hook.hpp ├── d3d10 │ ├── state_block.hpp │ ├── draw_call_tracker.hpp │ ├── runtime_d3d10.hpp │ ├── state_block.cpp │ └── d3d10.cpp ├── update_check.cpp ├── log.hpp ├── d3d11 │ ├── state_block.hpp │ ├── draw_call_tracker.hpp │ ├── runtime_d3d11.hpp │ └── d3d11.cpp ├── input.hpp ├── windows │ ├── user32.cpp │ └── ws2_32.cpp ├── d3d12 │ ├── d3d12_command_queue.hpp │ ├── runtime_d3d12.hpp │ ├── d3d12.cpp │ └── d3d12_command_queue.cpp ├── effect_symbol_table.hpp ├── hook_manager.hpp ├── effect_parser.hpp ├── ini_file.cpp ├── com_ptr.hpp ├── effect_preprocessor.hpp ├── runtime_objects.hpp ├── gui_code_editor.hpp └── ini_file.hpp ├── setup ├── Properties │ ├── Icon.ico │ ├── App.xaml │ ├── AssemblyInfo.cs │ └── Assembly.manifest ├── FodyWeavers.xml ├── Packages.config ├── IniFile.cs ├── Select.xaml ├── Select.xaml.cs ├── Wizard.xaml ├── Settings.xaml ├── Glass.cs ├── PEInfo.cs └── Settings.xaml.cs ├── .editorconfig ├── deps ├── stb_impl.c ├── Windows.props ├── gl3w.props ├── utfcpp.props ├── MinHook.props ├── SPIRV.props ├── stb.props ├── ImGui.props ├── MinHook.vcxproj.filters ├── stb.vcxproj ├── MinHook.vcxproj ├── ImGui.vcxproj └── gl3w.vcxproj ├── ReShadeFXC.vcxproj.filters ├── Common.props ├── .gitignore ├── .gitmodules ├── ReShadeFX.vcxproj.filters ├── LICENSE.md └── README.md /res/resource.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/res/resource.h -------------------------------------------------------------------------------- /res/resource.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/res/resource.rc -------------------------------------------------------------------------------- /tools/7za.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/tools/7za.exe -------------------------------------------------------------------------------- /res/resource.rc2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/res/resource.rc2 -------------------------------------------------------------------------------- /source/input.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/source/input.cpp -------------------------------------------------------------------------------- /tools/verbuild.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/tools/verbuild.exe -------------------------------------------------------------------------------- /setup/Properties/Icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/0101011/reshade/master/setup/Properties/Icon.ico -------------------------------------------------------------------------------- /setup/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_size = 4 5 | indent_style = tab 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | -------------------------------------------------------------------------------- /setup/Properties/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /res/shader_copy_ps.hlsl: -------------------------------------------------------------------------------- 1 | Texture2D t0 : register(t0); 2 | SamplerState s0 : register(s0); 3 | 4 | void main(float4 vpos : SV_POSITION, float2 uv : TEXCOORD0, out float4 col : SV_TARGET) 5 | { 6 | col = t0.Sample(s0, uv); 7 | col.a = 1.0; // Clear alpha channel 8 | } 9 | -------------------------------------------------------------------------------- /res/shader_fullscreen_vs.hlsl: -------------------------------------------------------------------------------- 1 | void main(uint id : SV_VERTEXID, out float4 pos : SV_POSITION, out float2 uv : TEXCOORD0) 2 | { 3 | uv.x = (id == 2) ? 2.0 : 0.0; 4 | uv.y = (id == 1) ? 2.0 : 0.0; 5 | pos = float4(uv * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0); 6 | } 7 | -------------------------------------------------------------------------------- /res/shader_imgui_ps.hlsl: -------------------------------------------------------------------------------- 1 | Texture2D t0 : register(t0); 2 | SamplerState s0 : register(s0); 3 | 4 | void main(float4 vpos : SV_POSITION, float4 vcol : COLOR0, float2 uv : TEXCOORD0, out float4 col : SV_TARGET) 5 | { 6 | col = t0.Sample(s0, uv); 7 | col *= vcol; // Blend vertex color and texture 8 | } 9 | -------------------------------------------------------------------------------- /deps/stb_impl.c: -------------------------------------------------------------------------------- 1 | #define STB_IMAGE_IMPLEMENTATION 2 | #define STB_IMAGE_DDS_IMPLEMENTATION 3 | #define STB_IMAGE_WRITE_IMPLEMENTATION 4 | #define STB_IMAGE_RESIZE_IMPLEMENTATION 5 | 6 | #include "stb_image.h" 7 | #include "stb_image_dds.h" 8 | #include "stb_image_write.h" 9 | #include "stb_image_resize.h" 10 | -------------------------------------------------------------------------------- /ReShadeFXC.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /setup/Packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /deps/Windows.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Shlwapi.lib;WinInet.lib;%(AdditionalDependencies) 7 | 8 | 9 | -------------------------------------------------------------------------------- /setup/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("ReShade Setup")] 4 | [assembly: AssemblyVersion("2.0.0.0")] 5 | [assembly: AssemblyDescription("")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("crosire")] 8 | [assembly: AssemblyProduct("ReShade")] 9 | [assembly: AssemblyCopyright("Copyright © 2014. All rights reserved.")] 10 | -------------------------------------------------------------------------------- /Common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | $(SolutionDir)bin\$(Platform)\$(Configuration)\ 6 | $(SolutionDir)intermediate\$(ProjectName)\$(Platform)\$(Configuration)\ 7 | 8 | 9 | -------------------------------------------------------------------------------- /deps/gl3w.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)deps\gl3w\include;%(AdditionalIncludeDirectories) 7 | 8 | 9 | -------------------------------------------------------------------------------- /deps/utfcpp.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)deps\utfcpp\source;%(AdditionalIncludeDirectories) 7 | 8 | 9 | -------------------------------------------------------------------------------- /deps/MinHook.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)deps\minhook\include;%(AdditionalIncludeDirectories) 7 | 8 | 9 | -------------------------------------------------------------------------------- /deps/SPIRV.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)deps\spirv\include\spirv\unified1;%(AdditionalIncludeDirectories) 7 | 8 | 9 | -------------------------------------------------------------------------------- /res/shader_mipmap_cs.hlsl: -------------------------------------------------------------------------------- 1 | SamplerState s0 : register(s0); 2 | Texture2D t0 : register(t0); 3 | RWTexture2D dest : register(u0); 4 | 5 | cbuffer cb0 : register(b0) 6 | { 7 | float2 texel; // 1.0 / dimension 8 | } 9 | 10 | [numthreads(8, 8, 1)] 11 | void main(uint3 tid : SV_DispatchThreadID) 12 | { 13 | float2 uv = texel * (tid.xy + 0.5); 14 | 15 | // Sample input texture and write result to the destination mipmap level 16 | dest[tid.xy] = t0.SampleLevel(s0, uv, 0); 17 | } 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build results 2 | [Bb]in/ 3 | [Oo]bj/ 4 | [Ii]ntermediate/ 5 | [Bb]uild/ 6 | [Dd]ebug/ 7 | [Rr]elease/ 8 | *.obj 9 | *.cso 10 | 11 | # Visual Studio cache files 12 | .vs/ 13 | ipch/ 14 | packages/ 15 | *.aps 16 | *.VC.db 17 | *.VC.opendb 18 | *.sdf 19 | *.opensdf 20 | *.suo 21 | *.vcxproj.user 22 | 23 | # Visual Studio performance profiling 24 | *.vsp 25 | *.psess 26 | 27 | # Code signing 28 | *.pfx 29 | *.pvk 30 | 31 | # Temporary OS files 32 | .DS_Store 33 | Thumbs.db 34 | 35 | # Versioning 36 | /res/Version.h 37 | -------------------------------------------------------------------------------- /res/shader_imgui_vs.hlsl: -------------------------------------------------------------------------------- 1 | struct VS_INPUT 2 | { 3 | float2 pos : POSITION; 4 | float4 col : COLOR0; 5 | float2 tex : TEXCOORD0; 6 | }; 7 | struct PS_INPUT 8 | { 9 | float4 pos : SV_POSITION; 10 | float4 col : COLOR0; 11 | float2 tex : TEXCOORD0; 12 | }; 13 | 14 | cbuffer cb0 : register(b0) 15 | { 16 | float4x4 ProjectionMatrix; 17 | }; 18 | 19 | void main(VS_INPUT input, out PS_INPUT output) 20 | { 21 | output.pos = mul(ProjectionMatrix, float4(input.pos.xy, 0.0, 1.0)); 22 | output.col = input.col; 23 | output.tex = input.tex; 24 | } 25 | -------------------------------------------------------------------------------- /deps/stb.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)deps\stb;$(SolutionDir)deps\stb_image_dds;%(AdditionalIncludeDirectories) 7 | _CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 8 | 9 | 10 | -------------------------------------------------------------------------------- /deps/ImGui.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $(SolutionDir)deps\imgui;%(AdditionalIncludeDirectories) 7 | IMGUI_DEFINE_MATH_OPERATORS;IMGUI_DISABLE_OBSOLETE_FUNCTIONS;%(PreprocessorDefinitions) 8 | 9 | 10 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "imgui"] 2 | path = deps/imgui 3 | url = https://github.com/ocornut/imgui.git 4 | [submodule "minhook"] 5 | path = deps/minhook 6 | url = https://github.com/TsudaKageyu/minhook.git 7 | [submodule "stb"] 8 | path = deps/stb 9 | url = https://github.com/nothings/stb.git 10 | [submodule "gl3w"] 11 | path = deps/gl3w 12 | url = https://github.com/skaslev/gl3w.git 13 | [submodule "utfcpp"] 14 | path = deps/utfcpp 15 | url = https://github.com/nemtrif/utfcpp 16 | [submodule "spirv"] 17 | path = deps/spirv 18 | url = https://github.com/KhronosGroup/SPIRV-Headers/ 19 | -------------------------------------------------------------------------------- /source/resource_loading.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "resource.h" 9 | 10 | namespace reshade::resources 11 | { 12 | struct data_resource 13 | { 14 | size_t data_size; 15 | const void *data; 16 | }; 17 | struct image_resource : public data_resource 18 | { 19 | unsigned int width, height, bits_per_pixel; 20 | }; 21 | 22 | data_resource load_data_resource(unsigned int id); 23 | image_resource load_image_resource(unsigned int id); 24 | } 25 | -------------------------------------------------------------------------------- /source/d3d9/state_block.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "com_ptr.hpp" 9 | #include 10 | 11 | namespace reshade::d3d9 12 | { 13 | class state_block 14 | { 15 | public: 16 | explicit state_block(IDirect3DDevice9 *device); 17 | ~state_block(); 18 | 19 | bool init_state_block(); 20 | void release_state_block(); 21 | 22 | void capture(); 23 | void apply_and_release(); 24 | 25 | private: 26 | void release_all_device_objects(); 27 | 28 | com_ptr _device; 29 | com_ptr _state_block; 30 | UINT _num_simultaneous_rendertargets; 31 | D3DVIEWPORT9 _viewport; 32 | com_ptr _depth_stencil; 33 | com_ptr _render_targets[8]; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /source/moving_average.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #pragma once 7 | 8 | template 9 | class moving_average 10 | { 11 | public: 12 | moving_average() : _index(0), _average(0), _tick_sum(0), _tick_list() { } 13 | 14 | inline operator T() const { return _average; } 15 | 16 | void clear() 17 | { 18 | _index = 0; 19 | _average = 0; 20 | _tick_sum = 0; 21 | 22 | for (size_t i = 0; i < SAMPLES; i++) 23 | { 24 | _tick_list[i] = 0; 25 | } 26 | } 27 | void append(T value) 28 | { 29 | _tick_sum -= _tick_list[_index]; 30 | _tick_sum += _tick_list[_index] = value; 31 | _index = ++_index % SAMPLES; 32 | _average = _tick_sum / SAMPLES; 33 | } 34 | 35 | private: 36 | size_t _index; 37 | T _average, _tick_sum, _tick_list[SAMPLES]; 38 | }; 39 | -------------------------------------------------------------------------------- /setup/IniFile.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | using System.Runtime.InteropServices; 3 | 4 | public static class IniFile 5 | { 6 | [DllImport("kernel32", CharSet = CharSet.Unicode)] 7 | private static extern int GetPrivateProfileString(string section, string key, string defaultValue, StringBuilder value, int size, string filePath); 8 | [DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)] 9 | [return: MarshalAs(UnmanagedType.Bool)] 10 | private static extern bool WritePrivateProfileString(string section, string key, string value, string filePath); 11 | 12 | public static string ReadValue(string file, string section, string key, string defaultValue = "") 13 | { 14 | var value = new StringBuilder(512); 15 | GetPrivateProfileString(section, key, defaultValue, value, value.Capacity, file); 16 | return value.ToString(); 17 | } 18 | public static bool WriteValue(string file, string section, string key, string value) 19 | { 20 | return WritePrivateProfileString(section, key, value, file); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /setup/Properties/Assembly.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /ReShadeFX.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /source/resource_loading.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #include "resource_loading.hpp" 7 | #include 8 | 9 | extern HMODULE g_module_handle; 10 | 11 | reshade::resources::data_resource reshade::resources::load_data_resource(unsigned int id) 12 | { 13 | const HRSRC info = FindResource(g_module_handle, MAKEINTRESOURCE(id), RT_RCDATA); 14 | const HGLOBAL handle = LoadResource(g_module_handle, info); 15 | 16 | data_resource result; 17 | result.data = LockResource(handle); 18 | result.data_size = SizeofResource(g_module_handle, info); 19 | 20 | return result; 21 | } 22 | reshade::resources::image_resource reshade::resources::load_image_resource(unsigned int id) 23 | { 24 | DIBSECTION dib = {}; 25 | const HANDLE handle = LoadImage(g_module_handle, MAKEINTRESOURCE(id), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); 26 | GetObject(handle, sizeof(dib), &dib); 27 | 28 | image_resource result; 29 | result.width = dib.dsBm.bmWidth; 30 | result.height = dib.dsBm.bmHeight; 31 | result.bits_per_pixel = dib.dsBm.bmBitsPixel; 32 | result.data = dib.dsBm.bmBits; 33 | result.data_size = dib.dsBmih.biSizeImage; 34 | 35 | return result; 36 | } 37 | -------------------------------------------------------------------------------- /setup/Select.xaml: -------------------------------------------------------------------------------- 1 | 10 | 11 | 88 | -------------------------------------------------------------------------------- /source/d3d11/state_block.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "com_ptr.hpp" 9 | #include 10 | 11 | namespace reshade::d3d11 12 | { 13 | class state_block 14 | { 15 | public: 16 | explicit state_block(ID3D11Device *device); 17 | ~state_block(); 18 | 19 | void capture(ID3D11DeviceContext *devicecontext); 20 | void apply_and_release(); 21 | 22 | private: 23 | void release_all_device_objects(); 24 | 25 | D3D_FEATURE_LEVEL _device_feature_level; 26 | com_ptr _device; 27 | com_ptr _device_context; 28 | ID3D11InputLayout *_ia_input_layout; 29 | D3D11_PRIMITIVE_TOPOLOGY _ia_primitive_topology; 30 | ID3D11Buffer *_ia_vertex_buffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; 31 | UINT _ia_vertex_strides[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; 32 | UINT _ia_vertex_offsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]; 33 | ID3D11Buffer *_ia_index_buffer; 34 | DXGI_FORMAT _ia_index_format; 35 | UINT _ia_index_offset; 36 | ID3D11VertexShader *_vs; 37 | UINT _vs_num_class_instances; 38 | ID3D11ClassInstance *_vs_class_instances[256]; 39 | ID3D11Buffer *_vs_constant_buffers[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; 40 | ID3D11SamplerState *_vs_sampler_states[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; 41 | ID3D11ShaderResourceView *_vs_shader_resources[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; 42 | ID3D11HullShader *_hs; 43 | UINT _hs_num_class_instances; 44 | ID3D11ClassInstance *_hs_class_instances[256]; 45 | ID3D11DomainShader *_ds; 46 | UINT _ds_num_class_instances; 47 | ID3D11ClassInstance *_ds_class_instances[256]; 48 | ID3D11GeometryShader *_gs; 49 | UINT _gs_num_class_instances; 50 | ID3D11ClassInstance *_gs_class_instances[256]; 51 | ID3D11RasterizerState *_rs_state; 52 | UINT _rs_num_viewports; 53 | D3D11_VIEWPORT _rs_viewports[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; 54 | UINT _rs_num_scissor_rects; 55 | D3D11_RECT _rs_scissor_rects[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE]; 56 | ID3D11PixelShader *_ps; 57 | UINT _ps_num_class_instances; 58 | ID3D11ClassInstance *_ps_class_instances[256]; 59 | ID3D11Buffer *_ps_constant_buffers[D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT]; 60 | ID3D11SamplerState *_ps_sampler_states[D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT]; 61 | ID3D11ShaderResourceView *_ps_shader_resources[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT]; 62 | ID3D11BlendState *_om_blend_state; 63 | FLOAT _om_blend_factor[4]; 64 | UINT _om_sample_mask; 65 | ID3D11DepthStencilState *_om_depth_stencil_state; 66 | UINT _om_stencil_ref; 67 | ID3D11RenderTargetView *_om_render_targets[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT]; 68 | ID3D11DepthStencilView *_om_depth_stencil; 69 | }; 70 | } 71 | -------------------------------------------------------------------------------- /source/input.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2014 Patrick Mours. All rights reserved. 3 | * License: https://github.com/crosire/reshade#license 4 | */ 5 | 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace reshade 13 | { 14 | class input 15 | { 16 | public: 17 | using window_handle = void *; 18 | 19 | explicit input(window_handle window); 20 | 21 | static void register_window_with_raw_input(window_handle window, bool no_legacy_keyboard, bool no_legacy_mouse); 22 | static std::shared_ptr register_window(window_handle window); 23 | 24 | bool is_key_down(unsigned int keycode) const; 25 | bool is_key_pressed(unsigned int keycode) const; 26 | bool is_key_pressed(unsigned int keycode, bool ctrl, bool shift, bool alt) const; 27 | bool is_key_pressed(const unsigned int key[4]) const { return is_key_pressed(key[0], key[1] != 0, key[2] != 0, key[3] != 0); } 28 | bool is_key_released(unsigned int keycode) const; 29 | bool is_any_key_down() const; 30 | bool is_any_key_pressed() const; 31 | bool is_any_key_released() const; 32 | unsigned int last_key_pressed() const; 33 | unsigned int last_key_released() const; 34 | bool is_mouse_button_down(unsigned int button) const; 35 | bool is_mouse_button_pressed(unsigned int button) const; 36 | bool is_mouse_button_released(unsigned int button) const; 37 | bool is_any_mouse_button_down() const; 38 | bool is_any_mouse_button_pressed() const; 39 | bool is_any_mouse_button_released() const; 40 | short mouse_wheel_delta() const { return _mouse_wheel_delta; } 41 | int mouse_movement_delta_x() const { return _mouse_position[0] - _last_mouse_position[0]; } 42 | int mouse_movement_delta_y() const { return _mouse_position[1] - _last_mouse_position[1]; } 43 | unsigned int mouse_position_x() const { return _mouse_position[0]; } 44 | unsigned int mouse_position_y() const { return _mouse_position[1]; } 45 | const std::wstring &text_input() const { return _text_input; } 46 | 47 | void block_mouse_input(bool enable); 48 | void block_keyboard_input(bool enable); 49 | 50 | bool is_blocking_mouse_input() const { return _block_mouse; } 51 | bool is_blocking_keyboard_input() const { return _block_keyboard; } 52 | 53 | auto lock() { return std::lock_guard(_mutex); } 54 | void next_frame(); 55 | 56 | static std::string key_name(unsigned int keycode); 57 | static std::string key_name(const unsigned int key[4]); 58 | 59 | static bool handle_window_message(const void *message_data); 60 | 61 | private: 62 | std::mutex _mutex; 63 | window_handle _window; 64 | bool _block_mouse = false, _block_keyboard = false; 65 | uint8_t _keys[256] = {}, _mouse_buttons[5] = {}; 66 | short _mouse_wheel_delta = 0; 67 | unsigned int _mouse_position[2] = {}; 68 | unsigned int _last_mouse_position[2] = {}; 69 | uint64_t _frame_count = 0; 70 | std::wstring _text_input; 71 | }; 72 | } 73 | -------------------------------------------------------------------------------- /setup/Settings.xaml: -------------------------------------------------------------------------------- 1 | 11 | 12 | 13 |