/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: sgx/src/sgx/input/logger.cpp

*/

#include "sgx/core/core.hpp"
#include "sgx/input/input.hpp"

#if TODO
void
CLoggingInputManager::StartPlaybackInput(CSGXFile &file)
{
    m_pFile = &file;
}

void
CLoggingInputManager::update()
{
    if (m_pFile->IsSaving()) {
        *m_pFile << CGameClock::get()->GetGameTime();
        // Calculate memory efficient deltas
    } else if (m_pFile->isLoading()) {
        tREAL32 time_elapsed;
        *m_pFile >> time_elapsed;

        // Check for the terminator
        if (time_elapsed == 0) {
            StopPlaybackInput();
            return;
        }

        // Apply the game time
        CGameClock::get()->SetModeConstant(time_elapsed);
    }

    *m_pFile | delta_stick0;
    *m_pFile | delta_stick1;	// and so on...

    if (m_pFile->isLoading()) {
        // Apply deltas to all sticks
        m_Controller[controller].Stick[0].x += delta_stick0.x;
        // and so on...
    }
    
}

void
CLoggingInputManager::StopPlaybackInput()
{
    if (m_pFile->IsSaving()) {
        *m_pFile | 0;   // a delta of zero to terminate
    }

    CGameClock::get()->SetModeRealtime();
    m_pFile->close();	
}
#endif
