Skip to content

Commit

Permalink
New virtual keyboard code from 1.6.1130
Browse files Browse the repository at this point in the history
  • Loading branch information
Exit-9B committed Dec 6, 2023
1 parent f4e85c8 commit a06f2e3
Show file tree
Hide file tree
Showing 8 changed files with 210 additions and 10 deletions.
3 changes: 3 additions & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ set(SOURCES
include/RE/B/BSStringPool.h
include/RE/B/BSSystemFile.h
include/RE/B/BSSystemFileStorage.h
include/RE/B/BSSystemUtility.h
include/RE/B/BSTAnimationGraphDataChannel.h
include/RE/B/BSTArray.h
include/RE/B/BSTCaseInsensitiveStringMap.h
Expand Down Expand Up @@ -306,6 +307,7 @@ set(SOURCES
include/RE/B/BSWin32KeyboardDevice.h
include/RE/B/BSWin32MouseDevice.h
include/RE/B/BSWin32SaveDataSystemUtility.h
include/RE/B/BSWin32SystemUtility.h
include/RE/B/BSWin32VirtualKeyboardDevice.h
include/RE/B/BSXAudio2GameSound.h
include/RE/B/BSXFlags.h
Expand Down Expand Up @@ -346,6 +348,7 @@ set(SOURCES
include/RE/B/bhkThreadMemorySource.h
include/RE/B/bhkWorld.h
include/RE/B/bhkWorldObject.h
include/RE/C/CCallback.h
include/RE/C/CFilter.h
include/RE/C/CRC.h
include/RE/C/Calendar.h
Expand Down
47 changes: 47 additions & 0 deletions include/RE/B/BSSystemUtility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once

#include "RE/B/BSTEvent.h"

namespace RE
{
class BSSystemEvent;
struct BSGamepadEvent;

class BSSystemUtility :
public BSTEventSink<BSGamepadEvent>, // 000
public BSTEventSource<BSSystemEvent> // 008
{
public:
virtual ~BSSystemUtility(); // 00

// override (BSTEventSink<BSGamepadEvent>)
BSEventNotifyControl ProcessEvent(const BSGamepadEvent* a_event, BSTEventSource<BSGamepadEvent>* a_eventSource); // 01

// add
virtual void GetAuthenticationInfo(char*& userAuthID, std::uint64_t& size); // 02
virtual void Func03(void); // 03
virtual void DoInitialize(); // 04
virtual void Func05(void); // 05
virtual void DoUpdate(); // 06
virtual void Func07(void); // 07
virtual void DoGetUserName(char* buffer, std::uint64_t size); // 08
virtual void Func09(void); // 09
virtual void Func0A(void); // 0A
virtual void Func0B(void); // 0B
virtual void Func0C(void); // 0C
virtual void DoGetComputerName(char* buffer, std::uint64_t size); // 0D
virtual void Func0E(void); // 0E
virtual void Func0F(void); // 0F
virtual void DoAuthenticateUser(); // 10
virtual void Func11(void); // 11
virtual bool Func12(); // 12 - added in 1.6.1130

// members
std::uint64_t unk060[24]; // 060
std::uint8_t unk120; // 120 - added in 1.6.1130
std::uint8_t unk121; // 121 - added in 1.6.1130
std::uint16_t pad122; // 122
std::uint32_t pad124; // 124
};
static_assert(sizeof(BSSystemUtility) == 0x128);
}
18 changes: 15 additions & 3 deletions include/RE/B/BSVirtualKeyboardDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ namespace RE
class BSVirtualKeyboardDevice : public BSKeyboardDevice
{
public:
struct kbInfo
{
using DoneCallback = void(void*, const char*);
using CancelCallback = void();

const char* startingText; // 00
DoneCallback* doneCallback; // 08
CancelCallback* cancelCallback; // 10
void* userParam; // 18
std::uint32_t maxChars; // 20
};

inline static constexpr auto RTTI = RTTI_BSVirtualKeyboardDevice;

~BSVirtualKeyboardDevice() override; // 00
Expand All @@ -16,9 +28,9 @@ namespace RE
void Unk_0A(void) override; // 0A - { return; }

// add
virtual void Unk_0B(void) = 0; // 0B
virtual void Unk_0C(void) = 0; // 0C
virtual void Unk_0D(void) = 0; // 0D
virtual void Start(const kbInfo* info) = 0; // 0B
virtual void Stop() = 0; // 0C
virtual void UserCancelled() = 0; // 0D
};
static_assert(sizeof(BSVirtualKeyboardDevice) == 0x70);
}
66 changes: 66 additions & 0 deletions include/RE/B/BSWin32SystemUtility.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#pragma once

#include "RE/B/BSSystemUtility.h"
#include "RE/B/BSVirtualKeyboardDevice.h"
#include "RE/C/CCallback.h"

class ISteamClient;
class ISteamUtils;
struct EncryptedAppTicketResponse_t;
struct FloatingGamepadTextInputDismissed_t;
struct GameOverlayActivated_t;
struct GamepadTextInputDismissed_t;

using HSteamPipe = std::int32_t;

namespace RE
{
class BSWin32SystemUtility : public BSSystemUtility
{
public:
template <class P>
using SteamCallback = CCallback<BSWin32SystemUtility, P, false>;
template <class P>
using SteamCallResult = CCallResult<BSWin32SystemUtility, P>;

using VirtualKeyboardDoneCallback = void(void*, const char*);
using VirtualKeyboardCancelCallback = void();

virtual ~BSWin32SystemUtility(); // 00

// override (BSSystemUtility)
void GetAuthenticationInfo(char*& userAuthID, std::uint64_t& size) override; // 02
void DoInitialize() override; // 04
void DoUpdate() override; // 06
void DoGetUserName(char* buffer, std::uint64_t size) override; // 08
void DoGetComputerName(char* buffer, std::uint64_t size) override; // 0D
void DoAuthenticateUser() override; // 10
bool Func12() override; // 12

[[nodiscard]] static BSWin32SystemUtility* GetSingleton()
{
using func_t = decltype(&BSWin32SystemUtility::GetSingleton);
REL::Relocation<func_t> func{ Offset::BSWin32SystemUtility::GetSingleton };
return func();
}

// members
SteamCallback<GameOverlayActivated_t> steamcallback_GameOverlayActivated; // 128
SteamCallback<FloatingGamepadTextInputDismissed_t> steamcallback_FloatingGamepadTextInputDismissed; // 150 - added in 1.6.1130
SteamCallback<GamepadTextInputDismissed_t> steamcallback_GamepadTextInputDismissed; // 178 - added in 1.6.1130
SteamCallResult<EncryptedAppTicketResponse_t> steamcallresult_EncryptedAppTicketResponse; // 1A0
VirtualKeyboardDoneCallback* virtualKeyboardDone; // 1D0 - added in 1.6.1130
VirtualKeyboardCancelCallback* virtualKeyboardCancel; // 1D8 - added in 1.6.1130
void* virtualKeyboardUserParam; // 1E0 - added in 1.6.1130
bool steamAPIInitialized; // 1E8 - added in 1.6.1130
std::uint8_t pad1E9; // 1E9
std::uint16_t pad1EA; // 1EA
std::uint32_t pad1EC; // 1EC
ISteamClient* steamClient; // 1F0 - added in 1.6.1130
HSteamPipe steamPipe; // 1F8 - added in 1.6.1130
std::uint32_t pad1FC; // 1FC
ISteamUtils* steamUtils; // 200 - added in 1.6.1130
bool isRunningOnSteamDeck; // 208 - added in 1.6.1130
};
static_assert(sizeof(BSWin32SystemUtility) == 0x210);
}
14 changes: 7 additions & 7 deletions include/RE/B/BSWin32VirtualKeyboardDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace RE
~BSWin32VirtualKeyboardDevice() override; // 00

// override (BSVirtualKeyboardDevice)
void Initialize() override; // 01 - { return; }
void Poll(float a_timeDelta) override; // 02 - { return; }
void Shutdown() override; // 03 - { return; }
void ClearInputState() override; // 08 - { return; }
void Unk_0B(void) override; // 0B - { return; }
void Unk_0C(void) override; // 0C - { return; }
void Unk_0D(void) override; // 0D - { return; }
void Initialize() override; // 01 - { return; }
void Poll(float a_timeDelta) override; // 02 - { return; }
void Shutdown() override; // 03 - { return; }
void ClearInputState() override; // 08 - { return; }
void Start(const kbInfo* info) override; // 0B - { return; }
void Stop() override; // 0C - { return; }
void UserCancelled() override; // 0D - { return; }
};
static_assert(sizeof(BSWin32VirtualKeyboardDevice) == 0x70);
}
64 changes: 64 additions & 0 deletions include/RE/C/CCallback.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma once

using SteamAPICall_t = std::uint64_t;

namespace RE
{
class CCallbackBase
{
public:
enum
{
k_ECallbackFlagsRegistered = 0x01,
k_ECallbackFlagsGameServer = 0x02
};

virtual void Run(void* vParam); // 01
virtual void Run(void* vParam, bool ioFailure, SteamAPICall_t steamAPICall); // 00
virtual int GetCallbackSizeBytes(); // 02

// members
std::uint8_t callbackFlags; // 08
std::uint8_t pad09; // 09
std::uint16_t pad0A; // 0A
std::int32_t iCallback; // 0C
};
static_assert(sizeof(CCallbackBase) == 0x10);

template <class T, class P>
class CCallResult : public CCallbackBase
{
public:
using func_t = void (T::*)(P*);

// override (CCallbackBase)
void Run(void* vParam) override; // 01
void Run(void* vParam, bool ioFailure, SteamAPICall_t steamAPICall) override; // 00
int GetCallbackSizeBytes() override; // 02

SteamAPICall_t apiCall; // 10
T* obj; // 18
func_t func; // 20
};
// size == 0x30

template <class T, class P, bool bGameserver = false>
class CCallback : public CCallbackBase
{
public:
using func_t = void (T::*)(P*);

// override (CCallbackBase)
void Run(void* vParam) override; // 01
void Run(void* vParam, bool ioFailure, SteamAPICall_t steamAPICall) override; // 00
int GetCallbackSizeBytes() override; // 02

// add
virtual ~CCallback(); // 03

// members
T* pObj; // 10
func_t func; // 18
};
// size == 0x28
}
5 changes: 5 additions & 0 deletions include/RE/Offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ namespace RE
inline constexpr REL::ID GetSingleton(static_cast<std::uint64_t>(109278));
}

namespace BSWin32SystemUtility
{
inline constexpr REL::ID GetSingleton(static_cast<std::uint64_t>(109206));
}

namespace Calendar
{
inline constexpr REL::ID Singleton(static_cast<std::uint64_t>(400447));
Expand Down
3 changes: 3 additions & 0 deletions include/RE/Skyrim.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
#include "RE/B/BSStringPool.h"
#include "RE/B/BSSystemFile.h"
#include "RE/B/BSSystemFileStorage.h"
#include "RE/B/BSSystemUtility.h"
#include "RE/B/BSTAnimationGraphDataChannel.h"
#include "RE/B/BSTArray.h"
#include "RE/B/BSTCaseInsensitiveStringMap.h"
Expand Down Expand Up @@ -308,6 +309,7 @@
#include "RE/B/BSWin32KeyboardDevice.h"
#include "RE/B/BSWin32MouseDevice.h"
#include "RE/B/BSWin32SaveDataSystemUtility.h"
#include "RE/B/BSWin32SystemUtility.h"
#include "RE/B/BSWin32VirtualKeyboardDevice.h"
#include "RE/B/BSXAudio2GameSound.h"
#include "RE/B/BSXFlags.h"
Expand Down Expand Up @@ -348,6 +350,7 @@
#include "RE/B/bhkThreadMemorySource.h"
#include "RE/B/bhkWorld.h"
#include "RE/B/bhkWorldObject.h"
#include "RE/C/CCallback.h"
#include "RE/C/CFilter.h"
#include "RE/C/CRC.h"
#include "RE/C/Calendar.h"
Expand Down

0 comments on commit a06f2e3

Please sign in to comment.