unit modul_conin;

{$mode objfpc}{$H+}

interface

// is this not defined, is the maximum resolution for this monitor used
// {$DEFINE Keyboard_ist_deutsch}


uses

  Keyboard, {Keyboard uses USB so that will be included automatically}

//{$IFDEF Keyboard_ist_deutsch}
  Keymap_DE,
//{$ENDIF}


  DWCOTG,   {We need to include the USB host driver for the Raspberry Pi}
  Console,
  SysUtils,
  GraphicsConsole,

  modul_conout,
  modul_image,
  screenshot;






type


  Tmod_conin = class(TObject)

    constructor Create; overload;
    destructor Destroy; override;

  private

  public
    function CONST_ausgeben : Byte;
    function CONIN_ausgeben : Byte;

  end; // Tmod_conin = class(TObject)



var
  mod_conin : Tmod_conin;




implementation





constructor Tmod_conin.Create;
begin
  inherited Create;

end; { constructor Tmod_conin.Create }










function Tmod_conin.CONST_ausgeben : Byte;
var
  CONST_Byte : Byte;
begin

  if ConsoleKeypressed then
    CONST_Byte:=$FF
  else
    CONST_Byte:=$00;


  Result:=CONST_Byte;


end; { procedure Tmod_conin.CONST_ausgeben }











function Tmod_conin.CONIN_ausgeben : Byte;
var
  CONIN_Byte : Byte;
begin

  CONIN_Byte:=Byte(ConsoleReadKey);

  // Del -> RUN_DEL
  if CONIN_Byte=$08 then
    CONIN_Byte:=$7F;


  if CONIN_Byte=0 then begin

    CONIN_Byte:=Byte(ConsoleReadKey);

    case CONIN_Byte of
      $3B : begin
              GraphicsWindowDrawText(GraphicHandle,'ScreenShot',1,1);
              make_ScreenShot(GraphicHandle); // F1 -> ScreenShot
              GraphicsWindowDrawText(GraphicHandle,'              ',1,1);
              CONIN_Byte:=$0;
            end;

      $3C : begin
              GraphicsWindowDrawText(GraphicHandle,'Save Files',1,1);
              mod_image.Save_Files; // F2 -> Save Files
              GraphicsWindowDrawText(GraphicHandle,'              ',1,1);
              CONIN_Byte:=$0;
            end;

      $44 : begin
              GraphicsWindowDrawText(GraphicHandle,'Keymap',1,1);
              // SysUtils.
              // mod_image.Save_Files; // F10 -> Keymap_DE / Keymap_EN
              GraphicsWindowDrawText(GraphicHandle,'              ',1,1);
              CONIN_Byte:=$0;
            end;


      $52 : CONIN_Byte:=$16;  // Einfg -> 16H = Ctrl+V
      $53 : CONIN_Byte:=$07;  // Entf  -> 07H
      $47 : CONIN_Byte:=$01;  // Pos1  -> 01H = Ctrl+A (Turbo Pascal Editor - Wort links)
      $4F : CONIN_Byte:=$06;  // Ende  -> 06H = Ctrl+F (Turbo Pascal Editor - Wort rechts)
      $49 : CONIN_Byte:=$12;  // Bild hoch     -> 12H = Ctrl+R (Turbo Pascal Editor - Bild hoch)
      $51 : CONIN_Byte:=$03;  // Bild runter   -> 03H = Ctrl+C (Turbo Pascal Editor - Bild runter)
      $48 : CONIN_Byte:=$05;  // Kursor hoch   -> 05H = Ctrl+E (Turbo Pascal Editor - Kursor hoch)
      $50 : CONIN_Byte:=$18;  // Kursor runter -> 18H = Ctrl+X (Turbo Pascal Editor - Kursor runter)
      $4B : CONIN_Byte:=$13;  // Kursor links  -> 13H = Ctrl+S (Turbo Pascal Editor - Kursor links)
      $4D : CONIN_Byte:=$04;  // Kursor rechts -> 04H = Ctrl+D (Turbo Pascal Editor - Kursor rechts)



    end; { case CONIN_Byte of }

  end; { if CONIN_Byte=0 then }


  if CONIN_Byte=0 then
    CONIN_Byte:=3;


  Result:=CONIN_Byte;

end; { function Tmod_conin.CONIN_ausgeben }






destructor Tmod_conin.Destroy;
begin

  inherited Destroy;
end; { destructor Tmod_conin.Destroy }





end.

