Better Scroll and vKeyboard

This commit is contained in:
CT5
2025-11-12 18:50:24 +11:00
parent 1fe65d4d62
commit 13f24e788a
5 changed files with 38 additions and 25 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "common", "dlls\common\commo
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XFrontPanelDisplay", "dlls\XFrontPanelDisplay\XFrontPanelDisplay.vcxproj", "{4A5072B4-8304-4CC4-88C1-CF875110FF47}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XAudio2_9", "dlls\XAudio2_9\XAudio2_9.vcxproj", "{0C02E6B1-4532-4194-8891-11DDC164C0A8}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "XAudio2_9_x", "dlls\XAudio2_9\XAudio2_9.vcxproj", "{0C02E6B1-4532-4194-8891-11DDC164C0A8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Detours", "thirdparty\Detours\vc\Detours.vcxproj", "{37489709-8054-4903-9C49-A79846049FC9}"
EndProject
+19 -3
View File
@@ -104,12 +104,12 @@ void SetupImGuiKeyboardInputUWP()
if (key != ImGuiKey_None)
ImGui::GetIO().AddKeyEvent(key, false);
}));
/*
window.CharacterReceived(TypedEventHandler<CoreWindow, CharacterReceivedEventArgs>(
[](CoreWindow const&, CharacterReceivedEventArgs const& args)
{
ImGui::GetIO().AddInputCharacter(static_cast<unsigned int>(args.KeyCode()));
}));
}));*/
}
ImGuiKey MapVirtualKeyToImGuiKey(VirtualKey key)
{
@@ -280,7 +280,7 @@ void wd::Overlay::RenderKeyboardWindow( )
ImGui::PushStyleColor(ImGuiCol_Button, IM_COL32(0x37, 0x37, 0x37, 0xFF));
ImGui::PushItemWidth(-FLT_MIN);
ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0x05, 0x05, 0x05, 0xFF));
ImGui::InputText("", g_KeyboardText, IM_ARRAYSIZE(g_KeyboardText), ImGuiInputTextFlags_CallbackAlways,
ImGui::InputText("", g_KeyboardText, IM_ARRAYSIZE(g_KeyboardText), ImGuiInputTextFlags_CallbackAlways | ImGuiInputTextFlags_ReadOnly,
[](ImGuiInputTextCallbackData* data) -> int {
data->CursorPos = cursorPos;
return 0;
@@ -511,6 +511,22 @@ void wd::Overlay::RenderKeyboardWindow( )
ImGui::PopStyleColor( );
ImGui::End( );
ImGui::PopStyleColor( );
for (int i = 0; i < io.InputQueueCharacters.Size; i++)
{
ImWchar c = io.InputQueueCharacters[ i ];
if (c >= 32 && c < 127)
{
size_t len = strlen(g_KeyboardText);
if (len + 1 < IM_ARRAYSIZE(g_KeyboardText))
{
g_KeyboardText[ len ] = (char) c;
g_KeyboardText[ len + 1 ] = '\0';
cursorPos++;
}
}
}
io.InputQueueCharacters.clear( );
}
void wd::Overlay::RenderKeyboardRow(const char** keys, int start, int end, bool isUppercase)
@@ -8,6 +8,7 @@
#include <winrt/Windows.UI.Input.h>
#include <windowsx.h>
#include <Xinput.h>
#include <iostream>
#include "Windows.Xbox.System.User.h"
#include "../WinDurangoConfig.h"
@@ -59,8 +60,15 @@ namespace winrt::Windows::Xbox::Input::implementation
[&](winrt::Windows::UI::Core::CoreWindow const&, winrt::Windows::UI::Core::PointerEventArgs const& args)
{
auto delta = args.CurrentPoint().Properties().MouseWheelDelta();
int scrollUnits = delta / 120.0f;
Gamepad::currNeed += scrollUnits;
float scrollUnits = delta / 120.0f;
if (scrollUnits < 1 && scrollUnits > 0.1f) {
Gamepad::currNeed += 1;
}
else if (scrollUnits > -1 && scrollUnits < -0.1f) {
Gamepad::currNeed -= 1;
} else {
Gamepad::currNeed += (int)scrollUnits;
}
LOG_INFO_W((L"Wheel delta: " + std::to_wstring(scrollUnits) + L"\n").c_str());
}
)
@@ -157,6 +165,7 @@ namespace winrt::Windows::Xbox::Input::implementation
winrt::Windows::Xbox::Input::RawGamepadReading Gamepad::GetRawCurrentReading()
{
XINPUT_STATE xiState;
ZeroMemory(&xiState, sizeof(XINPUT_STATE));
reading = {};
@@ -310,23 +319,13 @@ namespace winrt::Windows::Xbox::Input::implementation
deltasumY = 0.0f;
if (currNeed != 0) {
if (!isCtrl) {
isCtrl = true;
if (currNeed > 0) {
reading.Buttons |= GamepadButtons::RightShoulder;
}
else if (currNeed < 0) {
reading.Buttons |= GamepadButtons::LeftShoulder;
}
if (currNeed > 0) {
reading.Buttons |= GamepadButtons::RightShoulder;
currNeed--;
}
else {
isCtrl = false;
if (currNeed > 0) {
currNeed--;
}
else if (currNeed < 0) {
currNeed++;
}
else if (currNeed < 0) {
reading.Buttons |= GamepadButtons::LeftShoulder;
currNeed++;
}
}
@@ -60,9 +60,7 @@ namespace winrt::Windows::Xbox::Input::implementation
bool firstFrame = true;
bool menuOpened = false;
WinDurangoConfig& wdcfg;
bool isCtrl = false;
static int currNeed;
int currDone;
static bool isMC;
inline static std::pair<WORD, GamepadButtons> const gamepadButtons[] =
+1 -1
View File
@@ -158,7 +158,7 @@
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">xinput.lib;shell32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies Condition="'$(Configuration)|$(Platform)'=='Release|x64'">xinput.lib;shell32.lib;$(SolutionDir)thirdparty\Detours\lib.X64\detours.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>