DEFINITION MODULE LowlevelD; (*$ Implementation:=FALSE *)
(* 02-Apr-1994/bp *)

FROM SYSTEM IMPORT ADDRESS, LONGSET;
FROM UtilityD IMPORT tagUser;
IMPORT ExecD;

CONST
  lowlevelName="lowlevel.library";

TYPE
  StrPtr=ADDRESS;

  LowlevelBase=ExecD.Library;
  LowlevelBasePtr=POINTER TO LowlevelBase;


(* structure for use with QueryKeys() *)
  KeyQuery=RECORD
    keyCode: CARDINAL;
    pressed: CARDINAL; (* <>0: TRUE *)
  END;
  KeyQueryPtr=POINTER TO KeyQuery;


CONST

(* bits in the return value of GetKey() *)
  llkbLShift    =16;
  llkbRShift    =17;
  llkbCapslock  =18;
  llkbControl   =19;
  llkbLAlt      =20;
  llkbRAlt      =21;
  llkbLAmiga    =22;
  llkbRAmiga    =23;


(* Tags for SetJoyPortAttrs() *)
  sjaDummy       =tagUser+0C00100H;
  sjaType        =sjaDummy+1; (* force type to mouse, joy, game cntrlr *)
  sjaReinitialize=sjaDummy+2; (* free potgo bits, reset to autosense	*)

(* Controller types for sjaType tag *)
  sjaTypeAutoSense=0;
  sjaTypeGameCtlr =1;
  sjaTypeMouse    =2;
  sjaTypeJoystk   =3;


TYPE

  JP=(jp0,jp1,jp2,jp3,jp4,jp5,jp6,jp7,
      jp8,jp9,jp10,jp11,jp12,jp13,jp14,jp15,
      jp16,jp17,jp18,jp19,jp20,jp21,jp22,jp23,
      jp24,jp25,jp26,jp27,jp28,jp29,jp30,jp31);
  JPSet=SET OF JP;

CONST

  (* ReadJoyPort() return value definitions *)

  (* Port types *)
  jpTypeNotAvail=JPSet{};         (* port data unavailable    *)
  jpTypeGameCtlr=JPSet{jp28};     (* port has game controller *)
  jpTypeMouse=JPSet{jp29};        (* port has mouse	      *)
  jpTypeJoystk=JPSet{jp28,jp29};  (* port has joystick	      *)
  jpTypeUnknown=JPSet{jp30};      (* port has unknown device  *)
  jpTypeMask=JPSet{jp28..jp31};   (* controller type	      *)

  (* Button types, valid for all types except jpType  NOTAVAIL *)
  jpbButtonBlue    =jp23; (* Blue - Stop; Right Mouse		     *)
  jpbButtonRed     =jp22; (* Red - Select; Left Mouse; Joystick Fire *)
  jpbButtonYellow  =jp21; (* Yellow - Repeat			     *)
  jpbButtonGreen   =jp20; (* Green - Shuffle			     *)
  jpbButtonForward =jp19; (* Charcoal - Forward		     *)
  jpbButtonReverse =jp18; (* Charcoal - Reverse		     *)
  jpbButtonPlay    =jp17; (* Grey - Play/Pause; Middle Mouse	     *)
  jpButtonMask     =JPSet{jpbButtonPlay..jpbButtonBlue};

  (* Direction types, valid for jpType  GAMECTLR and jpType  JOYSTK *)
  jpbJoyUp        =jp3;
  jpbJoyDown      =jp2;
  jpbJoyLeft      =jp1;
  jpbJoyRight     =jp0;
  jpDirectionMask =JPSet{jpbJoyRight..jpbJoyUp};

  (* Mouse position reports, valid for jpType  MOUSE *)
  jpMHorzMask=JPSet{jp0..jp7};   (* horzizontal position *)
  jpMVertMask=JPSet{jp8..jp15};    (* vertical position	*)
  jpMouseMask=jpMHorzMask+jpMVertMask;


  (* Tags for SystemControl() *)
  sconDummy        =tagUser+0C00000H;
  sconTakeOverSys  =sconDummy+0;
  sconKillReq      =sconDummy+1;
  sconCDReboot     =sconDummy+2;
  sconStopInput    =sconDummy+3;
  sconAddCreateKeys=sconDummy+4;
  sconRemCreateKeys=sconDummy+5;

  (* Reboot control values for use with sconCDReboot tag *)
  cdRebootOn     =1;
  cdRebootOff    =0;
  cdRebootDefault=2;


(*****************************************************************************)


(* Rawkey codes returned when using sconAddCreateKeys with SystemControl() *)

  rawkeyPort0ButtonBlue         =072H;
  rawkeyPort0ButtonRed          =078H;
  rawkeyPort0ButtonYellow       =077H;
  rawkeyPort0ButtonGreen        =076H;
  rawkeyPort0ButtonForward      =075H;
  rawkeyPort0ButtonReverse      =074H;
  rawkeyPort0ButtonPLAY         =073H;
  rawkeyPort0JoyUp              =079H;
  rawkeyPort0JoyDown            =07AH;
  rawkeyPort0JoyLeft            =07CH;
  rawkeyPort0JoyRight           =07BH;

  rawkeyPort1ButtonBlue         =0172H;
  rawkeyPort1ButtonRed          =0178H;
  rawkeyPort1ButtonYellow       =0177H;
  rawkeyPort1ButtonGreen        =0176H;
  rawkeyPort1ButtonForward      =0175H;
  rawkeyPort1ButtonReverse      =0174H;
  rawkeyPort1ButtonPLAY         =0173H;
  rawkeyPort1JoyUp              =0179H;
  rawkeyPort1JoyDown            =017AH;
  rawkeyPort1JoyLeft            =017CH;
  rawkeyPort1JoyRight           =017BH;

  rawkeyPort2ButtonBlue         =0272H;
  rawkeyPort2ButtonRed          =0278H;
  rawkeyPort2ButtonYellow       =0277H;
  rawkeyPort2ButtonGreen        =0276H;
  rawkeyPort2ButtonForward      =0275H;
  rawkeyPort2ButtonReverse      =0274H;
  rawkeyPort2ButtonPLAY         =0273H;
  rawkeyPort2JoyUp              =0279H;
  rawkeyPort2JoyDown            =027AH;
  rawkeyPort2JoyLeft            =027CH;
  rawkeyPort2JoyRight           =027BH;

  rawkeyPort3ButtonBlue         =0372H;
  rawkeyPort3ButtonRed          =0378H;
  rawkeyPort3ButtonYellow       =0377H;
  rawkeyPort3ButtonGreen        =0376H;
  rawkeyPort3ButtonForward      =0375H;
  rawkeyPort3ButtonReverse      =0374H;
  rawkeyPort3ButtonPLAY         =0373H;
  rawkeyPort3JoyUp              =0379H;
  rawkeyPort3JoyDown            =037AH;
  rawkeyPort3JoyLeft            =037CH;
  rawkeyPort3JoyRight           =037BH;


(*****************************************************************************)


(* Return values for GetLanguageSelection() *)
  langUnknown   =0;
  langAmerican  =1;  (* American English *)
  langEnglish   =2;  (* British English  *)
  langGerman    =3;
  langFrench    =4;
  langSpanish   =5;
  langItalian   =6;
  langPortuguese=7;
  langDanish    =8;
  langDutch     =9;
  langNorwegian =10;
  langFinnish   =11;
  langSwedish   =12;
  langJapanese  =13;
  langChinese   =14;
  langArabic    =15;
  langGreek     =16;
  langHebrew    =17;
  langKorean    =18;

END LowlevelD.noimp
