thobbsinteractive / magic-carpet-2-hd

Recode Binary code of game Magic Carpet2 to C/C++ language(remake MC2 for any platform)
GNU General Public License v3.0
27 stars 4 forks source link

Abstract Input into game so that input state can be set by "anything" #241

Open thobbsinteractive opened 1 year ago

thobbsinteractive commented 1 year ago

Abstract Input so that game code checks a State struct set by Keyboard/Mouse/Joysticks/scripts/headsets....

This is a two stage implementation:

  1. Get magic carpet 2 to read from a State structure (see below) rather than checking itself for key presses. I have attached my first draft at this structure based on the game manual and all actions
  2. Move the current the SDL keyboard/mouse/joypad detection code to its own input class to set this struct

Why do this? It will allow for any input in the future, included even scripting It will be easier to implement button combinations for Game Pads etc...

typedef struct InputActions
{
    uint8_t m_PauseGame;
    uint8_t m_ChangeScreenResolution;
    uint8_t m_AbortMission;
    uint8_t m_ShowCurrentObjective;
    uint8_t m_AdjustMusicVolume;
    uint8_t m_AdjustSoundVolume;
    uint8_t m_SendMessage1;
    uint8_t m_SendMessage2;
    uint8_t m_SendMessage3;
    uint8_t m_SendMessage4;
    uint8_t m_SendMessage5;
    uint8_t m_SendMessage6;
    uint8_t m_SendMessage7;
    uint8_t m_SendMessage8;

    uint8_t m_ToggleHelp;
    uint8_t m_ToggleFlightAssistance;
    uint8_t m_ToggleSpeed;
    uint8_t m_ToggleSpeech;
    uint8_t m_ToggleSound;
    uint8_t m_ToggleMusic;
    uint8_t m_AdjustGammaCorrection;
    uint8_t m_ToggleNames;
    uint8_t m_ToggleReflections;
    uint8_t m_ToggleSky;
    uint8_t m_ToggleShadows;
    uint8_t m_ToggleLightSources;
    uint8_t m_ToggleMapIcons;
    uint8_t m_TogglePanelTransparency;
    uint8_t m_ToggleFlatShading;

    uint8_t m_FireLeftAssignedSpell;
    uint8_t m_FireRightAssignedSpell;
    uint8_t m_IncreaseSpeed;
    uint8_t m_DecreaseSpeed;
    uint8_t m_MoveLeft;
    uint8_t m_MoveRight;
    uint8_t m_BarrelRoll;
    uint8_t m_StopMoving;
    uint8_t m_ResurrectMission;
    uint8_t m_ScrollLeftAssignedSpellsForward;
    uint8_t m_ScrollRightAssignedSpellsForward;
    uint8_t m_ScrollLeftAssignedSpellsBackward;
    uint8_t m_ScrollRightAssignedSpellsBackward;

    uint8_t m_DestroyLastCastleStage;

    uint8_t m_IncreaseScreenSize;
    uint8_t m_DecreaseScreenSize;
    uint8_t m_StartTextInput;
    uint8_t m_CalibrateHeadSet;

    uint8_t m_OpenSpellsMenu;
    uint8_t m_ToggleLeftAssignedSpell;
    uint8_t m_ToggleRightAssignedSpell;
    uint8_t m_AssignHighlightedSpellToLeftHand;
    uint8_t m_AssignHighlightedSpellToRightHand;
    uint8_t m_FireSpellWithoutAssigning;
    uint8_t m_AccessHigherLevelSpells;

    uint8_t m_DisplayPlayerInformation;

    uint8_t m_OptionsPanel;

    int16_t m_Pitch;
    int16_t m_Yaw;
}
Type_InputActions;
thobbsinteractive commented 1 year ago

I should probably add the Cheats as well to the above Action states