pxt-arcade 1.13.54 → 1.13.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/common-sim.d.ts +98 -0
- package/built/common-sim.js +343 -0
- package/built/sim.js +390 -26
- package/built/target-strings.json +1 -1
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.json +1 -1
- package/built/theme.json +1 -1
- package/package.json +3 -3
- package/pxtarget.json +12 -2
package/built/common-sim.d.ts
CHANGED
|
@@ -269,6 +269,104 @@ declare namespace pxsim.loops {
|
|
|
269
269
|
let pause: typeof thread.pause;
|
|
270
270
|
let forever: typeof thread.forever;
|
|
271
271
|
}
|
|
272
|
+
declare namespace pxsim.browserEvents {
|
|
273
|
+
function mouseX(): number;
|
|
274
|
+
function mouseY(): number;
|
|
275
|
+
function wheelDx(): number;
|
|
276
|
+
function wheelDy(): number;
|
|
277
|
+
function wheelDz(): number;
|
|
278
|
+
}
|
|
279
|
+
declare namespace pxsim.browserEvents {
|
|
280
|
+
enum Key {
|
|
281
|
+
Zero = 48,
|
|
282
|
+
One = 49,
|
|
283
|
+
Two = 50,
|
|
284
|
+
Three = 51,
|
|
285
|
+
Four = 52,
|
|
286
|
+
Five = 53,
|
|
287
|
+
Six = 54,
|
|
288
|
+
Seven = 55,
|
|
289
|
+
Eight = 56,
|
|
290
|
+
Nine = 57,
|
|
291
|
+
BackTick = 192,
|
|
292
|
+
Hyphen = 189,
|
|
293
|
+
Equals = 187,
|
|
294
|
+
Q = 81,
|
|
295
|
+
W = 87,
|
|
296
|
+
E = 69,
|
|
297
|
+
R = 82,
|
|
298
|
+
T = 84,
|
|
299
|
+
Y = 89,
|
|
300
|
+
U = 85,
|
|
301
|
+
I = 73,
|
|
302
|
+
O = 79,
|
|
303
|
+
P = 80,
|
|
304
|
+
OpenBracket = 219,
|
|
305
|
+
CloseBracket = 221,
|
|
306
|
+
BackSlash = 220,
|
|
307
|
+
A = 65,
|
|
308
|
+
S = 83,
|
|
309
|
+
D = 68,
|
|
310
|
+
F = 70,
|
|
311
|
+
G = 71,
|
|
312
|
+
H = 72,
|
|
313
|
+
Space = 32,
|
|
314
|
+
PageUp = 33,
|
|
315
|
+
J = 74,
|
|
316
|
+
K = 75,
|
|
317
|
+
L = 76,
|
|
318
|
+
SemiColon = 186,
|
|
319
|
+
Apostrophe = 222,
|
|
320
|
+
Z = 90,
|
|
321
|
+
X = 88,
|
|
322
|
+
C = 67,
|
|
323
|
+
V = 86,
|
|
324
|
+
B = 66,
|
|
325
|
+
N = 78,
|
|
326
|
+
M = 77,
|
|
327
|
+
Comma = 188,
|
|
328
|
+
Period = 190,
|
|
329
|
+
ForwardSlash = 191,
|
|
330
|
+
Shift = 16,
|
|
331
|
+
Enter = 13,
|
|
332
|
+
CapsLock = 20,
|
|
333
|
+
Tab = 9,
|
|
334
|
+
Control = 17,
|
|
335
|
+
Meta = 91,
|
|
336
|
+
Alt = 18,
|
|
337
|
+
ArrowUp = 38,
|
|
338
|
+
ArrowDown = 40,
|
|
339
|
+
ArrowLeft = 37,
|
|
340
|
+
ArrowRight = 39,
|
|
341
|
+
PageDown = 34,
|
|
342
|
+
End = 35,
|
|
343
|
+
Home = 36
|
|
344
|
+
}
|
|
345
|
+
function onKeyboardEvent(event: KeyboardEvent, pressed: boolean): void;
|
|
346
|
+
function getValueForKey(event: KeyboardEvent): 0 | Key;
|
|
347
|
+
}
|
|
348
|
+
declare namespace pxsim.browserEvents {
|
|
349
|
+
interface BrowserEventsBoard extends CommonBoard {
|
|
350
|
+
mouseState: MouseState;
|
|
351
|
+
}
|
|
352
|
+
type MouseEvent = "pointerdown" | "pointerup" | "pointermove" | "pointerleave" | "pointerenter" | "pointercancel" | "pointerover" | "pointerout";
|
|
353
|
+
class MouseState {
|
|
354
|
+
protected x: number;
|
|
355
|
+
protected y: number;
|
|
356
|
+
protected dx: number;
|
|
357
|
+
protected dy: number;
|
|
358
|
+
protected dz: number;
|
|
359
|
+
protected onMove: any;
|
|
360
|
+
protected onWheel: any;
|
|
361
|
+
onEvent(event: PointerEvent, x: number, y: number): void;
|
|
362
|
+
onWheelEvent(dx: number, dy: number, dz: number): void;
|
|
363
|
+
mouseX(): number;
|
|
364
|
+
mouseY(): number;
|
|
365
|
+
wheelDx(): number;
|
|
366
|
+
wheelDy(): number;
|
|
367
|
+
wheelDz(): number;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
272
370
|
declare namespace pxsim {
|
|
273
371
|
class CommonButton extends Button {
|
|
274
372
|
private _pressedTime;
|
package/built/common-sim.js
CHANGED
|
@@ -711,6 +711,349 @@ var pxsim;
|
|
|
711
711
|
loops.forever = pxsim.thread.forever;
|
|
712
712
|
})(loops = pxsim.loops || (pxsim.loops = {}));
|
|
713
713
|
})(pxsim || (pxsim = {}));
|
|
714
|
+
var pxsim;
|
|
715
|
+
(function (pxsim) {
|
|
716
|
+
var browserEvents;
|
|
717
|
+
(function (browserEvents) {
|
|
718
|
+
function mouseX() {
|
|
719
|
+
return pxsim.board().mouseState.mouseX();
|
|
720
|
+
}
|
|
721
|
+
browserEvents.mouseX = mouseX;
|
|
722
|
+
function mouseY() {
|
|
723
|
+
return pxsim.board().mouseState.mouseY();
|
|
724
|
+
}
|
|
725
|
+
browserEvents.mouseY = mouseY;
|
|
726
|
+
function wheelDx() {
|
|
727
|
+
return pxsim.board().mouseState.wheelDx();
|
|
728
|
+
}
|
|
729
|
+
browserEvents.wheelDx = wheelDx;
|
|
730
|
+
function wheelDy() {
|
|
731
|
+
return pxsim.board().mouseState.wheelDy();
|
|
732
|
+
}
|
|
733
|
+
browserEvents.wheelDy = wheelDy;
|
|
734
|
+
function wheelDz() {
|
|
735
|
+
return pxsim.board().mouseState.wheelDz();
|
|
736
|
+
}
|
|
737
|
+
browserEvents.wheelDz = wheelDz;
|
|
738
|
+
})(browserEvents = pxsim.browserEvents || (pxsim.browserEvents = {}));
|
|
739
|
+
})(pxsim || (pxsim = {}));
|
|
740
|
+
var pxsim;
|
|
741
|
+
(function (pxsim) {
|
|
742
|
+
var browserEvents;
|
|
743
|
+
(function (browserEvents) {
|
|
744
|
+
let Key;
|
|
745
|
+
(function (Key) {
|
|
746
|
+
Key[Key["Zero"] = 48] = "Zero";
|
|
747
|
+
Key[Key["One"] = 49] = "One";
|
|
748
|
+
Key[Key["Two"] = 50] = "Two";
|
|
749
|
+
Key[Key["Three"] = 51] = "Three";
|
|
750
|
+
Key[Key["Four"] = 52] = "Four";
|
|
751
|
+
Key[Key["Five"] = 53] = "Five";
|
|
752
|
+
Key[Key["Six"] = 54] = "Six";
|
|
753
|
+
Key[Key["Seven"] = 55] = "Seven";
|
|
754
|
+
Key[Key["Eight"] = 56] = "Eight";
|
|
755
|
+
Key[Key["Nine"] = 57] = "Nine";
|
|
756
|
+
Key[Key["BackTick"] = 192] = "BackTick";
|
|
757
|
+
Key[Key["Hyphen"] = 189] = "Hyphen";
|
|
758
|
+
Key[Key["Equals"] = 187] = "Equals";
|
|
759
|
+
Key[Key["Q"] = 81] = "Q";
|
|
760
|
+
Key[Key["W"] = 87] = "W";
|
|
761
|
+
Key[Key["E"] = 69] = "E";
|
|
762
|
+
Key[Key["R"] = 82] = "R";
|
|
763
|
+
Key[Key["T"] = 84] = "T";
|
|
764
|
+
Key[Key["Y"] = 89] = "Y";
|
|
765
|
+
Key[Key["U"] = 85] = "U";
|
|
766
|
+
Key[Key["I"] = 73] = "I";
|
|
767
|
+
Key[Key["O"] = 79] = "O";
|
|
768
|
+
Key[Key["P"] = 80] = "P";
|
|
769
|
+
Key[Key["OpenBracket"] = 219] = "OpenBracket";
|
|
770
|
+
Key[Key["CloseBracket"] = 221] = "CloseBracket";
|
|
771
|
+
Key[Key["BackSlash"] = 220] = "BackSlash";
|
|
772
|
+
Key[Key["A"] = 65] = "A";
|
|
773
|
+
Key[Key["S"] = 83] = "S";
|
|
774
|
+
Key[Key["D"] = 68] = "D";
|
|
775
|
+
Key[Key["F"] = 70] = "F";
|
|
776
|
+
Key[Key["G"] = 71] = "G";
|
|
777
|
+
Key[Key["H"] = 72] = "H";
|
|
778
|
+
Key[Key["Space"] = 32] = "Space";
|
|
779
|
+
Key[Key["PageUp"] = 33] = "PageUp";
|
|
780
|
+
Key[Key["J"] = 74] = "J";
|
|
781
|
+
Key[Key["K"] = 75] = "K";
|
|
782
|
+
Key[Key["L"] = 76] = "L";
|
|
783
|
+
Key[Key["SemiColon"] = 186] = "SemiColon";
|
|
784
|
+
Key[Key["Apostrophe"] = 222] = "Apostrophe";
|
|
785
|
+
Key[Key["Z"] = 90] = "Z";
|
|
786
|
+
Key[Key["X"] = 88] = "X";
|
|
787
|
+
Key[Key["C"] = 67] = "C";
|
|
788
|
+
Key[Key["V"] = 86] = "V";
|
|
789
|
+
Key[Key["B"] = 66] = "B";
|
|
790
|
+
Key[Key["N"] = 78] = "N";
|
|
791
|
+
Key[Key["M"] = 77] = "M";
|
|
792
|
+
Key[Key["Comma"] = 188] = "Comma";
|
|
793
|
+
Key[Key["Period"] = 190] = "Period";
|
|
794
|
+
Key[Key["ForwardSlash"] = 191] = "ForwardSlash";
|
|
795
|
+
Key[Key["Shift"] = 16] = "Shift";
|
|
796
|
+
Key[Key["Enter"] = 13] = "Enter";
|
|
797
|
+
Key[Key["CapsLock"] = 20] = "CapsLock";
|
|
798
|
+
Key[Key["Tab"] = 9] = "Tab";
|
|
799
|
+
Key[Key["Control"] = 17] = "Control";
|
|
800
|
+
Key[Key["Meta"] = 91] = "Meta";
|
|
801
|
+
Key[Key["Alt"] = 18] = "Alt";
|
|
802
|
+
Key[Key["ArrowUp"] = 38] = "ArrowUp";
|
|
803
|
+
Key[Key["ArrowDown"] = 40] = "ArrowDown";
|
|
804
|
+
Key[Key["ArrowLeft"] = 37] = "ArrowLeft";
|
|
805
|
+
Key[Key["ArrowRight"] = 39] = "ArrowRight";
|
|
806
|
+
Key[Key["PageDown"] = 34] = "PageDown";
|
|
807
|
+
Key[Key["End"] = 35] = "End";
|
|
808
|
+
Key[Key["Home"] = 36] = "Home";
|
|
809
|
+
})(Key = browserEvents.Key || (browserEvents.Key = {}));
|
|
810
|
+
function onKeyboardEvent(event, pressed) {
|
|
811
|
+
if (pressed) {
|
|
812
|
+
pxsim.board().bus.queue(6866, getValueForKey(event));
|
|
813
|
+
}
|
|
814
|
+
else {
|
|
815
|
+
pxsim.board().bus.queue(6867, getValueForKey(event));
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
browserEvents.onKeyboardEvent = onKeyboardEvent;
|
|
819
|
+
function getValueForKey(event) {
|
|
820
|
+
switch (event.key) {
|
|
821
|
+
case "0":
|
|
822
|
+
case ")":
|
|
823
|
+
return Key.Zero;
|
|
824
|
+
case "1":
|
|
825
|
+
case "!":
|
|
826
|
+
return Key.One;
|
|
827
|
+
case "2":
|
|
828
|
+
case "@":
|
|
829
|
+
return Key.Two;
|
|
830
|
+
case "3":
|
|
831
|
+
case "#":
|
|
832
|
+
return Key.Three;
|
|
833
|
+
case "4":
|
|
834
|
+
case "$":
|
|
835
|
+
return Key.Four;
|
|
836
|
+
case "5":
|
|
837
|
+
case "%":
|
|
838
|
+
return Key.Five;
|
|
839
|
+
case "6":
|
|
840
|
+
case "^":
|
|
841
|
+
return Key.Six;
|
|
842
|
+
case "7":
|
|
843
|
+
case "&":
|
|
844
|
+
return Key.Seven;
|
|
845
|
+
case "8":
|
|
846
|
+
case "*":
|
|
847
|
+
return Key.Eight;
|
|
848
|
+
case "9":
|
|
849
|
+
case "(":
|
|
850
|
+
return Key.Nine;
|
|
851
|
+
case "`":
|
|
852
|
+
case "~":
|
|
853
|
+
return Key.BackTick;
|
|
854
|
+
case "-":
|
|
855
|
+
case "_":
|
|
856
|
+
return Key.Hyphen;
|
|
857
|
+
case "=":
|
|
858
|
+
case "+":
|
|
859
|
+
return Key.Equals;
|
|
860
|
+
case "Q":
|
|
861
|
+
case "q":
|
|
862
|
+
return Key.Q;
|
|
863
|
+
case "W":
|
|
864
|
+
case "w":
|
|
865
|
+
return Key.W;
|
|
866
|
+
case "E":
|
|
867
|
+
case "e":
|
|
868
|
+
return Key.E;
|
|
869
|
+
case "R":
|
|
870
|
+
case "r":
|
|
871
|
+
return Key.R;
|
|
872
|
+
case "T":
|
|
873
|
+
case "t":
|
|
874
|
+
return Key.T;
|
|
875
|
+
case "Y":
|
|
876
|
+
case "y":
|
|
877
|
+
return Key.Y;
|
|
878
|
+
case "U":
|
|
879
|
+
case "u":
|
|
880
|
+
return Key.U;
|
|
881
|
+
case "I":
|
|
882
|
+
case "i":
|
|
883
|
+
return Key.I;
|
|
884
|
+
case "O":
|
|
885
|
+
case "o":
|
|
886
|
+
return Key.O;
|
|
887
|
+
case "P":
|
|
888
|
+
case "p":
|
|
889
|
+
return Key.P;
|
|
890
|
+
case "[":
|
|
891
|
+
case "{":
|
|
892
|
+
return Key.OpenBracket;
|
|
893
|
+
case "]":
|
|
894
|
+
case "}":
|
|
895
|
+
return Key.CloseBracket;
|
|
896
|
+
case "\\":
|
|
897
|
+
case "|":
|
|
898
|
+
return Key.BackSlash;
|
|
899
|
+
case "A":
|
|
900
|
+
case "a":
|
|
901
|
+
return Key.A;
|
|
902
|
+
case "S":
|
|
903
|
+
case "s":
|
|
904
|
+
return Key.S;
|
|
905
|
+
case "D":
|
|
906
|
+
case "d":
|
|
907
|
+
return Key.D;
|
|
908
|
+
case "F":
|
|
909
|
+
case "f":
|
|
910
|
+
return Key.F;
|
|
911
|
+
case "G":
|
|
912
|
+
case "g":
|
|
913
|
+
return Key.G;
|
|
914
|
+
case "H":
|
|
915
|
+
case "h":
|
|
916
|
+
return Key.H;
|
|
917
|
+
case " ":
|
|
918
|
+
return Key.Space;
|
|
919
|
+
case "PageUp":
|
|
920
|
+
return Key.PageUp;
|
|
921
|
+
case "J":
|
|
922
|
+
case "j":
|
|
923
|
+
return Key.J;
|
|
924
|
+
case "K":
|
|
925
|
+
case "k":
|
|
926
|
+
return Key.K;
|
|
927
|
+
case "L":
|
|
928
|
+
case "l":
|
|
929
|
+
return Key.L;
|
|
930
|
+
case ";":
|
|
931
|
+
case ":":
|
|
932
|
+
return Key.SemiColon;
|
|
933
|
+
case "'":
|
|
934
|
+
case "\"":
|
|
935
|
+
return Key.Apostrophe;
|
|
936
|
+
case "Z":
|
|
937
|
+
case "z":
|
|
938
|
+
return Key.Z;
|
|
939
|
+
case "X":
|
|
940
|
+
case "x":
|
|
941
|
+
return Key.X;
|
|
942
|
+
case "C":
|
|
943
|
+
case "c":
|
|
944
|
+
return Key.C;
|
|
945
|
+
case "V":
|
|
946
|
+
case "v":
|
|
947
|
+
return Key.V;
|
|
948
|
+
case "B":
|
|
949
|
+
case "b":
|
|
950
|
+
return Key.B;
|
|
951
|
+
case "N":
|
|
952
|
+
case "n":
|
|
953
|
+
return Key.N;
|
|
954
|
+
case "M":
|
|
955
|
+
case "m":
|
|
956
|
+
return Key.M;
|
|
957
|
+
case ",":
|
|
958
|
+
case "<":
|
|
959
|
+
return Key.Comma;
|
|
960
|
+
case ".":
|
|
961
|
+
case ">":
|
|
962
|
+
return Key.Period;
|
|
963
|
+
case "/":
|
|
964
|
+
case "?":
|
|
965
|
+
return Key.ForwardSlash;
|
|
966
|
+
case "Shift":
|
|
967
|
+
return Key.Shift;
|
|
968
|
+
case "Enter":
|
|
969
|
+
return Key.Enter;
|
|
970
|
+
case "CapsLock":
|
|
971
|
+
return Key.CapsLock;
|
|
972
|
+
case "Tab":
|
|
973
|
+
return Key.Tab;
|
|
974
|
+
case "Control":
|
|
975
|
+
return Key.Control;
|
|
976
|
+
case "Meta":
|
|
977
|
+
return Key.Meta;
|
|
978
|
+
case "Alt":
|
|
979
|
+
return Key.Alt;
|
|
980
|
+
case "ArrowUp":
|
|
981
|
+
return Key.ArrowUp;
|
|
982
|
+
case "ArrowDown":
|
|
983
|
+
return Key.ArrowDown;
|
|
984
|
+
case "ArrowLeft":
|
|
985
|
+
return Key.ArrowLeft;
|
|
986
|
+
case "ArrowRight":
|
|
987
|
+
return Key.ArrowRight;
|
|
988
|
+
case "PageDown":
|
|
989
|
+
return Key.PageDown;
|
|
990
|
+
case "End":
|
|
991
|
+
return Key.End;
|
|
992
|
+
case "Home":
|
|
993
|
+
return Key.Home;
|
|
994
|
+
default:
|
|
995
|
+
return 0;
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
browserEvents.getValueForKey = getValueForKey;
|
|
999
|
+
})(browserEvents = pxsim.browserEvents || (pxsim.browserEvents = {}));
|
|
1000
|
+
})(pxsim || (pxsim = {}));
|
|
1001
|
+
var pxsim;
|
|
1002
|
+
(function (pxsim) {
|
|
1003
|
+
var browserEvents;
|
|
1004
|
+
(function (browserEvents) {
|
|
1005
|
+
const THROTTLE_INTERVAL = 50;
|
|
1006
|
+
class MouseState {
|
|
1007
|
+
constructor() {
|
|
1008
|
+
this.onMove = pxsim.U.throttle(() => {
|
|
1009
|
+
pxsim.board().bus.queue(6859, 0);
|
|
1010
|
+
}, THROTTLE_INTERVAL, true);
|
|
1011
|
+
this.onWheel = pxsim.U.throttle(() => {
|
|
1012
|
+
pxsim.board().bus.queue(6865, 0);
|
|
1013
|
+
}, THROTTLE_INTERVAL, true);
|
|
1014
|
+
}
|
|
1015
|
+
onEvent(event, x, y) {
|
|
1016
|
+
this.x = x;
|
|
1017
|
+
this.y = y;
|
|
1018
|
+
const events = [
|
|
1019
|
+
"pointerdown",
|
|
1020
|
+
"pointerup",
|
|
1021
|
+
"pointermove",
|
|
1022
|
+
"pointerleave",
|
|
1023
|
+
"pointerenter",
|
|
1024
|
+
"pointercancel",
|
|
1025
|
+
"pointerover",
|
|
1026
|
+
"pointerout",
|
|
1027
|
+
];
|
|
1028
|
+
// We add 1 to the button here because the left button is 0 and
|
|
1029
|
+
// that's used as a wildcard in our event bus
|
|
1030
|
+
pxsim.board().bus.queue(6857 + events.indexOf(event.type), (event.button || 0) + 1);
|
|
1031
|
+
}
|
|
1032
|
+
onWheelEvent(dx, dy, dz) {
|
|
1033
|
+
this.dx = dx;
|
|
1034
|
+
this.dy = dy;
|
|
1035
|
+
this.dz = dz;
|
|
1036
|
+
this.onWheel();
|
|
1037
|
+
}
|
|
1038
|
+
mouseX() {
|
|
1039
|
+
return this.x || 0;
|
|
1040
|
+
}
|
|
1041
|
+
mouseY() {
|
|
1042
|
+
return this.y || 0;
|
|
1043
|
+
}
|
|
1044
|
+
wheelDx() {
|
|
1045
|
+
return this.dx || 0;
|
|
1046
|
+
}
|
|
1047
|
+
wheelDy() {
|
|
1048
|
+
return this.dy || 0;
|
|
1049
|
+
}
|
|
1050
|
+
wheelDz() {
|
|
1051
|
+
return this.dz || 0;
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
browserEvents.MouseState = MouseState;
|
|
1055
|
+
})(browserEvents = pxsim.browserEvents || (pxsim.browserEvents = {}));
|
|
1056
|
+
})(pxsim || (pxsim = {}));
|
|
714
1057
|
/// <reference path="../../core/dal.d.ts"/>
|
|
715
1058
|
var pxsim;
|
|
716
1059
|
(function (pxsim) {
|