1

I'm not much of a C++ programmer, and I'm looking for help with implementing Steam Input into my Unreal Engine 3 game (yes, that's 3 and not 4). I'm under NDAs to both Epic (for Unreal 3) and Valve (for Steamworks), so I don't think I'm able to copy any of their code, but I'm going to do my best here to describe what's going on. And if you know of a better place I can ask these questions, please let me know. And if you think I'm violating an NDA, please let me know that too so I can delete the offending portions.

I have a UE3 game that works with mouse and keyboard. Steam Input, which is part of the Steamworks SDK, provides a way to get input from any controller. Basically, your controller, your actions (such as "shoot" or "walk forward"), and action sets (control schemes that can change based on game state, such as "in menu," "walking," or "driving") all get assigned unique UINT64 handles. I'm at the stage where I'm using the provided functions to assign handles, and it's crashing my game.

I have a class that contains these variables...

    // typedef uint64 InputActionSetHandle_t;
    InputActionSetHandle_t IsometricSetHandle;
    InputActionSetHandle_t WorldMapSetHandle;
    InputActionSetHandle_t SquadMenuSetHandle;
    InputActionSetHandle_t BattleSetupSetHandle;
    InputActionSetHandle_t InBattleSetHandle;
    InputActionSetHandle_t MenuSetHandle;

I create an object and then I try to set up its variables by calling this function.

void URPGTacSteamInput::SetActionSetHandles()
{
    IsometricSetHandle = SteamInput()->GetActionSetHandle( "Isometric" );
    WorldMapSetHandle = SteamInput()->GetActionSetHandle( "WorldMap" );
    SquadMenuSetHandle = SteamInput()->GetActionSetHandle( "SquadMenu" );
    BattleSetupSetHandle = SteamInput()->GetActionSetHandle( "BattleSetup" );
    InBattleSetHandle = SteamInput()->GetActionSetHandle( "InBattle" );
    MenuSetHandle = SteamInput()->GetActionSetHandle( "Menu" );
}

The function completes, but the game crashes later, with the error "Unhandled exception ... Access violation reading location ..." Call stack location is FArchiveRealtimeGC::PerformReachabilityAnalysis(), which I understand is part of Unreal 3's garbage collection system.

I'm not sure how to tackle this problem, and I've just been trying stuff. I logged the handles that get assigned, and I tried setting those handles manually:

void URPGTacSteamInput::SetActionSetHandles()
{
    IsometricSetHandle = 1;
    WorldMapSetHandle = 2;
    SquadMenuSetHandle = 3;
    BattleSetupSetHandle = 4;
    InBattleSetHandle = 5;
    MenuSetHandle = 6;
}

But the game still crashes after running that function. So I tried removing more from it.

void URPGTacSteamInput::SetActionSetHandles()
{
}

And I can run that function, and the game moves along just fine, except that I don't have any Steam Input action sets I can switch to.

So what might I be able to check to find out why my game is crashing? What else would I need to find out in order to track this down? Is there somewhere else I might have better luck asking about this issue?

Thanks for any guidance you can give me on this.

4

1 回答 1

2

我发现了问题。我在 UnrealScript 类的 cpptext 区域中声明了所有 InputActionSetHandle_t 变量。我不应该那样做。我将所有这些变量声明为 UnrealScript qwords,它们可以很好地保存由 Steam API 发回的 C++ uint64 句柄。并且没有更多的崩溃。

于 2019-12-02T18:01:19.223 回答