c++unreal-engine4steamunreal-development-kitsteamworks-api

Unreal Engine 3 game crashes with Steam Input


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.


Solution

  • I found the problem. I was declaring all of my InputActionSetHandle_t variables in the cpptext area of my UnrealScript classes. I'm not supposed to do that. I declared all of those variables as UnrealScript qwords instead, and they work just fine for holding the C++ uint64 handles that get sent back by the Steam API. And no more crashes.