1 (*
2 * The contents of this file are subject to the Mozilla Public License
3 * Version 1.1 (the "License"); you may not use this file except in
4 * compliance with the License. You may obtain a copy of the License at
5 * http://www.mozilla.org/MPL/
6 *
7 * Software distributed under the License is distributed on an "AS IS"
8 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
9 * License for the specific language governing rights and limitations
10 * under the License.
11 *
12 * The Initial Developer of this code is John Hansen.
13 * Portions created by John Hansen are Copyright (C) 2009 John Hansen.
14 * All Rights Reserved.
15 *
16 *)
17 unit uGlobals;
18
19 {$IFDEF FPC}
20 {$MODE Delphi}
21 {$ENDIF}
22
23 interface
24
25 const
26 // remote commands
27 kRemoteKeysReleased = $0000;
28 kRemotePBMessage1 = $0100;
29 kRemotePBMessage2 = $0200;
30 kRemotePBMessage3 = $0400;
31 kRemoteOutAForward = $0800;
32 kRemoteOutBForward = $1000;
33 kRemoteOutCForward = $2000;
34 kRemoteOutABackward = $4000;
35 kRemoteOutBBackward = $8000;
36 kRemoteOutCBackward = $0001;
37 kRemoteSelProgram1 = $0002;
38 kRemoteSelProgram2 = $0004;
39 kRemoteSelProgram3 = $0008;
40 kRemoteSelProgram4 = $0010;
41 kRemoteSelProgram5 = $0020;
42 kRemoteStopOutOff = $0040;
43 kRemotePlayASound = $0080;
44
45 {$IFDEF FPC}
46 const
47 MB_ICONASTERISK = $00000040;
48 {$ENDIF}
49
50 const
51 K_RCX = 'RCX';
52 K_CYBER = 'CyberMaster';
53 K_SCOUT = 'Scout';
54 K_RCX2 = 'RCX2';
55 K_SPY = 'Spybot';
56 K_SWAN = 'Swan';
57 K_NXT = 'NXT';
58
59 const
60 rtRCX = 0;
61 rtCybermaster = 1;
62 rtScout = 2;
63 rtRCX2 = 3;
64 rtSpy = 4;
65 rtSwan = 5;
66 rtNXT = 6;
67
68 const
69 SU_RCX = rtRCX;
70 SU_CYBERMASTER = rtCybermaster;
71 SU_SCOUT = rtScout;
72 SU_RCX2 = rtRCX2;
73 SU_SPYBOTIC = rtSpy;
74 SU_SWAN = rtSwan;
75 SU_NXT = rtNXT;
76
77 var
78 UserDataLocalPath : string;
79 SymFileLibraryPath : string;
80
81 var
82 LocalBrickType : integer;
83 LocalStandardFirmware : Boolean;
84
85 var
86 GlobalAbort : boolean;
87
IsNXTnull88 function IsNXT : boolean;
IsSwannull89 function IsSwan : boolean;
IsRCX2null90 function IsRCX2 : boolean;
IsRCXnull91 function IsRCX : boolean;
IsScoutnull92 function IsScout : boolean;
IsSpyboticnull93 function IsSpybotic : boolean;
GetJoystickButtonScriptnull94 function GetJoystickButtonScript(const i : byte; bPress : boolean) : string;
95
96 {$IFNDEF FPC}
GetSpecialFolderPathnull97 function GetSpecialFolderPath(folder : integer) : string;
98 {$ENDIF}
99
100 implementation
101
102 uses
103 {$IFNDEF FPC}
104 SHFolder,
105 Windows,
106 {$ENDIF}
107 SysUtils;
108
IsNXTnull109 function IsNXT : boolean;
110 begin
111 result := (LocalBrickType = SU_NXT);
112 end;
113
IsSwannull114 function IsSwan : boolean;
115 begin
116 result := (LocalBrickType = SU_SWAN);
117 end;
118
IsRCX2null119 function IsRCX2 : boolean;
120 begin
121 result := (LocalBrickType = SU_RCX2) or (LocalBrickType = SU_SWAN);
122 end;
123
IsRCXnull124 function IsRCX : boolean;
125 begin
126 result := (LocalBrickType = SU_RCX) or (LocalBrickType = SU_RCX2) or (LocalBrickType = SU_SWAN);
127 end;
128
IsScoutnull129 function IsScout : boolean;
130 begin
131 result := (LocalBrickType = SU_SCOUT);
132 end;
133
IsSpyboticnull134 function IsSpybotic : boolean;
135 begin
136 result := (LocalBrickType = SU_SPYBOTIC);
137 end;
138
GetJoystickButtonScriptnull139 function GetJoystickButtonScript(const i : byte; bPress : boolean) : string;
140 const
141 name_postfix : array[boolean] of string = ('r', 'p');
142 begin
143 Result := UserDataLocalPath+Format('joybtn%2.2d%s.rops', [i, name_postfix[bPress]]);
144 end;
145
146 {$IFNDEF FPC}
GetSpecialFolderPathnull147 function GetSpecialFolderPath(folder : integer) : string;
148 const
149 SHGFP_TYPE_CURRENT = 0;
150 var
151 path: array [0..MAX_PATH] of char;
152 begin
153 if SUCCEEDED(SHGetFolderPath(0,folder,0,SHGFP_TYPE_CURRENT,@path[0])) then
154 Result := path
155 else
156 Result := '';
157 end;
158 {$ENDIF}
159
160 initialization
161
162 {$IFNDEF FPC}
163 UserDataLocalPath := GetSpecialFolderPath(CSIDL_APPDATA{CSIDL_LOCAL_APPDATA})+'\JoCar Consulting\BricxCC\3.3\';
164 SymFileLibraryPath := GetSpecialFolderPath(CSIDL_APPDATA{CSIDL_LOCAL_APPDATA})+'\JoCar Consulting\BricxCC\3.3\sym\';
165 {$ELSE}
166 UserDataLocalPath := IncludeTrailingPathDelimiter(ExpandFilename('~'));
167 SymFileLibraryPath := IncludeTrailingPathDelimiter(ExpandFilename('~')) + IncludeTrailingPathDelimiter('sym');
168 {$ENDIF}
169
170 end.
171