Sdldoom-1.10 conversion

I’m trying to convert sdldoom-1.10 and I’m trying to convert d_event.h to Fortran how do I convert this

// Input event types.
typedef enum
{
    ev_keydown,
    ev_keyup,
    ev_mouse,
    ev_joystick
} evtype_t;

// Event structure.
typedef struct
{
    evtype_t	type;
    int		data1;		// keys / mouse/joystick buttons
    int		data2;		// mouse/joystick x move
    int		data3;		// mouse/joystick y move
} event_t;

 
typedef enum
{
    ga_nothing,
    ga_loadlevel,
    ga_newgame,
    ga_loadgame,
    ga_savegame,
    ga_playdemo,
    ga_completed,
    ga_victory,
    ga_worlddone,
    ga_screenshot
} gameaction_t;



//
// Button/action code definitions.
//
typedef enum
{
    // Press "Fire".
    BT_ATTACK		= 1,
    // Use button, to open doors, activate switches.
    BT_USE		= 2,

    // Flag: game events, not really buttons.
    BT_SPECIAL		= 128,
    BT_SPECIALMASK	= 3,
    
    // Flag, weapon change pending.
    // If true, the next 3 bits hold weapon num.
    BT_CHANGE		= 4,
    // The 3bit weapon mask and shift, convenience.
    BT_WEAPONMASK	= (8+16+32),
    BT_WEAPONSHIFT	= 3,

    // Pause the game.
    BTS_PAUSE		= 1,
    // Save the game at each console.
    BTS_SAVEGAME	= 2,

    // Savegame slot numbers
    //  occupy the second byte of buttons.    
    BTS_SAVEMASK	= (4+8+16),
    BTS_SAVESHIFT 	= 2,
  
} buttoncode_t;

into Fortran

Hi and welcome.

Fortran’s interoperability with C includes the enum construct, so you can use it to translate the enums. Enums are just integers of kind C_INT (as of C17), so you can just create a parameter for the typedef to the enum. And use derived types for the structs, e.g.:

use ISO_C_BINDING

implicit none

enum, bind(C)
    enumerator :: ev_keydown, ev_keyup
    enumerator :: ev_mouse
    enumerator :: ev_joystick
end enum

integer, parameter :: evtype_t = C_INT

type, bind(C) :: event_t
    integer(evtype_t) :: type
    integer(C_INT) :: data1
    integer(C_INT) :: data2
    integer(C_INT) :: data3
end type

end

I think Fortran 2023 allows the enum to be named (thus creating the parameter for you under the hood?).