File: uGlobals.pas

package info (click to toggle)
nbc 1.2.1.r4%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,924 kB
  • ctags: 11,604
  • sloc: pascal: 44,581; ansic: 14,747; makefile: 8
file content (170 lines) | stat: -rw-r--r-- 4,144 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
(*
 * The contents of this file are subject to the Mozilla Public License
 * Version 1.1 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * The Initial Developer of this code is John Hansen.
 * Portions created by John Hansen are Copyright (C) 2009 John Hansen.
 * All Rights Reserved.
 *
 *)
unit uGlobals;

{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}

interface

const
  // remote commands
  kRemoteKeysReleased = $0000;
  kRemotePBMessage1   = $0100;
  kRemotePBMessage2   = $0200;
  kRemotePBMessage3   = $0400;
  kRemoteOutAForward  = $0800;
  kRemoteOutBForward  = $1000;
  kRemoteOutCForward  = $2000;
  kRemoteOutABackward = $4000;
  kRemoteOutBBackward = $8000;
  kRemoteOutCBackward = $0001;
  kRemoteSelProgram1  = $0002;
  kRemoteSelProgram2  = $0004;
  kRemoteSelProgram3  = $0008;
  kRemoteSelProgram4  = $0010;
  kRemoteSelProgram5  = $0020;
  kRemoteStopOutOff   = $0040;
  kRemotePlayASound   = $0080;

{$IFDEF FPC}
const
  MB_ICONASTERISK = $00000040;
{$ENDIF}

const
  K_RCX   = 'RCX';
  K_CYBER = 'CyberMaster';
  K_SCOUT = 'Scout';
  K_RCX2  = 'RCX2';
  K_SPY   = 'Spybot';
  K_SWAN  = 'Swan';
  K_NXT   = 'NXT';

const
  rtRCX         = 0;
  rtCybermaster = 1;
  rtScout       = 2;
  rtRCX2        = 3;
  rtSpy         = 4;
  rtSwan        = 5;
  rtNXT         = 6;

const
  SU_RCX         = rtRCX;
  SU_CYBERMASTER = rtCybermaster;
  SU_SCOUT       = rtScout;
  SU_RCX2        = rtRCX2;
  SU_SPYBOTIC    = rtSpy;
  SU_SWAN        = rtSwan;
  SU_NXT         = rtNXT;

var
  UserDataLocalPath : string;
  SymFileLibraryPath : string;
  
var
  LocalBrickType : integer;
  LocalStandardFirmware : Boolean;

var
  GlobalAbort : boolean;

function IsNXT : boolean;
function IsSwan : boolean;
function IsRCX2 : boolean;
function IsRCX : boolean;
function IsScout : boolean;
function IsSpybotic : boolean;
function GetJoystickButtonScript(const i : byte; bPress : boolean) : string;

{$IFNDEF FPC}
function GetSpecialFolderPath(folder : integer) : string;
{$ENDIF}

implementation

uses
{$IFNDEF FPC}
  SHFolder,
  Windows,
{$ENDIF}
  SysUtils;

function IsNXT : boolean;
begin
  result := (LocalBrickType = SU_NXT);
end;

function IsSwan : boolean;
begin
  result := (LocalBrickType = SU_SWAN);
end;

function IsRCX2 : boolean;
begin
  result := (LocalBrickType = SU_RCX2) or (LocalBrickType = SU_SWAN);
end;

function IsRCX : boolean;
begin
  result := (LocalBrickType = SU_RCX) or (LocalBrickType = SU_RCX2) or (LocalBrickType = SU_SWAN);
end;

function IsScout : boolean;
begin
  result := (LocalBrickType = SU_SCOUT);
end;

function IsSpybotic : boolean;
begin
  result := (LocalBrickType = SU_SPYBOTIC);
end;

function GetJoystickButtonScript(const i : byte; bPress : boolean) : string;
const
  name_postfix : array[boolean] of string = ('r', 'p');
begin
  Result := UserDataLocalPath+Format('joybtn%2.2d%s.rops', [i, name_postfix[bPress]]);
end;

{$IFNDEF FPC}
function GetSpecialFolderPath(folder : integer) : string;
const
  SHGFP_TYPE_CURRENT = 0;
var
  path: array [0..MAX_PATH] of char;
begin
  if SUCCEEDED(SHGetFolderPath(0,folder,0,SHGFP_TYPE_CURRENT,@path[0])) then
    Result := path
  else
    Result := '';
end;
{$ENDIF}

initialization

{$IFNDEF FPC}
  UserDataLocalPath := GetSpecialFolderPath(CSIDL_APPDATA{CSIDL_LOCAL_APPDATA})+'\JoCar Consulting\BricxCC\3.3\';
  SymFileLibraryPath := GetSpecialFolderPath(CSIDL_APPDATA{CSIDL_LOCAL_APPDATA})+'\JoCar Consulting\BricxCC\3.3\sym\';
{$ELSE}
  UserDataLocalPath := IncludeTrailingPathDelimiter(ExpandFilename('~'));
  SymFileLibraryPath := IncludeTrailingPathDelimiter(ExpandFilename('~')) + IncludeTrailingPathDelimiter('sym');
{$ENDIF}

end.