summaryrefslogtreecommitdiff
path: root/Library/Artifacts/92/920fc7a1f480254e88f6e819a091543c
blob: adfdc3b9af53da900c8b1109e2a26b83b6099c46 (plain)
ofshex dumpascii
0000 00 00 0f 81 00 02 82 80 00 00 00 15 00 00 10 00 00 00 00 00 32 30 31 39 2e 33 2e 36 66 31 00 fe ....................2019.3.6f1..
0020 ff ff ff 01 02 00 00 00 0b 04 00 00 00 ff ff 66 9a 86 21 eb 14 35 98 39 dd 34 1d 51 0e c1 f3 42 ...............f..!..5.9.4.Q...B
0040 00 00 00 ed 00 00 00 02 00 00 00 00 00 00 00 37 00 00 80 ff ff ff ff 00 00 00 00 00 80 00 00 00 ...............7................
0060 00 00 00 00 00 00 00 01 00 01 00 a6 03 00 80 b2 01 00 80 04 00 00 00 01 00 00 00 01 00 00 00 00 ................................
0080 00 00 00 00 00 00 00 01 00 01 00 0d 00 00 00 45 04 00 80 0c 00 00 00 02 00 00 00 01 00 00 00 00 ...............E................
00a0 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 23 00 00 00 04 00 00 00 03 00 00 00 01 00 80 00 00 ...............#................
00c0 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 2c 00 00 00 08 00 00 00 04 00 00 00 01 00 80 00 00 ...............,................
00e0 00 00 00 00 00 00 00 01 00 01 00 35 00 00 00 61 04 00 80 0c 00 00 00 05 00 00 00 01 00 00 00 00 ...........5...a................
0100 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 23 00 00 00 04 00 00 00 06 00 00 00 01 00 80 00 00 ...............#................
0120 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 2c 00 00 00 08 00 00 00 07 00 00 00 01 00 80 00 00 ...............,................
0140 00 00 00 00 00 00 00 01 00 01 00 86 02 00 80 72 04 00 80 0c 00 00 00 08 00 00 00 01 00 00 00 00 ...............r................
0160 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 23 00 00 00 04 00 00 00 09 00 00 00 01 00 80 00 00 ...............#................
0180 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 2c 00 00 00 08 00 00 00 0a 00 00 00 01 00 80 00 00 ...............,................
01a0 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 ab 01 00 80 ff ff ff ff 0b 00 00 00 01 80 08 00 00 ...........H....................
01c0 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 0c 00 00 00 01 40 08 00 00 ...........1...1............@...
01e0 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 0d 00 00 00 01 00 08 00 00 ................................
0200 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a 00 00 80 01 00 00 00 0e 00 00 00 01 00 08 00 00 ...........Q...j................
0220 00 00 00 00 00 00 00 01 00 01 00 f1 00 00 80 4a 00 00 00 ff ff ff ff 0f 00 00 00 00 c0 00 00 00 ...............J................
0240 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 10 00 00 00 00 80 00 00 00 ...........1...1................
0260 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 11 00 00 00 00 00 00 00 00 ................................
0280 00 00 00 00 00 00 00 01 00 03 00 1f 02 00 80 6a 00 00 80 ff ff ff ff 12 00 00 00 00 80 00 00 00 ...............j................
02a0 00 00 00 00 00 00 00 01 00 04 00 5c 00 00 00 9b 00 00 80 ff ff ff ff 13 00 00 00 00 80 00 00 00 ...........\....................
02c0 00 00 00 00 00 00 00 01 00 05 00 48 03 00 80 72 00 00 00 ff ff ff ff 14 00 00 00 00 80 00 00 00 ...........H...r................
02e0 00 00 00 00 00 00 00 01 00 06 01 31 00 00 80 31 00 00 80 ff ff ff ff 15 00 00 00 01 40 00 00 00 ...........1...1............@...
0300 00 00 00 00 00 00 00 01 00 07 00 de 00 00 80 1b 03 00 80 04 00 00 00 16 00 00 00 01 00 00 00 00 ................................
0320 00 00 00 00 00 00 00 01 00 07 00 51 00 00 80 6a 00 00 80 01 00 00 00 17 00 00 00 01 00 00 00 00 ...........Q...j................
0340 00 00 00 00 00 00 00 01 00 05 00 48 03 00 80 77 00 00 00 ff ff ff ff 18 00 00 00 00 80 00 00 00 ...........H...w................
0360 00 00 00 00 00 00 00 01 00 06 01 31 00 00 80 31 00 00 80 ff ff ff ff 19 00 00 00 01 40 00 00 00 ...........1...1............@...
0380 00 00 00 00 00 00 00 01 00 07 00 de 00 00 80 1b 03 00 80 04 00 00 00 1a 00 00 00 01 00 00 00 00 ................................
03a0 00 00 00 00 00 00 00 01 00 07 00 51 00 00 80 6a 00 00 80 01 00 00 00 1b 00 00 00 01 00 00 00 00 ...........Q...j................
03c0 00 00 00 00 00 00 00 01 00 05 00 48 03 00 80 80 00 00 00 ff ff ff ff 1c 00 00 00 00 80 00 00 00 ...........H....................
03e0 00 00 00 00 00 00 00 01 00 06 01 31 00 00 80 31 00 00 80 ff ff ff ff 1d 00 00 00 01 40 00 00 00 ...........1...1............@...
0400 00 00 00 00 00 00 00 01 00 07 00 de 00 00 80 1b 03 00 80 04 00 00 00 1e 00 00 00 01 00 00 00 00 ................................
0420 00 00 00 00 00 00 00 01 00 07 00 51 00 00 80 6a 00 00 80 01 00 00 00 1f 00 00 00 01 00 00 00 00 ...........Q...j................
0440 00 00 00 00 00 00 00 01 00 04 00 79 02 00 80 0a 03 00 80 0c 00 00 00 20 00 00 00 00 00 00 00 00 ...........y....................
0460 00 00 00 00 00 00 00 01 00 05 00 de 00 00 80 23 00 00 00 04 00 00 00 21 00 00 00 01 00 80 00 00 ...............#.......!........
0480 00 00 00 00 00 00 00 01 00 05 00 2e 03 00 80 2c 00 00 00 08 00 00 00 22 00 00 00 01 00 80 00 00 ...............,......."........
04a0 00 00 00 00 00 00 00 01 00 01 00 11 03 00 80 85 00 00 00 ff ff ff ff 23 00 00 00 01 40 08 00 00 .......................#....@...
04c0 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 24 00 00 00 01 00 08 00 00 ...........1...1.......$........
04e0 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 25 00 00 00 01 00 08 00 00 .......................%........
0500 00 00 00 00 00 00 00 01 00 03 00 2e 03 00 80 6a 00 00 80 08 00 00 00 26 00 00 00 01 00 08 00 00 ...............j.......&........
0520 00 00 00 00 00 00 00 01 00 01 00 d5 03 00 80 93 00 00 00 ff ff ff ff 27 00 00 00 00 80 00 00 00 .......................'........
0540 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 28 00 00 00 00 c0 00 00 00 ...........1...1.......(........
0560 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 29 00 00 00 00 00 00 00 00 .......................)........
0580 00 00 00 00 00 00 00 01 00 03 00 1f 02 00 80 6a 00 00 80 ff ff ff ff 2a 00 00 00 00 80 00 00 00 ...............j.......*........
05a0 00 00 00 00 00 00 00 01 00 04 00 48 03 00 80 9b 00 00 80 ff ff ff ff 2b 00 00 00 00 80 00 00 00 ...........H...........+........
05c0 00 00 00 00 00 00 00 01 00 05 01 31 00 00 80 31 00 00 80 ff ff ff ff 2c 00 00 00 01 40 00 00 00 ...........1...1.......,....@...
05e0 00 00 00 00 00 00 00 01 00 06 00 de 00 00 80 1b 03 00 80 04 00 00 00 2d 00 00 00 01 00 00 00 00 .......................-........
0600 00 00 00 00 00 00 00 01 00 06 00 51 00 00 80 6a 00 00 80 01 00 00 00 2e 00 00 00 01 00 00 00 00 ...........Q...j................
0620 00 00 00 00 00 00 00 01 00 04 00 79 02 00 80 0a 03 00 80 0c 00 00 00 2f 00 00 00 00 00 00 00 00 ...........y.........../........
0640 00 00 00 00 00 00 00 01 00 05 00 de 00 00 80 23 00 00 00 04 00 00 00 30 00 00 00 01 00 80 00 00 ...............#.......0........
0660 00 00 00 00 00 00 00 01 00 05 00 2e 03 00 80 2c 00 00 00 08 00 00 00 31 00 00 00 01 00 80 00 00 ...............,.......1........
0680 00 00 00 00 00 00 00 01 00 01 00 20 03 00 80 a7 00 00 00 02 00 00 00 32 00 00 00 00 40 00 00 00 .......................2....@...
06a0 00 00 00 00 00 00 00 01 00 01 00 be 02 00 80 b6 00 00 00 0c 00 00 00 33 00 00 00 00 40 00 00 00 .......................3....@...
06c0 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 23 00 00 00 04 00 00 00 34 00 00 00 01 00 80 00 00 ...............#.......4........
06e0 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 2c 00 00 00 08 00 00 00 35 00 00 00 01 00 80 00 00 ...............,.......5........
0700 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 bb 00 00 00 ff ff ff ff 36 00 00 00 01 80 00 00 00 ...........H...........6........
0720 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 37 00 00 00 01 40 00 00 00 ...........1...1.......7....@...
0740 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 38 00 00 00 01 00 00 00 00 .......................8........
0760 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a 00 00 80 01 00 00 00 39 00 00 00 01 00 00 00 00 ...........Q...j.......9........
0780 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 c6 00 00 00 ff ff ff ff 3a 00 00 00 01 80 00 00 00 ...........H...........:........
07a0 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 3b 00 00 00 01 40 00 00 00 ...........1...1.......;....@...
07c0 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 3c 00 00 00 01 00 00 00 00 .......................<........
07e0 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a 00 00 80 01 00 00 00 3d 00 00 00 01 00 00 00 00 ...........Q...j.......=........
0800 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 d8 00 00 00 ff ff ff ff 3e 00 00 00 01 80 00 00 00 ...........H...........>........
0820 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 00 00 80 ff ff ff ff 3f 00 00 00 01 40 00 00 00 ...........1...1.......?....@...
0840 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b 03 00 80 04 00 00 00 40 00 00 00 01 00 00 00 00 .......................@........
0860 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a 00 00 80 01 00 00 00 41 00 00 00 01 00 00 00 00 ...........Q...j.......A........
0880 00 00 00 00 00 00 00 4d 6f 6e 6f 49 6d 70 6f 72 74 65 72 00 50 50 74 72 3c 45 64 69 74 6f 72 45 .......MonoImporter.PPtr<EditorE
08a0 78 74 65 6e 73 69 6f 6e 3e 00 6d 5f 46 69 6c 65 49 44 00 6d 5f 50 61 74 68 49 44 00 50 50 74 72 xtension>.m_FileID.m_PathID.PPtr
08c0 3c 50 72 65 66 61 62 49 6e 73 74 61 6e 63 65 3e 00 6d 5f 45 78 74 65 72 6e 61 6c 4f 62 6a 65 63 <PrefabInstance>.m_ExternalObjec
08e0 74 73 00 53 6f 75 72 63 65 41 73 73 65 74 49 64 65 6e 74 69 66 69 65 72 00 74 79 70 65 00 61 73 ts.SourceAssetIdentifier.type.as
0900 73 65 6d 62 6c 79 00 6e 61 6d 65 00 6d 5f 55 73 65 64 46 69 6c 65 49 44 73 00 6d 5f 44 65 66 61 sembly.name.m_UsedFileIDs.m_Defa
0920 75 6c 74 52 65 66 65 72 65 6e 63 65 73 00 65 78 65 63 75 74 69 6f 6e 4f 72 64 65 72 00 69 63 6f ultReferences.executionOrder.ico
0940 6e 00 6d 5f 55 73 65 72 44 61 74 61 00 6d 5f 41 73 73 65 74 42 75 6e 64 6c 65 4e 61 6d 65 00 6d n.m_UserData.m_AssetBundleName.m
0960 5f 41 73 73 65 74 42 75 6e 64 6c 65 56 61 72 69 61 6e 74 00 00 00 00 00 73 00 00 00 00 ff ff a3 _AssetBundleVariant.....s.......
0980 47 f1 d7 dc 8f 5a 35 36 a0 3a 21 40 69 c1 4a 2a 00 00 00 81 00 00 00 05 00 00 00 15 01 00 80 37 G....Z56.:!@i.J*...............7
09a0 00 00 80 ff ff ff ff 00 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 01 00 01 00 a6 03 00 80 b2 ................................
09c0 01 00 80 04 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 00 00 45 ...............................E
09e0 04 00 80 0c 00 00 00 02 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 16 ................................
0a00 00 00 00 04 00 00 00 03 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 1f ................................
0a20 00 00 00 08 00 00 00 04 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 01 00 28 00 00 00 61 ...........................(...a
0a40 04 00 80 0c 00 00 00 05 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 16 ................................
0a60 00 00 00 04 00 00 00 06 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 1f ................................
0a80 00 00 00 08 00 00 00 07 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 01 00 86 02 00 80 72 ...............................r
0aa0 04 00 80 0c 00 00 00 08 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 16 ................................
0ac0 00 00 00 04 00 00 00 09 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 1f ................................
0ae0 00 00 00 08 00 00 00 0a 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 ab ...........................H....
0b00 01 00 80 ff ff ff ff 0b 00 00 00 01 80 08 00 00 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 ...........................1...1
0b20 00 00 80 ff ff ff ff 0c 00 00 00 01 40 08 00 00 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b ............@...................
0b40 03 00 80 04 00 00 00 0d 00 00 00 01 00 08 00 00 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a ...........................Q...j
0b60 00 00 80 01 00 00 00 0e 00 00 00 01 00 08 00 00 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 ea ...........................H....
0b80 01 00 80 ff ff ff ff 0f 00 00 00 01 80 00 00 00 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 ...........................1...1
0ba0 00 00 80 ff ff ff ff 10 00 00 00 01 40 00 00 00 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b ............@...................
0bc0 03 00 80 04 00 00 00 11 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a ...........................Q...j
0be0 00 00 80 01 00 00 00 12 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 f1 00 00 80 3d ...............................=
0c00 00 00 00 ff ff ff ff 13 00 00 00 01 80 00 00 00 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 ...........................1...1
0c20 00 00 80 ff ff ff ff 14 00 00 00 01 80 00 00 00 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b ................................
0c40 03 00 80 04 00 00 00 15 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 03 00 1f 02 00 80 6a ...............................j
0c60 00 00 80 ff ff ff ff 16 00 00 00 01 80 00 00 00 00 00 00 00 00 00 00 01 00 04 00 48 03 00 80 9b ...........................H....
0c80 00 00 80 ff ff ff ff 17 00 00 00 01 80 00 00 00 00 00 00 00 00 00 00 01 00 05 01 31 00 00 80 31 ...........................1...1
0ca0 00 00 80 ff ff ff ff 18 00 00 00 01 40 00 00 00 00 00 00 00 00 00 00 01 00 06 00 de 00 00 80 1b ............@...................
0cc0 03 00 80 04 00 00 00 19 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 06 00 51 00 00 80 6a ...........................Q...j
0ce0 00 00 80 01 00 00 00 1a 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 04 00 79 02 00 80 0a ...........................y....
0d00 03 00 80 0c 00 00 00 1b 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 01 00 05 00 de 00 00 80 16 ................................
0d20 00 00 00 04 00 00 00 1c 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 05 00 2e 03 00 80 1f ................................
0d40 00 00 00 08 00 00 00 1d 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 01 00 79 02 00 80 51 ...........................y...Q
0d60 00 00 00 0c 00 00 00 1e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 02 00 de 00 00 80 16 ................................
0d80 00 00 00 04 00 00 00 1f 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 02 00 2e 03 00 80 1f ................................
0da0 00 00 00 08 00 00 00 20 00 00 00 01 00 80 00 00 00 00 00 00 00 00 00 01 00 01 00 de 00 00 80 58 ...............................X
0dc0 00 00 00 04 00 00 00 21 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 69 .......!...................H...i
0de0 00 00 00 ff ff ff ff 22 00 00 00 10 80 00 00 00 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 ......."...................1...1
0e00 00 00 80 ff ff ff ff 23 00 00 00 11 40 00 00 00 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b .......#....@...................
0e20 03 00 80 04 00 00 00 24 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a .......$...................Q...j
0e40 00 00 80 01 00 00 00 25 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 01 00 01 00 48 03 00 80 75 .......%...................H...u
0e60 00 00 00 ff ff ff ff 26 00 00 00 10 80 00 00 00 00 00 00 00 00 00 00 01 00 02 01 31 00 00 80 31 .......&...................1...1
0e80 00 00 80 ff ff ff ff 27 00 00 00 11 40 00 00 00 00 00 00 00 00 00 00 01 00 03 00 de 00 00 80 1b .......'....@...................
0ea0 03 00 80 04 00 00 00 28 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 01 00 03 00 51 00 00 80 6a .......(...................Q...j
0ec0 00 00 80 01 00 00 00 29 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 50 50 74 72 3c 45 64 69 74 .......)...............PPtr<Edit
0ee0 6f 72 45 78 74 65 6e 73 69 6f 6e 3e 00 6d 5f 46 69 6c 65 49 44 00 6d 5f 50 61 74 68 49 44 00 50 orExtension>.m_FileID.m_PathID.P
0f00 50 74 72 3c 50 72 65 66 61 62 49 6e 73 74 61 6e 63 65 3e 00 6d 5f 44 65 66 61 75 6c 74 52 65 66 Ptr<PrefabInstance>.m_DefaultRef
0f20 65 72 65 6e 63 65 73 00 6d 5f 49 63 6f 6e 00 6d 5f 45 78 65 63 75 74 69 6f 6e 4f 72 64 65 72 00 erences.m_Icon.m_ExecutionOrder.
0f40 6d 5f 43 6c 61 73 73 4e 61 6d 65 00 6d 5f 4e 61 6d 65 73 70 61 63 65 00 00 00 00 00 02 00 00 00 m_ClassName.m_Namespace.........
0f60 03 00 00 00 00 00 00 00 00 00 00 00 5c 00 00 00 00 00 00 00 e0 79 af 00 00 00 00 00 60 00 00 00 ............\........y......`...
0f80 20 72 02 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .r..............................
0fa0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
0fc0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
0fe0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
1000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
1020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 e0 79 af 00 00 00 00 00 00 00 00 00 .....................y..........
1040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
1060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
1080 00 00 00 00 00 00 00 00 0c 00 00 00 49 6e 70 75 74 4d 61 6e 61 67 65 72 a1 71 02 00 75 73 69 6e ............InputManager.q..usin
10a0 67 20 53 79 73 74 65 6d 3b 0d 0a 75 73 69 6e 67 20 53 79 73 74 65 6d 2e 43 6f 6c 6c 65 63 74 69 g.System;..using.System.Collecti
10c0 6f 6e 73 2e 47 65 6e 65 72 69 63 3b 0d 0a 75 73 69 6e 67 20 53 79 73 74 65 6d 2e 4c 69 6e 71 3b ons.Generic;..using.System.Linq;
10e0 0d 0a 75 73 69 6e 67 20 55 6e 69 74 79 2e 43 6f 6c 6c 65 63 74 69 6f 6e 73 3b 0d 0a 75 73 69 6e ..using.Unity.Collections;..usin
1100 67 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d 2e 43 6f 6d 70 6f 73 g.UnityEngine.InputSystem.Compos
1120 69 74 65 73 3b 0d 0a 75 73 69 6e 67 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 ites;..using.UnityEngine.InputSy
1140 73 74 65 6d 2e 43 6f 6e 74 72 6f 6c 73 3b 0d 0a 75 73 69 6e 67 20 55 6e 69 74 79 2e 43 6f 6c 6c stem.Controls;..using.Unity.Coll
1160 65 63 74 69 6f 6e 73 2e 4c 6f 77 4c 65 76 65 6c 2e 55 6e 73 61 66 65 3b 0d 0a 75 73 69 6e 67 20 ections.LowLevel.Unsafe;..using.
1180 55 6e 69 74 79 45 6e 67 69 6e 65 2e 50 72 6f 66 69 6c 69 6e 67 3b 0d 0a 75 73 69 6e 67 20 55 6e UnityEngine.Profiling;..using.Un
11a0 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d 2e 4c 6f 77 4c 65 76 65 6c 3b 0d ityEngine.InputSystem.LowLevel;.
11c0 0a 75 73 69 6e 67 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d 2e 50 .using.UnityEngine.InputSystem.P
11e0 72 6f 63 65 73 73 6f 72 73 3b 0d 0a 75 73 69 6e 67 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e rocessors;..using.UnityEngine.In
1200 70 75 74 53 79 73 74 65 6d 2e 49 6e 74 65 72 61 63 74 69 6f 6e 73 3b 0d 0a 75 73 69 6e 67 20 55 putSystem.Interactions;..using.U
1220 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d 2e 55 74 69 6c 69 74 69 65 73 nityEngine.InputSystem.Utilities
1240 3b 0d 0a 75 73 69 6e 67 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d ;..using.UnityEngine.InputSystem
1260 2e 4c 61 79 6f 75 74 73 3b 0d 0a 0d 0a 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 75 .Layouts;....#if.UNITY_EDITOR..u
1280 73 69 6e 67 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d 2e 45 64 69 sing.UnityEngine.InputSystem.Edi
12a0 74 6f 72 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 2f 2f 2f 2f 54 4f 44 4f 3a 20 6d 61 6b 65 20 64 tor;..#endif....////TODO:.make.d
12c0 69 61 67 6e 6f 73 74 69 63 73 20 61 76 61 69 6c 61 62 6c 65 20 69 6e 20 64 65 76 20 70 6c 61 79 iagnostics.available.in.dev.play
12e0 65 72 73 20 61 6e 64 20 67 69 76 65 20 69 74 20 61 20 70 75 62 6c 69 63 20 41 50 49 20 74 6f 20 ers.and.give.it.a.public.API.to.
1300 65 6e 61 62 6c 65 20 74 68 65 6d 0d 0a 0d 0a 2f 2f 2f 2f 54 4f 44 4f 3a 20 77 6f 72 6b 20 74 6f enable.them....////TODO:.work.to
1320 77 61 72 64 73 20 49 6e 70 75 74 4d 61 6e 61 67 65 72 20 68 61 76 69 6e 67 20 6e 6f 20 64 69 72 wards.InputManager.having.no.dir
1340 65 63 74 20 6b 6e 6f 77 6c 65 64 67 65 20 6f 66 20 61 63 74 69 6f 6e 73 0d 0a 0d 0a 2f 2f 2f 2f ect.knowledge.of.actions....////
1360 54 4f 44 4f 3a 20 61 6c 6c 6f 77 20 70 75 73 68 69 6e 67 20 65 76 65 6e 74 73 20 69 6e 74 6f 20 TODO:.allow.pushing.events.into.
1380 74 68 65 20 73 79 73 74 65 6d 20 61 6e 79 20 77 68 69 63 68 20 77 61 79 3b 20 64 65 63 6f 75 70 the.system.any.which.way;.decoup
13a0 6c 65 20 66 72 6f 6d 20 74 68 65 20 62 75 66 66 65 72 20 69 6e 20 4e 61 74 69 76 65 49 6e 70 75 le.from.the.buffer.in.NativeInpu
13c0 74 53 79 73 74 65 6d 20 62 65 69 6e 67 20 74 68 65 20 6f 6e 6c 79 20 73 6f 75 72 63 65 0d 0a 0d tSystem.being.the.only.source...
13e0 0a 2f 2f 2f 2f 54 4f 44 4f 3a 20 6d 61 6b 65 20 73 75 72 65 20 77 65 20 64 69 73 63 61 72 64 20 .////TODO:.make.sure.we.discard.
1400 65 76 65 6e 74 73 20 69 6e 20 65 64 69 74 6f 72 20 75 70 64 61 74 65 73 20 77 68 65 6e 20 6c 6f events.in.editor.updates.when.lo
1420 63 6b 49 6e 70 75 74 54 6f 47 61 6d 65 56 69 65 77 20 69 73 20 74 72 75 65 20 61 6e 64 20 74 68 ckInputToGameView.is.true.and.th
1440 65 20 70 6c 61 79 65 72 20 69 73 6e 27 74 20 72 75 6e 6e 69 6e 67 20 6f 72 20 70 61 75 73 65 64 e.player.isn't.running.or.paused
1460 0d 0a 0d 0a 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 63 68 61 6e 67 65 20 74 68 65 20 65 76 65 6e 74 ....////REVIEW:.change.the.event
1480 20 70 72 6f 70 65 72 74 69 65 73 20 6f 76 65 72 20 74 6f 20 75 73 69 6e 67 20 49 4f 62 73 65 72 .properties.over.to.using.IObser
14a0 76 61 62 6c 65 3f 0d 0a 0d 0a 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 69 6e 73 74 65 61 64 20 6f 66 vable?....////REVIEW:.instead.of
14c0 20 52 65 67 69 73 74 65 72 49 6e 74 65 72 61 63 74 69 6f 6e 20 61 6e 64 20 52 65 67 69 73 74 65 .RegisterInteraction.and.Registe
14e0 72 50 72 6f 63 65 73 73 6f 72 2c 20 68 61 76 65 20 61 20 67 65 6e 65 72 69 63 20 52 65 67 69 73 rProcessor,.have.a.generic.Regis
1500 74 65 72 49 6e 74 65 72 66 61 63 65 20 28 6f 72 20 73 6f 6d 65 74 68 69 6e 67 29 3f 0d 0a 0d 0a terInterface.(or.something)?....
1520 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 63 61 6e 20 77 65 20 64 6f 20 61 77 61 79 20 77 69 74 68 20 ////REVIEW:.can.we.do.away.with.
1540 74 68 65 20 27 70 72 65 76 69 6f 75 73 20 3d 3d 20 70 72 65 76 69 6f 75 73 20 66 72 61 6d 65 27 the.'previous.==.previous.frame'
1560 20 61 6e 64 20 73 69 6d 70 6c 79 20 62 75 66 66 65 72 20 66 6c 69 70 20 6f 6e 20 65 76 65 72 79 .and.simply.buffer.flip.on.every
1580 20 76 61 6c 75 65 20 77 72 69 74 65 3f 0d 0a 0d 0a 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 73 68 6f .value.write?....////REVIEW:.sho
15a0 75 6c 64 20 77 65 20 66 6f 72 63 65 20 6b 65 65 70 69 6e 67 20 6d 6f 75 73 65 2f 70 65 6e 2f 6b uld.we.force.keeping.mouse/pen/k
15c0 65 79 62 6f 61 72 64 2f 74 6f 75 63 68 20 61 72 6f 75 6e 64 20 69 6e 20 65 64 69 74 6f 72 20 65 eyboard/touch.around.in.editor.e
15e0 76 65 6e 20 69 66 20 6e 6f 74 20 69 6e 20 6c 69 73 74 20 6f 66 20 73 75 70 70 6f 72 74 65 64 20 ven.if.not.in.list.of.supported.
1600 64 65 76 69 63 65 73 3f 0d 0a 0d 0a 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 64 6f 20 77 65 20 77 61 devices?....////REVIEW:.do.we.wa
1620 6e 74 20 74 6f 20 66 69 6c 74 65 72 20 6f 75 74 20 73 74 61 74 65 20 65 76 65 6e 74 73 20 74 68 nt.to.filter.out.state.events.th
1640 61 74 20 72 65 73 75 6c 74 20 69 6e 20 6e 6f 20 73 74 61 74 65 20 63 68 61 6e 67 65 3f 0d 0a 0d at.result.in.no.state.change?...
1660 0a 23 70 72 61 67 6d 61 20 77 61 72 6e 69 6e 67 20 64 69 73 61 62 6c 65 20 43 53 30 36 34 39 0d .#pragma.warning.disable.CS0649.
1680 0a 6e 61 6d 65 73 70 61 63 65 20 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 .namespace.UnityEngine.InputSyst
16a0 65 6d 0d 0a 7b 0d 0a 20 20 20 20 75 73 69 6e 67 20 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 em..{......using.DeviceChangeLis
16c0 74 65 6e 65 72 20 3d 20 41 63 74 69 6f 6e 3c 49 6e 70 75 74 44 65 76 69 63 65 2c 20 49 6e 70 75 tener.=.Action<InputDevice,.Inpu
16e0 74 44 65 76 69 63 65 43 68 61 6e 67 65 3e 3b 0d 0a 20 20 20 20 75 73 69 6e 67 20 44 65 76 69 63 tDeviceChange>;......using.Devic
1700 65 53 74 61 74 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 20 3d 20 41 63 74 69 6f 6e 3c 49 6e eStateChangeListener.=.Action<In
1720 70 75 74 44 65 76 69 63 65 2c 20 49 6e 70 75 74 45 76 65 6e 74 50 74 72 3e 3b 0d 0a 20 20 20 20 putDevice,.InputEventPtr>;......
1740 75 73 69 6e 67 20 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 20 3d 20 41 63 74 using.LayoutChangeListener.=.Act
1760 69 6f 6e 3c 73 74 72 69 6e 67 2c 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 43 68 ion<string,.InputControlLayoutCh
1780 61 6e 67 65 3e 3b 0d 0a 20 20 20 20 75 73 69 6e 67 20 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 20 ange>;......using.EventListener.
17a0 3d 20 41 63 74 69 6f 6e 3c 49 6e 70 75 74 45 76 65 6e 74 50 74 72 2c 20 49 6e 70 75 74 44 65 76 =.Action<InputEventPtr,.InputDev
17c0 69 63 65 3e 3b 0d 0a 20 20 20 20 75 73 69 6e 67 20 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 20 ice>;......using.UpdateListener.
17e0 3d 20 41 63 74 69 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a =.Action;........///.<summary>..
1800 20 20 20 20 2f 2f 2f 20 48 75 62 20 6f 66 20 74 68 65 20 69 6e 70 75 74 20 73 79 73 74 65 6d 2e ....///.Hub.of.the.input.system.
1820 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 72 ......///.</summary>......///.<r
1840 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 2f 2f 2f 20 4e 6f 74 20 65 78 70 6f 73 65 64 2e 20 55 73 emarks>......///.Not.exposed..Us
1860 65 20 3c 73 65 65 20 63 72 65 66 3d 22 49 6e 70 75 74 53 79 73 74 65 6d 22 2f 3e 20 61 73 20 74 e.<see.cref="InputSystem"/>.as.t
1880 68 65 20 70 75 62 6c 69 63 20 65 6e 74 72 79 20 70 6f 69 6e 74 20 74 6f 20 74 68 65 20 73 79 73 he.public.entry.point.to.the.sys
18a0 74 65 6d 2e 0d 0a 20 20 20 20 2f 2f 2f 0d 0a 20 20 20 20 2f 2f 2f 20 4d 61 6e 61 67 65 73 20 64 tem.......///......///.Manages.d
18c0 65 76 69 63 65 73 2c 20 6c 61 79 6f 75 74 73 2c 20 61 6e 64 20 65 76 65 6e 74 20 70 72 6f 63 65 evices,.layouts,.and.event.proce
18e0 73 73 69 6e 67 2e 0d 0a 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 ssing.......///.</remarks>......
1900 69 6e 74 65 72 6e 61 6c 20 63 6c 61 73 73 20 49 6e 70 75 74 4d 61 6e 61 67 65 72 0d 0a 20 20 20 internal.class.InputManager.....
1920 20 7b 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 52 65 61 64 4f 6e 6c 79 41 72 72 61 79 .{..........public.ReadOnlyArray
1940 3c 49 6e 70 75 74 44 65 76 69 63 65 3e 20 64 65 76 69 63 65 73 20 3d 3e 20 6e 65 77 20 52 65 61 <InputDevice>.devices.=>.new.Rea
1960 64 4f 6e 6c 79 41 72 72 61 79 3c 49 6e 70 75 74 44 65 76 69 63 65 3e 28 6d 5f 44 65 76 69 63 65 dOnlyArray<InputDevice>(m_Device
1980 73 2c 20 30 2c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 s,.0,.m_DevicesCount);..........
19a0 20 20 70 75 62 6c 69 63 20 54 79 70 65 54 61 62 6c 65 20 70 72 6f 63 65 73 73 6f 72 73 20 3d 3e ..public.TypeTable.processors.=>
19c0 20 6d 5f 50 72 6f 63 65 73 73 6f 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 54 .m_Processors;..........public.T
19e0 79 70 65 54 61 62 6c 65 20 69 6e 74 65 72 61 63 74 69 6f 6e 73 20 3d 3e 20 6d 5f 49 6e 74 65 72 ypeTable.interactions.=>.m_Inter
1a00 61 63 74 69 6f 6e 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 54 79 70 65 54 61 62 actions;..........public.TypeTab
1a20 6c 65 20 63 6f 6d 70 6f 73 69 74 65 73 20 3d 3e 20 6d 5f 43 6f 6d 70 6f 73 69 74 65 73 3b 0d 0a le.composites.=>.m_Composites;..
1a40 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 4d 65 74 72 69 63 73 20 6d 65 ..........public.InputMetrics.me
1a60 74 72 69 63 73 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 67 65 trics..........{..............ge
1a80 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 t..............{................
1aa0 20 20 76 61 72 20 72 65 73 75 6c 74 20 3d 20 6d 5f 4d 65 74 72 69 63 73 3b 0d 0a 0d 0a 20 20 20 ..var.result.=.m_Metrics;.......
1ac0 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 63 75 72 72 65 6e 74 4e 75 6d 44 65 .............result.currentNumDe
1ae0 76 69 63 65 73 20 3d 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 vices.=.m_DevicesCount;.........
1b00 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 63 75 72 72 65 6e 74 53 74 61 74 65 53 69 7a 65 .........result.currentStateSize
1b20 49 6e 42 79 74 65 73 20 3d 20 28 69 6e 74 29 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 74 6f InBytes.=.(int)m_StateBuffers.to
1b40 74 61 6c 53 69 7a 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 talSize;....................//.C
1b60 6f 75 6e 74 20 63 6f 6e 74 72 6f 6c 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ount.controls...................
1b80 72 65 73 75 6c 74 2e 63 75 72 72 65 6e 74 43 6f 6e 74 72 6f 6c 43 6f 75 6e 74 20 3d 20 6d 5f 44 result.currentControlCount.=.m_D
1ba0 65 76 69 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f evicesCount;..................fo
1bc0 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 r.(var.i.=.0;.i.<.m_DevicesCount
1be0 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 ;.++i)......................resu
1c00 6c 74 2e 63 75 72 72 65 6e 74 43 6f 6e 74 72 6f 6c 43 6f 75 6e 74 20 2b 3d 20 6d 5f 44 65 76 69 lt.currentControlCount.+=.m_Devi
1c20 63 65 73 5b 69 5d 2e 61 6c 6c 43 6f 6e 74 72 6f 6c 73 2e 43 6f 75 6e 74 3b 0d 0a 0d 0a 20 20 20 ces[i].allControls.Count;.......
1c40 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 6f 75 6e 74 20 6c 61 79 6f 75 74 73 2e 0d 0a .............//.Count.layouts...
1c60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 63 75 72 72 65 6e 74 4c 61 ................result.currentLa
1c80 79 6f 75 74 43 6f 75 6e 74 20 3d 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 54 79 70 65 youtCount.=.m_Layouts.layoutType
1ca0 73 2e 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 s.Count;..................result
1cc0 2e 63 75 72 72 65 6e 74 4c 61 79 6f 75 74 43 6f 75 6e 74 20 2b 3d 20 6d 5f 4c 61 79 6f 75 74 73 .currentLayoutCount.+=.m_Layouts
1ce0 2e 6c 61 79 6f 75 74 53 74 72 69 6e 67 73 2e 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 .layoutStrings.Count;...........
1d00 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 63 75 72 72 65 6e 74 4c 61 79 6f 75 74 43 6f 75 6e 74 .......result.currentLayoutCount
1d20 20 2b 3d 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 42 75 69 6c 64 65 72 73 2e 43 6f 75 .+=.m_Layouts.layoutBuilders.Cou
1d40 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 73 75 6c 74 2e 63 75 72 72 nt;..................result.curr
1d60 65 6e 74 4c 61 79 6f 75 74 43 6f 75 6e 74 20 2b 3d 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f entLayoutCount.+=.m_Layouts.layo
1d80 75 74 4f 76 65 72 72 69 64 65 73 2e 43 6f 75 6e 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 utOverrides.Count;..............
1da0 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 65 73 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ......return.result;............
1dc0 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 ..}..........}............public
1de0 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 20 73 65 74 74 69 6e 67 73 0d 0a 20 20 20 20 20 20 20 .InputSettings.settings.........
1e00 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .{..............get.............
1e20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 .{..................Debug.Assert
1e40 28 6d 5f 53 65 74 74 69 6e 67 73 20 21 3d 20 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 (m_Settings.!=.null);...........
1e60 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d 5f 53 65 74 74 69 6e 67 73 3b 0d 0a 20 20 20 20 20 .......return.m_Settings;.......
1e80 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 0d 0a 20 20 20 20 20 .......}..............set.......
1ea0 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 76 61 .......{..................if.(va
1ec0 6c 75 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 lue.==.null)....................
1ee0 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f ..throw.new.ArgumentNullExceptio
1f00 6e 28 6e 61 6d 65 6f 66 28 76 61 6c 75 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 n(nameof(value));...............
1f20 20 20 20 20 20 69 66 20 28 6d 5f 53 65 74 74 69 6e 67 73 20 3d 3d 20 76 61 6c 75 65 29 0d 0a 20 .....if.(m_Settings.==.value)...
1f40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 ...................return;......
1f60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 65 74 74 69 6e 67 73 20 3d 20 76 61 6c 75 65 ..............m_Settings.=.value
1f80 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 70 70 6c 79 53 65 74 74 69 6e 67 73 ;..................ApplySettings
1fa0 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d ();..............}..........}...
1fc0 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 20 .........public.InputUpdateType.
1fe0 75 70 64 61 74 65 4d 61 73 6b 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 updateMask..........{...........
2000 20 20 20 67 65 74 20 3d 3e 20 6d 5f 55 70 64 61 74 65 4d 61 73 6b 3b 0d 0a 20 20 20 20 20 20 20 ...get.=>.m_UpdateMask;.........
2020 20 20 20 20 20 73 65 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 .....set..............{.........
2040 20 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 20 65 64 69 74 6f 72 2c 20 77 65 20 64 6f 6e 27 74 20 .........//.In.editor,.we.don't.
2060 61 6c 6c 6f 77 20 64 69 73 61 62 6c 69 6e 67 20 65 64 69 74 6f 72 20 75 70 64 61 74 65 73 2e 0d allow.disabling.editor.updates..
2080 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f .................#if.UNITY_EDITO
20a0 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 6c 75 65 20 7c 3d 20 49 6e 70 75 R..................value.|=.Inpu
20c0 74 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 tUpdateType.Editor;.............
20e0 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 .....#endif....................i
2100 66 20 28 6d 5f 55 70 64 61 74 65 4d 61 73 6b 20 3d 3d 20 76 61 6c 75 65 29 0d 0a 20 20 20 20 20 f.(m_UpdateMask.==.value).......
2120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 ...............return;..........
2140 20 20 20 20 20 20 20 20 20 20 6d 5f 55 70 64 61 74 65 4d 61 73 6b 20 3d 20 76 61 6c 75 65 3b 0d ..........m_UpdateMask.=.value;.
2160 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 63 72 65 61 74 65 20 73 ...................//.Recreate.s
2180 74 61 74 65 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 tate.buffers...................i
21a0 66 20 28 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 f.(m_DevicesCount.>.0)..........
21c0 20 20 20 20 20 20 20 20 20 20 20 20 52 65 61 6c 6c 6f 63 61 74 65 53 74 61 74 65 42 75 66 66 65 ............ReallocateStateBuffe
21e0 72 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d rs();..............}..........}.
2200 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 ...........public.InputUpdateTyp
2220 65 20 64 65 66 61 75 6c 74 55 70 64 61 74 65 54 79 70 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a e.defaultUpdateType..........{..
2240 20 20 20 20 20 20 20 20 20 20 20 20 67 65 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a ............get..............{..
2260 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 69 66 20 77 65 27 ................////TODO:.if.we'
2280 72 65 20 2a 69 6e 73 69 64 65 2a 20 61 6e 20 75 70 64 61 74 65 2c 20 74 68 69 73 20 73 68 6f 75 re.*inside*.an.update,.this.shou
22a0 6c 64 20 75 73 65 20 74 68 65 20 63 75 72 72 65 6e 74 20 75 70 64 61 74 65 20 74 79 70 65 0d 0a ld.use.the.current.update.type..
22c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 ..................#if.UNITY_EDIT
22e0 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 67 61 6d 65 49 73 50 OR..................if.(!gameIsP
2300 6c 61 79 69 6e 67 41 6e 64 48 61 73 46 6f 63 75 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 layingAndHasFocus)..............
2320 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 45 ........return.InputUpdateType.E
2340 64 69 74 6f 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a ditor;..................#endif..
2360 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 6d 5f 55 70 64 61 74 65 4d ..................if.((m_UpdateM
2380 61 73 6b 20 26 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 4d 61 6e 75 61 6c 29 20 21 3d ask.&.InputUpdateType.Manual).!=
23a0 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 .0)......................return.
23c0 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 4d 61 6e 75 61 6c 3b 0d 0a 0d 0a 20 20 20 20 20 InputUpdateType.Manual;.........
23e0 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 6d 5f 55 70 64 61 74 65 4d 61 73 6b 20 26 20 49 ...........if.((m_UpdateMask.&.I
2400 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 44 79 6e 61 6d 69 63 29 20 21 3d 20 30 29 0d 0a 20 nputUpdateType.Dynamic).!=.0)...
2420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 49 6e 70 75 74 55 ...................return.InputU
2440 70 64 61 74 65 54 79 70 65 2e 44 79 6e 61 6d 69 63 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 pdateType.Dynamic;..............
2460 20 20 20 20 20 20 69 66 20 28 28 6d 5f 55 70 64 61 74 65 4d 61 73 6b 20 26 20 49 6e 70 75 74 55 ......if.((m_UpdateMask.&.InputU
2480 70 64 61 74 65 54 79 70 65 2e 46 69 78 65 64 29 20 21 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 pdateType.Fixed).!=.0)..........
24a0 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 ............return.InputUpdateTy
24c0 70 65 2e 46 69 78 65 64 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 pe.Fixed;....................ret
24e0 75 72 6e 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 4e 6f 6e 65 3b 0d 0a 20 20 20 20 20 urn.InputUpdateType.None;.......
2500 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 .......}..........}............p
2520 75 62 6c 69 63 20 66 6c 6f 61 74 20 70 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 0d 0a 20 20 ublic.float.pollingFrequency....
2540 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 67 65 74 20 3d 3e 20 6d 5f 50 6f ......{..............get.=>.m_Po
2560 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 65 74 llingFrequency;..............set
2580 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..............{.................
25a0 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 61 6c 6c 6f 77 20 73 65 74 74 69 6e 67 20 74 6f 20 7a 65 .////REVIEW:.allow.setting.to.ze
25c0 72 6f 20 74 6f 20 74 75 72 6e 20 6f 66 66 20 70 6f 6c 6c 69 6e 67 20 61 6c 74 6f 67 65 74 68 65 ro.to.turn.off.polling.altogethe
25e0 72 3f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 76 61 6c 75 65 20 3c 3d r?..................if.(value.<=
2600 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e .0)......................throw.n
2620 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 22 50 6f 6c 6c 69 6e 67 20 66 72 ew.ArgumentException("Polling.fr
2640 65 71 75 65 6e 63 79 20 6d 75 73 74 20 62 65 20 67 72 65 61 74 65 72 20 74 68 61 6e 20 7a 65 72 equency.must.be.greater.than.zer
2660 6f 22 2c 20 22 76 61 6c 75 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 o",."value");...................
2680 20 6d 5f 50 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 20 3d 20 76 61 6c 75 65 3b 0d 0a 20 20 .m_PollingFrequency.=.value;....
26a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 52 75 6e 74 69 6d 65 20 21 3d 20 6e ..............if.(m_Runtime.!=.n
26c0 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 ull)......................m_Runt
26e0 69 6d 65 2e 70 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 20 3d 20 76 61 6c 75 65 3b 0d 0a 20 ime.pollingFrequency.=.value;...
2700 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 ...........}..........}.........
2720 20 20 20 70 75 62 6c 69 63 20 65 76 65 6e 74 20 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 ...public.event.DeviceChangeList
2740 65 6e 65 72 20 6f 6e 44 65 76 69 63 65 43 68 61 6e 67 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a ener.onDeviceChange..........{..
2760 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 20 3d 3e 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 ............add.=>.m_DeviceChang
2780 65 4c 69 73 74 65 6e 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 69 74 79 28 76 61 eListeners.AppendWithCapacity(va
27a0 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 6d 6f 76 65 0d 0a 20 20 20 20 20 lue);..............remove.......
27c0 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e .......{..................var.in
27e0 64 65 78 20 3d 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 49 6e dex.=.m_DeviceChangeListeners.In
2800 64 65 78 4f 66 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 dexOf(value);..................i
2820 66 20 28 69 6e 64 65 78 20 3e 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 f.(index.>=.0)..................
2840 20 20 20 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 52 65 6d 6f ....m_DeviceChangeListeners.Remo
2860 76 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 veAtWithCapacity(index);........
2880 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 ......}..........}............pu
28a0 62 6c 69 63 20 65 76 65 6e 74 20 44 65 76 69 63 65 53 74 61 74 65 43 68 61 6e 67 65 4c 69 73 74 blic.event.DeviceStateChangeList
28c0 65 6e 65 72 20 6f 6e 44 65 76 69 63 65 53 74 61 74 65 43 68 61 6e 67 65 0d 0a 20 20 20 20 20 20 ener.onDeviceStateChange........
28e0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 20 3d 3e 20 6d 5f 44 65 76 69 63 65 ..{..............add.=>.m_Device
2900 53 74 61 74 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 StateChangeListeners.AppendWithC
2920 61 70 61 63 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 6d apacity(value);..............rem
2940 6f 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ove..............{..............
2960 20 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 44 65 76 69 63 65 53 74 61 74 65 43 68 61 ....var.index.=.m_DeviceStateCha
2980 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 49 6e 64 65 78 4f 66 28 76 61 6c 75 65 29 3b 0d 0a 20 20 ngeListeners.IndexOf(value);....
29a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 3e 3d 20 30 29 0d 0a 20 ..............if.(index.>=.0)...
29c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 53 74 61 74 65 ...................m_DeviceState
29e0 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 52 65 6d 6f 76 65 41 74 57 69 74 68 43 61 70 61 ChangeListeners.RemoveAtWithCapa
2a00 63 69 74 79 28 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 city(index);..............}.....
2a20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 76 65 6e 74 20 49 .....}............public.event.I
2a40 6e 70 75 74 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 20 6f 6e 44 65 76 69 nputDeviceCommandDelegate.onDevi
2a60 63 65 43 6f 6d 6d 61 6e 64 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 ceCommand..........{............
2a80 20 20 61 64 64 20 3d 3e 20 6d 5f 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 43 61 6c 6c 62 61 63 6b ..add.=>.m_DeviceCommandCallback
2aa0 73 2e 41 70 70 65 6e 64 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 s.Append(value);..............re
2ac0 6d 6f 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 move..............{.............
2ae0 20 20 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 .....var.index.=.m_DeviceCommand
2b00 43 61 6c 6c 62 61 63 6b 73 2e 49 6e 64 65 78 4f 66 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 Callbacks.IndexOf(value);.......
2b20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 3e 3d 20 30 29 0d 0a 20 20 20 20 ...........if.(index.>=.0)......
2b40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 43 ................m_DeviceCommandC
2b60 61 6c 6c 62 61 63 6b 73 2e 52 65 6d 6f 76 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 69 6e allbacks.RemoveAtWithCapacity(in
2b80 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d dex);..............}..........}.
2ba0 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 77 6f 75 6c 64 20 62 65 20 ...........////REVIEW:.would.be.
2bc0 67 72 65 61 74 20 74 6f 20 68 61 76 65 20 61 20 77 61 79 20 74 6f 20 73 6f 72 74 20 6f 75 74 20 great.to.have.a.way.to.sort.out.
2be0 70 72 65 63 65 64 65 6e 63 65 20 62 65 74 77 65 65 6e 20 74 77 6f 20 63 61 6c 6c 62 61 63 6b 73 precedence.between.two.callbacks
2c00 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 76 65 6e 74 20 49 6e 70 75 74 44 65 76 69 ..........public.event.InputDevi
2c20 63 65 46 69 6e 64 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 44 65 6c 65 67 61 74 65 20 6f 6e 46 69 ceFindControlLayoutDelegate.onFi
2c40 6e 64 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 46 6f 72 44 65 76 69 63 65 0d 0a 20 20 20 20 20 20 ndControlLayoutForDevice........
2c60 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 0d 0a 20 20 20 20 20 20 20 20 20 20 ..{..............add............
2c80 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 46 69 6e ..{..................m_DeviceFin
2ca0 64 4c 61 79 6f 75 74 43 61 6c 6c 62 61 63 6b 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 dLayoutCallbacks.AppendWithCapac
2cc0 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f ity(value);..................../
2ce0 2f 20 48 61 76 69 6e 67 20 61 20 6e 65 77 20 63 61 6c 6c 62 61 63 6b 20 6f 6e 20 74 68 69 73 20 /.Having.a.new.callback.on.this.
2d00 65 76 65 6e 74 20 63 61 6e 20 63 68 61 6e 67 65 20 74 68 65 20 73 65 74 20 6f 66 20 64 65 76 69 event.can.change.the.set.of.devi
2d20 63 65 73 20 77 65 20 72 65 63 6f 67 6e 69 7a 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ces.we.recognize................
2d40 20 20 20 2f 2f 20 53 65 65 20 69 66 20 74 68 65 72 65 27 73 20 61 6e 79 74 68 69 6e 67 20 69 6e ...//.See.if.there's.anything.in
2d60 20 74 68 65 20 6c 69 73 74 20 6f 66 20 61 76 61 69 6c 61 62 6c 65 20 64 65 76 69 63 65 73 20 74 .the.list.of.available.devices.t
2d80 68 61 74 20 77 65 20 63 61 6e 20 6e 6f 77 20 74 75 72 6e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 hat.we.can.now.turn.............
2da0 20 20 20 20 20 2f 2f 20 69 6e 74 6f 20 61 6e 20 49 6e 70 75 74 44 65 76 69 63 65 20 77 68 65 72 .....//.into.an.InputDevice.wher
2dc0 65 61 73 20 77 65 20 63 6f 75 6c 64 6e 27 74 20 62 65 66 6f 72 65 2e 0d 0a 20 20 20 20 20 20 20 eas.we.couldn't.before..........
2de0 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 .........//..................//.
2e00 4e 4f 54 45 3a 20 41 20 63 61 6c 6c 62 61 63 6b 20 63 6f 75 6c 64 20 61 6c 73 6f 20 69 6d 70 61 NOTE:.A.callback.could.also.impa
2e20 63 74 20 61 6c 72 65 61 64 79 20 65 78 69 73 74 69 6e 67 20 64 65 76 69 63 65 73 20 61 6e 64 20 ct.already.existing.devices.and.
2e40 74 68 65 6f 72 65 74 69 63 61 6c 6c 79 20 61 6c 74 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 theoretically.alter.............
2e60 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 77 68 61 74 20 6c 61 79 6f 75 74 20 77 65 20 77 6f 75 .....//.......what.layout.we.wou
2e80 6c 64 20 68 61 76 65 20 75 73 65 64 20 66 6f 72 20 74 68 6f 73 65 2e 20 57 65 20 64 6f 20 2a 4e ld.have.used.for.those..We.do.*N
2ea0 4f 54 2a 20 72 65 74 72 6f 61 63 74 69 76 65 6c 79 20 61 70 70 6c 79 0d 0a 20 20 20 20 20 20 20 OT*.retroactively.apply.........
2ec0 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 74 68 6f 73 65 20 63 68 61 6e 67 65 73 2e .........//.......those.changes.
2ee0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 64 64 41 76 61 69 6c 61 62 6c 65 44 65 ..................AddAvailableDe
2f00 76 69 63 65 73 54 68 61 74 41 72 65 4e 6f 77 52 65 63 6f 67 6e 69 7a 65 64 28 29 3b 0d 0a 20 20 vicesThatAreNowRecognized();....
2f20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 6d 6f 76 65 0d ..........}..............remove.
2f40 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .............{..................
2f60 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 44 65 76 69 63 65 46 69 6e 64 4c 61 79 6f 75 74 43 61 var.index.=.m_DeviceFindLayoutCa
2f80 6c 6c 62 61 63 6b 73 2e 49 6e 64 65 78 4f 66 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 llbacks.IndexOf(value);.........
2fa0 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 3e 3d 20 30 29 0d 0a 20 20 20 20 20 20 .........if.(index.>=.0)........
2fc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 46 69 6e 64 4c 61 79 6f 75 74 ..............m_DeviceFindLayout
2fe0 43 61 6c 6c 62 61 63 6b 73 2e 52 65 6d 6f 76 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 69 Callbacks.RemoveAtWithCapacity(i
3000 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d ndex);..............}..........}
3020 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 76 65 6e 74 20 4c 61 79 6f 75 74 43 ............public.event.LayoutC
3040 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 20 6f 6e 4c 61 79 6f 75 74 43 68 61 6e 67 65 0d 0a 20 20 hangeListener.onLayoutChange....
3060 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 20 3d 3e 20 6d 5f 4c 61 ......{..............add.=>.m_La
3080 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 youtChangeListeners.AppendWithCa
30a0 70 61 63 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 6d 6f pacity(value);..............remo
30c0 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ve..............{...............
30e0 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 ...var.index.=.m_LayoutChangeLis
3100 74 65 6e 65 72 73 2e 49 6e 64 65 78 4f 66 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 teners.IndexOf(value);..........
3120 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 3e 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 ........if.(index.>=.0).........
3140 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 .............m_LayoutChangeListe
3160 6e 65 72 73 2e 52 65 6d 6f 76 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 69 6e 64 65 78 29 ners.RemoveAtWithCapacity(index)
3180 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 ;..............}..........}.....
31a0 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 61 64 64 20 49 6e 70 75 74 45 76 65 6e 74 42 .......////TODO:.add.InputEventB
31c0 75 66 66 65 72 20 73 74 72 75 63 74 20 74 68 61 74 20 75 73 65 73 20 4e 61 74 69 76 65 41 72 72 uffer.struct.that.uses.NativeArr
31e0 61 79 20 75 6e 64 65 72 6e 65 61 74 68 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a ay.underneath..........////TODO:
3200 20 6d 61 6b 65 20 49 6e 70 75 74 45 76 65 6e 74 54 72 61 63 65 20 75 73 65 20 4e 61 74 69 76 65 .make.InputEventTrace.use.Native
3220 41 72 72 61 79 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 69 6e 74 72 6f 64 75 Array..........////TODO:.introdu
3240 63 65 20 61 6e 20 61 6c 74 65 72 6e 61 74 69 76 65 20 74 68 61 74 20 63 6f 6e 73 75 6d 65 73 20 ce.an.alternative.that.consumes.
3260 65 76 65 6e 74 73 20 69 6e 20 62 75 6c 6b 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 events.in.bulk..........public.e
3280 76 65 6e 74 20 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 20 6f 6e 45 76 65 6e 74 0d 0a 20 20 20 20 vent.EventListener.onEvent......
32a0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 0d 0a 20 20 20 20 20 20 20 20 ....{..............add..........
32c0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 6d 5f 45 76 ....{..................if.(!m_Ev
32e0 65 6e 74 4c 69 73 74 65 6e 65 72 73 2e 43 6f 6e 74 61 69 6e 73 28 76 61 6c 75 65 29 29 0d 0a 20 entListeners.Contains(value))...
3300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 45 76 65 6e 74 4c 69 73 74 65 6e ...................m_EventListen
3320 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a ers.AppendWithCapacity(value);..
3340 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 6d 6f 76 ............}..............remov
3360 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e..............{................
3380 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 73 2e 49 ..var.index.=.m_EventListeners.I
33a0 6e 64 65 78 4f 66 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ndexOf(value);..................
33c0 69 66 20 28 69 6e 64 65 78 20 3e 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 if.(index.>=.0).................
33e0 20 20 20 20 20 6d 5f 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 73 2e 52 65 6d 6f 76 65 41 74 57 69 .....m_EventListeners.RemoveAtWi
3400 74 68 43 61 70 61 63 69 74 79 28 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 thCapacity(index);..............
3420 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 }..........}............public.e
3440 76 65 6e 74 20 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 20 6f 6e 42 65 66 6f 72 65 55 70 64 61 vent.UpdateListener.onBeforeUpda
3460 74 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 0d 0a te..........{..............add..
3480 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 ............{..................I
34a0 6e 73 74 61 6c 6c 42 65 66 6f 72 65 55 70 64 61 74 65 48 6f 6f 6b 49 66 4e 65 63 65 73 73 61 72 nstallBeforeUpdateHookIfNecessar
34c0 79 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 6d 5f 42 65 66 y();..................if.(!m_Bef
34e0 6f 72 65 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 43 6f 6e 74 61 69 6e 73 28 76 61 6c 75 oreUpdateListeners.Contains(valu
3500 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 42 65 66 6f 72 e))......................m_Befor
3520 65 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 eUpdateListeners.AppendWithCapac
3540 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 ity(value);..............}......
3560 20 20 20 20 20 20 20 20 72 65 6d 6f 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 ........remove..............{...
3580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 42 65 66 ...............var.index.=.m_Bef
35a0 6f 72 65 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 49 6e 64 65 78 4f 66 28 76 61 6c 75 65 oreUpdateListeners.IndexOf(value
35c0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 3e 3d );..................if.(index.>=
35e0 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 42 65 66 6f 72 .0)......................m_Befor
3600 65 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 52 65 6d 6f 76 65 41 74 57 69 74 68 43 61 70 eUpdateListeners.RemoveAtWithCap
3620 61 63 69 74 79 28 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 acity(index);..............}....
3640 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 76 65 6e 74 20 ......}............public.event.
3660 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 20 6f 6e 41 66 74 65 72 55 70 64 61 74 65 0d 0a 20 20 UpdateListener.onAfterUpdate....
3680 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 0d 0a 20 20 20 20 20 20 ......{..............add........
36a0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 6d 5f ......{..................if.(!m_
36c0 41 66 74 65 72 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 43 6f 6e 74 61 69 6e 73 28 76 61 AfterUpdateListeners.Contains(va
36e0 6c 75 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 41 66 74 lue))......................m_Aft
3700 65 72 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 erUpdateListeners.AppendWithCapa
3720 63 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 city(value);..............}.....
3740 20 20 20 20 20 20 20 20 20 72 65 6d 6f 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a .........remove..............{..
3760 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f 41 66 ................var.index.=.m_Af
3780 74 65 72 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 49 6e 64 65 78 4f 66 28 76 61 6c 75 65 terUpdateListeners.IndexOf(value
37a0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 64 65 78 20 3e 3d );..................if.(index.>=
37c0 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 41 66 74 65 72 .0)......................m_After
37e0 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 52 65 6d 6f 76 65 41 74 57 69 74 68 43 61 70 61 UpdateListeners.RemoveAtWithCapa
3800 63 69 74 79 28 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 city(index);..............}.....
3820 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 65 76 65 6e 74 20 41 .....}............public.event.A
3840 63 74 69 6f 6e 20 6f 6e 53 65 74 74 69 6e 67 73 43 68 61 6e 67 65 0d 0a 20 20 20 20 20 20 20 20 ction.onSettingsChange..........
3860 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 61 64 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 {..............add..............
3880 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 6d 5f 53 65 74 74 69 6e {..................if.(!m_Settin
38a0 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e 65 72 73 2e 43 6f 6e 74 61 69 6e 73 28 76 61 6c 75 gsChangedListeners.Contains(valu
38c0 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 65 74 74 69 e))......................m_Setti
38e0 6e 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 ngsChangedListeners.AppendWithCa
3900 70 61 63 69 74 79 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 pacity(value);..............}...
3920 20 20 20 20 20 20 20 20 20 20 20 72 65 6d 6f 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b ...........remove..............{
3940 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 64 65 78 20 3d 20 6d 5f ..................var.index.=.m_
3960 53 65 74 74 69 6e 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e 65 72 73 2e 49 6e 64 65 78 4f 66 SettingsChangedListeners.IndexOf
3980 28 76 61 6c 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e (value);..................if.(in
39a0 64 65 78 20 3e 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d dex.>=.0)......................m
39c0 5f 53 65 74 74 69 6e 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e 65 72 73 2e 52 65 6d 6f 76 65 _SettingsChangedListeners.Remove
39e0 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 69 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 AtWithCapacity(index);..........
3a00 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 ....}..........}............priv
3a20 61 74 65 20 62 6f 6f 6c 20 67 61 6d 65 49 73 50 6c 61 79 69 6e 67 41 6e 64 48 61 73 46 6f 63 75 ate.bool.gameIsPlayingAndHasFocu
3a40 73 20 3d 3e 0d 0a 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 s.=>..#if.UNITY_EDITOR..........
3a60 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 69 73 49 6e 50 6c 61 79 4d .............m_Runtime.isInPlayM
3a80 6f 64 65 20 26 26 20 21 6d 5f 52 75 6e 74 69 6d 65 2e 69 73 50 61 75 73 65 64 20 26 26 20 28 6d ode.&&.!m_Runtime.isPaused.&&.(m
3aa0 5f 48 61 73 46 6f 63 75 73 20 7c 7c 20 49 6e 70 75 74 45 64 69 74 6f 72 55 73 65 72 53 65 74 74 _HasFocus.||.InputEditorUserSett
3ac0 69 6e 67 73 2e 6c 6f 63 6b 49 6e 70 75 74 54 6f 47 61 6d 65 56 69 65 77 29 3b 0d 0a 23 65 6c 73 ings.lockInputToGameView);..#els
3ae0 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 72 75 65 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a e..............true;..#endif....
3b00 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 77 68 65 6e 20 72 65 67 69 73 74 65 72 69 ........////TODO:.when.registeri
3b20 6e 67 20 61 20 6c 61 79 6f 75 74 20 74 68 61 74 20 65 78 69 73 74 73 20 61 73 20 61 20 6c 61 79 ng.a.layout.that.exists.as.a.lay
3b40 6f 75 74 20 6f 66 20 61 20 64 69 66 66 65 72 65 6e 74 20 74 79 70 65 20 28 74 79 70 65 20 76 73 out.of.a.different.type.(type.vs
3b60 20 73 74 72 69 6e 67 20 76 73 20 63 6f 6e 73 74 72 75 63 74 6f 72 29 2c 0d 0a 20 20 20 20 20 20 .string.vs.constructor),........
3b80 20 20 2f 2f 2f 2f 20 20 20 20 20 20 72 65 6d 6f 76 65 20 74 68 65 20 65 78 69 73 74 69 6e 67 20 ..////......remove.the.existing.
3ba0 72 65 67 69 73 74 72 61 74 69 6f 6e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 64 64 20 61 registration............//.Add.a
3bc0 20 6c 61 79 6f 75 74 20 63 6f 6e 73 74 72 75 63 74 65 64 20 66 72 6f 6d 20 61 20 74 79 70 65 2e .layout.constructed.from.a.type.
3be0 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 61 20 6c 61 79 6f 75 74 20 77 69 74 68 20 74 68 ..........//.If.a.layout.with.th
3c00 65 20 73 61 6d 65 20 6e 61 6d 65 20 61 6c 72 65 61 64 79 20 65 78 69 73 74 73 2c 20 74 68 65 20 e.same.name.already.exists,.the.
3c20 6e 65 77 20 6c 61 79 6f 75 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 74 61 6b 65 73 20 69 74 73 new.layout..........//.takes.its
3c40 20 70 6c 61 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 52 65 67 .place...........public.void.Reg
3c60 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 73 74 72 69 6e 67 20 6e 61 6d 65 2c 20 isterControlLayout(string.name,.
3c80 54 79 70 65 20 74 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 Type.type)..........{...........
3ca0 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 6e 61 6d 65 ...if.(string.IsNullOrEmpty(name
3cc0 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 ))..................throw.new.Ar
3ce0 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 6e 61 6d 65 29 gumentNullException(nameof(name)
3d00 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 79 70 65 20 3d 3d 20 6e 75 6c 6c );..............if.(type.==.null
3d20 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 )..................throw.new.Arg
3d40 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 74 79 70 65 29 29 umentNullException(nameof(type))
3d60 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 74 65 20 74 68 61 74 20 73 69 ;................//.Note.that.si
3d80 6e 63 65 20 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 72 69 76 65 73 20 66 72 6f 6d 20 49 6e 70 nce.InputDevice.derives.from.Inp
3da0 75 74 43 6f 6e 74 72 6f 6c 2c 20 69 73 44 65 76 69 63 65 4c 61 79 6f 75 74 20 69 6d 70 6c 69 65 utControl,.isDeviceLayout.implie
3dc0 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 73 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 s..............//.isControlLayou
3de0 74 20 74 6f 20 62 65 20 74 72 75 65 20 61 73 20 77 65 6c 6c 2e 0d 0a 20 20 20 20 20 20 20 20 20 t.to.be.true.as.well............
3e00 20 20 20 76 61 72 20 69 73 44 65 76 69 63 65 4c 61 79 6f 75 74 20 3d 20 74 79 70 65 6f 66 28 49 ...var.isDeviceLayout.=.typeof(I
3e20 6e 70 75 74 44 65 76 69 63 65 29 2e 49 73 41 73 73 69 67 6e 61 62 6c 65 46 72 6f 6d 28 74 79 70 nputDevice).IsAssignableFrom(typ
3e40 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 73 43 6f 6e 74 72 6f 6c 4c 61 e);..............var.isControlLa
3e60 79 6f 75 74 20 3d 20 74 79 70 65 6f 66 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 29 2e 49 73 41 73 yout.=.typeof(InputControl).IsAs
3e80 73 69 67 6e 61 62 6c 65 46 72 6f 6d 28 74 79 70 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 signableFrom(type);.............
3ea0 20 20 20 69 66 20 28 21 69 73 44 65 76 69 63 65 4c 61 79 6f 75 74 20 26 26 20 21 69 73 43 6f 6e ...if.(!isDeviceLayout.&&.!isCon
3ec0 74 72 6f 6c 4c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 trolLayout)..................thr
3ee0 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 24 22 54 79 70 65 73 ow.new.ArgumentException($"Types
3f00 20 75 73 65 64 20 61 73 20 6c 61 79 6f 75 74 73 20 68 61 76 65 20 74 6f 20 62 65 20 49 6e 70 75 .used.as.layouts.have.to.be.Inpu
3f20 74 43 6f 6e 74 72 6f 6c 73 20 6f 72 20 49 6e 70 75 74 44 65 76 69 63 65 73 3b 20 27 7b 74 79 70 tControls.or.InputDevices;.'{typ
3f40 65 2e 4e 61 6d 65 7d 27 20 69 73 20 61 20 27 7b 74 79 70 65 2e 42 61 73 65 54 79 70 65 2e 4e 61 e.Name}'.is.a.'{type.BaseType.Na
3f60 6d 65 7d 27 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 61 6d 65 me}'",......................name
3f80 6f 66 28 74 79 70 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e of(type));................var.in
3fa0 74 65 72 6e 65 64 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 ternedName.=.new.InternedString(
3fc0 6e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 73 52 65 70 6c 61 63 name);..............var.isReplac
3fe0 65 6d 65 6e 74 20 3d 20 44 6f 65 73 4c 61 79 6f 75 74 45 78 69 73 74 28 69 6e 74 65 72 6e 65 64 ement.=.DoesLayoutExist(interned
4000 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 6c 6c 20 77 65 20 Name);................//.All.we.
4020 64 6f 20 69 73 20 65 6e 74 65 72 20 74 68 65 20 74 79 70 65 20 69 6e 74 6f 20 61 20 6d 61 70 2e do.is.enter.the.type.into.a.map.
4040 20 57 65 20 64 6f 6e 27 74 20 63 6f 6e 73 74 72 75 63 74 20 61 6e 20 49 6e 70 75 74 43 6f 6e 74 .We.don't.construct.an.InputCont
4060 72 6f 6c 4c 61 79 6f 75 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 66 72 6f 6d 20 69 rolLayout..............//.from.i
4080 74 20 75 6e 74 69 6c 20 77 65 20 61 63 74 75 61 6c 6c 79 20 6e 65 65 64 20 69 74 20 69 6e 20 61 t.until.we.actually.need.it.in.a
40a0 6e 20 49 6e 70 75 74 44 65 76 69 63 65 42 75 69 6c 64 65 72 20 74 6f 20 63 72 65 61 74 65 20 61 n.InputDeviceBuilder.to.create.a
40c0 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 68 69 73 20 6e 6f .device...............//.This.no
40e0 74 20 6f 6e 6c 79 20 61 76 6f 69 64 73 20 75 73 20 63 72 65 61 74 69 6e 67 20 61 20 62 75 6e 63 t.only.avoids.us.creating.a.bunc
4100 68 20 6f 66 20 6f 62 6a 65 63 74 73 20 6f 6e 20 74 68 65 20 6d 61 6e 61 67 65 64 20 68 65 61 70 h.of.objects.on.the.managed.heap
4120 20 62 75 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 6c 73 6f 20 61 76 6f 69 64 73 .but..............//.also.avoids
4140 20 75 73 20 6c 61 62 6f 72 69 6f 75 73 6c 79 20 63 6f 6e 73 74 72 75 63 74 69 6e 67 20 61 20 58 .us.laboriously.constructing.a.X
4160 52 43 6f 6e 74 72 6f 6c 6c 65 72 20 6c 61 79 6f 75 74 2c 20 66 6f 72 20 65 78 61 6d 70 6c 65 2c RController.layout,.for.example,
4180 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 20 61 20 67 61 6d 65 20 74 68 61 74 20 ..............//.in.a.game.that.
41a0 6e 65 76 65 72 20 75 73 65 73 20 58 52 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 never.uses.XR...............m_La
41c0 79 6f 75 74 73 2e 6c 61 79 6f 75 74 54 79 70 65 73 5b 69 6e 74 65 72 6e 65 64 4e 61 6d 65 5d 20 youts.layoutTypes[internedName].
41e0 3d 20 74 79 70 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a =.type;................////TODO:
4200 20 6d 61 6b 65 20 74 68 69 73 20 69 6e 64 65 70 65 6e 64 65 6e 74 20 6f 66 20 69 6e 69 74 69 61 .make.this.independent.of.initia
4220 6c 69 7a 61 74 69 6f 6e 20 6f 72 64 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f lization.order..............////
4240 54 4f 44 4f 3a 20 72 65 2d 73 63 61 6e 20 62 61 73 65 20 74 79 70 65 20 69 6e 66 6f 72 6d 61 74 TODO:.re-scan.base.type.informat
4260 69 6f 6e 20 61 66 74 65 72 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 73 0d 0a 0d 0a 20 20 20 20 ion.after.domain.reloads........
4280 20 20 20 20 20 20 20 20 2f 2f 20 57 61 6c 6b 20 63 6c 61 73 73 20 68 69 65 72 61 72 63 68 79 20 ........//.Walk.class.hierarchy.
42a0 61 6c 6c 20 74 68 65 20 77 61 79 20 75 70 20 74 6f 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 20 74 all.the.way.up.to.InputControl.t
42c0 6f 20 73 65 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 66 20 74 68 65 72 65 27 73 o.see..............//.if.there's
42e0 20 61 6e 6f 74 68 65 72 20 74 79 70 65 20 74 68 61 74 27 73 20 62 65 65 6e 20 72 65 67 69 73 74 .another.type.that's.been.regist
4300 65 72 65 64 20 61 73 20 61 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f ered.as.a.layout.............../
4320 2f 20 49 66 20 73 6f 2c 20 6d 61 6b 65 20 69 74 20 61 20 62 61 73 65 20 6c 61 79 6f 75 74 20 66 /.If.so,.make.it.a.base.layout.f
4340 6f 72 20 74 68 69 73 20 6f 6e 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 or.this.one...............string
4360 20 62 61 73 65 4c 61 79 6f 75 74 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .baseLayout.=.null;.............
4380 20 66 6f 72 20 28 76 61 72 20 62 61 73 65 54 79 70 65 20 3d 20 74 79 70 65 2e 42 61 73 65 54 79 .for.(var.baseType.=.type.BaseTy
43a0 70 65 3b 20 62 61 73 65 4c 61 79 6f 75 74 20 3d 3d 20 6e 75 6c 6c 20 26 26 20 62 61 73 65 54 79 pe;.baseLayout.==.null.&&.baseTy
43c0 70 65 20 21 3d 20 74 79 70 65 6f 66 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 29 3b 0d 0a 20 20 20 pe.!=.typeof(InputControl);.....
43e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 61 73 65 54 79 70 65 20 3d 20 62 61 73 65 54 79 70 ..............baseType.=.baseTyp
4400 65 2e 42 61 73 65 54 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 e.BaseType)..............{......
4420 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20 28 76 61 72 20 65 6e 74 72 79 20 69 ............foreach.(var.entry.i
4440 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 54 79 70 65 73 29 0d 0a 20 20 20 20 20 20 n.m_Layouts.layoutTypes)........
4460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 65 6e 74 72 79 2e 56 61 6c 75 65 20 3d 3d ..............if.(entry.Value.==
4480 20 62 61 73 65 54 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .baseType)......................
44a0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 61 73 65 4c {..........................baseL
44c0 61 79 6f 75 74 20 3d 20 65 6e 74 72 79 2e 4b 65 79 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ayout.=.entry.Key;..............
44e0 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ............break;..............
4500 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ........}..............}........
4520 20 20 20 20 20 20 20 20 50 65 72 66 6f 72 6d 4c 61 79 6f 75 74 50 6f 73 74 52 65 67 69 73 74 72 ........PerformLayoutPostRegistr
4540 61 74 69 6f 6e 28 69 6e 74 65 72 6e 65 64 4e 61 6d 65 2c 20 6e 65 77 20 49 6e 6c 69 6e 65 64 41 ation(internedName,.new.InlinedA
4560 72 72 61 79 3c 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 3e 28 6e 65 77 20 49 6e 74 65 72 6e 65 rray<InternedString>(new.Interne
4580 64 53 74 72 69 6e 67 28 62 61 73 65 4c 61 79 6f 75 74 29 29 2c 0d 0a 20 20 20 20 20 20 20 20 20 dString(baseLayout)),...........
45a0 20 20 20 20 20 20 20 69 73 52 65 70 6c 61 63 65 6d 65 6e 74 2c 20 69 73 4b 6e 6f 77 6e 54 6f 42 .......isReplacement,.isKnownToB
45c0 65 44 65 76 69 63 65 4c 61 79 6f 75 74 3a 20 69 73 44 65 76 69 63 65 4c 61 79 6f 75 74 29 3b 0d eDeviceLayout:.isDeviceLayout);.
45e0 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 .........}............public.voi
4600 64 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 73 74 72 69 6e 67 20 6a d.RegisterControlLayout(string.j
4620 73 6f 6e 2c 20 73 74 72 69 6e 67 20 6e 61 6d 65 20 3d 20 6e 75 6c 6c 2c 20 62 6f 6f 6c 20 69 73 son,.string.name.=.null,.bool.is
4640 4f 76 65 72 72 69 64 65 20 3d 20 66 61 6c 73 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 Override.=.false)..........{....
4660 20 20 20 20 20 20 20 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 ..........if.(string.IsNullOrEmp
4680 74 79 28 6a 73 6f 6e 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 ty(json))..................throw
46a0 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f .new.ArgumentNullException(nameo
46c0 66 28 6a 73 6f 6e 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 f(json));................////REV
46e0 49 45 57 3a 20 61 73 20 6c 6f 6e 67 20 61 73 20 6e 6f 20 6f 6e 65 20 68 61 73 20 69 6e 73 74 61 IEW:.as.long.as.no.one.has.insta
4700 6e 74 69 61 74 65 64 20 74 68 65 20 6c 61 79 6f 75 74 2c 20 74 68 65 20 62 61 73 65 20 6c 61 79 ntiated.the.layout,.the.base.lay
4720 6f 75 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 69 73 20 6b 69 6e 64 61 20 70 6f 69 6e 74 6c 65 out.information.is.kinda.pointle
4740 73 73 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 50 61 72 73 65 20 6f 75 74 20 6e ss................//.Parse.out.n
4760 61 6d 65 2c 20 64 65 76 69 63 65 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 61 6e 64 20 62 61 73 ame,.device.description,.and.bas
4780 65 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 43 6f 6e 74 e.layout...............InputCont
47a0 72 6f 6c 4c 61 79 6f 75 74 2e 50 61 72 73 65 48 65 61 64 65 72 46 69 65 6c 64 73 46 72 6f 6d 4a rolLayout.ParseHeaderFieldsFromJ
47c0 73 6f 6e 28 6a 73 6f 6e 2c 20 6f 75 74 20 76 61 72 20 6e 61 6d 65 46 72 6f 6d 4a 73 6f 6e 2c 20 son(json,.out.var.nameFromJson,.
47e0 6f 75 74 20 76 61 72 20 62 61 73 65 4c 61 79 6f 75 74 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 out.var.baseLayouts,............
4800 20 20 20 20 20 20 6f 75 74 20 76 61 72 20 64 65 76 69 63 65 4d 61 74 63 68 65 72 29 3b 0d 0a 0d ......out.var.deviceMatcher);...
4820 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 65 63 69 64 65 20 77 68 65 74 68 65 72 20 74 .............//.Decide.whether.t
4840 6f 20 74 61 6b 65 20 6e 61 6d 65 20 66 72 6f 6d 20 4a 53 4f 4e 20 6f 72 20 66 72 6f 6d 20 63 6f o.take.name.from.JSON.or.from.co
4860 64 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 74 65 72 6e 65 64 4c 61 79 de...............var.internedLay
4880 6f 75 74 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 6e 61 6d outName.=.new.InternedString(nam
48a0 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 74 65 72 6e 65 64 4c 61 79 e);..............if.(internedLay
48c0 6f 75 74 4e 61 6d 65 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 outName.IsEmpty())..............
48e0 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 {..................internedLayou
4900 74 4e 61 6d 65 20 3d 20 6e 61 6d 65 46 72 6f 6d 4a 73 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 tName.=.nameFromJson;...........
4920 20 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 6b 65 20 73 75 72 65 20 77 65 20 68 61 76 65 20 61 20 .........//.Make.sure.we.have.a.
4940 6e 61 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 6e 74 65 72 name...................if.(inter
4960 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 nedLayoutName.IsEmpty())........
4980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 ..............throw.new.Argument
49a0 45 78 63 65 70 74 69 6f 6e 28 22 4c 61 79 6f 75 74 20 6e 61 6d 65 20 68 61 73 20 6e 6f 74 20 62 Exception("Layout.name.has.not.b
49c0 65 65 6e 20 67 69 76 65 6e 20 61 6e 64 20 69 73 20 6e 6f 74 20 73 65 74 20 69 6e 20 4a 53 4f 4e een.given.and.is.not.set.in.JSON
49e0 20 6c 61 79 6f 75 74 22 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .layout",.......................
4a00 20 20 20 6e 61 6d 65 6f 66 28 6e 61 6d 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d ...nameof(name));..............}
4a20 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 69 74 27 73 20 61 6e 20 6f 76 ................//.If.it's.an.ov
4a40 65 72 72 69 64 65 2c 20 69 74 20 6d 75 73 74 20 68 61 76 65 20 61 20 6c 61 79 6f 75 74 20 74 68 erride,.it.must.have.a.layout.th
4a60 65 20 6f 76 65 72 72 69 64 65 73 20 61 70 70 6c 79 20 74 6f 2e 0d 0a 20 20 20 20 20 20 20 20 20 e.overrides.apply.to............
4a80 20 20 20 69 66 20 28 69 73 4f 76 65 72 72 69 64 65 20 26 26 20 62 61 73 65 4c 61 79 6f 75 74 73 ...if.(isOverride.&&.baseLayouts
4aa0 2e 6c 65 6e 67 74 68 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 .length.==.0)..............{....
4ac0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 ..............throw.new.Argument
4ae0 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Exception(......................
4b00 24 22 4c 61 79 6f 75 74 20 6f 76 65 72 72 69 64 65 20 27 7b 69 6e 74 65 72 6e 65 64 4c 61 79 6f $"Layout.override.'{internedLayo
4b20 75 74 4e 61 6d 65 7d 27 20 6d 75 73 74 20 68 61 76 65 20 27 65 78 74 65 6e 64 27 20 70 72 6f 70 utName}'.must.have.'extend'.prop
4b40 65 72 74 79 20 6d 65 6e 74 69 6f 6e 69 6e 67 20 6c 61 79 6f 75 74 20 74 6f 20 77 68 69 63 68 20 erty.mentioning.layout.to.which.
4b60 74 6f 20 61 70 70 6c 79 20 74 68 65 20 6f 76 65 72 72 69 64 65 73 22 2c 0d 0a 20 20 20 20 20 20 to.apply.the.overrides",........
4b80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 61 6d 65 6f 66 28 6a 73 6f 6e 29 29 3b 0d 0a 20 20 ..............nameof(json));....
4ba0 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 64 ..........}................//.Ad
4bc0 64 20 69 74 20 74 6f 20 6f 75 72 20 72 65 63 6f 72 64 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 d.it.to.our.records.............
4be0 20 20 76 61 72 20 69 73 52 65 70 6c 61 63 65 6d 65 6e 74 20 3d 20 44 6f 65 73 4c 61 79 6f 75 74 ..var.isReplacement.=.DoesLayout
4c00 45 78 69 73 74 28 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 Exist(internedLayoutName);......
4c20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 53 74 72 69 6e 67 73 5b ........m_Layouts.layoutStrings[
4c40 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 5d 20 3d 20 6a 73 6f 6e 3b 0d 0a 20 20 20 internedLayoutName].=.json;.....
4c60 20 20 20 20 20 20 20 20 20 69 66 20 28 69 73 4f 76 65 72 72 69 64 65 29 0d 0a 20 20 20 20 20 20 .........if.(isOverride)........
4c80 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 ......{..................m_Layou
4ca0 74 73 2e 6c 61 79 6f 75 74 4f 76 65 72 72 69 64 65 4e 61 6d 65 73 2e 41 64 64 28 69 6e 74 65 72 ts.layoutOverrideNames.Add(inter
4cc0 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 nedLayoutName);.................
4ce0 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 62 61 73 65 4c 61 79 6f 75 74 73 .for.(var.i.=.0;.i.<.baseLayouts
4d00 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b .length;.++i)..................{
4d20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 62 61 73 65 4c 61 ......................var.baseLa
4d40 79 6f 75 74 4e 61 6d 65 20 3d 20 62 61 73 65 4c 61 79 6f 75 74 73 5b 69 5d 3b 0d 0a 20 20 20 20 youtName.=.baseLayouts[i];......
4d60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 ................m_Layouts.layout
4d80 4f 76 65 72 72 69 64 65 73 2e 54 72 79 47 65 74 56 61 6c 75 65 28 62 61 73 65 4c 61 79 6f 75 74 Overrides.TryGetValue(baseLayout
4da0 4e 61 6d 65 2c 20 6f 75 74 20 76 61 72 20 6f 76 65 72 72 69 64 65 4c 69 73 74 29 3b 0d 0a 20 20 Name,.out.var.overrideList);....
4dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 41 ..................ArrayHelpers.A
4de0 70 70 65 6e 64 28 72 65 66 20 6f 76 65 72 72 69 64 65 4c 69 73 74 2c 20 69 6e 74 65 72 6e 65 64 ppend(ref.overrideList,.interned
4e00 4c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 LayoutName);....................
4e20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 4f 76 65 72 72 69 64 65 73 5b 62 61 73 65 ..m_Layouts.layoutOverrides[base
4e40 4c 61 79 6f 75 74 4e 61 6d 65 5d 20 3d 20 6f 76 65 72 72 69 64 65 4c 69 73 74 3b 0d 0a 20 20 20 LayoutName].=.overrideList;.....
4e60 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d .............}..............}...
4e80 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 65 72 66 6f 72 6d 4c 61 79 6f 75 74 50 6f 73 74 52 65 .............PerformLayoutPostRe
4ea0 67 69 73 74 72 61 74 69 6f 6e 28 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 2c 20 62 gistration(internedLayoutName,.b
4ec0 61 73 65 4c 61 79 6f 75 74 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 73 52 aseLayouts,..................isR
4ee0 65 70 6c 61 63 65 6d 65 6e 74 3a 20 69 73 52 65 70 6c 61 63 65 6d 65 6e 74 2c 20 69 73 4f 76 65 eplacement:.isReplacement,.isOve
4f00 72 72 69 64 65 3a 20 69 73 4f 76 65 72 72 69 64 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 rride:.isOverride);.............
4f20 20 20 20 2f 2f 20 49 66 20 74 68 65 20 6c 61 79 6f 75 74 20 63 6f 6e 74 61 69 6e 65 64 20 61 20 ...//.If.the.layout.contained.a.
4f40 64 65 76 69 63 65 20 6d 61 74 63 68 65 72 2c 20 72 65 67 69 73 74 65 72 20 69 74 2e 0d 0a 20 20 device.matcher,.register.it.....
4f60 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 64 65 76 69 63 65 4d 61 74 63 68 65 72 2e 65 6d 70 ..........if.(!deviceMatcher.emp
4f80 74 79 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e ty)..................RegisterCon
4fa0 74 72 6f 6c 4c 61 79 6f 75 74 4d 61 74 63 68 65 72 28 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 trolLayoutMatcher(internedLayout
4fc0 4e 61 6d 65 2c 20 64 65 76 69 63 65 4d 61 74 63 68 65 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d Name,.deviceMatcher);..........}
4fe0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 52 65 67 69 73 74 65 72 ............public.void.Register
5000 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 42 75 69 6c 64 65 72 28 46 75 6e 63 3c 49 6e 70 75 74 43 ControlLayoutBuilder(Func<InputC
5020 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 3e 20 6d 65 74 68 6f 64 2c 20 73 74 72 69 6e 67 20 6e 61 6d ontrolLayout>.method,.string.nam
5040 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 20 62 61 73 65 4c 61 79 6f 75 e,..............string.baseLayou
5060 74 20 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 t.=.null)..........{............
5080 20 20 69 66 20 28 6d 65 74 68 6f 64 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 ..if.(method.==.null)...........
50a0 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 .......throw.new.ArgumentNullExc
50c0 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 6d 65 74 68 6f 64 29 29 3b 0d 0a 20 20 20 20 20 20 20 eption(nameof(method));.........
50e0 20 20 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 6e 61 .....if.(string.IsNullOrEmpty(na
5100 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 me))..................throw.new.
5120 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 6e 61 6d ArgumentNullException(nameof(nam
5140 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 74 65 72 6e 65 64 e));................var.interned
5160 4c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 LayoutName.=.new.InternedString(
5180 6e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 74 65 72 6e 65 64 name);..............var.interned
51a0 42 61 73 65 4c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 BaseLayoutName.=.new.InternedStr
51c0 69 6e 67 28 62 61 73 65 4c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 ing(baseLayout);..............va
51e0 72 20 69 73 52 65 70 6c 61 63 65 6d 65 6e 74 20 3d 20 44 6f 65 73 4c 61 79 6f 75 74 45 78 69 73 r.isReplacement.=.DoesLayoutExis
5200 74 28 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 t(internedLayoutName);..........
5220 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 42 75 69 6c 64 65 72 73 5b 69 ......m_Layouts.layoutBuilders[i
5240 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 5d 20 3d 20 6d 65 74 68 6f 64 3b 0d 0a 0d 0a nternedLayoutName].=.method;....
5260 20 20 20 20 20 20 20 20 20 20 20 20 50 65 72 66 6f 72 6d 4c 61 79 6f 75 74 50 6f 73 74 52 65 67 ............PerformLayoutPostReg
5280 69 73 74 72 61 74 69 6f 6e 28 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 2c 20 6e 65 istration(internedLayoutName,.ne
52a0 77 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 3e 28 69 w.InlinedArray<InternedString>(i
52c0 6e 74 65 72 6e 65 64 42 61 73 65 4c 61 79 6f 75 74 4e 61 6d 65 29 2c 0d 0a 20 20 20 20 20 20 20 nternedBaseLayoutName),.........
52e0 20 20 20 20 20 20 20 20 20 69 73 52 65 70 6c 61 63 65 6d 65 6e 74 29 3b 0d 0a 20 20 20 20 20 20 .........isReplacement);........
5300 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 50 65 72 66 ..}............private.void.Perf
5320 6f 72 6d 4c 61 79 6f 75 74 50 6f 73 74 52 65 67 69 73 74 72 61 74 69 6f 6e 28 49 6e 74 65 72 6e ormLayoutPostRegistration(Intern
5340 65 64 53 74 72 69 6e 67 20 6c 61 79 6f 75 74 4e 61 6d 65 2c 20 49 6e 6c 69 6e 65 64 41 72 72 61 edString.layoutName,.InlinedArra
5360 79 3c 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 3e 20 62 61 73 65 4c 61 79 6f 75 74 73 2c 0d 0a y<InternedString>.baseLayouts,..
5380 20 20 20 20 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 69 73 52 65 70 6c 61 63 65 6d 65 6e 74 2c 20 ............bool.isReplacement,.
53a0 62 6f 6f 6c 20 69 73 4b 6e 6f 77 6e 54 6f 42 65 44 65 76 69 63 65 4c 61 79 6f 75 74 20 3d 20 66 bool.isKnownToBeDeviceLayout.=.f
53c0 61 6c 73 65 2c 20 62 6f 6f 6c 20 69 73 4f 76 65 72 72 69 64 65 20 3d 20 66 61 6c 73 65 29 0d 0a alse,.bool.isOverride.=.false)..
53e0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2b 2b 6d 5f 4c 61 79 6f 75 ........{..............++m_Layou
5400 74 52 65 67 69 73 74 72 61 74 69 6f 6e 56 65 72 73 69 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 tRegistrationVersion;...........
5420 20 20 20 20 20 2f 2f 20 46 6f 72 63 65 2d 63 6c 65 61 72 20 6c 61 79 6f 75 74 20 63 61 63 68 65 .....//.Force-clear.layout.cache
5440 2e 20 44 6f 6e 27 74 20 63 6c 65 61 72 20 72 65 66 65 72 65 6e 63 65 20 63 6f 75 6e 74 20 73 6f ..Don't.clear.reference.count.so
5460 20 74 68 61 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 65 20 63 61 63 68 65 20 .that..............//.the.cache.
5480 67 65 74 73 20 63 6c 65 61 72 65 64 20 6f 75 74 20 70 72 6f 70 65 72 6c 79 20 77 68 65 6e 20 72 gets.cleared.out.properly.when.r
54a0 65 6c 65 61 73 65 64 20 69 6e 20 63 61 73 65 20 73 6f 6d 65 6f 6e 65 0d 0a 20 20 20 20 20 20 20 eleased.in.case.someone.........
54c0 20 20 20 20 20 2f 2f 20 69 73 20 75 73 69 6e 67 20 69 74 20 41 54 4d 2e 0d 0a 20 20 20 20 20 20 .....//.is.using.it.ATM.........
54e0 20 20 20 20 20 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 2e 73 5f 43 61 63 68 65 ......InputControlLayout.s_Cache
5500 49 6e 73 74 61 6e 63 65 2e 43 6c 65 61 72 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 Instance.Clear();...............
5520 20 2f 2f 20 46 6f 72 20 6c 61 79 6f 75 74 73 20 74 68 61 74 20 61 72 65 6e 27 74 20 6f 76 65 72 .//.For.layouts.that.aren't.over
5540 72 69 64 65 73 2c 20 61 64 64 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 62 61 73 65 0d rides,.add.the.name.of.the.base.
5560 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6c 61 79 6f 75 74 20 74 6f 20 74 68 65 20 6c 6f .............//.layout.to.the.lo
5580 6f 6b 75 70 20 74 61 62 6c 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 69 73 okup.table...............if.(!is
55a0 4f 76 65 72 72 69 64 65 20 26 26 20 62 61 73 65 4c 61 79 6f 75 74 73 2e 6c 65 6e 67 74 68 20 3e Override.&&.baseLayouts.length.>
55c0 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .0)..............{..............
55e0 20 20 20 20 69 66 20 28 62 61 73 65 4c 61 79 6f 75 74 73 2e 6c 65 6e 67 74 68 20 3e 20 31 29 0d ....if.(baseLayouts.length.>.1).
5600 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 4e .....................throw.new.N
5620 6f 74 53 75 70 70 6f 72 74 65 64 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 otSupportedException(...........
5640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 24 22 4c 61 79 6f 75 74 20 27 7b 6c 61 79 6f 75 74 ...............$"Layout.'{layout
5660 4e 61 6d 65 7d 27 20 68 61 73 20 6d 75 6c 74 69 70 6c 65 20 62 61 73 65 20 6c 61 79 6f 75 74 73 Name}'.has.multiple.base.layouts
5680 3b 20 74 68 69 73 20 69 73 20 6f 6e 6c 79 20 73 75 70 70 6f 72 74 65 64 20 6f 6e 20 6c 61 79 6f ;.this.is.only.supported.on.layo
56a0 75 74 20 6f 76 65 72 72 69 64 65 73 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ut.overrides");.................
56c0 20 20 20 76 61 72 20 62 61 73 65 4c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 62 61 73 65 4c 61 79 6f ...var.baseLayoutName.=.baseLayo
56e0 75 74 73 5b 30 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 62 61 uts[0];..................if.(!ba
5700 73 65 4c 61 79 6f 75 74 4e 61 6d 65 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 seLayoutName.IsEmpty()).........
5720 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 62 61 73 65 4c 61 79 6f 75 .............m_Layouts.baseLayou
5740 74 54 61 62 6c 65 5b 6c 61 79 6f 75 74 4e 61 6d 65 5d 20 3d 20 62 61 73 65 4c 61 79 6f 75 74 4e tTable[layoutName].=.baseLayoutN
5760 61 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ame;..............}.............
5780 20 20 20 2f 2f 20 52 65 63 72 65 61 74 65 20 61 6e 79 20 64 65 76 69 63 65 73 20 75 73 69 6e 67 ...//.Recreate.any.devices.using
57a0 20 74 68 65 20 6c 61 79 6f 75 74 2e 20 49 66 20 69 74 27 73 20 61 6e 20 6f 76 65 72 72 69 64 65 .the.layout..If.it's.an.override
57c0 2c 20 72 65 63 72 65 61 74 65 20 64 65 76 69 63 65 73 20 75 73 69 6e 67 20 61 6e 79 20 6f 66 20 ,.recreate.devices.using.any.of.
57e0 74 68 65 20 62 61 73 65 20 6c 61 79 6f 75 74 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 the.base.layouts...............i
5800 66 20 28 69 73 4f 76 65 72 72 69 64 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 f.(isOverride)..............{...
5820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 ...............for.(var.i.=.0;.i
5840 20 3c 20 62 61 73 65 4c 61 79 6f 75 74 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 .<.baseLayouts.length;.++i).....
5860 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 63 72 65 61 74 65 44 65 76 69 63 65 73 .................RecreateDevices
5880 55 73 69 6e 67 4c 61 79 6f 75 74 28 62 61 73 65 4c 61 79 6f 75 74 73 5b 69 5d 2c 20 69 73 4b 6e UsingLayout(baseLayouts[i],.isKn
58a0 6f 77 6e 54 6f 42 65 44 65 76 69 63 65 4c 61 79 6f 75 74 3a 20 69 73 4b 6e 6f 77 6e 54 6f 42 65 ownToBeDeviceLayout:.isKnownToBe
58c0 44 65 76 69 63 65 4c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 DeviceLayout);..............}...
58e0 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a ...........else..............{..
5900 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 63 72 65 61 74 65 44 65 76 69 63 65 73 55 ................RecreateDevicesU
5920 73 69 6e 67 4c 61 79 6f 75 74 28 6c 61 79 6f 75 74 4e 61 6d 65 2c 20 69 73 4b 6e 6f 77 6e 54 6f singLayout(layoutName,.isKnownTo
5940 42 65 44 65 76 69 63 65 4c 61 79 6f 75 74 3a 20 69 73 4b 6e 6f 77 6e 54 6f 42 65 44 65 76 69 63 BeDeviceLayout:.isKnownToBeDevic
5960 65 4c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 eLayout);..............}........
5980 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 20 74 68 65 20 65 64 69 74 6f 72 2c 20 6c 61 79 6f 75 74 ........//.In.the.editor,.layout
59a0 73 20 6d 61 79 20 62 65 63 6f 6d 65 20 61 76 61 69 6c 61 62 6c 65 20 73 75 63 63 65 73 73 69 76 s.may.become.available.successiv
59c0 65 6c 79 20 61 66 74 65 72 20 61 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 20 73 6f 0d 0a 20 20 ely.after.a.domain.reload.so....
59e0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 77 65 20 6d 61 79 20 65 6e 64 20 75 70 20 72 65 74 61 69 ..........//.we.may.end.up.retai
5a00 6e 69 6e 67 20 64 65 76 69 63 65 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 61 6c 6c 20 74 68 65 20 ning.device.information.all.the.
5a20 77 61 79 20 75 6e 74 69 6c 20 77 65 20 72 75 6e 20 74 68 65 20 66 69 72 73 74 20 66 75 6c 6c 0d way.until.we.run.the.first.full.
5a40 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 70 6c 61 79 65 72 20 75 70 64 61 74 65 2e 20 46 .............//.player.update..F
5a60 6f 72 20 65 76 65 72 79 20 6c 61 79 6f 75 74 20 77 65 20 72 65 67 69 73 74 65 72 2c 20 77 65 20 or.every.layout.we.register,.we.
5a80 63 68 65 63 6b 20 68 65 72 65 20 77 68 65 74 68 65 72 20 77 65 20 68 61 76 65 20 61 20 73 61 76 check.here.whether.we.have.a.sav
5aa0 65 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 65 76 69 63 65 20 73 74 61 74 65 20 ed..............//.device.state.
5ac0 75 73 69 6e 67 20 61 20 6c 61 79 6f 75 74 20 77 69 74 68 20 74 68 65 20 73 61 6d 65 20 6e 61 6d using.a.layout.with.the.same.nam
5ae0 65 20 62 75 74 20 6e 6f 74 20 68 61 76 69 6e 67 20 61 20 64 65 76 69 63 65 20 64 65 73 63 72 69 e.but.not.having.a.device.descri
5b00 70 74 69 6f 6e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 28 74 68 65 20 6c 61 74 74 65 ption..............//.(the.latte
5b20 72 20 69 73 20 69 6d 70 6f 72 74 61 6e 74 20 61 73 20 69 6e 20 74 68 61 74 20 63 61 73 65 2c 20 r.is.important.as.in.that.case,.
5b40 77 65 20 73 68 6f 75 6c 64 20 67 6f 20 74 68 72 6f 75 67 68 20 74 68 65 20 6e 6f 72 6d 61 6c 20 we.should.go.through.the.normal.
5b60 6d 61 74 63 68 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 70 72 6f 63 65 73 73 matching..............//.process
5b80 20 61 6e 64 20 6e 6f 74 20 6a 75 73 74 20 72 65 6c 79 20 6f 6e 20 74 68 65 20 6e 61 6d 65 20 6f .and.not.just.rely.on.the.name.o
5ba0 66 20 74 68 65 20 6c 61 79 6f 75 74 29 2e 20 49 66 20 73 6f 2c 20 77 65 20 74 72 79 20 68 65 72 f.the.layout)..If.so,.we.try.her
5bc0 65 20 74 6f 20 72 65 63 72 65 61 74 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 e.to.recreate..............//.th
5be0 65 20 64 65 76 69 63 65 20 77 69 74 68 20 74 68 65 20 6a 75 73 74 20 72 65 67 69 73 74 65 72 65 e.device.with.the.just.registere
5c00 64 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 d.layout...............#if.UNITY
5c20 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 _EDITOR..............for.(var.i.
5c40 3d 20 30 3b 20 69 20 3c 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 2e 4c 65 6e =.0;.i.<.m_SavedDeviceStates.Len
5c60 67 74 68 53 61 66 65 28 29 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a gthSafe();.++i)..............{..
5c80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 76 61 72 20 64 65 76 69 63 65 53 74 ................ref.var.deviceSt
5ca0 61 74 65 20 3d 20 72 65 66 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 5b 69 5d ate.=.ref.m_SavedDeviceStates[i]
5cc0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d ;..................if.(layoutNam
5ce0 65 20 21 3d 20 64 65 76 69 63 65 53 74 61 74 65 2e 6c 61 79 6f 75 74 20 7c 7c 20 21 64 65 76 69 e.!=.deviceState.layout.||.!devi
5d00 63 65 53 74 61 74 65 2e 64 65 73 63 72 69 70 74 69 6f 6e 2e 65 6d 70 74 79 29 0d 0a 20 20 20 20 ceState.description.empty)......
5d20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 ................continue;.......
5d40 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 52 65 73 74 6f 72 65 44 65 76 69 63 65 46 72 .............if.(RestoreDeviceFr
5d60 6f 6d 53 61 76 65 64 53 74 61 74 65 28 72 65 66 20 64 65 76 69 63 65 53 74 61 74 65 2c 20 6c 61 omSavedState(ref.deviceState,.la
5d80 79 6f 75 74 4e 61 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 youtName))..................{...
5da0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e ...................ArrayHelpers.
5dc0 45 72 61 73 65 41 74 28 72 65 66 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 2c EraseAt(ref.m_SavedDeviceStates,
5de0 20 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 69 3b 0d 0a .i);......................--i;..
5e00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d ................}..............}
5e20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ..............#endif............
5e40 20 20 20 20 2f 2f 20 4c 65 74 20 6c 69 73 74 65 6e 65 72 73 20 6b 6e 6f 77 2e 0d 0a 20 20 20 20 ....//.Let.listeners.know.......
5e60 20 20 20 20 20 20 20 20 76 61 72 20 63 68 61 6e 67 65 20 3d 20 69 73 52 65 70 6c 61 63 65 6d 65 ........var.change.=.isReplaceme
5e80 6e 74 20 3f 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 43 68 61 6e 67 65 2e 52 65 nt.?.InputControlLayoutChange.Re
5ea0 70 6c 61 63 65 64 20 3a 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 43 68 61 6e 67 placed.:.InputControlLayoutChang
5ec0 65 2e 41 64 64 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 e.Added;..............for.(var.i
5ee0 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 .=.0;.i.<.m_LayoutChangeListener
5f00 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 s.length;.++i)..................
5f20 6d 5f 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 6c 61 79 6f 75 m_LayoutChangeListeners[i](layou
5f40 74 4e 61 6d 65 2e 54 6f 53 74 72 69 6e 67 28 29 2c 20 63 68 61 6e 67 65 29 3b 0d 0a 20 20 20 20 tName.ToString(),.change);......
5f60 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 52 65 ....}............private.void.Re
5f80 63 72 65 61 74 65 44 65 76 69 63 65 73 55 73 69 6e 67 4c 61 79 6f 75 74 28 49 6e 74 65 72 6e 65 createDevicesUsingLayout(Interne
5fa0 64 53 74 72 69 6e 67 20 6c 61 79 6f 75 74 2c 20 62 6f 6f 6c 20 69 73 4b 6e 6f 77 6e 54 6f 42 65 dString.layout,.bool.isKnownToBe
5fc0 44 65 76 69 63 65 4c 61 79 6f 75 74 20 3d 20 66 61 6c 73 65 29 0d 0a 20 20 20 20 20 20 20 20 7b DeviceLayout.=.false)..........{
5fe0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 ..............if.(m_DevicesCount
6000 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d .==.0)..................return;.
6020 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4c 69 73 74 3c 49 6e 70 75 74 44 65 76 69 63 65 3e ...............List<InputDevice>
6040 20 64 65 76 69 63 65 73 55 73 69 6e 67 4c 61 79 6f 75 74 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 .devicesUsingLayout.=.null;.....
6060 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 69 6e 64 20 61 6c 6c 20 64 65 76 69 63 65 73 20 75 ...........//.Find.all.devices.u
6080 73 69 6e 67 20 74 68 65 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f sing.the.layout...............fo
60a0 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 r.(var.i.=.0;.i.<.m_DevicesCount
60c0 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 ;.++i)..............{...........
60e0 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d .......var.device.=.m_Devices[i]
6100 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 6f 6f 6c 20 75 73 65 73 4c 61 ;....................bool.usesLa
6120 79 6f 75 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 73 4b 6e 6f yout;..................if.(isKno
6140 77 6e 54 6f 42 65 44 65 76 69 63 65 4c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 wnToBeDeviceLayout).............
6160 20 20 20 20 20 20 20 20 20 75 73 65 73 4c 61 79 6f 75 74 20 3d 20 49 73 43 6f 6e 74 72 6f 6c 55 .........usesLayout.=.IsControlU
6180 73 69 6e 67 4c 61 79 6f 75 74 28 64 65 76 69 63 65 2c 20 6c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 singLayout(device,.layout);.....
61a0 20 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 .............else...............
61c0 20 20 20 20 20 20 20 75 73 65 73 4c 61 79 6f 75 74 20 3d 20 49 73 43 6f 6e 74 72 6f 6c 4f 72 43 .......usesLayout.=.IsControlOrC
61e0 68 69 6c 64 55 73 69 6e 67 4c 61 79 6f 75 74 52 65 63 75 72 73 69 76 65 28 64 65 76 69 63 65 2c hildUsingLayoutRecursive(device,
6200 20 6c 61 79 6f 75 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 .layout);....................if.
6220 28 75 73 65 73 4c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d (usesLayout)..................{.
6240 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 73 .....................if.(devices
6260 55 73 69 6e 67 4c 61 79 6f 75 74 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 UsingLayout.==.null)............
6280 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 73 55 73 69 6e 67 4c 61 79 6f 75 74 ..............devicesUsingLayout
62a0 20 3d 20 6e 65 77 20 4c 69 73 74 3c 49 6e 70 75 74 44 65 76 69 63 65 3e 28 29 3b 0d 0a 20 20 20 .=.new.List<InputDevice>();.....
62c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 73 55 73 69 6e 67 4c 61 79 .................devicesUsingLay
62e0 6f 75 74 2e 41 64 64 28 64 65 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 out.Add(device);................
6300 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 ..}..............}..............
6320 20 20 2f 2f 20 49 66 20 74 68 65 72 65 27 73 20 6e 6f 6e 65 2c 20 77 65 27 72 65 20 67 6f 6f 64 ..//.If.there's.none,.we're.good
6340 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 73 55 73 69 6e 67 4c ...............if.(devicesUsingL
6360 61 79 6f 75 74 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ayout.==.null)..................
6380 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 6f 76 65 return;................//.Remove
63a0 20 61 6e 64 20 72 65 2d 61 64 64 20 74 68 65 20 6d 61 74 63 68 69 6e 67 20 64 65 76 69 63 65 73 .and.re-add.the.matching.devices
63c0 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 75 73 69 6e 67 20 28 49 6e 70 75 74 44 65 76 69 63 ...............using.(InputDevic
63e0 65 42 75 69 6c 64 65 72 2e 52 65 66 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a eBuilder.Ref())..............{..
6400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 ................for.(var.i.=.0;.
6420 69 20 3c 20 64 65 76 69 63 65 73 55 73 69 6e 67 4c 61 79 6f 75 74 2e 43 6f 75 6e 74 3b 20 2b 2b i.<.devicesUsingLayout.Count;.++
6440 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 i)..................{...........
6460 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 64 65 76 69 63 65 73 55 ...........var.device.=.devicesU
6480 73 69 6e 67 4c 61 79 6f 75 74 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 singLayout[i];..................
64a0 20 20 20 20 52 65 63 72 65 61 74 65 44 65 76 69 63 65 28 64 65 76 69 63 65 2c 20 64 65 76 69 63 ....RecreateDevice(device,.devic
64c0 65 2e 6d 5f 4c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d e.m_Layout);..................}.
64e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .............}..........}.......
6500 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f 6f 6c 20 49 73 43 6f 6e 74 72 6f 6c 4f 72 43 68 69 .....private.bool.IsControlOrChi
6520 6c 64 55 73 69 6e 67 4c 61 79 6f 75 74 52 65 63 75 72 73 69 76 65 28 49 6e 70 75 74 43 6f 6e 74 ldUsingLayoutRecursive(InputCont
6540 72 6f 6c 20 63 6f 6e 74 72 6f 6c 2c 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 6c 61 79 6f rol.control,.InternedString.layo
6560 75 74 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 ut)..........{..............//.C
6580 68 65 63 6b 20 63 6f 6e 74 72 6f 6c 20 69 74 73 65 6c 66 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 heck.control.itself.............
65a0 20 20 69 66 20 28 49 73 43 6f 6e 74 72 6f 6c 55 73 69 6e 67 4c 61 79 6f 75 74 28 63 6f 6e 74 72 ..if.(IsControlUsingLayout(contr
65c0 6f 6c 2c 20 6c 61 79 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 ol,.layout))..................re
65e0 74 75 72 6e 20 74 72 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 68 65 turn.true;................//.Che
6600 63 6b 20 63 68 69 6c 64 72 65 6e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 68 ck.children...............var.ch
6620 69 6c 64 72 65 6e 20 3d 20 63 6f 6e 74 72 6f 6c 2e 63 68 69 6c 64 72 65 6e 3b 0d 0a 20 20 20 20 ildren.=.control.children;......
6640 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 63 68 69 6c ........for.(var.i.=.0;.i.<.chil
6660 64 72 65 6e 2e 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 dren.Count;.++i)................
6680 20 20 69 66 20 28 49 73 43 6f 6e 74 72 6f 6c 4f 72 43 68 69 6c 64 55 73 69 6e 67 4c 61 79 6f 75 ..if.(IsControlOrChildUsingLayou
66a0 74 52 65 63 75 72 73 69 76 65 28 63 68 69 6c 64 72 65 6e 5b 69 5d 2c 20 6c 61 79 6f 75 74 29 29 tRecursive(children[i],.layout))
66c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 ......................return.tru
66e0 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d e;................return.false;.
6700 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f .........}............private.bo
6720 6f 6c 20 49 73 43 6f 6e 74 72 6f 6c 55 73 69 6e 67 4c 61 79 6f 75 74 28 49 6e 70 75 74 43 6f 6e ol.IsControlUsingLayout(InputCon
6740 74 72 6f 6c 20 63 6f 6e 74 72 6f 6c 2c 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 6c 61 79 trol.control,.InternedString.lay
6760 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 out)..........{..............//.
6780 43 68 65 63 6b 20 64 69 72 65 63 74 20 6d 61 74 63 68 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 Check.direct.match..............
67a0 20 69 66 20 28 63 6f 6e 74 72 6f 6c 2e 6c 61 79 6f 75 74 20 3d 3d 20 6c 61 79 6f 75 74 29 0d 0a .if.(control.layout.==.layout)..
67c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 0d 0a ................return.true;....
67e0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 68 65 63 6b 20 62 61 73 65 20 6c 61 79 6f 75 74 ............//.Check.base.layout
6800 20 63 68 61 69 6e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 62 61 73 65 4c 61 79 .chain...............var.baseLay
6820 6f 75 74 20 3d 20 63 6f 6e 74 72 6f 6c 2e 6d 5f 4c 61 79 6f 75 74 3b 0d 0a 20 20 20 20 20 20 20 out.=.control.m_Layout;.........
6840 20 20 20 20 20 77 68 69 6c 65 20 28 6d 5f 4c 61 79 6f 75 74 73 2e 62 61 73 65 4c 61 79 6f 75 74 .....while.(m_Layouts.baseLayout
6860 54 61 62 6c 65 2e 54 72 79 47 65 74 56 61 6c 75 65 28 62 61 73 65 4c 61 79 6f 75 74 2c 20 6f 75 Table.TryGetValue(baseLayout,.ou
6880 74 20 62 61 73 65 4c 61 79 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 t.baseLayout))..................
68a0 69 66 20 28 62 61 73 65 4c 61 79 6f 75 74 20 3d 3d 20 6c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 if.(baseLayout.==.layout).......
68c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 0d 0a 20 ...............return.true;.....
68e0 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 ...........return.false;........
6900 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 52 65 67 69 73 ..}............public.void.Regis
6920 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 4d 61 74 63 68 65 72 28 73 74 72 69 6e 67 20 6c terControlLayoutMatcher(string.l
6940 61 79 6f 75 74 4e 61 6d 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 4d 61 74 63 68 65 72 20 6d 61 ayoutName,.InputDeviceMatcher.ma
6960 74 63 68 65 72 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 tcher)..........{..............i
6980 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 6c 61 79 6f 75 74 4e 61 f.(string.IsNullOrEmpty(layoutNa
69a0 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 me))..................throw.new.
69c0 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 6c 61 79 ArgumentNullException(nameof(lay
69e0 6f 75 74 4e 61 6d 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 61 74 63 outName));..............if.(matc
6a00 68 65 72 2e 65 6d 70 74 79 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f her.empty)..................thro
6a20 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 22 4d 61 74 63 68 65 72 w.new.ArgumentException("Matcher
6a40 20 63 61 6e 6e 6f 74 20 62 65 20 65 6d 70 74 79 22 2c 20 6e 61 6d 65 6f 66 28 6d 61 74 63 68 65 .cannot.be.empty",.nameof(matche
6a60 72 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 64 64 20 74 6f 20 74 61 r));................//.Add.to.ta
6a80 62 6c 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6e 74 65 72 6e 65 64 4c 61 ble...............var.internedLa
6aa0 79 6f 75 74 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 6c 61 youtName.=.new.InternedString(la
6ac0 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 youtName);..............m_Layout
6ae0 73 2e 41 64 64 4d 61 74 63 68 65 72 28 69 6e 74 65 72 6e 65 64 4c 61 79 6f 75 74 4e 61 6d 65 2c s.AddMatcher(internedLayoutName,
6b00 20 6d 61 74 63 68 65 72 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 63 .matcher);................//.Rec
6b20 72 65 61 74 65 20 61 6e 79 20 64 65 76 69 63 65 20 74 68 61 74 20 77 65 20 6d 61 74 63 68 20 62 reate.any.device.that.we.match.b
6b40 65 74 74 65 72 20 74 68 61 6e 20 69 74 73 20 63 75 72 72 65 6e 74 20 6c 61 79 6f 75 74 2e 0d 0a etter.than.its.current.layout...
6b60 20 20 20 20 20 20 20 20 20 20 20 20 52 65 63 72 65 61 74 65 44 65 76 69 63 65 73 55 73 69 6e 67 ............RecreateDevicesUsing
6b80 4c 61 79 6f 75 74 57 69 74 68 49 6e 66 65 72 69 6f 72 4d 61 74 63 68 28 6d 61 74 63 68 65 72 29 LayoutWithInferiorMatch(matcher)
6ba0 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 65 20 69 66 20 77 65 20 63 61 ;................//.See.if.we.ca
6bc0 6e 20 6d 61 6b 65 20 73 65 6e 73 65 20 6f 66 20 61 6e 79 20 64 65 76 69 63 65 20 77 65 20 63 6f n.make.sense.of.any.device.we.co
6be0 75 6c 64 6e 27 74 20 6d 61 6b 65 20 73 65 6e 73 65 20 6f 66 20 62 65 66 6f 72 65 2e 0d 0a 20 20 uldn't.make.sense.of.before.....
6c00 20 20 20 20 20 20 20 20 20 20 41 64 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 4d 61 74 ..........AddAvailableDevicesMat
6c20 63 68 69 6e 67 44 65 73 63 72 69 70 74 69 6f 6e 28 6d 61 74 63 68 65 72 2c 20 69 6e 74 65 72 6e chingDescription(matcher,.intern
6c40 65 64 4c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 edLayoutName);..........}.......
6c60 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c .....public.void.RegisterControl
6c80 4c 61 79 6f 75 74 4d 61 74 63 68 65 72 28 54 79 70 65 20 74 79 70 65 2c 20 49 6e 70 75 74 44 65 LayoutMatcher(Type.type,.InputDe
6ca0 76 69 63 65 4d 61 74 63 68 65 72 20 6d 61 74 63 68 65 72 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d viceMatcher.matcher)..........{.
6cc0 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 79 70 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a .............if.(type.==.null)..
6ce0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 ................throw.new.Argume
6d00 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 74 79 70 65 29 29 3b 0d 0a ntNullException(nameof(type));..
6d20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 61 74 63 68 65 72 2e 65 6d 70 74 79 29 0d 0a ............if.(matcher.empty)..
6d40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 ................throw.new.Argume
6d60 6e 74 45 78 63 65 70 74 69 6f 6e 28 22 4d 61 74 63 68 65 72 20 63 61 6e 6e 6f 74 20 62 65 20 65 ntException("Matcher.cannot.be.e
6d80 6d 70 74 79 22 2c 20 6e 61 6d 65 6f 66 28 6d 61 74 63 68 65 72 29 29 3b 0d 0a 0d 0a 20 20 20 20 mpty",.nameof(matcher));........
6da0 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6d 5f 4c 61 79 6f 75 ........var.layoutName.=.m_Layou
6dc0 74 73 2e 54 72 79 46 69 6e 64 4c 61 79 6f 75 74 46 6f 72 54 79 70 65 28 74 79 70 65 29 3b 0d 0a ts.TryFindLayoutForType(type);..
6de0 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d 65 2e 49 73 45 6d 70 ............if.(layoutName.IsEmp
6e00 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 ty())..................throw.new
6e20 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .ArgumentException(.............
6e40 20 20 20 20 20 20 20 20 20 24 22 54 79 70 65 20 27 7b 74 79 70 65 2e 4e 61 6d 65 7d 27 20 68 61 .........$"Type.'{type.Name}'.ha
6e60 73 20 6e 6f 74 20 62 65 65 6e 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20 61 20 63 6f 6e 74 72 s.not.been.registered.as.a.contr
6e80 6f 6c 20 6c 61 79 6f 75 74 22 2c 20 6e 61 6d 65 6f 66 28 74 79 70 65 29 29 3b 0d 0a 0d 0a 20 20 ol.layout",.nameof(type));......
6ea0 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 4d ..........RegisterControlLayoutM
6ec0 61 74 63 68 65 72 28 6c 61 79 6f 75 74 4e 61 6d 65 2c 20 6d 61 74 63 68 65 72 29 3b 0d 0a 20 20 atcher(layoutName,.matcher);....
6ee0 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 ......}............private.void.
6f00 52 65 63 72 65 61 74 65 44 65 76 69 63 65 73 55 73 69 6e 67 4c 61 79 6f 75 74 57 69 74 68 49 6e RecreateDevicesUsingLayoutWithIn
6f20 66 65 72 69 6f 72 4d 61 74 63 68 28 49 6e 70 75 74 44 65 76 69 63 65 4d 61 74 63 68 65 72 20 64 feriorMatch(InputDeviceMatcher.d
6f40 65 76 69 63 65 4d 61 74 63 68 65 72 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 eviceMatcher)..........{........
6f60 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 20 3d 3d 20 30 29 0d 0a ......if.(m_DevicesCount.==.0)..
6f80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 ................return;.........
6fa0 20 20 20 20 20 20 20 75 73 69 6e 67 20 28 49 6e 70 75 74 44 65 76 69 63 65 42 75 69 6c 64 65 72 .......using.(InputDeviceBuilder
6fc0 2e 52 65 66 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 .Ref())..............{..........
6fe0 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 43 6f 75 6e 74 20 3d 20 6d 5f 44 65 76 69 ........var.deviceCount.=.m_Devi
7000 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 cesCount;..................for.(
7020 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 64 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 var.i.=.0;.i.<.deviceCount;.++i)
7040 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ..................{.............
7060 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b .........var.device.=.m_Devices[
7080 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 i];......................var.dev
70a0 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 20 3d 20 64 65 76 69 63 65 2e 64 65 73 63 72 69 70 74 iceDescription.=.device.descript
70c0 69 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 ion;........................if.(
70e0 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2e 65 6d 70 74 79 20 7c 7c 20 21 28 64 65 76 deviceDescription.empty.||.!(dev
7100 69 63 65 4d 61 74 63 68 65 72 2e 4d 61 74 63 68 50 65 72 63 65 6e 74 61 67 65 28 64 65 76 69 63 iceMatcher.MatchPercentage(devic
7120 65 44 65 73 63 72 69 70 74 69 6f 6e 29 20 3e 20 30 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 eDescription).>.0)).............
7140 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 .............continue;..........
7160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 54 ..............var.layoutName.=.T
7180 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 72 65 66 20 ryFindMatchingControlLayout(ref.
71a0 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2c 20 64 65 76 69 63 65 2e 64 65 76 69 63 65 deviceDescription,.device.device
71c0 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 Id);......................if.(la
71e0 79 6f 75 74 4e 61 6d 65 20 21 3d 20 64 65 76 69 63 65 2e 6d 5f 4c 61 79 6f 75 74 29 0d 0a 20 20 youtName.!=.device.m_Layout)....
7200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ..................{.............
7220 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 73 63 72 69 70 74 69 6f .............device.m_Descriptio
7240 6e 20 3d 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 n.=.deviceDescription;..........
7260 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 63 72 65 61 74 65 44 65 76 69 63 65 ..................RecreateDevice
7280 28 64 65 76 69 63 65 2c 20 6c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 (device,.layoutName);...........
72a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 27 72 65 20 72 65 6d 6f 76 69 .................//.We're.removi
72c0 6e 67 20 64 65 76 69 63 65 73 20 69 6e 20 74 68 65 20 6d 69 64 64 6c 65 20 6f 66 20 74 68 65 20 ng.devices.in.the.middle.of.the.
72e0 61 72 72 61 79 20 61 6e 64 20 61 70 70 65 6e 64 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 array.and.appending.............
7300 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 65 6d 20 61 74 20 74 68 65 20 65 6e 64 2e .............//.them.at.the.end.
7320 20 41 64 6a 75 73 74 20 6f 75 72 20 69 6e 64 65 78 20 61 6e 64 20 64 65 76 69 63 65 20 63 6f 75 .Adjust.our.index.and.device.cou
7340 6e 74 20 74 6f 20 6d 61 6b 65 20 73 75 72 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 nt.to.make.sure.................
7360 20 20 20 20 20 20 20 20 20 2f 2f 20 77 65 27 72 65 20 6e 6f 74 20 69 74 65 72 61 74 69 6e 67 20 .........//.we're.not.iterating.
7380 61 6c 6c 20 74 68 65 20 77 61 79 20 69 6e 74 6f 20 61 6c 72 65 61 64 79 20 70 72 6f 63 65 73 73 all.the.way.into.already.process
73a0 65 64 20 64 65 76 69 63 65 73 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ed.devices......................
73c0 20 20 20 20 20 20 20 2d 2d 69 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .......--i;.....................
73e0 20 20 20 20 20 2d 2d 64 65 76 69 63 65 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .....--deviceCount;.............
7400 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 .........}..................}...
7420 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 ...........}..........}.........
7440 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 52 65 63 72 65 61 74 65 44 65 76 69 63 65 28 49 ...private.void.RecreateDevice(I
7460 6e 70 75 74 44 65 76 69 63 65 20 6f 6c 64 44 65 76 69 63 65 2c 20 49 6e 74 65 72 6e 65 64 53 74 nputDevice.oldDevice,.InternedSt
7480 72 69 6e 67 20 6e 65 77 4c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 ring.newLayout)..........{......
74a0 20 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 6f 76 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ........//.Remove...............
74c0 52 65 6d 6f 76 65 44 65 76 69 63 65 28 6f 6c 64 44 65 76 69 63 65 2c 20 6b 65 65 70 4f 6e 4c 69 RemoveDevice(oldDevice,.keepOnLi
74e0 73 74 4f 66 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 3a 20 74 72 75 65 29 3b 0d 0a 0d 0a stOfAvailableDevices:.true);....
7500 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 2d 73 65 74 75 70 20 64 65 76 69 63 65 2e 0d ............//.Re-setup.device..
7520 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 65 77 44 65 76 69 63 65 20 3d 20 49 6e 70 .............var.newDevice.=.Inp
7540 75 74 44 65 76 69 63 65 2e 42 75 69 6c 64 3c 49 6e 70 75 74 44 65 76 69 63 65 3e 28 6e 65 77 4c utDevice.Build<InputDevice>(newL
7560 61 79 6f 75 74 2c 20 6f 6c 64 44 65 76 69 63 65 2e 6d 5f 56 61 72 69 61 6e 74 73 2c 0d 0a 20 20 ayout,.oldDevice.m_Variants,....
7580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 3a ..............deviceDescription:
75a0 20 6f 6c 64 44 65 76 69 63 65 2e 6d 5f 44 65 73 63 72 69 70 74 69 6f 6e 29 3b 0d 0a 0d 0a 20 20 .oldDevice.m_Description);......
75c0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 50 72 65 73 65 72 76 65 20 64 65 76 69 63 65 20 70 72 6f ..........//.Preserve.device.pro
75e0 70 65 72 74 69 65 73 20 74 68 61 74 20 73 68 6f 75 6c 64 20 6e 6f 74 20 62 65 20 63 68 61 6e 67 perties.that.should.not.be.chang
7600 65 64 20 62 79 20 74 68 65 20 72 65 2d 63 72 65 61 74 69 6f 6e 0d 0a 20 20 20 20 20 20 20 20 20 ed.by.the.re-creation...........
7620 20 20 20 2f 2f 20 6f 66 20 61 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ...//.of.a.device...............
7640 6e 65 77 44 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 64 20 3d 20 6f 6c 64 44 65 76 69 63 65 newDevice.m_DeviceId.=.oldDevice
7660 2e 6d 5f 44 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 44 65 76 .m_DeviceId;..............newDev
7680 69 63 65 2e 6d 5f 44 65 73 63 72 69 70 74 69 6f 6e 20 3d 20 6f 6c 64 44 65 76 69 63 65 2e 6d 5f ice.m_Description.=.oldDevice.m_
76a0 44 65 73 63 72 69 70 74 69 6f 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6f 6c Description;..............if.(ol
76c0 64 44 65 76 69 63 65 2e 6e 61 74 69 76 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 dDevice.native).................
76e0 20 6e 65 77 44 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 46 6c 61 67 73 20 7c 3d 20 49 6e 70 75 .newDevice.m_DeviceFlags.|=.Inpu
7700 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 2e 4e 61 74 69 76 65 3b 0d 0a 20 20 20 tDevice.DeviceFlags.Native;.....
7720 20 20 20 20 20 20 20 20 20 69 66 20 28 6f 6c 64 44 65 76 69 63 65 2e 72 65 6d 6f 74 65 29 0d 0a .........if.(oldDevice.remote)..
7740 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 44 65 76 69 63 65 2e 6d 5f 44 65 76 69 ................newDevice.m_Devi
7760 63 65 46 6c 61 67 73 20 7c 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 ceFlags.|=.InputDevice.DeviceFla
7780 67 73 2e 52 65 6d 6f 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 6f 6c 64 gs.Remote;..............if.(!old
77a0 44 65 76 69 63 65 2e 65 6e 61 62 6c 65 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a Device.enabled)..............{..
77c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 44 65 76 69 63 65 2e 6d 5f 44 65 76 69 ................newDevice.m_Devi
77e0 63 65 46 6c 61 67 73 20 7c 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 ceFlags.|=.InputDevice.DeviceFla
7800 67 73 2e 44 69 73 61 62 6c 65 64 53 74 61 74 65 48 61 73 42 65 65 6e 51 75 65 72 69 65 64 3b 0d gs.DisabledStateHasBeenQueried;.
7820 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 44 65 76 69 63 65 2e 6d 5f 44 65 76 .................newDevice.m_Dev
7840 69 63 65 46 6c 61 67 73 20 7c 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c iceFlags.|=.InputDevice.DeviceFl
7860 61 67 73 2e 44 69 73 61 62 6c 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ags.Disabled;..............}....
7880 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 2d 61 64 64 2e 0d 0a 20 20 20 20 20 20 20 20 ............//.Re-add...........
78a0 20 20 20 20 41 64 64 44 65 76 69 63 65 28 6e 65 77 44 65 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 ....AddDevice(newDevice);.......
78c0 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 41 64 64 ...}............private.void.Add
78e0 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 4d 61 74 63 68 69 6e 67 44 65 73 63 72 69 70 74 AvailableDevicesMatchingDescript
7900 69 6f 6e 28 49 6e 70 75 74 44 65 76 69 63 65 4d 61 74 63 68 65 72 20 6d 61 74 63 68 65 72 2c 20 ion(InputDeviceMatcher.matcher,.
7920 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 6c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 InternedString.layout)..........
7940 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d {..............#if.UNITY_EDITOR.
7960 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 77 65 20 73 74 69 6c 6c 20 68 61 76 65 .............//.If.we.still.have
7980 20 73 6f 6d 65 20 64 65 76 69 63 65 73 20 73 61 76 65 64 20 66 72 6f 6d 20 74 68 65 20 6c 61 73 .some.devices.saved.from.the.las
79a0 74 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 2c 20 73 65 65 0d 0a 20 20 20 20 20 20 20 20 20 20 t.domain.reload,.see............
79c0 20 20 2f 2f 20 69 66 20 74 68 65 79 20 61 72 65 20 6d 61 74 63 68 65 64 20 62 79 20 74 68 65 20 ..//.if.they.are.matched.by.the.
79e0 67 69 76 65 6e 20 6d 61 74 63 68 65 72 2e 20 49 66 20 73 6f 2c 20 74 75 72 6e 20 74 68 65 6d 20 given.matcher..If.so,.turn.them.
7a00 69 6e 74 6f 20 64 65 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 into.devices...............for.(
7a20 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 var.i.=.0;.i.<.m_SavedDeviceStat
7a40 65 73 2e 4c 65 6e 67 74 68 53 61 66 65 28 29 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 es.LengthSafe();.++i)...........
7a60 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 76 61 72 20 64 65 ...{..................ref.var.de
7a80 76 69 63 65 53 74 61 74 65 20 3d 20 72 65 66 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 viceState.=.ref.m_SavedDeviceSta
7aa0 74 65 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 61 74 tes[i];..................if.(mat
7ac0 63 68 65 72 2e 4d 61 74 63 68 50 65 72 63 65 6e 74 61 67 65 28 64 65 76 69 63 65 53 74 61 74 65 cher.MatchPercentage(deviceState
7ae0 2e 64 65 73 63 72 69 70 74 69 6f 6e 29 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .description).>.0)..............
7b00 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 73 74 6f ....{......................Resto
7b20 72 65 44 65 76 69 63 65 46 72 6f 6d 53 61 76 65 64 53 74 61 74 65 28 72 65 66 20 64 65 76 69 63 reDeviceFromSavedState(ref.devic
7b40 65 53 74 61 74 65 2c 20 6c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eState,.layout);................
7b60 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 45 72 61 73 65 41 74 28 72 65 66 20 6d ......ArrayHelpers.EraseAt(ref.m
7b80 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 2c 20 69 29 3b 0d 0a 20 20 20 20 20 20 20 _SavedDeviceStates,.i);.........
7ba0 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 69 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 .............--i;...............
7bc0 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ...}..............}.............
7be0 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 65 20 69 66 .#endif................//.See.if
7c00 20 74 68 65 20 6e 65 77 20 64 65 73 63 72 69 70 74 69 6f 6e 20 74 6f 20 6c 61 79 6f 75 74 20 6d .the.new.description.to.layout.m
7c20 61 70 70 69 6e 67 20 61 6c 6c 6f 77 73 20 75 73 20 74 6f 20 6d 61 6b 65 0d 0a 20 20 20 20 20 20 apping.allows.us.to.make........
7c40 20 20 20 20 20 20 2f 2f 20 73 65 6e 73 65 20 6f 66 20 61 20 64 65 76 69 63 65 20 77 65 20 63 6f ......//.sense.of.a.device.we.co
7c60 75 6c 64 6e 27 74 20 6d 61 6b 65 20 73 65 6e 73 65 20 6f 66 20 73 6f 20 66 61 72 2e 0d 0a 20 20 uldn't.make.sense.of.so.far.....
7c80 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f ..........for.(var.i.=.0;.i.<.m_
7ca0 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 AvailableDeviceCount;.++i)......
7cc0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 ........{..................//.Ig
7ce0 6e 6f 72 65 20 69 66 20 69 74 27 73 20 61 20 64 65 76 69 63 65 20 74 68 61 74 20 68 61 73 20 62 nore.if.it's.a.device.that.has.b
7d00 65 65 6e 20 65 78 70 6c 69 63 69 74 6c 79 20 72 65 6d 6f 76 65 64 2e 0d 0a 20 20 20 20 20 20 20 een.explicitly.removed..........
7d20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b .........if.(m_AvailableDevices[
7d40 69 5d 2e 69 73 52 65 6d 6f 76 65 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 i].isRemoved)...................
7d60 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...continue;....................
7d80 76 61 72 20 64 65 76 69 63 65 49 64 20 3d 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 var.deviceId.=.m_AvailableDevice
7da0 73 5b 69 5d 2e 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 s[i].deviceId;..................
7dc0 69 66 20 28 54 72 79 47 65 74 44 65 76 69 63 65 42 79 49 64 28 64 65 76 69 63 65 49 64 29 20 21 if.(TryGetDeviceById(deviceId).!
7de0 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e =.null)......................con
7e00 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 61 tinue;....................if.(ma
7e20 74 63 68 65 72 2e 4d 61 74 63 68 50 65 72 63 65 6e 74 61 67 65 28 6d 5f 41 76 61 69 6c 61 62 6c tcher.MatchPercentage(m_Availabl
7e40 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 73 63 72 69 70 74 69 6f 6e 29 20 3e 20 30 66 29 0d 0a eDevices[i].description).>.0f)..
7e60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ................{...............
7e80 20 20 20 20 20 20 20 2f 2f 20 54 72 79 20 74 6f 20 63 72 65 61 74 65 20 49 6e 70 75 74 44 65 76 .......//.Try.to.create.InputDev
7ea0 69 63 65 20 69 6e 73 74 61 6e 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ice.instance....................
7ec0 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 ...try......................{...
7ee0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 64 64 44 65 76 69 63 65 .......................AddDevice
7f00 28 6c 61 79 6f 75 74 2c 20 64 65 76 69 63 65 49 64 2c 20 64 65 76 69 63 65 44 65 73 63 72 69 70 (layout,.deviceId,.deviceDescrip
7f20 74 69 6f 6e 3a 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 73 63 tion:.m_AvailableDevices[i].desc
7f40 72 69 70 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ription,........................
7f60 20 20 20 20 20 20 64 65 76 69 63 65 46 6c 61 67 73 3a 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 ......deviceFlags:.m_AvailableDe
7f80 76 69 63 65 73 5b 69 5d 2e 69 73 4e 61 74 69 76 65 20 3f 20 49 6e 70 75 74 44 65 76 69 63 65 2e vices[i].isNative.?.InputDevice.
7fa0 44 65 76 69 63 65 46 6c 61 67 73 2e 4e 61 74 69 76 65 20 3a 20 30 29 3b 0d 0a 20 20 20 20 20 20 DeviceFlags.Native.:.0);........
7fc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..............}.................
7fe0 20 20 20 20 20 63 61 74 63 68 20 28 45 78 63 65 70 74 69 6f 6e 20 65 78 63 65 70 74 69 6f 6e 29 .....catch.(Exception.exception)
8000 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 ......................{.........
8020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 4c 6f 67 45 72 72 6f 72 28 .................Debug.LogError(
8040 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 24 22 ..............................$"
8060 4c 61 79 6f 75 74 20 27 7b 6c 61 79 6f 75 74 7d 27 20 6d 61 74 63 68 65 73 20 65 78 69 73 74 69 Layout.'{layout}'.matches.existi
8080 6e 67 20 64 65 76 69 63 65 20 27 7b 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 ng.device.'{m_AvailableDevices[i
80a0 5d 2e 64 65 73 63 72 69 70 74 69 6f 6e 7d 27 20 62 75 74 20 66 61 69 6c 65 64 20 74 6f 20 69 6e ].description}'.but.failed.to.in
80c0 73 74 61 6e 74 69 61 74 65 3a 20 7b 65 78 63 65 70 74 69 6f 6e 7d 22 29 3b 0d 0a 20 20 20 20 20 stantiate:.{exception}");.......
80e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 4c 6f 67 45 78 63 65 ...................Debug.LogExce
8100 70 74 69 6f 6e 28 65 78 63 65 70 74 69 6f 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ption(exception);...............
8120 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ...........continue;............
8140 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..........}.....................
8160 20 20 20 2f 2f 20 52 65 2d 65 6e 61 62 6c 65 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 ...//.Re-enable.device..........
8180 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 6f 6d 6d 61 6e 64 20 3d 20 45 6e 61 62 6c .............var.command.=.Enabl
81a0 65 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 2e 43 72 65 61 74 65 28 29 3b 0d 0a 20 20 20 20 20 20 eDeviceCommand.Create();........
81c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 44 65 76 69 63 65 43 6f ..............m_Runtime.DeviceCo
81e0 6d 6d 61 6e 64 28 64 65 76 69 63 65 49 64 2c 20 72 65 66 20 63 6f 6d 6d 61 6e 64 29 3b 0d 0a 20 mmand(deviceId,.ref.command);...
8200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d ...............}..............}.
8220 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 .........}............public.voi
8240 64 20 52 65 6d 6f 76 65 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 73 74 72 69 6e 67 20 6e 61 6d d.RemoveControlLayout(string.nam
8260 65 2c 20 73 74 72 69 6e 67 20 40 6e 61 6d 65 73 70 61 63 65 20 3d 20 6e 75 6c 6c 29 0d 0a 20 20 e,.string.@namespace.=.null)....
8280 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e ......{..............if.(string.
82a0 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 6e 61 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 IsNullOrEmpty(name))............
82c0 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 ......throw.new.ArgumentNullExce
82e0 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 6e 61 6d 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ption(nameof(name));............
8300 20 20 20 20 69 66 20 28 40 6e 61 6d 65 73 70 61 63 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 ....if.(@namespace.!=.null).....
8320 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 61 6d 65 20 3d 20 24 22 7b 40 6e 61 6d 65 73 70 61 63 .............name.=.$"{@namespac
8340 65 7d 3a 3a 7b 6e 61 6d 65 7d 22 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 e}::{name}";................var.
8360 69 6e 74 65 72 6e 65 64 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e internedName.=.new.InternedStrin
8380 67 28 6e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 6f 76 g(name);................//.Remov
83a0 65 20 61 6c 6c 20 64 65 76 69 63 65 73 20 75 73 69 6e 67 20 74 68 65 20 6c 61 79 6f 75 74 2e 0d e.all.devices.using.the.layout..
83c0 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c .............for.(var.i.=.0;.i.<
83e0 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b .m_DevicesCount;)..............{
8400 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d ..................var.device.=.m
8420 5f 44 65 76 69 63 65 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 _Devices[i];..................if
8440 20 28 49 73 43 6f 6e 74 72 6f 6c 4f 72 43 68 69 6c 64 55 73 69 6e 67 4c 61 79 6f 75 74 52 65 63 .(IsControlOrChildUsingLayoutRec
8460 75 72 73 69 76 65 28 64 65 76 69 63 65 2c 20 69 6e 74 65 72 6e 65 64 4e 61 6d 65 29 29 0d 0a 20 ursive(device,.internedName))...
8480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...............{................
84a0 20 20 20 20 20 20 52 65 6d 6f 76 65 44 65 76 69 63 65 28 64 65 76 69 63 65 2c 20 6b 65 65 70 4f ......RemoveDevice(device,.keepO
84c0 6e 4c 69 73 74 4f 66 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 3a 20 74 72 75 65 29 3b 0d nListOfAvailableDevices:.true);.
84e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
8500 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 ....else..................{.....
8520 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2b 2b 69 3b 0d 0a 20 20 20 20 20 20 20 20 20 .................++i;...........
8540 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 .......}..............}.........
8560 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 6f 76 65 20 6c 61 79 6f 75 74 20 72 65 63 6f 72 64 2e 0d .......//.Remove.layout.record..
8580 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 54 79 70 .............m_Layouts.layoutTyp
85a0 65 73 2e 52 65 6d 6f 76 65 28 69 6e 74 65 72 6e 65 64 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 es.Remove(internedName);........
85c0 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 53 74 72 69 6e 67 73 2e 52 65 ......m_Layouts.layoutStrings.Re
85e0 6d 6f 76 65 28 69 6e 74 65 72 6e 65 64 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 move(internedName);.............
8600 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 42 75 69 6c 64 65 72 73 2e 52 65 6d 6f 76 65 .m_Layouts.layoutBuilders.Remove
8620 28 69 6e 74 65 72 6e 65 64 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c (internedName);..............m_L
8640 61 79 6f 75 74 73 2e 62 61 73 65 4c 61 79 6f 75 74 54 61 62 6c 65 2e 52 65 6d 6f 76 65 28 69 6e ayouts.baseLayoutTable.Remove(in
8660 74 65 72 6e 65 64 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f ternedName);................////
8680 54 4f 44 4f 3a 20 63 68 65 63 6b 20 61 6c 6c 20 6c 61 79 6f 75 74 20 69 6e 68 65 72 69 74 61 6e TODO:.check.all.layout.inheritan
86a0 63 65 20 63 68 61 69 6e 20 66 6f 72 20 77 68 65 74 68 65 72 20 74 68 65 79 20 61 72 65 20 62 61 ce.chain.for.whether.they.are.ba
86c0 73 65 64 20 6f 6e 20 74 68 65 20 6c 61 79 6f 75 74 20 61 6e 64 20 69 66 20 73 6f 0d 0a 20 20 20 sed.on.the.layout.and.if.so.....
86e0 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 72 65 6d 6f 76 65 20 74 68 6f 73 65 20 .........////......remove.those.
8700 6c 61 79 6f 75 74 73 2c 20 74 6f 6f 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4c layouts,.too................//.L
8720 65 74 20 6c 69 73 74 65 6e 65 72 73 20 6b 6e 6f 77 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 et.listeners.know...............
8740 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 4c 61 79 6f 75 74 43 68 61 6e for.(var.i.=.0;.i.<.m_LayoutChan
8760 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 geListeners.length;.++i)........
8780 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 ..........m_LayoutChangeListener
87a0 73 5b 69 5d 28 6e 61 6d 65 2c 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 43 68 61 s[i](name,.InputControlLayoutCha
87c0 6e 67 65 2e 52 65 6d 6f 76 65 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 nge.Removed);..........}........
87e0 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 20 54 72 ....public.InputControlLayout.Tr
8800 79 4c 6f 61 64 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 54 79 70 65 20 74 79 70 65 29 0d 0a 20 yLoadControlLayout(Type.type)...
8820 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 79 70 65 20 3d .......{..............if.(type.=
8840 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e =.null)..................throw.n
8860 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 ew.ArgumentNullException(nameof(
8880 74 79 70 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 74 79 70 65 6f 66 type));..............if.(!typeof
88a0 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 29 2e 49 73 41 73 73 69 67 6e 61 62 6c 65 46 72 6f 6d 28 (InputControl).IsAssignableFrom(
88c0 74 79 70 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 type))..................throw.ne
88e0 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 24 22 54 79 70 65 20 27 7b 74 79 70 w.ArgumentException($"Type.'{typ
8900 65 2e 4e 61 6d 65 7d 27 20 69 73 20 6e 6f 74 20 61 6e 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 22 e.Name}'.is.not.an.InputControl"
8920 2c 20 6e 61 6d 65 6f 66 28 74 79 70 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ,.nameof(type));................
8940 2f 2f 20 46 69 6e 64 20 74 68 65 20 6c 61 79 6f 75 74 20 6e 61 6d 65 20 74 68 61 74 20 74 68 65 //.Find.the.layout.name.that.the
8960 20 67 69 76 65 6e 20 74 79 70 65 20 77 61 73 20 72 65 67 69 73 74 65 72 65 64 20 77 69 74 68 2e .given.type.was.registered.with.
8980 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6d ..............var.layoutName.=.m
89a0 5f 4c 61 79 6f 75 74 73 2e 54 72 79 46 69 6e 64 4c 61 79 6f 75 74 46 6f 72 54 79 70 65 28 74 79 _Layouts.TryFindLayoutForType(ty
89c0 70 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d 65 pe);..............if.(layoutName
89e0 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 .IsEmpty())..................thr
8a00 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 ow.new.ArgumentException(.......
8a20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 24 22 54 79 70 65 20 27 7b 74 79 70 65 2e 4e 61 6d ...............$"Type.'{type.Nam
8a40 65 7d 27 20 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 72 65 67 69 73 74 65 72 65 64 20 61 73 20 61 e}'.has.not.been.registered.as.a
8a60 20 63 6f 6e 74 72 6f 6c 20 6c 61 79 6f 75 74 22 2c 20 6e 61 6d 65 6f 66 28 74 79 70 65 29 29 3b .control.layout",.nameof(type));
8a80 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d 5f 4c 61 79 6f 75 74 73 ................return.m_Layouts
8aa0 2e 54 72 79 4c 6f 61 64 4c 61 79 6f 75 74 28 6c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 .TryLoadLayout(layoutName);.....
8ac0 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 43 6f .....}............public.InputCo
8ae0 6e 74 72 6f 6c 4c 61 79 6f 75 74 20 54 72 79 4c 6f 61 64 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 ntrolLayout.TryLoadControlLayout
8b00 28 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 6e 61 6d 65 29 0d 0a 20 20 20 20 20 20 20 20 7b (InternedString.name)..........{
8b20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 54 ..............return.m_Layouts.T
8b40 72 79 4c 6f 61 64 4c 61 79 6f 75 74 28 6e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a ryLoadLayout(name);..........}..
8b60 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 46 49 58 4d 45 3a 20 61 6c 6c 6f 77 69 6e 67 20 74 68 ..........////FIXME:.allowing.th
8b80 65 20 64 65 73 63 72 69 70 74 69 6f 6e 20 74 6f 20 62 65 20 6d 6f 64 69 66 69 65 64 20 61 73 20 e.description.to.be.modified.as.
8ba0 70 61 72 74 20 6f 66 20 74 68 69 73 20 69 73 20 73 75 72 70 72 69 73 69 6e 67 3b 20 66 69 6e 64 part.of.this.is.surprising;.find
8bc0 20 61 20 62 65 74 74 65 72 20 77 61 79 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e .a.better.way..........public.In
8be0 74 65 72 6e 65 64 53 74 72 69 6e 67 20 54 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 ternedString.TryFindMatchingCont
8c00 72 6f 6c 4c 61 79 6f 75 74 28 72 65 66 20 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 rolLayout(ref.InputDeviceDescrip
8c20 74 69 6f 6e 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2c 20 69 6e 74 20 64 65 76 69 tion.deviceDescription,.int.devi
8c40 63 65 49 64 20 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 49 6e 76 61 6c 69 64 44 65 76 69 63 65 ceId.=.InputDevice.InvalidDevice
8c60 49 64 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 Id)..........{..............Prof
8c80 69 6c 65 72 2e 42 65 67 69 6e 53 61 6d 70 6c 65 28 22 49 6e 70 75 74 53 79 73 74 65 6d 2e 54 72 iler.BeginSample("InputSystem.Tr
8ca0 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 22 29 3b 0d 0a 20 yFindMatchingControlLayout");...
8cc0 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 74 68 69 73 20 77 69 6c 6c 20 77 ...........////TODO:.this.will.w
8ce0 61 6e 74 20 74 6f 20 74 61 6b 65 20 6f 76 65 72 72 69 64 65 73 20 69 6e 74 6f 20 61 63 63 6f 75 ant.to.take.overrides.into.accou
8d00 6e 74 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 65 20 69 66 20 77 65 20 63 nt................//.See.if.we.c
8d20 61 6e 20 6d 61 74 63 68 20 62 79 20 64 65 73 63 72 69 70 74 69 6f 6e 2e 0d 0a 20 20 20 20 20 20 an.match.by.description.........
8d40 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6d 5f 4c 61 79 6f 75 74 73 ......var.layoutName.=.m_Layouts
8d60 2e 54 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 4c 61 79 6f 75 74 28 64 65 76 69 63 65 44 65 73 .TryFindMatchingLayout(deviceDes
8d80 63 72 69 70 74 69 6f 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f cription);..............if.(layo
8da0 75 74 4e 61 6d 65 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b utName.IsEmpty())..............{
8dc0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 2c 20 73 6f 20 74 72 79 20 ..................//.No,.so.try.
8de0 74 6f 20 6d 61 74 63 68 20 62 79 20 64 65 76 69 63 65 20 63 6c 61 73 73 2e 20 49 66 20 77 65 20 to.match.by.device.class..If.we.
8e00 68 61 76 65 20 61 20 22 47 61 6d 65 70 61 64 22 20 6c 61 79 6f 75 74 2c 0d 0a 20 20 20 20 20 20 have.a."Gamepad".layout,........
8e20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 66 6f 72 20 65 78 61 6d 70 6c 65 2c 20 61 20 64 65 76 69 ..........//.for.example,.a.devi
8e40 63 65 20 74 68 61 74 20 63 6c 61 73 73 69 66 69 65 73 20 69 74 73 65 6c 66 20 61 73 20 61 20 22 ce.that.classifies.itself.as.a."
8e60 47 61 6d 65 70 61 64 22 20 77 69 6c 6c 20 6d 61 74 63 68 0d 0a 20 20 20 20 20 20 20 20 20 20 20 Gamepad".will.match.............
8e80 20 20 20 20 20 2f 2f 20 74 68 61 74 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 .....//.that.layout.............
8ea0 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 ......//..................//.NOT
8ec0 45 3a 20 48 61 76 65 20 74 6f 20 6d 61 6b 65 20 73 75 72 65 20 68 65 72 65 20 74 68 61 74 20 77 E:.Have.to.make.sure.here.that.w
8ee0 65 20 67 65 74 20 61 20 64 65 76 69 63 65 20 6c 61 79 6f 75 74 20 61 6e 64 20 6e 6f 74 20 61 0d e.get.a.device.layout.and.not.a.
8f00 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 63 6f 6e 74 72 6f .................//.......contro
8f20 6c 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 l.layout...................if.(!
8f40 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 76 69 63 65 44 65 73 63 72 string.IsNullOrEmpty(deviceDescr
8f60 69 70 74 69 6f 6e 2e 64 65 76 69 63 65 43 6c 61 73 73 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 iption.deviceClass))............
8f80 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 ......{......................var
8fa0 20 64 65 76 69 63 65 43 6c 61 73 73 4c 6f 77 65 72 43 61 73 65 20 3d 20 6e 65 77 20 49 6e 74 65 .deviceClassLowerCase.=.new.Inte
8fc0 72 6e 65 64 53 74 72 69 6e 67 28 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2e 64 65 76 rnedString(deviceDescription.dev
8fe0 69 63 65 43 6c 61 73 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 iceClass);......................
9000 76 61 72 20 74 79 70 65 20 3d 20 6d 5f 4c 61 79 6f 75 74 73 2e 47 65 74 43 6f 6e 74 72 6f 6c 54 var.type.=.m_Layouts.GetControlT
9020 79 70 65 46 6f 72 4c 61 79 6f 75 74 28 64 65 76 69 63 65 43 6c 61 73 73 4c 6f 77 65 72 43 61 73 ypeForLayout(deviceClassLowerCas
9040 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 79 70 e);......................if.(typ
9060 65 20 21 3d 20 6e 75 6c 6c 20 26 26 20 74 79 70 65 6f 66 28 49 6e 70 75 74 44 65 76 69 63 65 29 e.!=.null.&&.typeof(InputDevice)
9080 2e 49 73 41 73 73 69 67 6e 61 62 6c 65 46 72 6f 6d 28 74 79 70 65 29 29 0d 0a 20 20 20 20 20 20 .IsAssignableFrom(type))........
90a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6e ..................layoutName.=.n
90c0 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 64 65 76 69 63 65 44 65 73 63 72 69 70 74 ew.InternedString(deviceDescript
90e0 69 6f 6e 2e 64 65 76 69 63 65 43 6c 61 73 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ion.deviceClass);...............
9100 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ...}..............}.............
9120 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 6c 69 73 74 65 6e 65 72 73 20 72 65 67 69 73 74 65 ...////REVIEW:.listeners.registe
9140 72 69 6e 67 20 6e 65 77 20 6c 61 79 6f 75 74 73 20 66 72 6f 6d 20 69 6e 20 68 65 72 65 20 6d 61 ring.new.layouts.from.in.here.ma
9160 79 20 70 6f 74 65 6e 74 69 61 6c 6c 79 20 6c 65 61 64 20 74 6f 20 74 68 65 20 63 72 65 61 74 69 y.potentially.lead.to.the.creati
9180 6f 6e 20 6f 66 20 64 65 76 69 63 65 73 3b 20 73 68 6f 75 6c 64 20 77 65 20 64 69 73 61 6c 6c 6f on.of.devices;.should.we.disallo
91a0 77 20 74 68 61 74 3f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a w.that?..............////REVIEW:
91c0 20 69 66 20 61 20 63 61 6c 6c 62 61 63 6b 20 70 69 63 6b 73 20 61 20 6c 61 79 6f 75 74 2c 20 73 .if.a.callback.picks.a.layout,.s
91e0 68 6f 75 6c 64 20 77 65 20 72 65 2d 72 75 6e 20 74 68 72 6f 75 67 68 20 74 68 65 20 6c 69 73 74 hould.we.re-run.through.the.list
9200 20 6f 66 20 63 61 6c 6c 62 61 63 6b 73 3f 20 6f 72 20 73 68 6f 75 6c 64 20 77 65 20 6a 75 73 74 .of.callbacks?.or.should.we.just
9220 20 72 65 6d 6f 76 65 20 68 61 76 65 4f 76 65 72 72 69 64 65 6e 4c 61 79 6f 75 74 4e 61 6d 65 3f .remove.haveOverridenLayoutName?
9240 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 47 69 76 65 20 6c 69 73 74 65 6e 65 72 73 20 ..............//.Give.listeners.
9260 61 20 73 68 6f 74 20 74 6f 20 73 65 6c 65 63 74 2f 63 72 65 61 74 65 20 61 20 6c 61 79 6f 75 74 a.shot.to.select/create.a.layout
9280 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 46 69 6e 64 4c ...............if.(m_DeviceFindL
92a0 61 79 6f 75 74 43 61 6c 6c 62 61 63 6b 73 2e 6c 65 6e 67 74 68 20 3e 20 30 29 0d 0a 20 20 20 20 ayoutCallbacks.length.>.0)......
92c0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 69 ........{..................//.Fi
92e0 72 73 74 20 74 69 6d 65 20 77 65 20 67 65 74 20 68 65 72 65 2c 20 70 75 74 20 6f 75 72 20 64 65 rst.time.we.get.here,.put.our.de
9300 6c 65 67 61 74 65 20 66 6f 72 20 65 78 65 63 75 74 69 6e 67 20 64 65 76 69 63 65 20 63 6f 6d 6d legate.for.executing.device.comm
9320 61 6e 64 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 20 70 6c 61 63 ands..................//.in.plac
9340 65 2e 20 57 65 20 77 72 61 70 20 74 68 65 20 63 61 6c 6c 20 74 6f 20 49 49 6e 70 75 74 52 75 6e e..We.wrap.the.call.to.IInputRun
9360 74 69 6d 65 2e 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 20 73 6f 20 74 68 61 74 20 77 65 20 64 6f time.DeviceCommand.so.that.we.do
9380 6e 27 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6e 65 65 64 20 74 6f 20 n't..................//.need.to.
93a0 65 78 70 6f 73 65 20 74 68 65 20 72 75 6e 74 69 6d 65 20 74 6f 20 74 68 65 20 6f 6e 46 69 6e 64 expose.the.runtime.to.the.onFind
93c0 4c 61 79 6f 75 74 46 6f 72 44 65 76 69 63 65 20 63 61 6c 6c 62 61 63 6b 73 2e 0d 0a 20 20 20 20 LayoutForDevice.callbacks.......
93e0 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 46 69 6e 64 45 78 65 63 ............if.(m_DeviceFindExec
9400 75 74 65 43 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 uteCommandDelegate.==.null).....
9420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 46 69 6e 64 45 78 65 .................m_DeviceFindExe
9440 63 75 74 65 43 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 20 3d 0d 0a 20 20 20 20 20 20 20 20 20 cuteCommandDelegate.=...........
9460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 72 65 66 20 49 6e 70 75 74 44 65 76 69 63 65 43 ...............(ref.InputDeviceC
9480 6f 6d 6d 61 6e 64 20 63 6f 6d 6d 61 6e 64 52 65 66 29 20 3d 3e 0d 0a 20 20 20 20 20 20 20 20 20 ommand.commandRef).=>...........
94a0 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...........{....................
94c0 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 46 69 6e 64 45 78 65 63 75 74 65 43 6f 6d ......if.(m_DeviceFindExecuteCom
94e0 6d 61 6e 64 44 65 76 69 63 65 49 64 20 3d 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 49 6e 76 61 mandDeviceId.==.InputDevice.Inva
9500 6c 69 64 44 65 76 69 63 65 49 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 lidDeviceId)....................
9520 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 49 6e 70 75 74 44 65 76 69 63 65 43 6f 6d 6d ..........return.InputDeviceComm
9540 61 6e 64 2e 47 65 6e 65 72 69 63 46 61 69 6c 75 72 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 and.GenericFailure;.............
9560 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d 5f 52 75 6e 74 69 6d 65 2e 44 65 .............return.m_Runtime.De
9580 76 69 63 65 43 6f 6d 6d 61 6e 64 28 6d 5f 44 65 76 69 63 65 46 69 6e 64 45 78 65 63 75 74 65 43 viceCommand(m_DeviceFindExecuteC
95a0 6f 6d 6d 61 6e 64 44 65 76 69 63 65 49 64 2c 20 72 65 66 20 63 6f 6d 6d 61 6e 64 52 65 66 29 3b ommandDeviceId,.ref.commandRef);
95c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 3b 0d 0a 20 20 20 20 20 20 ......................};........
95e0 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 46 69 6e 64 45 78 65 63 75 74 65 43 6f 6d ..........m_DeviceFindExecuteCom
9600 6d 61 6e 64 44 65 76 69 63 65 49 64 20 3d 20 64 65 76 69 63 65 49 64 3b 0d 0a 0d 0a 20 20 20 20 mandDeviceId.=.deviceId;........
9620 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 68 61 76 65 4f 76 65 72 72 69 64 64 65 6e 4c 61 ............var.haveOverriddenLa
9640 79 6f 75 74 4e 61 6d 65 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 youtName.=.false;...............
9660 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 46 ...for.(var.i.=.0;.i.<.m_DeviceF
9680 69 6e 64 4c 61 79 6f 75 74 43 61 6c 6c 62 61 63 6b 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d indLayoutCallbacks.length;.++i).
96a0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................{..............
96c0 20 20 20 20 20 20 20 20 76 61 72 20 6e 65 77 4c 61 79 6f 75 74 20 3d 20 6d 5f 44 65 76 69 63 65 ........var.newLayout.=.m_Device
96e0 46 69 6e 64 4c 61 79 6f 75 74 43 61 6c 6c 62 61 63 6b 73 5b 69 5d 28 72 65 66 20 64 65 76 69 63 FindLayoutCallbacks[i](ref.devic
9700 65 44 65 73 63 72 69 70 74 69 6f 6e 2c 20 6c 61 79 6f 75 74 4e 61 6d 65 2c 0d 0a 20 20 20 20 20 eDescription,.layoutName,.......
9720 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ................................
9740 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f ..............................m_
9760 44 65 76 69 63 65 46 69 6e 64 45 78 65 63 75 74 65 43 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 DeviceFindExecuteCommandDelegate
9780 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 );........................if.(!s
97a0 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 6e 65 77 4c 61 79 6f 75 74 29 20 26 tring.IsNullOrEmpty(newLayout).&
97c0 26 20 21 68 61 76 65 4f 76 65 72 72 69 64 64 65 6e 4c 61 79 6f 75 74 4e 61 6d 65 29 0d 0a 20 20 &.!haveOverriddenLayoutName)....
97e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ..................{.............
9800 20 20 20 20 20 20 20 20 20 20 20 20 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e .............layoutName.=.new.In
9820 74 65 72 6e 65 64 53 74 72 69 6e 67 28 6e 65 77 4c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 ternedString(newLayout);........
9840 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 76 65 4f 76 65 72 72 69 64 64 65 6e ..................haveOverridden
9860 4c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 LayoutName.=.true;..............
9880 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ........}..................}....
98a0 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 69 ..........}................Profi
98c0 6c 65 72 2e 45 6e 64 53 61 6d 70 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 ler.EndSample();..............re
98e0 74 75 72 6e 20 6c 61 79 6f 75 74 4e 61 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 turn.layoutName;..........}.....
9900 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f .......///.<summary>..........//
9920 2f 20 52 65 74 75 72 6e 20 74 72 75 65 20 69 66 20 74 68 65 20 67 69 76 65 6e 20 64 65 76 69 63 /.Return.true.if.the.given.devic
9940 65 20 6c 61 79 6f 75 74 20 69 73 20 73 75 70 70 6f 72 74 65 64 20 62 79 20 74 68 65 20 67 61 6d e.layout.is.supported.by.the.gam
9960 65 20 61 63 63 6f 72 64 69 6e 67 20 74 6f 20 3c 73 65 65 20 63 72 65 66 3d 22 49 6e 70 75 74 53 e.according.to.<see.cref="InputS
9980 65 74 74 69 6e 67 73 2e 73 75 70 70 6f 72 74 65 64 44 65 76 69 63 65 73 22 2f 3e 2e 0d 0a 20 20 ettings.supportedDevices"/>.....
99a0 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f ......///.</summary>..........//
99c0 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 6c 61 79 6f 75 74 4e 61 6d 65 22 3e 4e 61 6d 65 20 /.<param.name="layoutName">Name.
99e0 6f 66 20 74 68 65 20 64 65 76 69 63 65 20 6c 61 79 6f 75 74 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 of.the.device.layout.</param>...
9a00 20 20 20 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e 54 72 75 65 20 69 66 20 61 20 64 65 .......///.<returns>True.if.a.de
9a20 76 69 63 65 20 77 69 74 68 20 74 68 65 20 67 69 76 65 6e 20 6c 61 79 6f 75 74 20 73 68 6f 75 6c vice.with.the.given.layout.shoul
9a40 64 20 62 65 20 63 72 65 61 74 65 64 20 66 6f 72 20 74 68 65 20 67 61 6d 65 2c 20 66 61 6c 73 65 d.be.created.for.the.game,.false
9a60 20 6f 74 68 65 72 77 69 73 65 2e 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 20 20 20 20 70 .otherwise.</returns>..........p
9a80 72 69 76 61 74 65 20 62 6f 6f 6c 20 49 73 44 65 76 69 63 65 4c 61 79 6f 75 74 4d 61 72 6b 65 64 rivate.bool.IsDeviceLayoutMarked
9aa0 41 73 53 75 70 70 6f 72 74 65 64 49 6e 53 65 74 74 69 6e 67 73 28 49 6e 74 65 72 6e 65 64 53 74 AsSupportedInSettings(InternedSt
9ac0 72 69 6e 67 20 6c 61 79 6f 75 74 4e 61 6d 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 ring.layoutName)..........{.....
9ae0 20 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 20 74 68 65 20 65 64 69 74 6f 72 2c 20 22 53 75 70 70 .........//.In.the.editor,."Supp
9b00 6f 72 74 65 64 20 44 65 76 69 63 65 73 22 20 63 61 6e 20 62 65 20 6f 76 65 72 72 69 64 64 65 6e orted.Devices".can.be.overridden
9b20 20 62 79 20 61 20 75 73 65 72 20 73 65 74 74 69 6e 67 2e 20 54 68 69 73 20 63 61 75 73 65 73 0d .by.a.user.setting..This.causes.
9b40 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 6c 6c 20 61 76 61 69 6c 61 62 6c 65 20 64 65 .............//.all.available.de
9b60 76 69 63 65 73 20 74 6f 20 62 65 20 61 64 64 65 64 20 72 65 67 61 72 64 6c 65 73 73 20 6f 66 20 vices.to.be.added.regardless.of.
9b80 77 68 61 74 20 22 53 75 70 70 6f 72 74 65 64 20 44 65 76 69 63 65 73 22 20 73 61 79 73 2e 20 54 what."Supported.Devices".says..T
9ba0 68 69 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 73 20 75 73 65 66 75 6c 20 74 6f his..............//.is.useful.to
9bc0 20 65 6e 73 75 72 65 20 74 68 61 74 20 74 68 69 6e 67 73 20 6c 69 6b 65 20 6b 65 79 62 6f 61 72 .ensure.that.things.like.keyboar
9be0 64 2c 20 6d 6f 75 73 65 2c 20 61 6e 64 20 70 65 6e 20 6b 65 65 70 20 77 6f 72 6b 69 6e 67 20 69 d,.mouse,.and.pen.keep.working.i
9c00 6e 20 74 68 65 20 65 64 69 74 6f 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 65 76 65 n.the.editor..............//.eve
9c20 6e 20 69 66 20 6e 6f 74 20 73 75 70 70 6f 72 74 65 64 20 61 73 20 64 65 76 69 63 65 73 20 69 6e n.if.not.supported.as.devices.in
9c40 20 74 68 65 20 67 61 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 .the.game...............#if.UNIT
9c60 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 49 6e 70 75 74 45 Y_EDITOR..............if.(InputE
9c80 64 69 74 6f 72 55 73 65 72 53 65 74 74 69 6e 67 73 2e 61 64 64 44 65 76 69 63 65 73 4e 6f 74 53 ditorUserSettings.addDevicesNotS
9ca0 75 70 70 6f 72 74 65 64 42 79 50 72 6f 6a 65 63 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 upportedByProject)..............
9cc0 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 ....return.true;..............#e
9ce0 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 73 75 70 70 6f 72 74 65 ndif................var.supporte
9d00 64 44 65 76 69 63 65 73 20 3d 20 6d 5f 53 65 74 74 69 6e 67 73 2e 73 75 70 70 6f 72 74 65 64 44 dDevices.=.m_Settings.supportedD
9d20 65 76 69 63 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 73 75 70 70 6f 72 74 evices;..............if.(support
9d40 65 64 44 65 76 69 63 65 73 2e 43 6f 75 6e 74 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 edDevices.Count.==.0)...........
9d60 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 73 75 70 70 ...{..................//.If.supp
9d80 6f 72 74 65 64 44 65 76 69 63 65 73 20 69 73 20 65 6d 70 74 79 2c 20 61 6c 6c 20 64 65 76 69 63 ortedDevices.is.empty,.all.devic
9da0 65 20 6c 61 79 6f 75 74 73 20 61 72 65 20 63 6f 6e 73 69 64 65 72 65 64 20 73 75 70 70 6f 72 74 e.layouts.are.considered.support
9dc0 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 ed...................return.true
9de0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ;..............}................
9e00 66 6f 72 20 28 76 61 72 20 6e 20 3d 20 30 3b 20 6e 20 3c 20 73 75 70 70 6f 72 74 65 64 44 65 76 for.(var.n.=.0;.n.<.supportedDev
9e20 69 63 65 73 2e 43 6f 75 6e 74 3b 20 2b 2b 6e 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d ices.Count;.++n)..............{.
9e40 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 73 75 70 70 6f 72 74 65 64 4c 61 .................var.supportedLa
9e60 79 6f 75 74 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 73 75 70 70 6f 72 yout.=.new.InternedString(suppor
9e80 74 65 64 44 65 76 69 63 65 73 5b 6e 5d 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tedDevices[n]);.................
9ea0 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 3d 20 73 75 70 70 6f 72 74 65 64 4c 61 79 6f .if.(layoutName.==.supportedLayo
9ec0 75 74 20 7c 7c 20 6d 5f 4c 61 79 6f 75 74 73 2e 49 73 42 61 73 65 64 4f 6e 28 73 75 70 70 6f 72 ut.||.m_Layouts.IsBasedOn(suppor
9ee0 74 65 64 4c 61 79 6f 75 74 2c 20 6c 61 79 6f 75 74 4e 61 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 tedLayout,.layoutName)).........
9f00 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 .............return.true;.......
9f20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 .......}................return.f
9f40 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 alse;..........}............priv
9f60 61 74 65 20 62 6f 6f 6c 20 44 6f 65 73 4c 61 79 6f 75 74 45 78 69 73 74 28 49 6e 74 65 72 6e 65 ate.bool.DoesLayoutExist(Interne
9f80 64 53 74 72 69 6e 67 20 6e 61 6d 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 dString.name)..........{........
9fa0 20 20 20 20 20 20 72 65 74 75 72 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 54 79 70 ......return.m_Layouts.layoutTyp
9fc0 65 73 2e 43 6f 6e 74 61 69 6e 73 4b 65 79 28 6e 61 6d 65 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 es.ContainsKey(name).||.........
9fe0 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 53 74 72 69 6e 67 73 .........m_Layouts.layoutStrings
a000 2e 43 6f 6e 74 61 69 6e 73 4b 65 79 28 6e 61 6d 65 29 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 20 .ContainsKey(name).||...........
a020 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 42 75 69 6c 64 65 72 73 2e .......m_Layouts.layoutBuilders.
a040 43 6f 6e 74 61 69 6e 73 4b 65 79 28 6e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d ContainsKey(name);..........}...
a060 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 45 6e 75 6d 65 72 61 62 6c 65 3c 73 74 72 69 .........public.IEnumerable<stri
a080 6e 67 3e 20 4c 69 73 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 73 28 73 74 72 69 6e 67 20 62 61 ng>.ListControlLayouts(string.ba
a0a0 73 65 64 4f 6e 20 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 sedOn.=.null)..........{........
a0c0 20 20 20 20 20 20 2f 2f 2f 2f 46 49 58 4d 45 3a 20 74 68 69 73 20 6d 61 79 20 61 64 64 20 61 20 ......////FIXME:.this.may.add.a.
a0e0 6e 61 6d 65 20 74 77 69 63 65 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 name.twice................if.(!s
a100 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 62 61 73 65 64 4f 6e 29 29 0d 0a 20 tring.IsNullOrEmpty(basedOn))...
a120 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 ...........{..................va
a140 72 20 69 6e 74 65 72 6e 65 64 42 61 73 65 64 4f 6e 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 r.internedBasedOn.=.new.Interned
a160 53 74 72 69 6e 67 28 62 61 73 65 64 4f 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 String(basedOn);................
a180 20 20 66 6f 72 65 61 63 68 20 28 76 61 72 20 65 6e 74 72 79 20 69 6e 20 6d 5f 4c 61 79 6f 75 74 ..foreach.(var.entry.in.m_Layout
a1a0 73 2e 6c 61 79 6f 75 74 54 79 70 65 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 s.layoutTypes)..................
a1c0 20 20 20 20 69 66 20 28 6d 5f 4c 61 79 6f 75 74 73 2e 49 73 42 61 73 65 64 4f 6e 28 69 6e 74 65 ....if.(m_Layouts.IsBasedOn(inte
a1e0 72 6e 65 64 42 61 73 65 64 4f 6e 2c 20 65 6e 74 72 79 2e 4b 65 79 29 29 0d 0a 20 20 20 20 20 20 rnedBasedOn,.entry.Key))........
a200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 79 69 65 6c 64 20 72 65 74 75 72 6e 20 65 ..................yield.return.e
a220 6e 74 72 79 2e 4b 65 79 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 ntry.Key;..................forea
a240 63 68 20 28 76 61 72 20 65 6e 74 72 79 20 69 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 ch.(var.entry.in.m_Layouts.layou
a260 74 53 74 72 69 6e 67 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 tStrings)......................i
a280 66 20 28 6d 5f 4c 61 79 6f 75 74 73 2e 49 73 42 61 73 65 64 4f 6e 28 69 6e 74 65 72 6e 65 64 42 f.(m_Layouts.IsBasedOn(internedB
a2a0 61 73 65 64 4f 6e 2c 20 65 6e 74 72 79 2e 4b 65 79 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 asedOn,.entry.Key)).............
a2c0 20 20 20 20 20 20 20 20 20 20 20 20 20 79 69 65 6c 64 20 72 65 74 75 72 6e 20 65 6e 74 72 79 2e .............yield.return.entry.
a2e0 4b 65 79 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20 28 76 Key;..................foreach.(v
a300 61 72 20 65 6e 74 72 79 20 69 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 42 75 69 6c ar.entry.in.m_Layouts.layoutBuil
a320 64 65 72 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d ders)......................if.(m
a340 5f 4c 61 79 6f 75 74 73 2e 49 73 42 61 73 65 64 4f 6e 28 69 6e 74 65 72 6e 65 64 42 61 73 65 64 _Layouts.IsBasedOn(internedBased
a360 4f 6e 2c 20 65 6e 74 72 79 2e 4b 65 79 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 On,.entry.Key)).................
a380 20 20 20 20 20 20 20 20 20 79 69 65 6c 64 20 72 65 74 75 72 6e 20 65 6e 74 72 79 2e 4b 65 79 3b .........yield.return.entry.Key;
a3a0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 ..............}..............els
a3c0 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e..............{................
a3e0 20 20 66 6f 72 65 61 63 68 20 28 76 61 72 20 65 6e 74 72 79 20 69 6e 20 6d 5f 4c 61 79 6f 75 74 ..foreach.(var.entry.in.m_Layout
a400 73 2e 6c 61 79 6f 75 74 54 79 70 65 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 s.layoutTypes)..................
a420 20 20 20 20 79 69 65 6c 64 20 72 65 74 75 72 6e 20 65 6e 74 72 79 2e 4b 65 79 3b 0d 0a 20 20 20 ....yield.return.entry.Key;.....
a440 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 68 20 28 76 61 72 20 65 6e 74 72 79 20 .............foreach.(var.entry.
a460 69 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 53 74 72 69 6e 67 73 29 0d 0a 20 20 20 in.m_Layouts.layoutStrings).....
a480 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 79 69 65 6c 64 20 72 65 74 75 72 6e 20 65 6e .................yield.return.en
a4a0 74 72 79 2e 4b 65 79 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 65 61 63 try.Key;..................foreac
a4c0 68 20 28 76 61 72 20 65 6e 74 72 79 20 69 6e 20 6d 5f 4c 61 79 6f 75 74 73 2e 6c 61 79 6f 75 74 h.(var.entry.in.m_Layouts.layout
a4e0 42 75 69 6c 64 65 72 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 79 Builders)......................y
a500 69 65 6c 64 20 72 65 74 75 72 6e 20 65 6e 74 72 79 2e 4b 65 79 3b 0d 0a 20 20 20 20 20 20 20 20 ield.return.entry.Key;..........
a520 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 ....}..........}............//.A
a540 64 64 73 20 61 6c 6c 20 63 6f 6e 74 72 6f 6c 73 20 74 68 61 74 20 6d 61 74 63 68 20 74 68 65 20 dds.all.controls.that.match.the.
a560 67 69 76 65 6e 20 70 61 74 68 20 73 70 65 63 20 74 6f 20 74 68 65 20 67 69 76 65 6e 20 6c 69 73 given.path.spec.to.the.given.lis
a580 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 52 65 74 75 72 6e 73 20 6e 75 6d 62 65 72 20 6f 66 t...........//.Returns.number.of
a5a0 20 63 6f 6e 74 72 6f 6c 73 20 61 64 64 65 64 20 74 6f 20 74 68 65 20 6c 69 73 74 2e 0d 0a 20 20 .controls.added.to.the.list.....
a5c0 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 44 6f 65 73 20 6e 6f 74 20 63 72 65 61 74 65 20 67 ......//.NOTE:.Does.not.create.g
a5e0 61 72 62 61 67 65 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e arbage.............///.<summary>
a600 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 41 64 64 73 20 74 6f 20 74 68 65 20 67 69 76 65 6e 20 ..........///.Adds.to.the.given.
a620 6c 69 73 74 20 61 6c 6c 20 63 6f 6e 74 72 6f 6c 73 20 74 68 61 74 20 6d 61 74 63 68 20 74 68 65 list.all.controls.that.match.the
a640 20 67 69 76 65 6e 20 3c 73 65 65 20 63 72 65 66 3d 22 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 50 61 .given.<see.cref="InputControlPa
a660 74 68 22 3e 70 61 74 68 20 73 70 65 63 3c 2f 73 65 65 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f th">path.spec</see>..........///
a680 20 61 6e 64 20 61 72 65 20 61 73 73 69 67 6e 61 62 6c 65 20 74 6f 20 74 68 65 20 67 69 76 65 6e .and.are.assignable.to.the.given
a6a0 20 74 79 70 65 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a .type...........///.</summary>..
a6c0 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 70 61 74 68 22 3e 3c ........///.<param.name="path"><
a6e0 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 /param>..........///.<param.name
a700 3d 22 63 6f 6e 74 72 6f 6c 73 22 3e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f ="controls"></param>..........//
a720 2f 20 3c 74 79 70 65 70 61 72 61 6d 20 6e 61 6d 65 3d 22 54 43 6f 6e 74 72 6f 6c 22 3e 3c 2f 74 /.<typeparam.name="TControl"></t
a740 79 70 65 70 61 72 61 6d 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 72 65 74 75 72 6e 73 3e ypeparam>..........///.<returns>
a760 3c 2f 72 65 74 75 72 6e 73 3e 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 69 6e 74 20 47 </returns>..........public.int.G
a780 65 74 43 6f 6e 74 72 6f 6c 73 3c 54 43 6f 6e 74 72 6f 6c 3e 28 73 74 72 69 6e 67 20 70 61 74 68 etControls<TControl>(string.path
a7a0 2c 20 72 65 66 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 69 73 74 3c 54 43 6f 6e 74 72 6f 6c 3e ,.ref.InputControlList<TControl>
a7c0 20 63 6f 6e 74 72 6f 6c 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 77 68 65 72 65 20 54 43 .controls)..............where.TC
a7e0 6f 6e 74 72 6f 6c 20 3a 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 0d 0a 20 20 20 20 20 20 20 20 7b ontrol.:.InputControl..........{
a800 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f ..............if.(string.IsNullO
a820 72 45 6d 70 74 79 28 70 61 74 68 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 rEmpty(path))..................r
a840 65 74 75 72 6e 20 30 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 eturn.0;..............if.(m_Devi
a860 63 65 73 43 6f 75 6e 74 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 cesCount.==.0)..................
a880 72 65 74 75 72 6e 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 return.0;................var.dev
a8a0 69 63 65 43 6f 75 6e 74 20 3d 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 iceCount.=.m_DevicesCount;......
a8c0 20 20 20 20 20 20 20 20 76 61 72 20 6e 75 6d 4d 61 74 63 68 65 73 20 3d 20 30 3b 0d 0a 20 20 20 ........var.numMatches.=.0;.....
a8e0 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 64 65 76 .........for.(var.i.=.0;.i.<.dev
a900 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 iceCount;.++i)..............{...
a920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 65 ...............var.device.=.m_De
a940 76 69 63 65 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 75 6d 4d 61 vices[i];..................numMa
a960 74 63 68 65 73 20 2b 3d 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 50 61 74 68 2e 54 72 79 46 69 6e tches.+=.InputControlPath.TryFin
a980 64 43 6f 6e 74 72 6f 6c 73 28 64 65 76 69 63 65 2c 20 70 61 74 68 2c 20 30 2c 20 72 65 66 20 63 dControls(device,.path,.0,.ref.c
a9a0 6f 6e 74 72 6f 6c 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ontrols);..............}........
a9c0 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6d 4d 61 74 63 68 65 73 3b 0d 0a 20 20 20 20 ........return.numMatches;......
a9e0 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 53 65 74 ....}............public.void.Set
aa00 44 65 76 69 63 65 55 73 61 67 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 2c 20 DeviceUsage(InputDevice.device,.
aa20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 75 73 61 67 65 29 0d 0a 20 20 20 20 20 20 20 20 7b InternedString.usage)..........{
aa40 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c ..............if.(device.==.null
aa60 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 )..................throw.new.Arg
aa80 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 64 65 76 69 63 65 umentNullException(nameof(device
aaa0 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 75 73 61 67 ));..............if.(device.usag
aac0 65 73 2e 43 6f 75 6e 74 20 3d 3d 20 31 20 26 26 20 64 65 76 69 63 65 2e 75 73 61 67 65 73 5b 30 es.Count.==.1.&&.device.usages[0
aae0 5d 20 3d 3d 20 75 73 61 67 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 ].==.usage)..................ret
ab00 75 72 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 75 73 61 urn;..............if.(device.usa
ab20 67 65 73 2e 43 6f 75 6e 74 20 3d 3d 20 30 20 26 26 20 75 73 61 67 65 2e 49 73 45 6d 70 74 79 28 ges.Count.==.0.&&.usage.IsEmpty(
ab40 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 ))..................return;.....
ab60 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 43 6c 65 61 72 44 65 76 69 63 65 55 73 61 ...........device.ClearDeviceUsa
ab80 67 65 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 75 73 61 67 65 2e 49 ges();..............if.(!usage.I
aba0 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 sEmpty())..................devic
abc0 65 2e 41 64 64 44 65 76 69 63 65 55 73 61 67 65 28 75 73 61 67 65 29 3b 0d 0a 20 20 20 20 20 20 e.AddDeviceUsage(usage);........
abe0 20 20 20 20 20 20 4e 6f 74 69 66 79 55 73 61 67 65 43 68 61 6e 67 65 64 28 64 65 76 69 63 65 29 ......NotifyUsageChanged(device)
ac00 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 ;..........}............public.v
ac20 6f 69 64 20 41 64 64 44 65 76 69 63 65 55 73 61 67 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 oid.AddDeviceUsage(InputDevice.d
ac40 65 76 69 63 65 2c 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 75 73 61 67 65 29 0d 0a 20 20 evice,.InternedString.usage)....
ac60 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 ......{..............if.(device.
ac80 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 ==.null)..................throw.
aca0 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 new.ArgumentNullException(nameof
acc0 28 64 65 76 69 63 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 75 73 61 67 (device));..............if.(usag
ace0 65 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 e.IsEmpty())..................th
ad00 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 22 55 73 61 67 65 row.new.ArgumentException("Usage
ad20 20 73 74 72 69 6e 67 20 63 61 6e 6e 6f 74 20 62 65 20 65 6d 70 74 79 22 2c 20 6e 61 6d 65 6f 66 .string.cannot.be.empty",.nameof
ad40 28 75 73 61 67 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 (usage));..............if.(devic
ad60 65 2e 75 73 61 67 65 73 2e 43 6f 6e 74 61 69 6e 73 28 75 73 61 67 65 29 29 0d 0a 20 20 20 20 20 e.usages.Contains(usage)).......
ad80 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 ...........return;..............
ada0 20 20 64 65 76 69 63 65 2e 41 64 64 44 65 76 69 63 65 55 73 61 67 65 28 75 73 61 67 65 29 3b 0d ..device.AddDeviceUsage(usage);.
adc0 0a 20 20 20 20 20 20 20 20 20 20 20 20 4e 6f 74 69 66 79 55 73 61 67 65 43 68 61 6e 67 65 64 28 .............NotifyUsageChanged(
ade0 64 65 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 device);..........}............p
ae00 75 62 6c 69 63 20 76 6f 69 64 20 52 65 6d 6f 76 65 44 65 76 69 63 65 55 73 61 67 65 28 49 6e 70 ublic.void.RemoveDeviceUsage(Inp
ae20 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 2c 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 utDevice.device,.InternedString.
ae40 75 73 61 67 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 usage)..........{..............i
ae60 66 20 28 64 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 f.(device.==.null)..............
ae80 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 ....throw.new.ArgumentNullExcept
aea0 69 6f 6e 28 6e 61 6d 65 6f 66 28 64 65 76 69 63 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ion(nameof(device));............
aec0 20 20 69 66 20 28 75 73 61 67 65 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 ..if.(usage.IsEmpty())..........
aee0 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 ........throw.new.ArgumentExcept
af00 69 6f 6e 28 22 55 73 61 67 65 20 73 74 72 69 6e 67 20 63 61 6e 6e 6f 74 20 62 65 20 65 6d 70 74 ion("Usage.string.cannot.be.empt
af20 79 22 2c 20 6e 61 6d 65 6f 66 28 75 73 61 67 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 y",.nameof(usage));.............
af40 20 69 66 20 28 21 64 65 76 69 63 65 2e 75 73 61 67 65 73 2e 43 6f 6e 74 61 69 6e 73 28 75 73 61 .if.(!device.usages.Contains(usa
af60 67 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d ge))..................return;...
af80 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 52 65 6d 6f 76 65 44 65 76 69 63 65 .............device.RemoveDevice
afa0 55 73 61 67 65 28 75 73 61 67 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4e 6f 74 69 66 Usage(usage);..............Notif
afc0 79 55 73 61 67 65 43 68 61 6e 67 65 64 28 64 65 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 yUsageChanged(device);..........
afe0 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 4e 6f 74 69 66 79 }............private.void.Notify
b000 55 73 61 67 65 43 68 61 6e 67 65 64 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 29 UsageChanged(InputDevice.device)
b020 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 41 63 ..........{..............InputAc
b040 74 69 6f 6e 53 74 61 74 65 2e 4f 6e 44 65 76 69 63 65 43 68 61 6e 67 65 28 64 65 76 69 63 65 2c tionState.OnDeviceChange(device,
b060 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 55 73 61 67 65 43 68 61 6e 67 65 64 29 .InputDeviceChange.UsageChanged)
b080 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 74 69 66 79 20 6c 69 73 74 65 ;................//.Notify.liste
b0a0 6e 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 ners...............for.(var.i.=.
b0c0 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 0;.i.<.m_DeviceChangeListeners.l
b0e0 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 ength;.++i)..................m_D
b100 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 76 69 63 65 2c 20 eviceChangeListeners[i](device,.
b120 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 55 73 61 67 65 43 68 61 6e 67 65 64 29 3b InputDeviceChange.UsageChanged);
b140 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 54 68 69 73 ................////REVIEW:.This
b160 20 77 61 73 20 66 6f 72 20 74 68 65 20 58 52 43 6f 6e 74 72 6f 6c 6c 65 72 20 6c 65 66 74 48 61 .was.for.the.XRController.leftHa
b180 6e 64 20 61 6e 64 20 72 69 67 68 74 48 61 6e 64 20 67 65 74 74 65 72 73 20 62 75 74 20 74 68 65 nd.and.rightHand.getters.but.the
b1a0 73 65 20 64 6f 20 6c 6f 6f 6b 75 70 73 20 64 79 6e 61 6d 69 63 61 6c 6c 79 20 6e 6f 77 3b 20 72 se.do.lookups.dynamically.now;.r
b1c0 65 6d 6f 76 65 3f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 73 61 67 65 20 6d 61 79 emove?..............//.Usage.may
b1e0 20 61 66 66 65 63 74 20 63 75 72 72 65 6e 74 20 64 65 76 69 63 65 20 73 6f 20 75 70 64 61 74 65 .affect.current.device.so.update
b200 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 4d 61 6b 65 43 75 72 72 65 6e ...............device.MakeCurren
b220 74 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 t();..........}............////T
b240 4f 44 4f 3a 20 6d 61 6b 65 20 73 75 72 65 20 74 68 61 74 20 6e 6f 20 64 65 76 69 63 65 20 6f 72 ODO:.make.sure.that.no.device.or
b260 20 63 6f 6e 74 72 6f 6c 20 77 69 74 68 20 61 20 27 2f 27 20 69 6e 20 74 68 65 20 6e 61 6d 65 20 .control.with.a.'/'.in.the.name.
b280 63 61 6e 20 63 72 65 65 70 20 69 6e 74 6f 20 74 68 65 20 73 79 73 74 65 6d 0d 0a 0d 0a 20 20 20 can.creep.into.the.system.......
b2a0 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 63 65 20 41 64 64 44 65 76 69 63 .....public.InputDevice.AddDevic
b2c0 65 28 54 79 70 65 20 74 79 70 65 2c 20 73 74 72 69 6e 67 20 6e 61 6d 65 20 3d 20 6e 75 6c 6c 29 e(Type.type,.string.name.=.null)
b2e0 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 79 70 ..........{..............if.(typ
b300 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f e.==.null)..................thro
b320 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 w.new.ArgumentNullException(name
b340 6f 66 28 74 79 70 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 69 6e of(type));................//.Fin
b360 64 20 74 68 65 20 6c 61 79 6f 75 74 20 6e 61 6d 65 20 74 68 61 74 20 74 68 65 20 67 69 76 65 6e d.the.layout.name.that.the.given
b380 20 74 79 70 65 20 77 61 73 20 72 65 67 69 73 74 65 72 65 64 20 77 69 74 68 2e 0d 0a 20 20 20 20 .type.was.registered.with.......
b3a0 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6d 5f 4c 61 79 6f 75 ........var.layoutName.=.m_Layou
b3c0 74 73 2e 54 72 79 46 69 6e 64 4c 61 79 6f 75 74 46 6f 72 54 79 70 65 28 74 79 70 65 29 3b 0d 0a ts.TryFindLayoutForType(type);..
b3e0 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d 65 2e 49 73 45 6d 70 ............if.(layoutName.IsEmp
b400 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 ty())..............{............
b420 20 20 20 20 20 20 2f 2f 20 41 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 72 65 67 69 73 74 65 72 20 ......//.Automatically.register.
b440 74 68 65 20 67 69 76 65 6e 20 74 79 70 65 20 61 73 20 61 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 the.given.type.as.a.layout......
b460 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d 65 2e 49 73 45 6d .............if.(layoutName.IsEm
b480 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 pty())..................{.......
b4a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6e 65 77 20 ...............layoutName.=.new.
b4c0 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 74 79 70 65 2e 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 InternedString(type.Name);......
b4e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c ................RegisterControlL
b500 61 79 6f 75 74 28 74 79 70 65 2e 4e 61 6d 65 2c 20 74 79 70 65 29 3b 0d 0a 20 20 20 20 20 20 20 ayout(type.Name,.type);.........
b520 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .........}..............}.......
b540 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 21 6c 61 79 6f 75 74 4e 61 6d .........Debug.Assert(!layoutNam
b560 65 2e 49 73 45 6d 70 74 79 28 29 2c 20 6e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 e.IsEmpty(),.name);.............
b580 20 20 20 2f 2f 20 4e 6f 74 65 20 74 68 61 74 20 73 69 6e 63 65 20 77 65 20 67 6f 20 74 68 72 6f ...//.Note.that.since.we.go.thro
b5a0 75 67 68 20 74 68 65 20 6e 6f 72 6d 61 6c 20 62 79 2d 6e 61 6d 65 20 6c 6f 6f 6b 75 70 20 68 65 ugh.the.normal.by-name.lookup.he
b5c0 72 65 2c 20 74 68 69 73 20 77 69 6c 6c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 73 74 re,.this.will..............//.st
b5e0 69 6c 6c 20 77 6f 72 6b 20 69 66 20 74 68 65 20 6c 61 79 6f 75 74 20 66 72 6f 6d 20 74 68 65 20 ill.work.if.the.layout.from.the.
b600 74 79 70 65 20 77 61 73 20 6f 76 65 72 72 69 64 65 20 77 69 74 68 20 61 20 73 74 72 69 6e 67 20 type.was.override.with.a.string.
b620 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 41 64 64 44 layout...............return.AddD
b640 65 76 69 63 65 28 6c 61 79 6f 75 74 4e 61 6d 65 2c 20 6e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 evice(layoutName,.name);........
b660 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 43 72 65 61 74 65 73 20 61 20 64 65 76 69 ..}............//.Creates.a.devi
b680 63 65 20 66 72 6f 6d 20 74 68 65 20 67 69 76 65 6e 20 6c 61 79 6f 75 74 20 61 6e 64 20 61 64 64 ce.from.the.given.layout.and.add
b6a0 73 20 69 74 20 74 6f 20 74 68 65 20 73 79 73 74 65 6d 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 s.it.to.the.system...........//.
b6c0 4e 4f 54 45 3a 20 43 72 65 61 74 65 73 20 67 61 72 62 61 67 65 2e 0d 0a 20 20 20 20 20 20 20 20 NOTE:.Creates.garbage...........
b6e0 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 63 65 20 41 64 64 44 65 76 69 63 65 28 73 74 72 public.InputDevice.AddDevice(str
b700 69 6e 67 20 6c 61 79 6f 75 74 2c 20 73 74 72 69 6e 67 20 6e 61 6d 65 20 3d 20 6e 75 6c 6c 2c 20 ing.layout,.string.name.=.null,.
b720 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 20 76 61 72 69 61 6e 74 73 20 3d 20 6e 65 77 20 49 6e InternedString.variants.=.new.In
b740 74 65 72 6e 65 64 53 74 72 69 6e 67 28 29 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 ternedString())..........{......
b760 20 20 20 20 20 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 ........if.(string.IsNullOrEmpty
b780 28 6c 61 79 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 (layout))..................throw
b7a0 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f .new.ArgumentNullException(nameo
b7c0 66 28 6c 61 79 6f 75 74 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 f(layout));................var.d
b7e0 65 76 69 63 65 20 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 42 75 69 6c 64 3c 49 6e 70 75 74 44 evice.=.InputDevice.Build<InputD
b800 65 76 69 63 65 3e 28 6c 61 79 6f 75 74 2c 20 76 61 72 69 61 6e 74 73 29 3b 0d 0a 0d 0a 20 20 20 evice>(layout,.variants);.......
b820 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 .........if.(!string.IsNullOrEmp
b840 74 79 28 6e 61 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 ty(name))..................devic
b860 65 2e 6d 5f 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 6e 61 e.m_Name.=.new.InternedString(na
b880 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 64 64 44 65 76 69 63 65 28 64 65 me);................AddDevice(de
b8a0 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 64 65 76 vice);................return.dev
b8c0 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 64 ice;..........}............//.Ad
b8e0 64 20 64 65 76 69 63 65 20 77 69 74 68 20 61 20 66 6f 72 63 65 64 20 49 44 2e 20 55 73 65 64 20 d.device.with.a.forced.ID..Used.
b900 77 68 65 6e 20 63 72 65 61 74 69 6e 67 20 64 65 76 69 63 65 73 20 72 65 70 6f 72 74 65 64 20 74 when.creating.devices.reported.t
b920 6f 20 75 73 20 62 79 20 6e 61 74 69 76 65 2e 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 o.us.by.native...........private
b940 20 49 6e 70 75 74 44 65 76 69 63 65 20 41 64 64 44 65 76 69 63 65 28 49 6e 74 65 72 6e 65 64 53 .InputDevice.AddDevice(InternedS
b960 74 72 69 6e 67 20 6c 61 79 6f 75 74 2c 20 69 6e 74 20 64 65 76 69 63 65 49 64 2c 0d 0a 20 20 20 tring.layout,.int.deviceId,.....
b980 20 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 20 64 65 76 69 63 65 4e 61 6d 65 20 3d 20 6e 75 6c .........string.deviceName.=.nul
b9a0 6c 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 l,..............InputDeviceDescr
b9c0 69 70 74 69 6f 6e 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 20 3d 20 6e 65 77 20 49 iption.deviceDescription.=.new.I
b9e0 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 28 29 2c 0d 0a 20 20 20 20 20 20 nputDeviceDescription(),........
ba00 20 20 20 20 20 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 20 64 65 ......InputDevice.DeviceFlags.de
ba20 76 69 63 65 46 6c 61 67 73 20 3d 20 30 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 74 65 viceFlags.=.0,..............Inte
ba40 72 6e 65 64 53 74 72 69 6e 67 20 76 61 72 69 61 6e 74 73 20 3d 20 64 65 66 61 75 6c 74 29 0d 0a rnedString.variants.=.default)..
ba60 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 ........{..............var.devic
ba80 65 20 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 42 75 69 6c 64 3c 49 6e 70 75 74 44 65 76 69 63 e.=.InputDevice.Build<InputDevic
baa0 65 3e 28 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 6c 61 79 6f 75 74 29 2c 0d 0a e>(new.InternedString(layout),..
bac0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f ................deviceDescriptio
bae0 6e 3a 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 20 20 n:.deviceDescription,...........
bb00 20 20 20 20 20 20 20 6c 61 79 6f 75 74 56 61 72 69 61 6e 74 73 3a 20 76 61 72 69 61 6e 74 73 29 .......layoutVariants:.variants)
bb20 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 ;................device.m_Device
bb40 49 64 20 3d 20 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 Id.=.deviceId;..............devi
bb60 63 65 2e 6d 5f 44 65 73 63 72 69 70 74 69 6f 6e 20 3d 20 64 65 76 69 63 65 44 65 73 63 72 69 70 ce.m_Description.=.deviceDescrip
bb80 74 69 6f 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 tion;..............device.m_Devi
bba0 63 65 46 6c 61 67 73 20 7c 3d 20 64 65 76 69 63 65 46 6c 61 67 73 3b 0d 0a 20 20 20 20 20 20 20 ceFlags.|=.deviceFlags;.........
bbc0 20 20 20 20 20 69 66 20 28 21 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 .....if.(!string.IsNullOrEmpty(d
bbe0 65 76 69 63 65 4e 61 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 eviceName))..................dev
bc00 69 63 65 2e 6d 5f 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 ice.m_Name.=.new.InternedString(
bc20 64 65 76 69 63 65 4e 61 6d 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 deviceName);................//.D
bc40 65 66 61 75 6c 74 20 64 69 73 70 6c 61 79 20 6e 61 6d 65 20 74 6f 20 70 72 6f 64 75 63 74 20 6e efault.display.name.to.product.n
bc60 61 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 74 72 69 6e 67 2e 49 73 ame...............if.(!string.Is
bc80 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2e 70 72 NullOrEmpty(deviceDescription.pr
bca0 6f 64 75 63 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e oduct))..................device.
bcc0 6d 5f 44 69 73 70 6c 61 79 4e 61 6d 65 20 3d 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f m_DisplayName.=.deviceDescriptio
bce0 6e 2e 70 72 6f 64 75 63 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 64 64 44 65 76 n.product;................AddDev
bd00 69 63 65 28 64 65 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 ice(device);................retu
bd20 72 6e 20 64 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 rn.device;..........}...........
bd40 20 70 75 62 6c 69 63 20 76 6f 69 64 20 41 64 64 44 65 76 69 63 65 28 49 6e 70 75 74 44 65 76 69 .public.void.AddDevice(InputDevi
bd60 63 65 20 64 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 ce.device)..........{...........
bd80 20 20 20 69 66 20 28 64 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 ...if.(device.==.null)..........
bda0 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 ........throw.new.ArgumentNullEx
bdc0 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 64 65 76 69 63 65 29 29 3b 0d 0a 20 20 20 20 20 20 ception(nameof(device));........
bde0 20 20 20 20 20 20 69 66 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 ......if.(string.IsNullOrEmpty(d
be00 65 76 69 63 65 2e 6c 61 79 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 evice.layout))..................
be20 74 68 72 6f 77 20 6e 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e 45 78 63 65 70 74 throw.new.InvalidOperationExcept
be40 69 6f 6e 28 22 44 65 76 69 63 65 20 68 61 73 20 6e 6f 20 61 73 73 6f 63 69 61 74 65 64 20 6c 61 ion("Device.has.no.associated.la
be60 79 6f 75 74 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 yout");................//.Ignore
be80 20 69 66 20 74 68 65 20 73 61 6d 65 20 64 65 76 69 63 65 20 67 65 74 73 20 61 64 64 65 64 20 6d .if.the.same.device.gets.added.m
bea0 75 6c 74 69 70 6c 65 20 74 69 6d 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 ultiple.times...............if.(
bec0 41 72 72 61 79 48 65 6c 70 65 72 73 2e 43 6f 6e 74 61 69 6e 73 28 6d 5f 44 65 76 69 63 65 73 2c ArrayHelpers.Contains(m_Devices,
bee0 20 64 65 76 69 63 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 .device))..................retur
bf00 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 4d 61 6b 65 44 65 76 69 63 65 4e 61 6d 65 n;................MakeDeviceName
bf20 55 6e 69 71 75 65 28 64 65 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 73 73 Unique(device);..............Ass
bf40 69 67 6e 55 6e 69 71 75 65 44 65 76 69 63 65 49 64 28 64 65 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 ignUniqueDeviceId(device);......
bf60 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 64 64 20 74 6f 20 6c 69 73 74 2e 0d 0a 20 20 20 20 20 ..........//.Add.to.list........
bf80 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 20 3d 20 41 72 .......device.m_DeviceIndex.=.Ar
bfa0 72 61 79 48 65 6c 70 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 69 74 79 28 72 65 rayHelpers.AppendWithCapacity(re
bfc0 66 20 6d 5f 44 65 76 69 63 65 73 2c 20 72 65 66 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 2c f.m_Devices,.ref.m_DevicesCount,
bfe0 20 64 65 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 .device);................////REV
c000 49 45 57 3a 20 4e 6f 74 20 73 75 72 65 20 61 20 66 75 6c 6c 2d 62 6c 6f 77 6e 20 64 69 63 74 69 IEW:.Not.sure.a.full-blown.dicti
c020 6f 6e 61 72 79 20 69 73 20 74 68 65 20 72 69 67 68 74 20 77 61 79 20 68 65 72 65 2e 20 41 6c 74 onary.is.the.right.way.here..Alt
c040 65 72 6e 61 74 69 76 65 73 20 61 72 65 20 74 6f 20 6b 65 65 70 0d 0a 20 20 20 20 20 20 20 20 20 ernatives.are.to.keep...........
c060 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 20 61 20 73 70 61 72 73 65 20 61 72 72 61 79 20 74 68 ...////........a.sparse.array.th
c080 61 74 20 64 69 72 65 63 74 6c 79 20 69 6e 64 65 78 65 73 20 75 73 69 6e 67 20 74 68 65 20 6c 69 at.directly.indexes.using.the.li
c0a0 6e 65 61 72 6c 79 20 69 6e 63 72 65 61 73 69 6e 67 20 49 44 73 20 28 74 68 6f 75 67 68 20 74 68 nearly.increasing.IDs.(though.th
c0c0 61 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 20 6d 61 79 20 at..............////........may.
c0e0 67 65 74 20 6c 61 72 67 65 20 6f 76 65 72 20 74 69 6d 65 29 2e 20 4f 72 20 74 6f 20 6a 75 73 74 get.large.over.time)..Or.to.just
c100 20 64 6f 20 61 20 6c 69 6e 65 61 72 20 73 65 61 72 63 68 20 74 68 72 6f 75 67 68 20 6d 5f 44 65 .do.a.linear.search.through.m_De
c120 76 69 63 65 73 20 28 62 75 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 vices.(but..............////....
c140 20 20 20 20 74 68 61 74 20 6d 61 79 20 65 6e 64 20 75 70 20 74 61 70 70 69 6e 67 20 61 20 62 75 ....that.may.end.up.tapping.a.bu
c160 6e 63 68 20 6f 66 20 6d 65 6d 6f 72 79 20 6c 6f 63 61 74 69 6f 6e 73 20 69 6e 20 74 68 65 20 68 nch.of.memory.locations.in.the.h
c180 65 61 70 20 74 6f 20 66 69 6e 64 20 74 68 65 20 72 69 67 68 74 0d 0a 20 20 20 20 20 20 20 20 20 eap.to.find.the.right...........
c1a0 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 20 64 65 76 69 63 65 3b 20 63 6f 75 6c 64 20 62 65 20 ...////........device;.could.be.
c1c0 69 6d 70 72 6f 76 65 64 20 62 79 20 73 6f 72 74 69 6e 67 20 6d 5f 44 65 76 69 63 65 73 20 62 79 improved.by.sorting.m_Devices.by
c1e0 20 49 44 20 61 6e 64 20 70 69 63 6b 69 6e 67 20 61 20 67 6f 6f 64 20 73 74 61 72 74 69 6e 67 0d .ID.and.picking.a.good.starting.
c200 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 20 70 6f 69 6e 74 20 62 .............////........point.b
c220 61 73 65 64 20 6f 6e 20 74 68 65 20 49 44 20 77 65 20 68 61 76 65 20 69 6e 73 74 65 61 64 20 6f ased.on.the.ID.we.have.instead.o
c240 66 20 73 65 61 72 63 68 69 6e 67 20 66 72 6f 6d 20 5b 30 5d 20 61 6c 77 61 79 73 29 2e 0d 0a 20 f.searching.from.[0].always)....
c260 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 73 42 79 49 64 5b 64 65 76 69 63 65 2e ...........m_DevicesById[device.
c280 64 65 76 69 63 65 49 64 5d 20 3d 20 64 65 76 69 63 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 deviceId].=.device;.............
c2a0 20 20 20 2f 2f 20 4c 65 74 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 20 6b 6e 6f 77 ...//.Let.InputStateBuffers.know
c2c0 20 74 68 69 73 20 64 65 76 69 63 65 20 64 6f 65 73 6e 27 74 20 68 61 76 65 20 61 6e 79 20 61 73 .this.device.doesn't.have.any.as
c2e0 73 6f 63 69 61 74 65 64 20 73 74 61 74 65 20 79 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 sociated.state.yet..............
c300 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 .device.m_StateBlock.byteOffset.
c320 3d 20 49 6e 70 75 74 53 74 61 74 65 42 6c 6f 63 6b 2e 49 6e 76 61 6c 69 64 4f 66 66 73 65 74 3b =.InputStateBlock.InvalidOffset;
c340 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 73 74 61 74 65 20 ................//.Update.state.
c360 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 61 6c 6c 6f 63 61 74 65 buffers...............Reallocate
c380 53 74 61 74 65 42 75 66 66 65 72 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 69 StateBuffers();..............Ini
c3a0 74 69 61 6c 69 7a 65 44 65 66 61 75 6c 74 53 74 61 74 65 28 64 65 76 69 63 65 29 3b 0d 0a 20 20 tializeDefaultState(device);....
c3c0 20 20 20 20 20 20 20 20 20 20 49 6e 69 74 69 61 6c 69 7a 65 4e 6f 69 73 65 4d 61 73 6b 28 64 65 ..........InitializeNoiseMask(de
c3e0 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 vice);................//.Update.
c400 6d 65 74 72 69 63 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4d 65 74 72 69 63 73 2e metrics...............m_Metrics.
c420 6d 61 78 4e 75 6d 44 65 76 69 63 65 73 20 3d 20 4d 61 74 68 66 2e 4d 61 78 28 6d 5f 44 65 76 69 maxNumDevices.=.Mathf.Max(m_Devi
c440 63 65 73 43 6f 75 6e 74 2c 20 6d 5f 4d 65 74 72 69 63 73 2e 6d 61 78 4e 75 6d 44 65 76 69 63 65 cesCount,.m_Metrics.maxNumDevice
c460 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4d 65 74 72 69 63 73 2e 6d 61 78 53 74 s);..............m_Metrics.maxSt
c480 61 74 65 53 69 7a 65 49 6e 42 79 74 65 73 20 3d 20 4d 61 74 68 66 2e 4d 61 78 28 28 69 6e 74 29 ateSizeInBytes.=.Mathf.Max((int)
c4a0 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 74 6f 74 61 6c 53 69 7a 65 2c 20 6d 5f 4d 65 74 72 m_StateBuffers.totalSize,.m_Metr
c4c0 69 63 73 2e 6d 61 78 53 74 61 74 65 53 69 7a 65 49 6e 42 79 74 65 73 29 3b 0d 0a 0d 0a 20 20 20 ics.maxStateSizeInBytes);.......
c4e0 20 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 6b 65 20 73 75 72 65 20 74 68 61 74 20 69 66 20 74 68 .........//.Make.sure.that.if.th
c500 65 20 64 65 76 69 63 65 20 49 44 20 69 73 20 6c 69 73 74 65 64 20 69 6e 20 6d 5f 41 76 61 69 6c e.device.ID.is.listed.in.m_Avail
c520 61 62 6c 65 44 65 76 69 63 65 73 2c 20 74 68 65 20 64 65 76 69 63 65 0d 0a 20 20 20 20 20 20 20 ableDevices,.the.device.........
c540 20 20 20 20 20 2f 2f 20 69 73 20 6e 6f 20 6c 6f 6e 67 65 72 20 6d 61 72 6b 65 64 20 61 73 20 72 .....//.is.no.longer.marked.as.r
c560 65 6d 6f 76 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 emoved...............for.(var.i.
c580 3d 20 30 3b 20 69 20 3c 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b =.0;.i.<.m_AvailableDeviceCount;
c5a0 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 .++i)..............{............
c5c0 20 20 20 20 20 20 69 66 20 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e ......if.(m_AvailableDevices[i].
c5e0 64 65 76 69 63 65 49 64 20 3d 3d 20 64 65 76 69 63 65 2e 64 65 76 69 63 65 49 64 29 0d 0a 20 20 deviceId.==.device.deviceId)....
c600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 ..................m_AvailableDev
c620 69 63 65 73 5b 69 5d 2e 69 73 52 65 6d 6f 76 65 64 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 ices[i].isRemoved.=.false;......
c640 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 ........}................////REV
c660 49 45 57 3a 20 77 65 20 6d 61 79 20 77 61 6e 74 20 74 6f 20 73 75 70 70 72 65 73 73 20 74 68 69 IEW:.we.may.want.to.suppress.thi
c680 73 20 64 75 72 69 6e 67 20 74 68 65 20 69 6e 69 74 69 61 6c 20 64 65 76 69 63 65 20 64 69 73 63 s.during.the.initial.device.disc
c6a0 6f 76 65 72 79 20 70 68 61 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4c 65 74 20 overy.phase..............//.Let.
c6c0 61 63 74 69 6f 6e 73 20 72 65 2d 72 65 73 6f 6c 76 65 20 74 68 65 69 72 20 70 61 74 68 73 2e 0d actions.re-resolve.their.paths..
c6e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 41 63 74 69 6f 6e 53 74 61 74 65 2e 4f 6e .............InputActionState.On
c700 44 65 76 69 63 65 43 68 61 6e 67 65 28 64 65 76 69 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 DeviceChange(device,.InputDevice
c720 43 68 61 6e 67 65 2e 41 64 64 65 64 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f Change.Added);................//
c740 20 49 66 20 74 68 65 20 64 65 76 69 63 65 20 77 61 6e 74 73 20 61 75 74 6f 6d 61 74 69 63 20 63 .If.the.device.wants.automatic.c
c760 61 6c 6c 62 61 63 6b 73 20 62 65 66 6f 72 65 20 69 6e 70 75 74 20 75 70 64 61 74 65 73 2c 0d 0a allbacks.before.input.updates,..
c780 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 70 75 74 20 69 74 20 6f 6e 20 74 68 65 20 6c 69 73 ............//.put.it.on.the.lis
c7a0 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 69 73 20 49 49 t...............if.(device.is.II
c7c0 6e 70 75 74 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 20 62 65 66 6f 72 nputUpdateCallbackReceiver.befor
c7e0 65 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 29 0d 0a 20 20 20 20 20 20 eUpdateCallbackReceiver)........
c800 20 20 20 20 20 20 20 20 20 20 6f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 20 2b 3d 20 62 65 66 6f ..........onBeforeUpdate.+=.befo
c820 72 65 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 2e 4f 6e 55 70 64 61 74 reUpdateCallbackReceiver.OnUpdat
c840 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 74 68 65 20 64 65 76 69 e;................//.If.the.devi
c860 63 65 20 68 61 73 20 73 74 61 74 65 20 63 61 6c 6c 62 61 63 6b 73 2c 20 6d 61 6b 65 20 61 20 6e ce.has.state.callbacks,.make.a.n
c880 6f 74 65 20 6f 66 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 ote.of.it...............if.(devi
c8a0 63 65 20 69 73 20 49 49 6e 70 75 74 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 ce.is.IInputStateCallbackReceive
c8c0 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 r)..............{...............
c8e0 20 20 20 49 6e 73 74 61 6c 6c 42 65 66 6f 72 65 55 70 64 61 74 65 48 6f 6f 6b 49 66 4e 65 63 65 ...InstallBeforeUpdateHookIfNece
c900 73 73 61 72 79 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 ssary();..................device
c920 2e 6d 5f 44 65 76 69 63 65 46 6c 61 67 73 20 7c 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 .m_DeviceFlags.|=.InputDevice.De
c940 76 69 63 65 46 6c 61 67 73 2e 48 61 73 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 73 3b 0d 0a 20 20 viceFlags.HasStateCallbacks;....
c960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 48 61 76 65 44 65 76 69 63 65 73 57 69 74 68 53 ..............m_HaveDevicesWithS
c980 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 73 20 3d 20 74 72 75 65 3b 0d 0a 20 tateCallbackReceivers.=.true;...
c9a0 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 ...........}................//.I
c9c0 66 20 74 68 65 20 64 65 76 69 63 65 20 77 61 6e 74 73 20 62 65 66 6f 72 65 2d 72 65 6e 64 65 72 f.the.device.wants.before-render
c9e0 20 75 70 64 61 74 65 73 2c 20 65 6e 61 62 6c 65 20 74 68 65 6d 20 69 66 20 74 68 65 79 0d 0a 20 .updates,.enable.them.if.they...
ca00 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 72 65 6e 27 74 20 61 6c 72 65 61 64 79 2e 0d 0a 20 ...........//.aren't.already....
ca20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 75 70 64 61 74 65 42 65 66 6f ...........if.(device.updateBefo
ca40 72 65 52 65 6e 64 65 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 70 64 61 74 reRender)..................updat
ca60 65 4d 61 73 6b 20 7c 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 42 65 66 6f 72 65 52 eMask.|=.InputUpdateType.BeforeR
ca80 65 6e 64 65 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 74 69 66 79 20 ender;................//.Notify.
caa0 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 4e 6f 74 69 device...............device.Noti
cac0 66 79 41 64 64 65 64 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 fyAdded();................////RE
cae0 56 49 45 57 3a 20 69 73 20 74 68 69 73 20 72 65 61 6c 6c 79 20 61 20 67 6f 6f 64 20 74 68 69 6e VIEW:.is.this.really.a.good.thin
cb00 67 20 74 6f 20 64 6f 3f 20 6a 75 73 74 20 70 6c 75 67 67 69 6e 67 20 69 6e 20 61 20 64 65 76 69 g.to.do?.just.plugging.in.a.devi
cb20 63 65 20 73 68 6f 75 6c 64 6e 27 74 20 6d 61 6b 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f ce.shouldn't.make............../
cb40 2f 2f 2f 20 20 20 20 20 20 20 20 69 74 20 63 75 72 72 65 6e 74 2c 20 6e 6f 3f 0d 0a 20 20 20 20 ///........it.current,.no?......
cb60 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 6b 65 20 74 68 65 20 64 65 76 69 63 65 20 63 75 72 72 65 ........//.Make.the.device.curre
cb80 6e 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 4d 61 6b 65 43 75 72 72 nt...............device.MakeCurr
cba0 65 6e 74 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 74 69 66 79 20 ent();................//.Notify.
cbc0 6c 69 73 74 65 6e 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 listeners...............for.(var
cbe0 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e .i.=.0;.i.<.m_DeviceChangeListen
cc00 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ers.length;.++i)................
cc20 20 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 76 ..m_DeviceChangeListeners[i](dev
cc40 69 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 41 64 64 65 64 29 3b 0d 0a ice,.InputDeviceChange.Added);..
cc60 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 74 ........}............////TODO:.t
cc80 68 69 73 20 70 61 74 68 20 73 68 6f 75 6c 64 20 72 65 61 6c 6c 79 20 70 75 74 20 74 68 65 20 64 his.path.should.really.put.the.d
cca0 65 76 69 63 65 20 6f 6e 20 74 68 65 20 6c 69 73 74 20 6f 66 20 61 76 61 69 6c 61 62 6c 65 20 64 evice.on.the.list.of.available.d
ccc0 65 76 69 63 65 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 74 68 69 73 20 70 evices..........////TODO:.this.p
cce0 61 74 68 20 73 68 6f 75 6c 64 20 64 69 73 63 6f 76 65 72 20 64 69 73 63 6f 6e 6e 65 63 74 65 64 ath.should.discover.disconnected
cd00 20 64 65 76 69 63 65 73 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 .devices..........public.InputDe
cd20 76 69 63 65 20 41 64 64 44 65 76 69 63 65 28 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 vice.AddDevice(InputDeviceDescri
cd40 70 74 69 6f 6e 20 64 65 73 63 72 69 70 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 ption.description)..........{...
cd60 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 69 73 20 74 68 72 6f 77 69 ...........////REVIEW:.is.throwi
cd80 6e 67 20 68 65 72 65 20 72 65 61 6c 6c 79 20 73 75 63 68 20 61 20 75 73 65 66 75 6c 20 74 68 69 ng.here.really.such.a.useful.thi
cda0 6e 67 3f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 41 64 64 44 65 76 69 63 ng?..............return.AddDevic
cdc0 65 28 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 74 68 72 6f 77 49 66 4e 6f 4c 61 79 6f 75 74 46 6f e(description,.throwIfNoLayoutFo
cde0 75 6e 64 3a 20 74 72 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 und:.true);..........}..........
ce00 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 63 65 20 41 64 64 44 65 76 69 63 65 28 49 ..public.InputDevice.AddDevice(I
ce20 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 20 64 65 73 63 72 69 70 74 69 6f nputDeviceDescription.descriptio
ce40 6e 2c 20 62 6f 6f 6c 20 74 68 72 6f 77 49 66 4e 6f 4c 61 79 6f 75 74 46 6f 75 6e 64 2c 0d 0a 20 n,.bool.throwIfNoLayoutFound,...
ce60 20 20 20 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 20 64 65 76 69 63 65 4e 61 6d 65 20 3d 20 6e ...........string.deviceName.=.n
ce80 75 6c 6c 2c 20 69 6e 74 20 64 65 76 69 63 65 49 64 20 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e ull,.int.deviceId.=.InputDevice.
cea0 49 6e 76 61 6c 69 64 44 65 76 69 63 65 49 64 2c 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 InvalidDeviceId,.InputDevice.Dev
cec0 69 63 65 46 6c 61 67 73 20 64 65 76 69 63 65 46 6c 61 67 73 20 3d 20 30 29 0d 0a 20 20 20 20 20 iceFlags.deviceFlags.=.0).......
cee0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 69 6c 65 72 2e 42 65 67 69 6e ...{..............Profiler.Begin
cf00 53 61 6d 70 6c 65 28 22 49 6e 70 75 74 53 79 73 74 65 6d 2e 41 64 64 44 65 76 69 63 65 22 29 3b Sample("InputSystem.AddDevice");
cf20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4c 6f 6f 6b 20 66 6f 72 20 6d 61 74 63 68 69 ..............//.Look.for.matchi
cf40 6e 67 20 6c 61 79 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f ng.layout...............var.layo
cf60 75 74 20 3d 20 54 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 ut.=.TryFindMatchingControlLayou
cf80 74 28 72 65 66 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 64 65 76 69 63 65 49 64 29 3b 0d 0a 0d t(ref.description,.deviceId);...
cfa0 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 6e 6f 20 6c 61 79 6f 75 74 20 77 61 73 .............//.If.no.layout.was
cfc0 20 66 6f 75 6e 64 2c 20 62 61 69 6c 20 6f 75 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 .found,.bail.out...............i
cfe0 66 20 28 6c 61 79 6f 75 74 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 f.(layout.IsEmpty())............
d000 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 68 72 6f 77 49 66 ..{..................if.(throwIf
d020 4e 6f 4c 61 79 6f 75 74 46 6f 75 6e 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 NoLayoutFound)..................
d040 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 ....throw.new.ArgumentException(
d060 24 22 43 61 6e 6e 6f 74 20 66 69 6e 64 20 6c 61 79 6f 75 74 20 6d 61 74 63 68 69 6e 67 20 64 65 $"Cannot.find.layout.matching.de
d080 76 69 63 65 20 64 65 73 63 72 69 70 74 69 6f 6e 20 27 7b 64 65 73 63 72 69 70 74 69 6f 6e 7d 27 vice.description.'{description}'
d0a0 22 2c 20 6e 61 6d 65 6f 66 28 64 65 73 63 72 69 70 74 69 6f 6e 29 29 3b 0d 0a 0d 0a 20 20 20 20 ",.nameof(description));........
d0c0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 69 74 27 73 20 61 20 64 65 76 69 63 65 20 ............//.If.it's.a.device.
d0e0 63 6f 6d 69 6e 67 20 66 72 6f 6d 20 74 68 65 20 72 75 6e 74 69 6d 65 2c 20 64 69 73 61 62 6c 65 coming.from.the.runtime,.disable
d100 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 .it...................if.(device
d120 49 64 20 21 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 49 6e 76 61 6c 69 64 44 65 76 69 63 65 49 Id.!=.InputDevice.InvalidDeviceI
d140 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 d)..................{...........
d160 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 6f 6d 6d 61 6e 64 20 3d 20 44 69 73 61 62 6c 65 ...........var.command.=.Disable
d180 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 2e 43 72 65 61 74 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 DeviceCommand.Create();.........
d1a0 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 44 65 76 69 63 65 43 6f 6d .............m_Runtime.DeviceCom
d1c0 6d 61 6e 64 28 64 65 76 69 63 65 49 64 2c 20 72 65 66 20 63 6f 6d 6d 61 6e 64 29 3b 0d 0a 20 20 mand(deviceId,.ref.command);....
d1e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ..............}.................
d200 20 20 20 50 72 6f 66 69 6c 65 72 2e 45 6e 64 53 61 6d 70 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 ...Profiler.EndSample();........
d220 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 ..........return.null;..........
d240 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 ....}................var.device.
d260 3d 20 41 64 64 44 65 76 69 63 65 28 6c 61 79 6f 75 74 2c 20 64 65 76 69 63 65 49 64 2c 20 64 65 =.AddDevice(layout,.deviceId,.de
d280 76 69 63 65 4e 61 6d 65 2c 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 64 65 76 69 63 65 46 6c 61 viceName,.description,.deviceFla
d2a0 67 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 73 63 72 gs);..............device.m_Descr
d2c0 69 70 74 69 6f 6e 20 3d 20 64 65 73 63 72 69 70 74 69 6f 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 iption.=.description;...........
d2e0 20 20 20 50 72 6f 66 69 6c 65 72 2e 45 6e 64 53 61 6d 70 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 ...Profiler.EndSample();........
d300 20 20 20 20 20 20 72 65 74 75 72 6e 20 64 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d ......return.device;..........}.
d320 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 52 65 6d 6f 76 65 44 65 76 ...........public.void.RemoveDev
d340 69 63 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 2c 20 62 6f 6f 6c 20 6b 65 65 ice(InputDevice.device,.bool.kee
d360 70 4f 6e 4c 69 73 74 4f 66 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 20 3d 20 66 61 6c 73 pOnListOfAvailableDevices.=.fals
d380 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 e)..........{..............if.(d
d3a0 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 evice.==.null)..................
d3c0 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 78 63 65 70 74 69 6f 6e 28 throw.new.ArgumentNullException(
d3e0 6e 61 6d 65 6f 66 28 64 65 76 69 63 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 nameof(device));................
d400 2f 2f 20 49 66 20 64 65 76 69 63 65 20 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 61 64 64 65 64 2c //.If.device.has.not.been.added,
d420 20 69 67 6e 6f 72 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 .ignore...............if.(device
d440 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 20 3d 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 6b 49 .m_DeviceIndex.==.InputDevice.kI
d460 6e 76 61 6c 69 64 44 65 76 69 63 65 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 nvalidDeviceIndex)..............
d480 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 ....return;................//.Re
d4a0 6d 6f 76 65 20 73 74 61 74 65 20 6d 6f 6e 69 74 6f 72 73 20 77 68 69 6c 65 20 64 65 76 69 63 65 move.state.monitors.while.device
d4c0 20 69 6e 64 65 78 20 69 73 20 73 74 69 6c 6c 20 76 61 6c 69 64 2e 0d 0a 20 20 20 20 20 20 20 20 .index.is.still.valid...........
d4e0 20 20 20 20 52 65 6d 6f 76 65 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 28 64 65 ....RemoveStateChangeMonitors(de
d500 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 6f 76 65 20 vice);................//.Remove.
d520 66 72 6f 6d 20 64 65 76 69 63 65 20 61 72 72 61 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 from.device.array...............
d540 76 61 72 20 64 65 76 69 63 65 49 6e 64 65 78 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 var.deviceIndex.=.device.m_Devic
d560 65 49 6e 64 65 78 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 49 eIndex;..............var.deviceI
d580 64 20 3d 20 64 65 76 69 63 65 2e 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 d.=.device.deviceId;............
d5a0 20 20 69 66 20 28 64 65 76 69 63 65 49 6e 64 65 78 20 3c 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 ..if.(deviceIndex.<.m_StateChang
d5c0 65 4d 6f 6e 69 74 6f 72 73 2e 4c 65 6e 67 74 68 53 61 66 65 28 29 29 0d 0a 20 20 20 20 20 20 20 eMonitors.LengthSafe()).........
d5e0 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6d 5f 53 74 61 .....{..................//.m_Sta
d600 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 20 6d 69 72 72 6f 72 73 20 6c 61 79 6f 75 74 20 teChangeMonitors.mirrors.layout.
d620 6f 66 20 6d 5f 44 65 76 69 63 65 73 20 2a 62 75 74 2a 20 6d 61 79 20 62 65 20 73 68 6f 72 74 65 of.m_Devices.*but*.may.be.shorte
d640 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 6f 75 6e 74 20 3d 20 r...................var.count.=.
d660 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 2e 4c 65 6e 67 74 68 3b 0d 0a 20 m_StateChangeMonitors.Length;...
d680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 45 72 61 73 ...............ArrayHelpers.Eras
d6a0 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e eAtWithCapacity(m_StateChangeMon
d6c0 69 74 6f 72 73 2c 20 72 65 66 20 63 6f 75 6e 74 2c 20 64 65 76 69 63 65 49 6e 64 65 78 29 3b 0d itors,.ref.count,.deviceIndex);.
d6e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 41 72 72 61 .............}..............Arra
d700 79 48 65 6c 70 65 72 73 2e 45 72 61 73 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 6d 5f 44 yHelpers.EraseAtWithCapacity(m_D
d720 65 76 69 63 65 73 2c 20 72 65 66 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 2c 20 64 65 76 69 evices,.ref.m_DevicesCount,.devi
d740 63 65 49 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 ceIndex);................m_Devic
d760 65 73 42 79 49 64 2e 52 65 6d 6f 76 65 28 64 65 76 69 63 65 49 64 29 3b 0d 0a 0d 0a 20 20 20 20 esById.Remove(deviceId);........
d780 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 73 20 21 3d 20 6e 75 6c 6c 29 0d 0a ........if.(m_Devices.!=.null)..
d7a0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f ............{................../
d7c0 2f 20 52 65 6d 6f 76 65 20 66 72 6f 6d 20 73 74 61 74 65 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 /.Remove.from.state.buffers.....
d7e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 61 6c 6c 6f 63 61 74 65 53 74 61 74 65 42 75 66 ..............ReallocateStateBuf
d800 66 65 72 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 fers();..............}..........
d820 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 ....else..............{.........
d840 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 20 6d 6f 72 65 20 64 65 76 69 63 65 73 2e 20 4b 69 6c .........//.No.more.devices..Kil
d860 6c 20 73 74 61 74 65 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 l.state.buffers.................
d880 20 20 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 46 72 65 65 41 6c 6c 28 29 3b 0d 0a 20 20 20 ..m_StateBuffers.FreeAll();.....
d8a0 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 .........}................//.Upd
d8c0 61 74 65 20 64 65 76 69 63 65 20 69 6e 64 69 63 65 73 2e 20 44 6f 20 74 68 69 73 20 61 66 74 65 ate.device.indices..Do.this.afte
d8e0 72 20 72 65 61 6c 6c 6f 63 61 74 69 6e 67 20 73 74 61 74 65 20 62 75 66 66 65 72 73 20 61 73 20 r.reallocating.state.buffers.as.
d900 74 68 61 74 20 63 61 6c 6c 20 72 65 71 75 69 72 65 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 that.call.requires..............
d920 2f 2f 20 74 68 65 20 6f 6c 64 20 69 6e 64 69 63 65 73 20 74 6f 20 73 74 69 6c 6c 20 62 65 20 69 //.the.old.indices.to.still.be.i
d940 6e 20 70 6c 61 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 n.place...............for.(var.i
d960 20 3d 20 64 65 76 69 63 65 49 6e 64 65 78 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 .=.deviceIndex;.i.<.m_DevicesCou
d980 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 6d 5f 44 65 nt;.++i)..................--m_De
d9a0 76 69 63 65 73 5b 69 5d 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 3b 20 2f 2f 20 49 6e 64 69 63 vices[i].m_DeviceIndex;.//.Indic
d9c0 65 73 20 68 61 76 65 20 73 68 69 66 74 65 64 20 64 6f 77 6e 20 62 79 20 6f 6e 65 2e 0d 0a 20 20 es.have.shifted.down.by.one.....
d9e0 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 20 3d ..........device.m_DeviceIndex.=
da00 20 49 6e 70 75 74 44 65 76 69 63 65 2e 6b 49 6e 76 61 6c 69 64 44 65 76 69 63 65 49 6e 64 65 78 .InputDevice.kInvalidDeviceIndex
da20 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 6c 69 73 74 20 ;................//.Update.list.
da40 6f 66 20 61 76 61 69 6c 61 62 6c 65 20 64 65 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 of.available.devices............
da60 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 41 76 61 69 6c 61 62 ...for.(var.i.=.0;.i.<.m_Availab
da80 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 leDeviceCount;.++i).............
daa0 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 41 76 61 69 6c 61 .{..................if.(m_Availa
dac0 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 76 69 63 65 49 64 20 3d 3d 20 64 65 76 69 63 65 bleDevices[i].deviceId.==.device
dae0 49 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 Id)..................{..........
db00 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6b 65 65 70 4f 6e 4c 69 73 74 4f 66 41 76 61 69 ............if.(keepOnListOfAvai
db20 6c 61 62 6c 65 44 65 76 69 63 65 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 lableDevices)...................
db40 20 20 20 20 20 20 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 69 73 52 .......m_AvailableDevices[i].isR
db60 65 6d 6f 76 65 64 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 emoved.=.true;..................
db80 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ....else........................
dba0 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 45 72 61 73 65 41 74 57 69 74 68 43 61 70 61 63 69 ..ArrayHelpers.EraseAtWithCapaci
dbc0 74 79 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 2c 20 72 65 66 20 6d 5f 41 76 61 ty(m_AvailableDevices,.ref.m_Ava
dbe0 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 2c 20 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 ilableDeviceCount,.i);..........
dc00 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ............break;..............
dc20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ....}..............}............
dc40 20 20 20 20 2f 2f 20 55 6e 62 61 6b 65 20 6f 66 66 73 65 74 20 69 6e 74 6f 20 67 6c 6f 62 61 6c ....//.Unbake.offset.into.global
dc60 20 73 74 61 74 65 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 .state.buffers...............dev
dc80 69 63 65 2e 42 61 6b 65 4f 66 66 73 65 74 49 6e 74 6f 53 74 61 74 65 42 6c 6f 63 6b 52 65 63 75 ice.BakeOffsetIntoStateBlockRecu
dca0 72 73 69 76 65 28 28 75 69 6e 74 29 2d 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b rsive((uint)-device.m_StateBlock
dcc0 2e 62 79 74 65 4f 66 66 73 65 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 .byteOffset);................//.
dce0 46 6f 72 63 65 20 65 6e 61 62 6c 65 64 20 61 63 74 69 6f 6e 73 20 74 6f 20 72 65 6d 6f 76 65 20 Force.enabled.actions.to.remove.
dd00 63 6f 6e 74 72 6f 6c 73 20 66 72 6f 6d 20 74 68 65 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 controls.from.the.device........
dd20 20 20 20 20 20 20 20 2f 2f 20 57 65 27 76 65 20 61 6c 72 65 61 64 79 20 73 65 74 20 74 68 65 20 .......//.We've.already.set.the.
dd40 64 65 76 69 63 65 20 69 6e 64 65 78 20 74 6f 20 62 65 20 69 6e 76 61 6c 69 64 20 73 6f 20 77 65 device.index.to.be.invalid.so.we
dd60 20 61 6e 79 20 61 74 74 65 6d 70 74 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 62 79 .any.attempts..............//.by
dd80 20 61 63 74 69 6f 6e 73 20 74 6f 20 75 6e 69 6e 73 74 61 6c 6c 20 73 74 61 74 65 20 6d 6f 6e 69 .actions.to.uninstall.state.moni
dda0 74 6f 72 73 20 77 69 6c 6c 20 67 65 74 20 69 67 6e 6f 72 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 tors.will.get.ignored...........
ddc0 20 20 20 20 49 6e 70 75 74 41 63 74 69 6f 6e 53 74 61 74 65 2e 4f 6e 44 65 76 69 63 65 43 68 61 ....InputActionState.OnDeviceCha
dde0 6e 67 65 28 64 65 76 69 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 52 65 nge(device,.InputDeviceChange.Re
de00 6d 6f 76 65 64 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4b 69 6c 6c 20 62 moved);................//.Kill.b
de20 65 66 6f 72 65 20 75 70 64 61 74 65 20 63 61 6c 6c 62 61 63 6b 2c 20 69 66 20 61 70 70 6c 69 63 efore.update.callback,.if.applic
de40 61 62 6c 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 69 73 able...............if.(device.is
de60 20 49 49 6e 70 75 74 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 20 62 65 .IInputUpdateCallbackReceiver.be
de80 66 6f 72 65 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 29 0d 0a 20 20 20 foreUpdateCallbackReceiver).....
dea0 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 20 2d 3d 20 62 .............onBeforeUpdate.-=.b
dec0 65 66 6f 72 65 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 2e 4f 6e 55 70 eforeUpdateCallbackReceiver.OnUp
dee0 64 61 74 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 69 73 61 62 6c 65 20 date;................//.Disable.
df00 62 65 66 6f 72 65 2d 72 65 6e 64 65 72 20 75 70 64 61 74 65 73 20 69 66 20 74 68 69 73 20 77 61 before-render.updates.if.this.wa
df20 73 20 74 68 65 20 6c 61 73 74 20 64 65 76 69 63 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f s.the.last.device............../
df40 2f 20 74 68 61 74 20 72 65 71 75 69 72 65 73 20 74 68 65 6d 2e 0d 0a 20 20 20 20 20 20 20 20 20 /.that.requires.them............
df60 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 75 70 64 61 74 65 42 65 66 6f 72 65 52 65 6e 64 65 72 ...if.(device.updateBeforeRender
df80 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 )..............{................
dfa0 20 20 76 61 72 20 68 61 76 65 44 65 76 69 63 65 52 65 71 75 69 72 69 6e 67 42 65 66 6f 72 65 52 ..var.haveDeviceRequiringBeforeR
dfc0 65 6e 64 65 72 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ender.=.false;..................
dfe0 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 for.(var.i.=.0;.i.<.m_DevicesCou
e000 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 nt;.++i)......................if
e020 20 28 6d 5f 44 65 76 69 63 65 73 5b 69 5d 2e 75 70 64 61 74 65 42 65 66 6f 72 65 52 65 6e 64 65 .(m_Devices[i].updateBeforeRende
e040 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 r)......................{.......
e060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 76 65 44 65 76 69 63 65 52 65 71 ...................haveDeviceReq
e080 75 69 72 69 6e 67 42 65 66 6f 72 65 52 65 6e 64 65 72 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 uiringBeforeRender.=.true;......
e0a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 ....................break;......
e0c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ................}...............
e0e0 20 20 20 20 20 69 66 20 28 21 68 61 76 65 44 65 76 69 63 65 52 65 71 75 69 72 69 6e 67 42 65 66 .....if.(!haveDeviceRequiringBef
e100 6f 72 65 52 65 6e 64 65 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 oreRender)......................
e120 75 70 64 61 74 65 4d 61 73 6b 20 26 3d 20 7e 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 42 updateMask.&=.~InputUpdateType.B
e140 65 66 6f 72 65 52 65 6e 64 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 eforeRender;..............}.....
e160 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4c 65 74 20 64 65 76 69 63 65 20 6b 6e 6f 77 2e 0d 0a ...........//.Let.device.know...
e180 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 4e 6f 74 69 66 79 52 65 6d 6f 76 65 64 ............device.NotifyRemoved
e1a0 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4c 65 74 20 6c 69 73 74 65 6e ();................//.Let.listen
e1c0 65 72 73 20 6b 6e 6f 77 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 ers.know...............for.(var.
e1e0 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 i.=.0;.i.<.m_DeviceChangeListene
e200 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 rs.length;.++i).................
e220 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 76 69 .m_DeviceChangeListeners[i](devi
e240 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 52 65 6d 6f 76 65 64 29 3b 0d ce,.InputDeviceChange.Removed);.
e260 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 .........}............public.voi
e280 64 20 46 6c 75 73 68 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 28 29 0d 0a 20 20 d.FlushDisconnectedDevices()....
e2a0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 ......{..............m_Disconnec
e2c0 74 65 64 44 65 76 69 63 65 73 2e 43 6c 65 61 72 28 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 tedDevices.Clear(m_DisconnectedD
e2e0 65 76 69 63 65 73 43 6f 75 6e 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 69 73 evicesCount);..............m_Dis
e300 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 43 6f 75 6e 74 20 3d 20 30 3b 0d 0a 20 20 20 20 connectedDevicesCount.=.0;......
e320 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 ....}............public.InputDev
e340 69 63 65 20 54 72 79 47 65 74 44 65 76 69 63 65 28 73 74 72 69 6e 67 20 6e 61 6d 65 4f 72 4c 61 ice.TryGetDevice(string.nameOrLa
e360 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 yout)..........{..............if
e380 20 28 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 6e 61 6d 65 4f 72 4c 61 79 .(string.IsNullOrEmpty(nameOrLay
e3a0 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 out))..................throw.new
e3c0 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 22 4e 61 6d 65 20 69 73 20 6e 75 6c 6c .ArgumentException("Name.is.null
e3e0 20 6f 72 20 65 6d 70 74 79 2e 22 2c 20 6e 61 6d 65 6f 66 28 6e 61 6d 65 4f 72 4c 61 79 6f 75 74 .or.empty.",.nameof(nameOrLayout
e400 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 73 ));................if.(m_Devices
e420 43 6f 75 6e 74 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 Count.==.0)..................ret
e440 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 61 6d urn.null;................var.nam
e460 65 4f 72 4c 61 79 6f 75 74 4c 6f 77 65 72 43 61 73 65 20 3d 20 6e 61 6d 65 4f 72 4c 61 79 6f 75 eOrLayoutLowerCase.=.nameOrLayou
e480 74 2e 54 6f 4c 6f 77 65 72 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 t.ToLower();................for.
e4a0 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 20 (var.i.=.0;.i.<.m_DevicesCount;.
e4c0 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ++i)..............{.............
e4e0 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d 3b 0d .....var.device.=.m_Devices[i];.
e500 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 6d 5f 4e 61 .................if.(device.m_Na
e520 6d 65 2e 54 6f 4c 6f 77 65 72 28 29 20 3d 3d 20 6e 61 6d 65 4f 72 4c 61 79 6f 75 74 4c 6f 77 65 me.ToLower().==.nameOrLayoutLowe
e540 72 43 61 73 65 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 rCase.||......................de
e560 76 69 63 65 2e 6d 5f 4c 61 79 6f 75 74 2e 54 6f 4c 6f 77 65 72 28 29 20 3d 3d 20 6e 61 6d 65 4f vice.m_Layout.ToLower().==.nameO
e580 72 4c 61 79 6f 75 74 4c 6f 77 65 72 43 61 73 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 rLayoutLowerCase)...............
e5a0 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 64 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 .......return.device;...........
e5c0 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b ...}................return.null;
e5e0 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e ..........}............public.In
e600 70 75 74 44 65 76 69 63 65 20 47 65 74 44 65 76 69 63 65 28 73 74 72 69 6e 67 20 6e 61 6d 65 4f putDevice.GetDevice(string.nameO
e620 72 4c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 rLayout)..........{.............
e640 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 54 72 79 47 65 74 44 65 76 69 63 65 28 6e 61 6d 65 4f .var.device.=.TryGetDevice(nameO
e660 72 4c 61 79 6f 75 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 rLayout);..............if.(devic
e680 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f e.==.null)..................thro
e6a0 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 45 78 63 65 70 74 69 6f 6e 28 24 22 43 61 6e 6e 6f 74 w.new.ArgumentException($"Cannot
e6c0 20 66 69 6e 64 20 64 65 76 69 63 65 20 77 69 74 68 20 6e 61 6d 65 20 6f 72 20 6c 61 79 6f 75 74 .find.device.with.name.or.layout
e6e0 20 27 7b 6e 61 6d 65 4f 72 4c 61 79 6f 75 74 7d 27 22 2c 20 6e 61 6d 65 6f 66 28 6e 61 6d 65 4f .'{nameOrLayout}'",.nameof(nameO
e700 72 4c 61 79 6f 75 74 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e rLayout));................return
e720 20 64 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 .device;..........}............p
e740 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 63 65 20 54 72 79 47 65 74 44 65 76 69 63 65 28 54 ublic.InputDevice.TryGetDevice(T
e760 79 70 65 20 6c 61 79 6f 75 74 54 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 ype.layoutType)..........{......
e780 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 4e 61 6d 65 20 3d 20 6d 5f 4c 61 79 6f 75 ........var.layoutName.=.m_Layou
e7a0 74 73 2e 54 72 79 46 69 6e 64 4c 61 79 6f 75 74 46 6f 72 54 79 70 65 28 6c 61 79 6f 75 74 54 79 ts.TryFindLayoutForType(layoutTy
e7c0 70 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 4e 61 6d 65 pe);..............if.(layoutName
e7e0 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 .IsEmpty())..................ret
e800 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 urn.null;................return.
e820 54 72 79 47 65 74 44 65 76 69 63 65 28 6c 61 79 6f 75 74 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 TryGetDevice(layoutName);.......
e840 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 ...}............public.InputDevi
e860 63 65 20 54 72 79 47 65 74 44 65 76 69 63 65 42 79 49 64 28 69 6e 74 20 69 64 29 0d 0a 20 20 20 ce.TryGetDeviceById(int.id).....
e880 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 44 65 76 69 63 65 .....{..............if.(m_Device
e8a0 73 42 79 49 64 2e 54 72 79 47 65 74 56 61 6c 75 65 28 69 64 2c 20 6f 75 74 20 76 61 72 20 72 65 sById.TryGetValue(id,.out.var.re
e8c0 73 75 6c 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 72 sult))..................return.r
e8e0 65 73 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b esult;..............return.null;
e900 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 64 64 73 20 61 ..........}............//.Adds.a
e920 6e 79 20 64 65 76 69 63 65 20 74 68 61 74 27 73 20 62 65 65 6e 20 72 65 70 6f 72 74 65 64 20 74 ny.device.that's.been.reported.t
e940 6f 20 74 68 65 20 73 79 73 74 65 6d 20 62 75 74 20 63 6f 75 6c 64 20 6e 6f 74 20 62 65 20 6d 61 o.the.system.but.could.not.be.ma
e960 74 63 68 65 64 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 61 20 6c 61 79 6f 75 74 20 74 6f tched.to..........//.a.layout.to
e980 20 74 68 65 20 67 69 76 65 6e 20 6c 69 73 74 2e 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 .the.given.list...........public
e9a0 20 69 6e 74 20 47 65 74 55 6e 73 75 70 70 6f 72 74 65 64 44 65 76 69 63 65 73 28 4c 69 73 74 3c .int.GetUnsupportedDevices(List<
e9c0 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 3e 20 64 65 73 63 72 69 70 74 InputDeviceDescription>.descript
e9e0 69 6f 6e 73 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 ions)..........{..............if
ea00 20 28 64 65 73 63 72 69 70 74 69 6f 6e 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 .(descriptions.==.null).........
ea20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c 6c 45 .........throw.new.ArgumentNullE
ea40 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 64 65 73 63 72 69 70 74 69 6f 6e 73 29 29 3b 0d xception(nameof(descriptions));.
ea60 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 75 6d 46 6f 75 6e 64 20 3d 20 30 3b ...............var.numFound.=.0;
ea80 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 ..............for.(var.i.=.0;.i.
eaa0 3c 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a <.m_AvailableDeviceCount;.++i)..
eac0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 ............{..................i
eae0 66 20 28 54 72 79 47 65 74 44 65 76 69 63 65 42 79 49 64 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 f.(TryGetDeviceById(m_AvailableD
eb00 65 76 69 63 65 73 5b 69 5d 2e 64 65 76 69 63 65 49 64 29 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 evices[i].deviceId).!=.null)....
eb20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 ..................continue;.....
eb40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 73 63 72 69 70 74 69 6f 6e 73 2e 41 64 64 28 ...............descriptions.Add(
eb60 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 73 63 72 69 70 74 69 6f m_AvailableDevices[i].descriptio
eb80 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2b 2b 6e 75 6d 46 6f 75 6e 64 3b n);..................++numFound;
eba0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 ..............}................r
ebc0 65 74 75 72 6e 20 6e 75 6d 46 6f 75 6e 64 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 eturn.numFound;..........}......
ebe0 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 74 68 69 73 20 73 68 6f 75 6c 64 20 72 65 73 65 ......////TODO:.this.should.rese
ec00 74 20 74 68 65 20 64 65 76 69 63 65 20 74 6f 20 69 74 73 20 64 65 66 61 75 6c 74 20 73 74 61 74 t.the.device.to.its.default.stat
ec20 65 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 45 6e 61 62 6c 65 4f 72 44 e..........public.void.EnableOrD
ec40 69 73 61 62 6c 65 44 65 76 69 63 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 2c isableDevice(InputDevice.device,
ec60 20 62 6f 6f 6c 20 65 6e 61 62 6c 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 .bool.enable)..........{........
ec80 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 ......if.(device.==.null).......
eca0 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 41 72 67 75 6d 65 6e 74 4e 75 6c ...........throw.new.ArgumentNul
ecc0 6c 45 78 63 65 70 74 69 6f 6e 28 6e 61 6d 65 6f 66 28 64 65 76 69 63 65 29 29 3b 0d 0a 0d 0a 20 lException(nameof(device));.....
ece0 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 20 69 66 20 64 65 76 69 63 65 20 61 ...........//.Ignore.if.device.a
ed00 6c 72 65 61 64 79 20 65 6e 61 62 6c 65 64 2f 64 69 73 61 62 6c 65 64 2e 0d 0a 20 20 20 20 20 20 lready.enabled/disabled.........
ed20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 65 6e 61 62 6c 65 64 20 3d 3d 20 65 6e 61 62 ......if.(device.enabled.==.enab
ed40 6c 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a le)..................return;....
ed60 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 74 2f 63 6c 65 61 72 20 66 6c 61 67 2e 0d 0a ............//.Set/clear.flag...
ed80 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 65 6e 61 62 6c 65 29 0d 0a 20 20 20 20 20 20 ............if.(!enable)........
eda0 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 46 6c 61 67 73 20 7c ..........device.m_DeviceFlags.|
edc0 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 2e 44 69 73 61 62 6c =.InputDevice.DeviceFlags.Disabl
ede0 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 ed;..............else...........
ee00 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 46 6c 61 67 73 20 26 3d 20 7e .......device.m_DeviceFlags.&=.~
ee20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 2e 44 69 73 61 62 6c 65 64 InputDevice.DeviceFlags.Disabled
ee40 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 6e 64 20 63 6f 6d 6d 61 6e 64 ;................//.Send.command
ee60 20 74 6f 20 74 65 6c 6c 20 62 61 63 6b 65 6e 64 20 61 62 6f 75 74 20 73 74 61 74 75 73 20 63 68 .to.tell.backend.about.status.ch
ee80 61 6e 67 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 65 6e 61 62 6c 65 29 0d 0a ange...............if.(enable)..
eea0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 ............{..................v
eec0 61 72 20 63 6f 6d 6d 61 6e 64 20 3d 20 45 6e 61 62 6c 65 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 ar.command.=.EnableDeviceCommand
eee0 2e 43 72 65 61 74 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 .Create();..................devi
ef00 63 65 2e 45 78 65 63 75 74 65 43 6f 6d 6d 61 6e 64 28 72 65 66 20 63 6f 6d 6d 61 6e 64 29 3b 0d ce.ExecuteCommand(ref.command);.
ef20 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 .............}..............else
ef40 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..............{.................
ef60 20 76 61 72 20 63 6f 6d 6d 61 6e 64 20 3d 20 44 69 73 61 62 6c 65 44 65 76 69 63 65 43 6f 6d 6d .var.command.=.DisableDeviceComm
ef80 61 6e 64 2e 43 72 65 61 74 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 and.Create();..................d
efa0 65 76 69 63 65 2e 45 78 65 63 75 74 65 43 6f 6d 6d 61 6e 64 28 72 65 66 20 63 6f 6d 6d 61 6e 64 evice.ExecuteCommand(ref.command
efc0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 );..............}...............
efe0 20 2f 2f 20 4c 65 74 20 6c 69 73 74 65 6e 65 72 73 20 6b 6e 6f 77 2e 0d 0a 20 20 20 20 20 20 20 .//.Let.listeners.know..........
f000 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 43 68 61 6e 67 65 20 3d 20 65 6e 61 62 6c 65 20 3f .....var.deviceChange.=.enable.?
f020 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 45 6e 61 62 6c 65 64 20 3a 20 49 6e 70 .InputDeviceChange.Enabled.:.Inp
f040 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 44 69 73 61 62 6c 65 64 3b 0d 0a 20 20 20 20 20 20 utDeviceChange.Disabled;........
f060 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 ......for.(var.i.=.0;.i.<.m_Devi
f080 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a ceChangeListeners.length;.++i)..
f0a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 ................m_DeviceChangeLi
f0c0 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 76 69 63 65 2c 20 64 65 76 69 63 65 43 68 61 6e 67 65 29 steners[i](device,.deviceChange)
f0e0 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f ;..........}............////TODO
f100 3a 20 73 75 70 70 6f 72 74 20 63 6f 6d 62 69 6e 69 6e 67 20 6d 6f 6e 69 74 6f 72 73 20 66 6f 72 :.support.combining.monitors.for
f120 20 62 69 74 66 69 65 6c 64 73 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 .bitfields..........public.void.
f140 41 64 64 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 28 49 6e 70 75 74 43 6f 6e 74 72 AddStateChangeMonitor(InputContr
f160 6f 6c 20 63 6f 6e 74 72 6f 6c 2c 20 49 49 6e 70 75 74 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e ol.control,.IInputStateChangeMon
f180 69 74 6f 72 20 6d 6f 6e 69 74 6f 72 2c 20 6c 6f 6e 67 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 29 itor.monitor,.long.monitorIndex)
f1a0 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 ..........{..............Debug.A
f1c0 73 73 65 72 74 28 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 20 3e 20 30 29 3b 0d 0a 0d 0a 20 20 ssert(m_DevicesCount.>.0);......
f1e0 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 63 6f 6e 74 72 6f 6c 2e 64 ..........var.device.=.control.d
f200 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 49 6e evice;..............var.deviceIn
f220 64 65 78 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 3b 0d 0a 20 20 20 dex.=.device.m_DeviceIndex;.....
f240 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 64 65 76 69 63 65 49 6e 64 65 .........Debug.Assert(deviceInde
f260 78 20 21 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 6b 49 6e 76 61 6c 69 64 44 65 76 69 63 65 49 x.!=.InputDevice.kInvalidDeviceI
f280 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 6c 6c 6f 63 61 74 ndex);................//.Allocat
f2a0 65 2f 72 65 61 6c 6c 6f 63 61 74 65 20 6d 6f 6e 69 74 6f 72 20 61 72 72 61 79 73 2c 20 69 66 20 e/reallocate.monitor.arrays,.if.
f2c0 6e 65 63 65 73 73 61 72 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 6c 61 necessary...............//.We.la
f2e0 7a 79 2d 73 79 6e 63 20 69 74 20 74 6f 20 61 72 72 61 79 20 6f 66 20 64 65 76 69 63 65 73 2e 0d zy-sync.it.to.array.of.devices..
f300 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f .............if.(m_StateChangeMo
f320 6e 69 74 6f 72 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 nitors.==.null).................
f340 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 20 3d 20 6e 65 77 20 53 74 61 .m_StateChangeMonitors.=.new.Sta
f360 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 46 6f 72 44 65 76 69 63 65 5b 6d 5f 44 65 76 69 teChangeMonitorsForDevice[m_Devi
f380 63 65 73 43 6f 75 6e 74 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 69 66 20 cesCount];..............else.if.
f3a0 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 2e 4c 65 6e 67 74 68 20 3c 3d (m_StateChangeMonitors.Length.<=
f3c0 20 64 65 76 69 63 65 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 .deviceIndex)..................A
f3e0 72 72 61 79 2e 52 65 73 69 7a 65 28 72 65 66 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e rray.Resize(ref.m_StateChangeMon
f400 69 74 6f 72 73 2c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 29 3b 0d 0a 0d 0a 20 20 20 20 20 itors,.m_DevicesCount);.........
f420 20 20 20 20 20 20 20 2f 2f 20 41 64 64 20 72 65 63 6f 72 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 .......//.Add.record............
f440 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 69 63 65 49 ...m_StateChangeMonitors[deviceI
f460 6e 64 65 78 5d 2e 41 64 64 28 63 6f 6e 74 72 6f 6c 2c 20 6d 6f 6e 69 74 6f 72 2c 20 6d 6f 6e 69 ndex].Add(control,.monitor,.moni
f480 74 6f 72 49 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 torIndex);..........}...........
f4a0 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 52 65 6d 6f 76 65 53 74 61 74 65 43 68 61 6e 67 65 4d .private.void.RemoveStateChangeM
f4c0 6f 6e 69 74 6f 72 73 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 29 0d 0a 20 20 20 onitors(InputDevice.device).....
f4e0 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 74 65 43 .....{..............if.(m_StateC
f500 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 hangeMonitors.==.null)..........
f520 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 ........return;................v
f540 61 72 20 64 65 76 69 63 65 49 6e 64 65 78 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 ar.deviceIndex.=.device.m_Device
f560 49 6e 64 65 78 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 Index;..............Debug.Assert
f580 28 64 65 76 69 63 65 49 6e 64 65 78 20 21 3d 20 49 6e 70 75 74 44 65 76 69 63 65 2e 6b 49 6e 76 (deviceIndex.!=.InputDevice.kInv
f5a0 61 6c 69 64 44 65 76 69 63 65 49 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 alidDeviceIndex);...............
f5c0 20 69 66 20 28 64 65 76 69 63 65 49 6e 64 65 78 20 3e 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 .if.(deviceIndex.>=.m_StateChang
f5e0 65 4d 6f 6e 69 74 6f 72 73 2e 4c 65 6e 67 74 68 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 eMonitors.Length)...............
f600 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 ...return;................m_Stat
f620 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 69 63 65 49 6e 64 65 78 5d 2e 43 6c 65 eChangeMonitors[deviceIndex].Cle
f640 61 72 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 6c 65 61 72 20 74 69 ar();................//.Clear.ti
f660 6d 65 6f 75 74 73 20 70 65 6e 64 69 6e 67 20 6f 6e 20 61 6e 79 20 63 6f 6e 74 72 6f 6c 20 6f 6e meouts.pending.on.any.control.on
f680 20 74 68 65 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 .the.device...............for.(v
f6a0 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 ar.i.=.0;.i.<.m_StateChangeMonit
f6c0 6f 72 54 69 6d 65 6f 75 74 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 orTimeouts.length;.++i).........
f6e0 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f .........if.(m_StateChangeMonito
f700 72 54 69 6d 65 6f 75 74 73 5b 69 5d 2e 63 6f 6e 74 72 6f 6c 3f 2e 64 65 76 69 63 65 20 3d 3d 20 rTimeouts[i].control?.device.==.
f720 64 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 device)......................m_S
f740 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 5b 69 5d 20 3d 20 64 tateChangeMonitorTimeouts[i].=.d
f760 65 66 61 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 efault;..........}............pu
f780 62 6c 69 63 20 76 6f 69 64 20 52 65 6d 6f 76 65 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 blic.void.RemoveStateChangeMonit
f7a0 6f 72 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 20 63 6f 6e 74 72 6f 6c 2c 20 49 49 6e 70 75 74 53 or(InputControl.control,.IInputS
f7c0 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 20 6d 6f 6e 69 74 6f 72 2c 20 6c 6f 6e 67 20 tateChangeMonitor.monitor,.long.
f7e0 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 monitorIndex)..........{........
f800 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 20 ......if.(m_StateChangeMonitors.
f820 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e ==.null)..................return
f840 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 63 6f ;................var.device.=.co
f860 6e 74 72 6f 6c 2e 64 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 ntrol.device;..............var.d
f880 65 76 69 63 65 49 6e 64 65 78 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 eviceIndex.=.device.m_DeviceInde
f8a0 78 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 20 69 66 20 64 x;................//.Ignore.if.d
f8c0 65 76 69 63 65 20 68 61 73 20 61 6c 72 65 61 64 79 20 62 65 65 6e 20 72 65 6d 6f 76 65 64 2e 0d evice.has.already.been.removed..
f8e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 49 6e 64 65 78 20 3d 3d 20 .............if.(deviceIndex.==.
f900 49 6e 70 75 74 44 65 76 69 63 65 2e 6b 49 6e 76 61 6c 69 64 44 65 76 69 63 65 49 6e 64 65 78 29 InputDevice.kInvalidDeviceIndex)
f920 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 ..................return;.......
f940 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 20 69 66 20 74 68 65 72 65 20 61 72 65 20 .........//.Ignore.if.there.are.
f960 6e 6f 20 73 74 61 74 65 20 6d 6f 6e 69 74 6f 72 73 20 73 65 74 20 75 70 20 66 6f 72 20 74 68 65 no.state.monitors.set.up.for.the
f980 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 .device...............if.(device
f9a0 49 6e 64 65 78 20 3e 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 2e 4c Index.>=.m_StateChangeMonitors.L
f9c0 65 6e 67 74 68 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d ength)..................return;.
f9e0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 ...............m_StateChangeMoni
fa00 74 6f 72 73 5b 64 65 76 69 63 65 49 6e 64 65 78 5d 2e 52 65 6d 6f 76 65 28 6d 6f 6e 69 74 6f 72 tors[deviceIndex].Remove(monitor
fa20 2c 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ,.monitorIndex);................
fa40 2f 2f 20 52 65 6d 6f 76 65 20 70 65 6e 64 69 6e 67 20 74 69 6d 65 6f 75 74 73 20 6f 6e 20 74 68 //.Remove.pending.timeouts.on.th
fa60 65 20 6d 6f 6e 69 74 6f 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 e.monitor...............for.(var
fa80 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 .i.=.0;.i.<.m_StateChangeMonitor
faa0 54 69 6d 65 6f 75 74 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 Timeouts.length;.++i)...........
fac0 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 .......if.(m_StateChangeMonitorT
fae0 69 6d 65 6f 75 74 73 5b 69 5d 2e 6d 6f 6e 69 74 6f 72 20 3d 3d 20 6d 6f 6e 69 74 6f 72 20 26 26 imeouts[i].monitor.==.monitor.&&
fb00 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 ......................m_StateCha
fb20 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 5b 69 5d 2e 6d 6f 6e 69 74 6f 72 49 6e 64 ngeMonitorTimeouts[i].monitorInd
fb40 65 78 20 3d 3d 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ex.==.monitorIndex).............
fb60 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d .........m_StateChangeMonitorTim
fb80 65 6f 75 74 73 5b 69 5d 20 3d 20 64 65 66 61 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a eouts[i].=.default;..........}..
fba0 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 41 64 64 53 74 61 74 65 43 68 ..........public.void.AddStateCh
fbc0 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 20 angeMonitorTimeout(InputControl.
fbe0 63 6f 6e 74 72 6f 6c 2c 20 49 49 6e 70 75 74 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f control,.IInputStateChangeMonito
fc00 72 20 6d 6f 6e 69 74 6f 72 2c 20 64 6f 75 62 6c 65 20 74 69 6d 65 2c 20 6c 6f 6e 67 20 6d 6f 6e r.monitor,.double.time,.long.mon
fc20 69 74 6f 72 49 6e 64 65 78 2c 20 69 6e 74 20 74 69 6d 65 72 49 6e 64 65 78 29 0d 0a 20 20 20 20 itorIndex,.int.timerIndex)......
fc40 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 ....{..............m_StateChange
fc60 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 2e 41 70 70 65 6e 64 28 0d 0a 20 20 20 20 20 20 20 MonitorTimeouts.Append(.........
fc80 20 20 20 20 20 20 20 20 20 6e 65 77 20 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 .........new.StateChangeMonitorT
fca0 69 6d 65 6f 75 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 imeout..................{.......
fcc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 72 6f 6c 20 3d 20 63 6f 6e 74 72 6f 6c ...............control.=.control
fce0 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 69 6d 65 20 3d 20 74 69 ,......................time.=.ti
fd00 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 6f 6e 69 74 6f 72 me,......................monitor
fd20 20 3d 20 6d 6f 6e 69 74 6f 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .=.monitor,.....................
fd40 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 20 3d 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 2c 0d 0a 20 .monitorIndex.=.monitorIndex,...
fd60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 69 6d 65 72 49 6e 64 65 78 20 3d 20 ...................timerIndex.=.
fd80 74 69 6d 65 72 49 6e 64 65 78 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 29 3b timerIndex,..................});
fda0 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f ..........}............public.vo
fdc0 69 64 20 52 65 6d 6f 76 65 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f id.RemoveStateChangeMonitorTimeo
fde0 75 74 28 49 49 6e 70 75 74 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 20 6d 6f 6e 69 ut(IInputStateChangeMonitor.moni
fe00 74 6f 72 2c 20 6c 6f 6e 67 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 2c 20 69 6e 74 20 74 69 6d 65 tor,.long.monitorIndex,.int.time
fe20 72 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 rIndex)..........{..............
fe40 76 61 72 20 74 69 6d 65 6f 75 74 43 6f 75 6e 74 20 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 var.timeoutCount.=.m_StateChange
fe60 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 2e 6c 65 6e 67 74 68 3b 0d 0a 20 20 20 20 20 20 20 MonitorTimeouts.length;.........
fe80 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 74 69 6d 65 6f 75 74 .....for.(var.i.=.0;.i.<.timeout
fea0 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 Count;.++i)..............{......
fec0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 63 61 6e 20 77 65 20 61 ............////REVIEW:.can.we.a
fee0 76 6f 69 64 20 74 68 65 20 72 65 70 65 61 74 65 64 20 61 72 72 61 79 20 6c 6f 6f 6b 75 70 73 20 void.the.repeated.array.lookups.
ff00 77 69 74 68 6f 75 74 20 63 6f 70 79 69 6e 67 20 74 68 65 20 73 74 72 75 63 74 20 6f 75 74 3f 0d without.copying.the.struct.out?.
ff20 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 52 65 66 65 72 65 6e 63 65 45 71 .................if.(ReferenceEq
ff40 75 61 6c 73 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 uals(m_StateChangeMonitorTimeout
ff60 73 5b 69 5d 2e 6d 6f 6e 69 74 6f 72 2c 20 6d 6f 6e 69 74 6f 72 29 0d 0a 20 20 20 20 20 20 20 20 s[i].monitor,.monitor)..........
ff80 20 20 20 20 20 20 20 20 20 20 20 20 26 26 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 ............&&.m_StateChangeMoni
ffa0 74 6f 72 54 69 6d 65 6f 75 74 73 5b 69 5d 2e 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 20 3d 3d 20 6d torTimeouts[i].monitorIndex.==.m
ffc0 6f 6e 69 74 6f 72 49 6e 64 65 78 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 onitorIndex.....................
ffe0 20 26 26 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 .&&.m_StateChangeMonitorTimeouts
10000 5b 69 5d 2e 74 69 6d 65 72 49 6e 64 65 78 20 3d 3d 20 74 69 6d 65 72 49 6e 64 65 78 29 0d 0a 20 [i].timerIndex.==.timerIndex)...
10020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...............{................
10040 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 ......m_StateChangeMonitorTimeou
10060 74 73 5b 69 5d 20 3d 20 64 65 66 61 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ts[i].=.default;................
10080 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d ......break;..................}.
100a0 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .............}..........}.......
100c0 20 20 20 20 20 70 75 62 6c 69 63 20 75 6e 73 61 66 65 20 76 6f 69 64 20 51 75 65 75 65 45 76 65 .....public.unsafe.void.QueueEve
100e0 6e 74 28 49 6e 70 75 74 45 76 65 6e 74 50 74 72 20 70 74 72 29 0d 0a 20 20 20 20 20 20 20 20 7b nt(InputEventPtr.ptr)..........{
10100 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 51 75 65 75 65 45 76 65 ..............m_Runtime.QueueEve
10120 6e 74 28 70 74 72 2e 64 61 74 61 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 nt(ptr.data);..........}........
10140 20 20 20 20 70 75 62 6c 69 63 20 75 6e 73 61 66 65 20 76 6f 69 64 20 51 75 65 75 65 45 76 65 6e ....public.unsafe.void.QueueEven
10160 74 3c 54 45 76 65 6e 74 3e 28 72 65 66 20 54 45 76 65 6e 74 20 69 6e 70 75 74 45 76 65 6e 74 29 t<TEvent>(ref.TEvent.inputEvent)
10180 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 77 68 65 72 65 20 54 45 76 65 6e 74 20 3a 20 73 74 72 ..............where.TEvent.:.str
101a0 75 63 74 2c 20 49 49 6e 70 75 74 45 76 65 6e 74 54 79 70 65 49 6e 66 6f 0d 0a 20 20 20 20 20 20 uct,.IInputEventTypeInfo........
101c0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 6f 6e 27 74 20 62 6f 74 68 65 72 ..{..............//.Don't.bother
101e0 20 6b 65 65 70 69 6e 67 20 74 68 65 20 64 61 74 61 20 6f 6e 20 74 68 65 20 6d 61 6e 61 67 65 64 .keeping.the.data.on.the.managed
10200 20 73 69 64 65 2e 20 4a 75 73 74 20 73 74 75 66 66 20 74 68 65 20 72 61 77 20 64 61 74 61 20 64 .side..Just.stuff.the.raw.data.d
10220 69 72 65 63 74 6c 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 74 6f 20 74 68 65 irectly..............//.into.the
10240 20 6e 61 74 69 76 65 20 62 75 66 66 65 72 73 2e 20 54 68 69 73 20 61 6c 73 6f 20 6d 65 61 6e 73 .native.buffers..This.also.means
10260 20 74 68 69 73 20 6d 65 74 68 6f 64 20 69 73 20 74 68 72 65 61 64 2d 73 61 66 65 2e 0d 0a 20 20 .this.method.is.thread-safe.....
10280 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 51 75 65 75 65 45 76 65 6e 74 28 28 ..........m_Runtime.QueueEvent((
102a0 49 6e 70 75 74 45 76 65 6e 74 2a 29 55 6e 73 61 66 65 55 74 69 6c 69 74 79 2e 41 64 64 72 65 73 InputEvent*)UnsafeUtility.Addres
102c0 73 4f 66 28 72 65 66 20 69 6e 70 75 74 45 76 65 6e 74 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d sOf(ref.inputEvent));..........}
102e0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 55 70 64 61 74 65 28 29 ............public.void.Update()
10300 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 55 70 64 61 74 65 28 ..........{..............Update(
10320 64 65 66 61 75 6c 74 55 70 64 61 74 65 54 79 70 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a defaultUpdateType);..........}..
10340 0d 0a 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 55 70 64 61 74 65 28 49 6e 70 ..........public.void.Update(Inp
10360 75 74 55 70 64 61 74 65 54 79 70 65 20 75 70 64 61 74 65 54 79 70 65 29 0d 0a 20 20 20 20 20 20 utUpdateType.updateType)........
10380 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 55 70 64 61 74 ..{..............m_Runtime.Updat
103a0 65 28 75 70 64 61 74 65 54 79 70 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 e(updateType);..........}.......
103c0 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 49 6e 69 74 69 61 6c 69 7a 65 28 49 49 .....internal.void.Initialize(II
103e0 6e 70 75 74 52 75 6e 74 69 6d 65 20 72 75 6e 74 69 6d 65 2c 20 49 6e 70 75 74 53 65 74 74 69 6e nputRuntime.runtime,.InputSettin
10400 67 73 20 73 65 74 74 69 6e 67 73 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 gs.settings)..........{.........
10420 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 73 65 74 74 69 6e 67 73 20 21 3d 20 6e 75 .....Debug.Assert(settings.!=.nu
10440 6c 6c 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 65 74 74 69 6e 67 73 20 3d ll);................m_Settings.=
10460 20 73 65 74 74 69 6e 67 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 69 74 69 61 .settings;................Initia
10480 6c 69 7a 65 44 61 74 61 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 73 74 61 6c 6c lizeData();..............Install
104a0 52 75 6e 74 69 6d 65 28 72 75 6e 74 69 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 Runtime(runtime);..............I
104c0 6e 73 74 61 6c 6c 47 6c 6f 62 61 6c 73 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 nstallGlobals();................
104e0 41 70 70 6c 79 53 65 74 74 69 6e 67 73 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 ApplySettings();..........}.....
10500 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 44 65 73 74 72 6f 79 28 29 0d 0a .......internal.void.Destroy()..
10520 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 68 65 72 65 20 ........{..............//.There.
10540 69 73 6e 27 74 20 72 65 61 6c 6c 79 20 6d 75 63 68 20 6f 66 20 61 20 70 6f 69 6e 74 20 69 6e 20 isn't.really.much.of.a.point.in.
10560 72 65 6d 6f 76 69 6e 67 20 64 65 76 69 63 65 73 20 62 75 74 20 77 65 20 73 74 69 6c 6c 0d 0a 20 removing.devices.but.we.still...
10580 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 77 61 6e 74 20 74 6f 20 63 6c 65 61 72 20 6f 75 74 20 ...........//.want.to.clear.out.
105a0 61 6e 79 20 67 6c 6f 62 61 6c 20 73 74 61 74 65 20 74 68 65 79 20 6d 61 79 20 62 65 20 6b 65 65 any.global.state.they.may.be.kee
105c0 70 69 6e 67 2e 20 53 6f 20 6a 75 73 74 20 74 65 6c 6c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ping..So.just.tell..............
105e0 2f 2f 20 74 68 65 20 64 65 76 69 63 65 73 20 74 68 61 74 20 74 68 65 79 20 67 6f 74 20 72 65 6d //.the.devices.that.they.got.rem
10600 6f 76 65 64 20 77 69 74 68 6f 75 74 20 61 63 74 75 61 6c 6c 79 20 72 65 6d 6f 76 69 6e 67 20 74 oved.without.actually.removing.t
10620 68 65 6d 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 hem...............for.(var.i.=.0
10640 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 ;.i.<.m_DevicesCount;.++i)......
10660 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d 2e 4e 6f 74 69 66 79 52 ............m_Devices[i].NotifyR
10680 65 6d 6f 76 65 64 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 72 65 65 emoved();................//.Free
106a0 20 61 6c 6c 20 73 74 61 74 65 20 6d 65 6d 6f 72 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .all.state.memory...............
106c0 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 46 72 65 65 41 6c 6c 28 29 3b 0d 0a 0d 0a 20 20 20 m_StateBuffers.FreeAll();.......
106e0 20 20 20 20 20 20 20 20 20 2f 2f 20 55 6e 69 6e 73 74 61 6c 6c 20 67 6c 6f 62 61 6c 73 2e 0d 0a .........//.Uninstall.globals...
10700 20 20 20 20 20 20 20 20 20 20 20 20 55 6e 69 6e 73 74 61 6c 6c 47 6c 6f 62 61 6c 73 28 29 3b 0d ............UninstallGlobals();.
10720 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 65 73 74 72 6f 79 20 73 65 74 74 69 6e ...............//.Destroy.settin
10740 67 73 20 69 66 20 74 68 65 79 20 61 72 65 20 74 65 6d 70 6f 72 61 72 79 2e 0d 0a 20 20 20 20 20 gs.if.they.are.temporary........
10760 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 65 74 74 69 6e 67 73 20 21 3d 20 6e 75 6c 6c 20 26 26 .......if.(m_Settings.!=.null.&&
10780 20 6d 5f 53 65 74 74 69 6e 67 73 2e 68 69 64 65 46 6c 61 67 73 20 3d 3d 20 48 69 64 65 46 6c 61 .m_Settings.hideFlags.==.HideFla
107a0 67 73 2e 48 69 64 65 41 6e 64 44 6f 6e 74 53 61 76 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 gs.HideAndDontSave).............
107c0 20 20 20 20 20 4f 62 6a 65 63 74 2e 44 65 73 74 72 6f 79 49 6d 6d 65 64 69 61 74 65 28 6d 5f 53 .....Object.DestroyImmediate(m_S
107e0 65 74 74 69 6e 67 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ettings);..........}............
10800 69 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 49 6e 69 74 69 61 6c 69 7a 65 44 61 74 61 28 29 0d 0a internal.void.InitializeData()..
10820 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4c 61 79 6f 75 74 73 ........{..............m_Layouts
10840 2e 41 6c 6c 6f 63 61 74 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 50 72 6f 63 .Allocate();..............m_Proc
10860 65 73 73 6f 72 73 2e 49 6e 69 74 69 61 6c 69 7a 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 essors.Initialize();............
10880 20 20 6d 5f 49 6e 74 65 72 61 63 74 69 6f 6e 73 2e 49 6e 69 74 69 61 6c 69 7a 65 28 29 3b 0d 0a ..m_Interactions.Initialize();..
108a0 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 43 6f 6d 70 6f 73 69 74 65 73 2e 49 6e 69 74 69 61 6c ............m_Composites.Initial
108c0 69 7a 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 73 42 79 49 ize();..............m_DevicesByI
108e0 64 20 3d 20 6e 65 77 20 44 69 63 74 69 6f 6e 61 72 79 3c 69 6e 74 2c 20 49 6e 70 75 74 44 65 76 d.=.new.Dictionary<int,.InputDev
10900 69 63 65 3e 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 65 74 65 72 6d ice>();................//.Determ
10920 69 6e 65 20 6f 75 72 20 64 65 66 61 75 6c 74 20 73 65 74 20 6f 66 20 65 6e 61 62 6c 65 64 20 75 ine.our.default.set.of.enabled.u
10940 70 64 61 74 65 20 74 79 70 65 73 2e 20 42 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 pdate.types..By..............//.
10960 64 65 66 61 75 6c 74 20 77 65 20 65 6e 61 62 6c 65 20 62 6f 74 68 20 66 69 78 65 64 20 61 6e 64 default.we.enable.both.fixed.and
10980 20 64 79 6e 61 6d 69 63 20 75 70 64 61 74 65 20 62 65 63 61 75 73 65 0d 0a 20 20 20 20 20 20 20 .dynamic.update.because.........
109a0 20 20 20 20 20 2f 2f 20 77 65 20 64 6f 6e 27 74 20 6b 6e 6f 77 20 77 68 69 63 68 20 6f 6e 65 20 .....//.we.don't.know.which.one.
109c0 74 68 65 20 75 73 65 72 20 69 73 20 67 6f 69 6e 67 20 74 6f 20 75 73 65 2e 20 54 68 65 20 75 73 the.user.is.going.to.use..The.us
109e0 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 63 61 6e 20 6d 61 6e 75 61 6c 6c 79 20 er..............//.can.manually.
10a00 74 75 72 6e 20 6f 66 66 20 6f 6e 65 20 6f 66 20 74 68 65 6d 20 74 6f 20 6f 70 74 69 6d 69 7a 65 turn.off.one.of.them.to.optimize
10a20 20 6f 70 65 72 61 74 69 6f 6e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 55 70 64 61 74 .operation...............m_Updat
10a40 65 4d 61 73 6b 20 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 44 79 6e 61 6d 69 63 20 eMask.=.InputUpdateType.Dynamic.
10a60 7c 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 46 69 78 65 64 3b 0d 0a 20 20 20 20 20 20 |.InputUpdateType.Fixed;........
10a80 20 20 20 20 20 20 6d 5f 48 61 73 46 6f 63 75 73 20 3d 20 41 70 70 6c 69 63 61 74 69 6f 6e 2e 69 ......m_HasFocus.=.Application.i
10aa0 73 46 6f 63 75 73 65 64 3b 0d 0a 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 sFocused;..#if.UNITY_EDITOR.....
10ac0 20 20 20 20 20 20 20 20 20 6d 5f 55 70 64 61 74 65 4d 61 73 6b 20 7c 3d 20 49 6e 70 75 74 55 70 .........m_UpdateMask.|=.InputUp
10ae0 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 3b 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 dateType.Editor;..#endif........
10b00 20 20 20 20 20 20 20 20 2f 2f 20 44 65 66 61 75 6c 74 20 70 6f 6c 6c 69 6e 67 20 66 72 65 71 75 ........//.Default.polling.frequ
10b20 65 6e 63 79 20 69 73 20 36 30 20 48 7a 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 50 6f ency.is.60.Hz...............m_Po
10b40 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 20 3d 20 36 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 llingFrequency.=.60;............
10b60 20 20 20 20 2f 2f 20 52 65 67 69 73 74 65 72 20 6c 61 79 6f 75 74 73 2e 0d 0a 20 20 20 20 20 20 ....//.Register.layouts.........
10b80 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 41 78 69 ......RegisterControlLayout("Axi
10ba0 73 22 2c 20 74 79 70 65 6f 66 28 41 78 69 73 43 6f 6e 74 72 6f 6c 29 29 3b 20 2f 2f 20 43 6f 6e s",.typeof(AxisControl));.//.Con
10bc0 74 72 6f 6c 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 trols...............RegisterCont
10be0 72 6f 6c 4c 61 79 6f 75 74 28 22 42 75 74 74 6f 6e 22 2c 20 74 79 70 65 6f 66 28 42 75 74 74 6f rolLayout("Button",.typeof(Butto
10c00 6e 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 nControl));..............Registe
10c20 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 44 69 73 63 72 65 74 65 42 75 74 74 6f 6e 22 2c rControlLayout("DiscreteButton",
10c40 20 74 79 70 65 6f 66 28 44 69 73 63 72 65 74 65 42 75 74 74 6f 6e 43 6f 6e 74 72 6f 6c 29 29 3b .typeof(DiscreteButtonControl));
10c60 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 ..............RegisterControlLay
10c80 6f 75 74 28 22 4b 65 79 22 2c 20 74 79 70 65 6f 66 28 4b 65 79 43 6f 6e 74 72 6f 6c 29 29 3b 0d out("Key",.typeof(KeyControl));.
10ca0 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f .............RegisterControlLayo
10cc0 75 74 28 22 41 6e 61 6c 6f 67 22 2c 20 74 79 70 65 6f 66 28 41 78 69 73 43 6f 6e 74 72 6f 6c 29 ut("Analog",.typeof(AxisControl)
10ce0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c );..............RegisterControlL
10d00 61 79 6f 75 74 28 22 49 6e 74 65 67 65 72 22 2c 20 74 79 70 65 6f 66 28 49 6e 74 65 67 65 72 43 ayout("Integer",.typeof(IntegerC
10d20 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 ontrol));..............RegisterC
10d40 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 44 69 67 69 74 61 6c 22 2c 20 74 79 70 65 6f 66 28 49 ontrolLayout("Digital",.typeof(I
10d60 6e 74 65 67 65 72 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 ntegerControl));..............Re
10d80 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 44 6f 75 62 6c 65 22 2c 20 74 79 gisterControlLayout("Double",.ty
10da0 70 65 6f 66 28 44 6f 75 62 6c 65 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 peof(DoubleControl));...........
10dc0 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 56 65 63 74 6f 72 ...RegisterControlLayout("Vector
10de0 32 22 2c 20 74 79 70 65 6f 66 28 56 65 63 74 6f 72 32 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 2",.typeof(Vector2Control));....
10e00 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 ..........RegisterControlLayout(
10e20 22 56 65 63 74 6f 72 33 22 2c 20 74 79 70 65 6f 66 28 56 65 63 74 6f 72 33 43 6f 6e 74 72 6f 6c "Vector3",.typeof(Vector3Control
10e40 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c ));..............RegisterControl
10e60 4c 61 79 6f 75 74 28 22 51 75 61 74 65 72 6e 69 6f 6e 22 2c 20 74 79 70 65 6f 66 28 51 75 61 74 Layout("Quaternion",.typeof(Quat
10e80 65 72 6e 69 6f 6e 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 ernionControl));..............Re
10ea0 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 53 74 69 63 6b 22 2c 20 74 79 70 gisterControlLayout("Stick",.typ
10ec0 65 6f 66 28 53 74 69 63 6b 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 eof(StickControl));.............
10ee0 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 44 70 61 64 22 2c 20 74 .RegisterControlLayout("Dpad",.t
10f00 79 70 65 6f 66 28 44 70 61 64 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ypeof(DpadControl));............
10f20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 44 70 61 64 41 78 69 ..RegisterControlLayout("DpadAxi
10f40 73 22 2c 20 74 79 70 65 6f 66 28 44 70 61 64 43 6f 6e 74 72 6f 6c 2e 44 70 61 64 41 78 69 73 43 s",.typeof(DpadControl.DpadAxisC
10f60 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 ontrol));..............RegisterC
10f80 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 41 6e 79 4b 65 79 22 2c 20 74 79 70 65 6f 66 28 41 6e ontrolLayout("AnyKey",.typeof(An
10fa0 79 4b 65 79 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 yKeyControl));..............Regi
10fc0 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 54 6f 75 63 68 22 2c 20 74 79 70 65 6f sterControlLayout("Touch",.typeo
10fe0 66 28 54 6f 75 63 68 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 f(TouchControl));..............R
11000 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 54 6f 75 63 68 50 68 61 73 65 egisterControlLayout("TouchPhase
11020 22 2c 20 74 79 70 65 6f 66 28 54 6f 75 63 68 50 68 61 73 65 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a ",.typeof(TouchPhaseControl));..
11040 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 ............RegisterControlLayou
11060 74 28 22 54 6f 75 63 68 50 72 65 73 73 22 2c 20 74 79 70 65 6f 66 28 54 6f 75 63 68 50 72 65 73 t("TouchPress",.typeof(TouchPres
11080 73 43 6f 6e 74 72 6f 6c 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 sControl));................Regis
110a0 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 47 61 6d 65 70 61 64 22 2c 20 74 79 70 65 terControlLayout("Gamepad",.type
110c0 6f 66 28 47 61 6d 65 70 61 64 29 29 3b 20 2f 2f 20 44 65 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 of(Gamepad));.//.Devices........
110e0 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 4a 6f .......RegisterControlLayout("Jo
11100 79 73 74 69 63 6b 22 2c 20 74 79 70 65 6f 66 28 4a 6f 79 73 74 69 63 6b 29 29 3b 0d 0a 20 20 20 ystick",.typeof(Joystick));.....
11120 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 .........RegisterControlLayout("
11140 4b 65 79 62 6f 61 72 64 22 2c 20 74 79 70 65 6f 66 28 4b 65 79 62 6f 61 72 64 29 29 3b 0d 0a 20 Keyboard",.typeof(Keyboard));...
11160 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 ...........RegisterControlLayout
11180 28 22 50 6f 69 6e 74 65 72 22 2c 20 74 79 70 65 6f 66 28 50 6f 69 6e 74 65 72 29 29 3b 0d 0a 20 ("Pointer",.typeof(Pointer));...
111a0 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 ...........RegisterControlLayout
111c0 28 22 4d 6f 75 73 65 22 2c 20 74 79 70 65 6f 66 28 4d 6f 75 73 65 29 29 3b 0d 0a 20 20 20 20 20 ("Mouse",.typeof(Mouse));.......
111e0 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 50 65 .......RegisterControlLayout("Pe
11200 6e 22 2c 20 74 79 70 65 6f 66 28 50 65 6e 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 n",.typeof(Pen));..............R
11220 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 54 6f 75 63 68 73 63 72 65 65 egisterControlLayout("Touchscree
11240 6e 22 2c 20 74 79 70 65 6f 66 28 54 6f 75 63 68 73 63 72 65 65 6e 29 29 3b 0d 0a 20 20 20 20 20 n",.typeof(Touchscreen));.......
11260 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 53 65 .......RegisterControlLayout("Se
11280 6e 73 6f 72 22 2c 20 74 79 70 65 6f 66 28 53 65 6e 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 nsor",.typeof(Sensor));.........
112a0 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 41 63 63 65 .....RegisterControlLayout("Acce
112c0 6c 65 72 6f 6d 65 74 65 72 22 2c 20 74 79 70 65 6f 66 28 41 63 63 65 6c 65 72 6f 6d 65 74 65 72 lerometer",.typeof(Accelerometer
112e0 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c ));..............RegisterControl
11300 4c 61 79 6f 75 74 28 22 47 79 72 6f 73 63 6f 70 65 22 2c 20 74 79 70 65 6f 66 28 47 79 72 6f 73 Layout("Gyroscope",.typeof(Gyros
11320 63 6f 70 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e cope));..............RegisterCon
11340 74 72 6f 6c 4c 61 79 6f 75 74 28 22 47 72 61 76 69 74 79 53 65 6e 73 6f 72 22 2c 20 74 79 70 65 trolLayout("GravitySensor",.type
11360 6f 66 28 47 72 61 76 69 74 79 53 65 6e 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 of(GravitySensor));.............
11380 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 41 74 74 69 74 75 64 65 .RegisterControlLayout("Attitude
113a0 53 65 6e 73 6f 72 22 2c 20 74 79 70 65 6f 66 28 41 74 74 69 74 75 64 65 53 65 6e 73 6f 72 29 29 Sensor",.typeof(AttitudeSensor))
113c0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 ;..............RegisterControlLa
113e0 79 6f 75 74 28 22 4c 69 6e 65 61 72 41 63 63 65 6c 65 72 61 74 69 6f 6e 53 65 6e 73 6f 72 22 2c yout("LinearAccelerationSensor",
11400 20 74 79 70 65 6f 66 28 4c 69 6e 65 61 72 41 63 63 65 6c 65 72 61 74 69 6f 6e 53 65 6e 73 6f 72 .typeof(LinearAccelerationSensor
11420 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c ));..............RegisterControl
11440 4c 61 79 6f 75 74 28 22 4d 61 67 6e 65 74 69 63 46 69 65 6c 64 53 65 6e 73 6f 72 22 2c 20 74 79 Layout("MagneticFieldSensor",.ty
11460 70 65 6f 66 28 4d 61 67 6e 65 74 69 63 46 69 65 6c 64 53 65 6e 73 6f 72 29 29 3b 0d 0a 20 20 20 peof(MagneticFieldSensor));.....
11480 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 .........RegisterControlLayout("
114a0 4c 69 67 68 74 53 65 6e 73 6f 72 22 2c 20 74 79 70 65 6f 66 28 4c 69 67 68 74 53 65 6e 73 6f 72 LightSensor",.typeof(LightSensor
114c0 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c ));..............RegisterControl
114e0 4c 61 79 6f 75 74 28 22 50 72 65 73 73 75 72 65 53 65 6e 73 6f 72 22 2c 20 74 79 70 65 6f 66 28 Layout("PressureSensor",.typeof(
11500 50 72 65 73 73 75 72 65 53 65 6e 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 PressureSensor));..............R
11520 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 48 75 6d 69 64 69 74 79 53 65 egisterControlLayout("HumiditySe
11540 6e 73 6f 72 22 2c 20 74 79 70 65 6f 66 28 48 75 6d 69 64 69 74 79 53 65 6e 73 6f 72 29 29 3b 0d nsor",.typeof(HumiditySensor));.
11560 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f .............RegisterControlLayo
11580 75 74 28 22 41 6d 62 69 65 6e 74 54 65 6d 70 65 72 61 74 75 72 65 53 65 6e 73 6f 72 22 2c 20 74 ut("AmbientTemperatureSensor",.t
115a0 79 70 65 6f 66 28 41 6d 62 69 65 6e 74 54 65 6d 70 65 72 61 74 75 72 65 53 65 6e 73 6f 72 29 29 ypeof(AmbientTemperatureSensor))
115c0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 ;..............RegisterControlLa
115e0 79 6f 75 74 28 22 53 74 65 70 43 6f 75 6e 74 65 72 22 2c 20 74 79 70 65 6f 66 28 53 74 65 70 43 yout("StepCounter",.typeof(StepC
11600 6f 75 6e 74 65 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 67 69 73 74 65 72 43 ounter));..............RegisterC
11620 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 22 54 72 61 63 6b 65 64 44 65 76 69 63 65 22 2c 20 74 79 ontrolLayout("TrackedDevice",.ty
11640 70 65 6f 66 28 54 72 61 63 6b 65 64 44 65 76 69 63 65 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 peof(TrackedDevice));...........
11660 20 20 20 20 20 2f 2f 20 52 65 67 69 73 74 65 72 20 70 72 6f 63 65 73 73 6f 72 73 2e 0d 0a 20 20 .....//.Register.processors.....
11680 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 ..........processors.AddTypeRegi
116a0 73 74 72 61 74 69 6f 6e 28 22 49 6e 76 65 72 74 22 2c 20 74 79 70 65 6f 66 28 49 6e 76 65 72 74 stration("Invert",.typeof(Invert
116c0 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 Processor));..............proces
116e0 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 49 6e 76 65 72 74 sors.AddTypeRegistration("Invert
11700 56 65 63 74 6f 72 32 22 2c 20 74 79 70 65 6f 66 28 49 6e 76 65 72 74 56 65 63 74 6f 72 32 50 72 Vector2",.typeof(InvertVector2Pr
11720 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f ocessor));..............processo
11740 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 49 6e 76 65 72 74 56 65 rs.AddTypeRegistration("InvertVe
11760 63 74 6f 72 33 22 2c 20 74 79 70 65 6f 66 28 49 6e 76 65 72 74 56 65 63 74 6f 72 33 50 72 6f 63 ctor3",.typeof(InvertVector3Proc
11780 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 essor));..............processors
117a0 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 43 6c 61 6d 70 22 2c 20 74 79 .AddTypeRegistration("Clamp",.ty
117c0 70 65 6f 66 28 43 6c 61 6d 70 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 peof(ClampProcessor));..........
117e0 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 ....processors.AddTypeRegistrati
11800 6f 6e 28 22 4e 6f 72 6d 61 6c 69 7a 65 22 2c 20 74 79 70 65 6f 66 28 4e 6f 72 6d 61 6c 69 7a 65 on("Normalize",.typeof(Normalize
11820 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 Processor));..............proces
11840 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 4e 6f 72 6d 61 6c sors.AddTypeRegistration("Normal
11860 69 7a 65 56 65 63 74 6f 72 32 22 2c 20 74 79 70 65 6f 66 28 4e 6f 72 6d 61 6c 69 7a 65 56 65 63 izeVector2",.typeof(NormalizeVec
11880 74 6f 72 32 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 tor2Processor));..............pr
118a0 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 4e 6f ocessors.AddTypeRegistration("No
118c0 72 6d 61 6c 69 7a 65 56 65 63 74 6f 72 33 22 2c 20 74 79 70 65 6f 66 28 4e 6f 72 6d 61 6c 69 7a rmalizeVector3",.typeof(Normaliz
118e0 65 56 65 63 74 6f 72 33 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 eVector3Processor));............
11900 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e ..processors.AddTypeRegistration
11920 28 22 53 63 61 6c 65 22 2c 20 74 79 70 65 6f 66 28 53 63 61 6c 65 50 72 6f 63 65 73 73 6f 72 29 ("Scale",.typeof(ScaleProcessor)
11940 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 );..............processors.AddTy
11960 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 53 63 61 6c 65 56 65 63 74 6f 72 32 22 2c 20 74 peRegistration("ScaleVector2",.t
11980 79 70 65 6f 66 28 53 63 61 6c 65 56 65 63 74 6f 72 32 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a ypeof(ScaleVector2Processor));..
119a0 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 ............processors.AddTypeRe
119c0 67 69 73 74 72 61 74 69 6f 6e 28 22 53 63 61 6c 65 56 65 63 74 6f 72 33 22 2c 20 74 79 70 65 6f gistration("ScaleVector3",.typeo
119e0 66 28 53 63 61 6c 65 56 65 63 74 6f 72 33 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 f(ScaleVector3Processor));......
11a00 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 ........processors.AddTypeRegist
11a20 72 61 74 69 6f 6e 28 22 53 74 69 63 6b 44 65 61 64 7a 6f 6e 65 22 2c 20 74 79 70 65 6f 66 28 53 ration("StickDeadzone",.typeof(S
11a40 74 69 63 6b 44 65 61 64 7a 6f 6e 65 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 tickDeadzoneProcessor));........
11a60 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 ......processors.AddTypeRegistra
11a80 74 69 6f 6e 28 22 41 78 69 73 44 65 61 64 7a 6f 6e 65 22 2c 20 74 79 70 65 6f 66 28 41 78 69 73 tion("AxisDeadzone",.typeof(Axis
11aa0 44 65 61 64 7a 6f 6e 65 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 DeadzoneProcessor));............
11ac0 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e ..processors.AddTypeRegistration
11ae0 28 22 43 6f 6d 70 65 6e 73 61 74 65 44 69 72 65 63 74 69 6f 6e 22 2c 20 74 79 70 65 6f 66 28 43 ("CompensateDirection",.typeof(C
11b00 6f 6d 70 65 6e 73 61 74 65 44 69 72 65 63 74 69 6f 6e 50 72 6f 63 65 73 73 6f 72 29 29 3b 0d 0a ompensateDirectionProcessor));..
11b20 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 64 64 54 79 70 65 52 65 ............processors.AddTypeRe
11b40 67 69 73 74 72 61 74 69 6f 6e 28 22 43 6f 6d 70 65 6e 73 61 74 65 52 6f 74 61 74 69 6f 6e 22 2c gistration("CompensateRotation",
11b60 20 74 79 70 65 6f 66 28 43 6f 6d 70 65 6e 73 61 74 65 52 6f 74 61 74 69 6f 6e 50 72 6f 63 65 73 .typeof(CompensateRotationProces
11b80 73 6f 72 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f sor));................#if.UNITY_
11ba0 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 6f 63 65 73 73 6f 72 73 2e 41 EDITOR..............processors.A
11bc0 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 41 75 74 6f 57 69 6e 64 6f 77 53 70 ddTypeRegistration("AutoWindowSp
11be0 61 63 65 22 2c 20 74 79 70 65 6f 66 28 45 64 69 74 6f 72 57 69 6e 64 6f 77 53 70 61 63 65 50 72 ace",.typeof(EditorWindowSpacePr
11c00 6f 63 65 73 73 6f 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a ocessor));..............#endif..
11c20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 67 69 73 74 65 72 20 69 6e 74 65 72 61 ..............//.Register.intera
11c40 63 74 69 6f 6e 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 65 72 61 63 74 69 6f 6e ctions...............interaction
11c60 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 48 6f 6c 64 22 2c 20 74 79 s.AddTypeRegistration("Hold",.ty
11c80 70 65 6f 66 28 48 6f 6c 64 49 6e 74 65 72 61 63 74 69 6f 6e 29 29 3b 0d 0a 20 20 20 20 20 20 20 peof(HoldInteraction));.........
11ca0 20 20 20 20 20 69 6e 74 65 72 61 63 74 69 6f 6e 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 .....interactions.AddTypeRegistr
11cc0 61 74 69 6f 6e 28 22 54 61 70 22 2c 20 74 79 70 65 6f 66 28 54 61 70 49 6e 74 65 72 61 63 74 69 ation("Tap",.typeof(TapInteracti
11ce0 6f 6e 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 65 72 61 63 74 69 6f 6e 73 2e on));..............interactions.
11d00 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 53 6c 6f 77 54 61 70 22 2c 20 74 AddTypeRegistration("SlowTap",.t
11d20 79 70 65 6f 66 28 53 6c 6f 77 54 61 70 49 6e 74 65 72 61 63 74 69 6f 6e 29 29 3b 0d 0a 20 20 20 ypeof(SlowTapInteraction));.....
11d40 20 20 20 20 20 20 20 20 20 69 6e 74 65 72 61 63 74 69 6f 6e 73 2e 41 64 64 54 79 70 65 52 65 67 .........interactions.AddTypeReg
11d60 69 73 74 72 61 74 69 6f 6e 28 22 4d 75 6c 74 69 54 61 70 22 2c 20 74 79 70 65 6f 66 28 4d 75 6c istration("MultiTap",.typeof(Mul
11d80 74 69 54 61 70 49 6e 74 65 72 61 63 74 69 6f 6e 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 tiTapInteraction));.............
11da0 20 69 6e 74 65 72 61 63 74 69 6f 6e 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f .interactions.AddTypeRegistratio
11dc0 6e 28 22 50 72 65 73 73 22 2c 20 74 79 70 65 6f 66 28 50 72 65 73 73 49 6e 74 65 72 61 63 74 69 n("Press",.typeof(PressInteracti
11de0 6f 6e 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 67 69 73 74 65 72 on));................//.Register
11e00 20 63 6f 6d 70 6f 73 69 74 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6d 70 6f 73 .composites...............compos
11e20 69 74 65 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 31 44 41 78 69 73 ites.AddTypeRegistration("1DAxis
11e40 22 2c 20 74 79 70 65 6f 66 28 41 78 69 73 43 6f 6d 70 6f 73 69 74 65 29 29 3b 0d 0a 20 20 20 20 ",.typeof(AxisComposite));......
11e60 20 20 20 20 20 20 20 20 63 6f 6d 70 6f 73 69 74 65 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 ........composites.AddTypeRegist
11e80 72 61 74 69 6f 6e 28 22 32 44 56 65 63 74 6f 72 22 2c 20 74 79 70 65 6f 66 28 56 65 63 74 6f 72 ration("2DVector",.typeof(Vector
11ea0 32 43 6f 6d 70 6f 73 69 74 65 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6d 70 6f 2Composite));..............compo
11ec0 73 69 74 65 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 41 78 69 73 22 sites.AddTypeRegistration("Axis"
11ee0 2c 20 74 79 70 65 6f 66 28 41 78 69 73 43 6f 6d 70 6f 73 69 74 65 29 29 3b 2f 2f 20 41 6c 69 61 ,.typeof(AxisComposite));//.Alia
11f00 73 20 66 6f 72 20 70 72 65 2d 30 2e 32 20 6e 61 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 s.for.pre-0.2.name..............
11f20 20 63 6f 6d 70 6f 73 69 74 65 73 2e 41 64 64 54 79 70 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 .composites.AddTypeRegistration(
11f40 22 44 70 61 64 22 2c 20 74 79 70 65 6f 66 28 56 65 63 74 6f 72 32 43 6f 6d 70 6f 73 69 74 65 29 "Dpad",.typeof(Vector2Composite)
11f60 29 3b 2f 2f 20 41 6c 69 61 73 20 66 6f 72 20 70 72 65 2d 30 2e 32 20 6e 61 6d 65 2e 0d 0a 20 20 );//.Alias.for.pre-0.2.name.....
11f80 20 20 20 20 20 20 20 20 20 20 63 6f 6d 70 6f 73 69 74 65 73 2e 41 64 64 54 79 70 65 52 65 67 69 ..........composites.AddTypeRegi
11fa0 73 74 72 61 74 69 6f 6e 28 22 42 75 74 74 6f 6e 57 69 74 68 4f 6e 65 4d 6f 64 69 66 69 65 72 22 stration("ButtonWithOneModifier"
11fc0 2c 20 74 79 70 65 6f 66 28 42 75 74 74 6f 6e 57 69 74 68 4f 6e 65 4d 6f 64 69 66 69 65 72 29 29 ,.typeof(ButtonWithOneModifier))
11fe0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6d 70 6f 73 69 74 65 73 2e 41 64 64 54 79 70 ;..............composites.AddTyp
12000 65 52 65 67 69 73 74 72 61 74 69 6f 6e 28 22 42 75 74 74 6f 6e 57 69 74 68 54 77 6f 4d 6f 64 69 eRegistration("ButtonWithTwoModi
12020 66 69 65 72 73 22 2c 20 74 79 70 65 6f 66 28 42 75 74 74 6f 6e 57 69 74 68 54 77 6f 4d 6f 64 69 fiers",.typeof(ButtonWithTwoModi
12040 66 69 65 72 73 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 fiers));..........}............i
12060 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 49 6e 73 74 61 6c 6c 52 75 6e 74 69 6d 65 28 49 49 6e 70 nternal.void.InstallRuntime(IInp
12080 75 74 52 75 6e 74 69 6d 65 20 72 75 6e 74 69 6d 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 utRuntime.runtime)..........{...
120a0 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 52 75 6e 74 69 6d 65 20 21 3d 20 6e 75 6c 6c ...........if.(m_Runtime.!=.null
120c0 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 )..............{................
120e0 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 55 70 64 61 74 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 ..m_Runtime.onUpdate.=.null;....
12100 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 42 65 66 6f 72 65 ..............m_Runtime.onBefore
12120 55 70 64 61 74 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Update.=.null;..................
12140 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 44 65 76 69 63 65 44 69 73 63 6f 76 65 72 65 64 20 3d 20 6e m_Runtime.onDeviceDiscovered.=.n
12160 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e ull;..................m_Runtime.
12180 6f 6e 50 6c 61 79 65 72 46 6f 63 75 73 43 68 61 6e 67 65 64 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 onPlayerFocusChanged.=.null;....
121a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 53 68 6f 75 6c 64 ..............m_Runtime.onShould
121c0 52 75 6e 55 70 64 61 74 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d RunUpdate.=.null;..............}
121e0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 20 3d 20 72 75 6e 74 ................m_Runtime.=.runt
12200 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 55 70 ime;..............m_Runtime.onUp
12220 64 61 74 65 20 3d 20 4f 6e 55 70 64 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f date.=.OnUpdate;..............m_
12240 52 75 6e 74 69 6d 65 2e 6f 6e 44 65 76 69 63 65 44 69 73 63 6f 76 65 72 65 64 20 3d 20 4f 6e 4e Runtime.onDeviceDiscovered.=.OnN
12260 61 74 69 76 65 44 65 76 69 63 65 44 69 73 63 6f 76 65 72 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 ativeDeviceDiscovered;..........
12280 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 50 6c 61 79 65 72 46 6f 63 75 73 43 68 61 6e 67 ....m_Runtime.onPlayerFocusChang
122a0 65 64 20 3d 20 4f 6e 46 6f 63 75 73 43 68 61 6e 67 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ed.=.OnFocusChanged;............
122c0 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 53 68 6f 75 6c 64 52 75 6e 55 70 64 61 74 65 20 3d 20 ..m_Runtime.onShouldRunUpdate.=.
122e0 53 68 6f 75 6c 64 52 75 6e 55 70 64 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f ShouldRunUpdate;..............m_
12300 52 75 6e 74 69 6d 65 2e 70 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 20 3d 20 70 6f 6c 6c 69 Runtime.pollingFrequency.=.polli
12320 6e 67 46 72 65 71 75 65 6e 63 79 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 ngFrequency;................//.W
12340 65 20 6f 6e 6c 79 20 68 6f 6f 6b 20 4e 61 74 69 76 65 49 6e 70 75 74 53 79 73 74 65 6d 2e 6f 6e e.only.hook.NativeInputSystem.on
12360 42 65 66 6f 72 65 55 70 64 61 74 65 20 69 66 20 6e 65 63 65 73 73 61 72 79 2e 0d 0a 20 20 20 20 BeforeUpdate.if.necessary.......
12380 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 42 65 66 6f 72 65 55 70 64 61 74 65 4c 69 73 74 65 6e ........if.(m_BeforeUpdateListen
123a0 65 72 73 2e 6c 65 6e 67 74 68 20 3e 20 30 20 7c 7c 20 6d 5f 48 61 76 65 44 65 76 69 63 65 73 57 ers.length.>.0.||.m_HaveDevicesW
123c0 69 74 68 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 73 29 0d 0a 20 20 20 20 ithStateCallbackReceivers)......
123e0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e ........{..................m_Run
12400 74 69 6d 65 2e 6f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 20 3d 20 4f 6e 42 65 66 6f 72 65 55 70 time.onBeforeUpdate.=.OnBeforeUp
12420 64 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4e 61 74 69 76 65 42 date;..................m_NativeB
12440 65 66 6f 72 65 55 70 64 61 74 65 48 6f 6f 6b 65 64 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 eforeUpdateHooked.=.true;.......
12460 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 .......}................#if.UNIT
12480 59 5f 41 4e 41 4c 59 54 49 43 53 20 7c 7c 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 Y_ANALYTICS.||.UNITY_EDITOR.....
124a0 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 41 6e 61 6c 79 74 69 63 73 2e 49 6e 69 74 69 61 6c 69 .........InputAnalytics.Initiali
124c0 7a 65 28 74 68 69 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 ze(this);..............m_Runtime
124e0 2e 6f 6e 53 68 75 74 64 6f 77 6e 20 3d 20 28 29 20 3d 3e 20 49 6e 70 75 74 41 6e 61 6c 79 74 69 .onShutdown.=.().=>.InputAnalyti
12500 63 73 2e 4f 6e 53 68 75 74 64 6f 77 6e 28 74 68 69 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 cs.OnShutdown(this);............
12520 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 ..#endif..........}............i
12540 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 49 6e 73 74 61 6c 6c 47 6c 6f 62 61 6c 73 28 29 0d 0a 20 nternal.void.InstallGlobals()...
12560 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 .......{..............Debug.Asse
12580 72 74 28 6d 5f 52 75 6e 74 69 6d 65 20 21 3d 20 6e 75 6c 6c 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 rt(m_Runtime.!=.null);..........
125a0 20 20 20 20 20 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 2e 73 5f 4c 61 79 6f 75 ......InputControlLayout.s_Layou
125c0 74 73 20 3d 20 6d 5f 4c 61 79 6f 75 74 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 ts.=.m_Layouts;..............Inp
125e0 75 74 50 72 6f 63 65 73 73 6f 72 2e 73 5f 50 72 6f 63 65 73 73 6f 72 73 20 3d 20 6d 5f 50 72 6f utProcessor.s_Processors.=.m_Pro
12600 63 65 73 73 6f 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 49 6e 74 65 72 cessors;..............InputInter
12620 61 63 74 69 6f 6e 2e 73 5f 49 6e 74 65 72 61 63 74 69 6f 6e 73 20 3d 20 6d 5f 49 6e 74 65 72 61 action.s_Interactions.=.m_Intera
12640 63 74 69 6f 6e 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 42 69 6e 64 69 6e ctions;..............InputBindin
12660 67 43 6f 6d 70 6f 73 69 74 65 2e 73 5f 43 6f 6d 70 6f 73 69 74 65 73 20 3d 20 6d 5f 43 6f 6d 70 gComposite.s_Composites.=.m_Comp
12680 6f 73 69 74 65 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 52 75 6e 74 osites;................InputRunt
126a0 69 6d 65 2e 73 5f 49 6e 73 74 61 6e 63 65 20 3d 20 6d 5f 52 75 6e 74 69 6d 65 3b 0d 0a 20 20 20 ime.s_Instance.=.m_Runtime;.....
126c0 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 52 75 6e 74 69 6d 65 2e 73 5f 43 75 72 72 65 6e 74 54 .........InputRuntime.s_CurrentT
126e0 69 6d 65 4f 66 66 73 65 74 54 6f 52 65 61 6c 74 69 6d 65 53 69 6e 63 65 53 74 61 72 74 75 70 20 imeOffsetToRealtimeSinceStartup.
12700 3d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 63 75 72 =..................m_Runtime.cur
12720 72 65 6e 74 54 69 6d 65 4f 66 66 73 65 74 54 6f 52 65 61 6c 74 69 6d 65 53 69 6e 63 65 53 74 61 rentTimeOffsetToRealtimeSinceSta
12740 72 74 75 70 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 73 65 74 20 75 70 rtup;................//.Reset.up
12760 64 61 74 65 20 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 date.state...............InputUp
12780 64 61 74 65 2e 52 65 73 74 6f 72 65 28 6e 65 77 20 49 6e 70 75 74 55 70 64 61 74 65 2e 53 65 72 date.Restore(new.InputUpdate.Ser
127a0 69 61 6c 69 7a 65 64 53 74 61 74 65 28 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ializedState());................
127c0 75 6e 73 61 66 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 unsafe..............{...........
127e0 20 20 20 20 20 20 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 53 77 69 74 63 68 54 .......InputStateBuffers.SwitchT
12800 6f 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2c 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 o(m_StateBuffers,.InputUpdateTyp
12820 65 2e 44 79 6e 61 6d 69 63 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 e.Dynamic);..................Inp
12840 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 73 5f 44 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 utStateBuffers.s_DefaultStateBuf
12860 66 65 72 20 3d 20 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 64 65 66 61 75 6c 74 53 74 61 74 fer.=.m_StateBuffers.defaultStat
12880 65 42 75 66 66 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 53 eBuffer;..................InputS
128a0 74 61 74 65 42 75 66 66 65 72 73 2e 73 5f 4e 6f 69 73 65 4d 61 73 6b 42 75 66 66 65 72 20 3d 20 tateBuffers.s_NoiseMaskBuffer.=.
128c0 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6e 6f 69 73 65 4d 61 73 6b 42 75 66 66 65 72 3b 0d m_StateBuffers.noiseMaskBuffer;.
128e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .............}..........}.......
12900 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 55 6e 69 6e 73 74 61 6c 6c 47 6c 6f 62 .....internal.void.UninstallGlob
12920 61 6c 73 28 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 als()..........{..............if
12940 20 28 52 65 66 65 72 65 6e 63 65 45 71 75 61 6c 73 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 .(ReferenceEquals(InputControlLa
12960 79 6f 75 74 2e 73 5f 4c 61 79 6f 75 74 73 2e 62 61 73 65 4c 61 79 6f 75 74 54 61 62 6c 65 2c 20 yout.s_Layouts.baseLayoutTable,.
12980 6d 5f 4c 61 79 6f 75 74 73 2e 62 61 73 65 4c 61 79 6f 75 74 54 61 62 6c 65 29 29 0d 0a 20 20 20 m_Layouts.baseLayoutTable)).....
129a0 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 2e .............InputControlLayout.
129c0 73 5f 4c 61 79 6f 75 74 73 20 3d 20 6e 65 77 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f s_Layouts.=.new.InputControlLayo
129e0 75 74 2e 43 6f 6c 6c 65 63 74 69 6f 6e 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 ut.Collection();..............if
12a00 20 28 52 65 66 65 72 65 6e 63 65 45 71 75 61 6c 73 28 49 6e 70 75 74 50 72 6f 63 65 73 73 6f 72 .(ReferenceEquals(InputProcessor
12a20 2e 73 5f 50 72 6f 63 65 73 73 6f 72 73 2e 74 61 62 6c 65 2c 20 6d 5f 50 72 6f 63 65 73 73 6f 72 .s_Processors.table,.m_Processor
12a40 73 2e 74 61 62 6c 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 s.table))..................Input
12a60 50 72 6f 63 65 73 73 6f 72 2e 73 5f 50 72 6f 63 65 73 73 6f 72 73 20 3d 20 6e 65 77 20 54 79 70 Processor.s_Processors.=.new.Typ
12a80 65 54 61 62 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 52 65 66 65 72 eTable();..............if.(Refer
12aa0 65 6e 63 65 45 71 75 61 6c 73 28 49 6e 70 75 74 49 6e 74 65 72 61 63 74 69 6f 6e 2e 73 5f 49 6e enceEquals(InputInteraction.s_In
12ac0 74 65 72 61 63 74 69 6f 6e 73 2e 74 61 62 6c 65 2c 20 6d 5f 49 6e 74 65 72 61 63 74 69 6f 6e 73 teractions.table,.m_Interactions
12ae0 2e 74 61 62 6c 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 49 .table))..................InputI
12b00 6e 74 65 72 61 63 74 69 6f 6e 2e 73 5f 49 6e 74 65 72 61 63 74 69 6f 6e 73 20 3d 20 6e 65 77 20 nteraction.s_Interactions.=.new.
12b20 54 79 70 65 54 61 62 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 52 65 TypeTable();..............if.(Re
12b40 66 65 72 65 6e 63 65 45 71 75 61 6c 73 28 49 6e 70 75 74 42 69 6e 64 69 6e 67 43 6f 6d 70 6f 73 ferenceEquals(InputBindingCompos
12b60 69 74 65 2e 73 5f 43 6f 6d 70 6f 73 69 74 65 73 2e 74 61 62 6c 65 2c 20 6d 5f 43 6f 6d 70 6f 73 ite.s_Composites.table,.m_Compos
12b80 69 74 65 73 2e 74 61 62 6c 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e ites.table))..................In
12ba0 70 75 74 42 69 6e 64 69 6e 67 43 6f 6d 70 6f 73 69 74 65 2e 73 5f 43 6f 6d 70 6f 73 69 74 65 73 putBindingComposite.s_Composites
12bc0 20 3d 20 6e 65 77 20 54 79 70 65 54 61 62 6c 65 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 .=.new.TypeTable();.............
12be0 20 20 20 2f 2f 20 43 6c 65 61 72 20 6c 61 79 6f 75 74 20 63 61 63 68 65 2e 0d 0a 20 20 20 20 20 ...//.Clear.layout.cache........
12c00 20 20 20 20 20 20 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 2e 73 5f 43 61 63 68 .......InputControlLayout.s_Cach
12c20 65 49 6e 73 74 61 6e 63 65 20 3d 20 64 65 66 61 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 eInstance.=.default;............
12c40 20 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 2e 73 5f 43 61 63 68 65 49 6e 73 74 ..InputControlLayout.s_CacheInst
12c60 61 6e 63 65 52 65 66 20 3d 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 anceRef.=.0;................//.D
12c80 65 74 61 63 68 20 66 72 6f 6d 20 72 75 6e 74 69 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 etach.from.runtime..............
12ca0 20 69 66 20 28 6d 5f 52 75 6e 74 69 6d 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 .if.(m_Runtime.!=.null).........
12cc0 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d .....{..................m_Runtim
12ce0 65 2e 6f 6e 55 70 64 61 74 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 e.onUpdate.=.null;..............
12d00 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 44 65 76 69 63 65 44 69 73 63 6f 76 65 72 65 64 ....m_Runtime.onDeviceDiscovered
12d20 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 .=.null;..................m_Runt
12d40 69 6d 65 2e 6f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 ime.onBeforeUpdate.=.null;......
12d60 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 50 6c 61 79 65 72 46 6f ............m_Runtime.onPlayerFo
12d80 63 75 73 43 68 61 6e 67 65 64 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 cusChanged.=.null;..............
12da0 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 53 68 6f 75 6c 64 52 75 6e 55 70 64 61 74 65 20 ....m_Runtime.onShouldRunUpdate.
12dc0 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 52 =.null;....................if.(R
12de0 65 66 65 72 65 6e 63 65 45 71 75 61 6c 73 28 49 6e 70 75 74 52 75 6e 74 69 6d 65 2e 73 5f 49 6e eferenceEquals(InputRuntime.s_In
12e00 73 74 61 6e 63 65 2c 20 6d 5f 52 75 6e 74 69 6d 65 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 stance,.m_Runtime)).............
12e20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 52 75 6e 74 69 6d 65 2e 73 5f 49 6e 73 74 61 6e 63 65 .........InputRuntime.s_Instance
12e40 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 .=.null;..............}.........
12e60 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 5b 53 65 72 69 61 6c 69 7a 61 62 6c 65 5d 0d 0a 20 20 .}............[Serializable]....
12e80 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 72 75 63 74 20 41 76 61 69 6c 61 62 6c 65 44 ......internal.struct.AvailableD
12ea0 65 76 69 63 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 evice..........{..............pu
12ec0 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 20 64 65 73 63 blic.InputDeviceDescription.desc
12ee0 72 69 70 74 69 6f 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 69 6e 74 ription;..............public.int
12f00 20 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 62 .deviceId;..............public.b
12f20 6f 6f 6c 20 69 73 4e 61 74 69 76 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 ool.isNative;..............publi
12f40 63 20 62 6f 6f 6c 20 69 73 52 65 6d 6f 76 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a c.bool.isRemoved;..........}....
12f60 20 20 20 20 20 20 20 20 2f 2f 20 55 73 65 64 20 62 79 20 45 64 69 74 6f 72 49 6e 70 75 74 43 6f ........//.Used.by.EditorInputCo
12f80 6e 74 72 6f 6c 4c 61 79 6f 75 74 43 61 63 68 65 20 74 6f 20 64 65 74 65 72 6d 69 6e 65 20 77 68 ntrolLayoutCache.to.determine.wh
12fa0 65 74 68 65 72 20 69 74 73 20 73 74 61 74 65 20 69 73 20 6f 75 74 64 61 74 65 64 2e 0d 0a 20 20 ether.its.state.is.outdated.....
12fc0 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 69 6e 74 20 6d 5f 4c 61 79 6f 75 74 52 65 67 69 73 ......internal.int.m_LayoutRegis
12fe0 74 72 61 74 69 6f 6e 56 65 72 73 69 6f 6e 3b 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 trationVersion;..........private
13000 20 66 6c 6f 61 74 20 6d 5f 50 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 3b 0d 0a 0d 0a 20 20 .float.m_PollingFrequency;......
13020 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 ......internal.InputControlLayou
13040 74 2e 43 6f 6c 6c 65 63 74 69 6f 6e 20 6d 5f 4c 61 79 6f 75 74 73 3b 0d 0a 20 20 20 20 20 20 20 t.Collection.m_Layouts;.........
13060 20 70 72 69 76 61 74 65 20 54 79 70 65 54 61 62 6c 65 20 6d 5f 50 72 6f 63 65 73 73 6f 72 73 3b .private.TypeTable.m_Processors;
13080 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 54 79 70 65 54 61 62 6c 65 20 6d 5f 49 6e ..........private.TypeTable.m_In
130a0 74 65 72 61 63 74 69 6f 6e 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 54 79 70 teractions;..........private.Typ
130c0 65 54 61 62 6c 65 20 6d 5f 43 6f 6d 70 6f 73 69 74 65 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 eTable.m_Composites;............
130e0 70 72 69 76 61 74 65 20 69 6e 74 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 private.int.m_DevicesCount;.....
13100 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 70 75 74 44 65 76 69 63 65 5b 5d 20 6d 5f 44 65 76 .....private.InputDevice[].m_Dev
13120 69 63 65 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 44 69 63 74 69 6f 6e ices;............private.Diction
13140 61 72 79 3c 69 6e 74 2c 20 49 6e 70 75 74 44 65 76 69 63 65 3e 20 6d 5f 44 65 76 69 63 65 73 42 ary<int,.InputDevice>.m_DevicesB
13160 79 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 69 6e 74 20 6d 5f 41 76 61 yId;..........internal.int.m_Ava
13180 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 ilableDeviceCount;..........inte
131a0 72 6e 61 6c 20 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 5b 5d 20 6d 5f 41 76 61 69 6c 61 62 rnal.AvailableDevice[].m_Availab
131c0 6c 65 44 65 76 69 63 65 73 3b 20 2f 2f 20 41 20 72 65 63 6f 72 64 20 6f 66 20 61 6c 6c 20 64 65 leDevices;.//.A.record.of.all.de
131e0 76 69 63 65 73 20 72 65 70 6f 72 74 65 64 20 74 6f 20 74 68 65 20 73 79 73 74 65 6d 20 28 66 72 vices.reported.to.the.system.(fr
13200 6f 6d 20 6e 61 74 69 76 65 20 6f 72 20 75 73 65 72 20 63 6f 64 65 29 2e 0d 0a 0d 0a 20 20 20 20 om.native.or.user.code).........
13220 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 73 68 6f 75 6c 64 20 74 68 65 73 65 20 62 65 20 ....////REVIEW:.should.these.be.
13240 77 65 61 6b 2d 72 65 66 65 72 65 6e 63 65 64 3f 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e weak-referenced?..........intern
13260 61 6c 20 69 6e 74 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 43 6f 75 6e al.int.m_DisconnectedDevicesCoun
13280 74 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 49 6e 70 75 74 44 65 76 69 63 65 t;..........internal.InputDevice
132a0 5b 5d 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 3b 0d 0a 0d 0a 20 20 20 [].m_DisconnectedDevices;.......
132c0 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 20 6d 5f 55 .....private.InputUpdateType.m_U
132e0 70 64 61 74 65 4d 61 73 6b 3b 20 2f 2f 20 57 68 69 63 68 20 6f 66 20 6f 75 72 20 75 70 64 61 74 pdateMask;.//.Which.of.our.updat
13300 65 20 74 79 70 65 73 20 61 72 65 20 65 6e 61 62 6c 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 69 6e e.types.are.enabled...........in
13320 74 65 72 6e 61 6c 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 20 6d 5f 53 74 61 74 65 ternal.InputStateBuffers.m_State
13340 42 75 66 66 65 72 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 64 6f 6e 27 74 20 Buffers;............//.We.don't.
13360 75 73 65 20 55 6e 69 74 79 45 76 65 6e 74 73 20 61 6e 64 20 74 68 75 73 20 64 6f 6e 27 74 20 70 use.UnityEvents.and.thus.don't.p
13380 65 72 73 69 73 74 20 74 68 65 20 63 61 6c 6c 62 61 63 6b 73 20 64 75 72 69 6e 67 20 64 6f 6d 61 ersist.the.callbacks.during.doma
133a0 69 6e 20 72 65 6c 6f 61 64 73 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 52 65 73 74 6f 72 61 74 in.reloads...........//.Restorat
133c0 69 6f 6e 20 6f 66 20 55 6e 69 74 79 41 63 74 69 6f 6e 73 20 69 73 20 75 6e 72 65 6c 69 61 62 6c ion.of.UnityActions.is.unreliabl
133e0 65 20 61 6e 64 20 69 74 27 73 20 74 6f 6f 20 65 61 73 79 20 74 6f 20 65 6e 64 20 75 70 20 77 69 e.and.it's.too.easy.to.end.up.wi
13400 74 68 20 64 6f 75 62 6c 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 72 65 67 69 73 74 72 61 74 69 th.double..........//.registrati
13420 6f 6e 73 20 77 68 61 74 20 77 69 6c 6c 20 6c 65 61 64 20 74 6f 20 61 6c 6c 20 6b 69 6e 64 73 20 ons.what.will.lead.to.all.kinds.
13440 6f 66 20 6d 69 73 62 65 68 61 76 69 6f 72 2e 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 of.misbehavior...........private
13460 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e .InlinedArray<DeviceChangeListen
13480 65 72 3e 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 3b 0d 0a 20 20 er>.m_DeviceChangeListeners;....
134a0 20 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 44 65 76 69 63 ......private.InlinedArray<Devic
134c0 65 53 74 61 74 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 3e 20 6d 5f 44 65 76 69 63 65 53 74 eStateChangeListener>.m_DeviceSt
134e0 61 74 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 72 69 ateChangeListeners;..........pri
13500 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 49 6e 70 75 74 44 65 76 69 63 65 46 69 6e vate.InlinedArray<InputDeviceFin
13520 64 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 44 65 6c 65 67 61 74 65 3e 20 6d 5f 44 65 76 69 63 65 dControlLayoutDelegate>.m_Device
13540 46 69 6e 64 4c 61 79 6f 75 74 43 61 6c 6c 62 61 63 6b 73 3b 0d 0a 20 20 20 20 20 20 20 20 69 6e FindLayoutCallbacks;..........in
13560 74 65 72 6e 61 6c 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 49 6e 70 75 74 44 65 76 69 63 65 43 ternal.InlinedArray<InputDeviceC
13580 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 3e 20 6d 5f 44 65 76 69 63 65 43 6f 6d 6d 61 6e 64 43 ommandDelegate>.m_DeviceCommandC
135a0 61 6c 6c 62 61 63 6b 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 6c 69 6e allbacks;..........private.Inlin
135c0 65 64 41 72 72 61 79 3c 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 3e 20 6d 5f edArray<LayoutChangeListener>.m_
135e0 4c 61 79 6f 75 74 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 LayoutChangeListeners;..........
13600 70 72 69 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 45 76 65 6e 74 4c 69 73 74 65 6e private.InlinedArray<EventListen
13620 65 72 3e 20 6d 5f 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 er>.m_EventListeners;..........p
13640 72 69 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 55 70 64 61 74 65 4c 69 73 74 65 6e rivate.InlinedArray<UpdateListen
13660 65 72 3e 20 6d 5f 42 65 66 6f 72 65 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 3b 0d 0a 20 20 er>.m_BeforeUpdateListeners;....
13680 20 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 55 70 64 61 74 ......private.InlinedArray<Updat
136a0 65 4c 69 73 74 65 6e 65 72 3e 20 6d 5f 41 66 74 65 72 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 eListener>.m_AfterUpdateListener
136c0 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 s;..........private.InlinedArray
136e0 3c 41 63 74 69 6f 6e 3e 20 6d 5f 53 65 74 74 69 6e 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e <Action>.m_SettingsChangedListen
13700 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f 6f 6c 20 6d 5f 4e 61 74 ers;..........private.bool.m_Nat
13720 69 76 65 42 65 66 6f 72 65 55 70 64 61 74 65 48 6f 6f 6b 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 iveBeforeUpdateHooked;..........
13740 70 72 69 76 61 74 65 20 62 6f 6f 6c 20 6d 5f 48 61 76 65 44 65 76 69 63 65 73 57 69 74 68 53 74 private.bool.m_HaveDevicesWithSt
13760 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 70 ateCallbackReceivers;..........p
13780 72 69 76 61 74 65 20 62 6f 6f 6c 20 6d 5f 48 61 73 46 6f 63 75 73 3b 0d 0a 0d 0a 20 20 20 20 20 rivate.bool.m_HasFocus;.........
137a0 20 20 20 2f 2f 20 57 65 20 61 6c 6c 6f 63 61 74 65 20 74 68 65 20 27 65 78 65 63 75 74 65 44 65 ...//.We.allocate.the.'executeDe
137c0 76 69 63 65 43 6f 6d 6d 61 6e 64 27 20 63 6c 6f 73 75 72 65 20 70 61 73 73 65 64 20 74 6f 20 27 viceCommand'.closure.passed.to.'
137e0 6f 6e 46 69 6e 64 4c 61 79 6f 75 74 46 6f 72 44 65 76 69 63 65 27 0d 0a 20 20 20 20 20 20 20 20 onFindLayoutForDevice'..........
13800 2f 2f 20 6f 6e 6c 79 20 6f 6e 63 65 20 74 6f 20 61 76 6f 69 64 20 63 72 65 61 74 69 6e 67 20 67 //.only.once.to.avoid.creating.g
13820 61 72 62 61 67 65 2e 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 70 75 74 44 65 arbage...........private.InputDe
13840 76 69 63 65 45 78 65 63 75 74 65 43 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 20 6d 5f 44 65 76 viceExecuteCommandDelegate.m_Dev
13860 69 63 65 46 69 6e 64 45 78 65 63 75 74 65 43 6f 6d 6d 61 6e 64 44 65 6c 65 67 61 74 65 3b 0d 0a iceFindExecuteCommandDelegate;..
13880 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 69 6e 74 20 6d 5f 44 65 76 69 63 65 46 69 6e 64 ........private.int.m_DeviceFind
138a0 45 78 65 63 75 74 65 43 6f 6d 6d 61 6e 64 44 65 76 69 63 65 49 64 3b 0d 0a 0d 0a 20 20 20 20 20 ExecuteCommandDeviceId;.........
138c0 20 20 20 23 69 66 20 55 4e 49 54 59 5f 41 4e 41 4c 59 54 49 43 53 20 7c 7c 20 55 4e 49 54 59 5f ...#if.UNITY_ANALYTICS.||.UNITY_
138e0 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f 6f 6c 20 6d 5f 48 EDITOR..........private.bool.m_H
13900 61 76 65 53 65 6e 74 53 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 3b 0d 0a 20 20 20 20 20 20 aveSentStartupAnalytics;........
13920 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 49 49 6e ..#endif............internal.IIn
13940 70 75 74 52 75 6e 74 69 6d 65 20 6d 5f 52 75 6e 74 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 69 putRuntime.m_Runtime;..........i
13960 6e 74 65 72 6e 61 6c 20 49 6e 70 75 74 4d 65 74 72 69 63 73 20 6d 5f 4d 65 74 72 69 63 73 3b 0d nternal.InputMetrics.m_Metrics;.
13980 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 20 .........internal.InputSettings.
139a0 6d 5f 53 65 74 74 69 6e 67 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 m_Settings;............#if.UNITY
139c0 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 49 49 6e 70 75 74 _EDITOR..........internal.IInput
139e0 44 69 61 67 6e 6f 73 74 69 63 73 20 6d 5f 44 69 61 67 6e 6f 73 74 69 63 73 3b 0d 0a 20 20 20 20 Diagnostics.m_Diagnostics;......
13a00 20 20 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 70 73 20 61 20 ....#endif............//.Maps.a.
13a20 73 69 6e 67 6c 65 20 63 6f 6e 74 72 6f 6c 20 74 6f 20 61 6e 20 61 63 74 69 6f 6e 20 69 6e 74 65 single.control.to.an.action.inte
13a40 72 65 73 74 65 64 20 69 6e 20 74 68 65 20 63 6f 6e 74 72 6f 6c 2e 20 49 66 0d 0a 20 20 20 20 20 rested.in.the.control..If.......
13a60 20 20 20 2f 2f 20 6d 75 6c 74 69 70 6c 65 20 61 63 74 69 6f 6e 73 20 61 72 65 20 69 6e 74 65 72 ...//.multiple.actions.are.inter
13a80 65 73 74 65 64 20 69 6e 20 74 68 65 20 73 61 6d 65 20 63 6f 6e 74 72 6f 6c 2c 20 77 65 20 77 69 ested.in.the.same.control,.we.wi
13aa0 6c 6c 20 65 6e 64 20 75 70 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 70 72 6f 63 65 73 73 69 6e 67 ll.end.up..........//.processing
13ac0 20 74 68 65 20 63 6f 6e 74 72 6f 6c 20 72 65 70 65 61 74 65 64 6c 79 20 62 75 74 20 77 65 20 61 .the.control.repeatedly.but.we.a
13ae0 73 73 75 6d 65 20 74 68 69 73 20 69 73 20 74 68 65 20 65 78 63 65 70 74 69 6f 6e 0d 0a 20 20 20 ssume.this.is.the.exception.....
13b00 20 20 20 20 20 2f 2f 20 61 6e 64 20 73 6f 20 6f 70 74 69 6d 69 7a 65 20 66 6f 72 20 74 68 65 20 .....//.and.so.optimize.for.the.
13b20 63 61 73 65 20 77 68 65 72 65 20 74 68 65 72 65 27 73 20 6f 6e 6c 79 20 6f 6e 65 20 61 63 74 69 case.where.there's.only.one.acti
13b40 6f 6e 20 67 6f 69 6e 67 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 61 20 63 6f 6e 74 72 6f on.going.to..........//.a.contro
13b60 6c 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 53 70 6c 69 74 l...........//..........//.Split
13b80 20 69 6e 74 6f 20 74 77 6f 20 73 74 72 75 63 74 75 72 65 73 20 74 6f 20 6b 65 65 70 20 64 61 74 .into.two.structures.to.keep.dat
13ba0 61 20 6e 65 65 64 65 64 20 6f 6e 6c 79 20 77 68 65 6e 20 74 68 65 72 65 20 69 73 20 61 6e 0d 0a a.needed.only.when.there.is.an..
13bc0 20 20 20 20 20 20 20 20 2f 2f 20 61 63 74 75 61 6c 20 76 61 6c 75 65 20 63 68 61 6e 67 65 20 6f ........//.actual.value.change.o
13be0 75 74 20 6f 66 20 74 68 65 20 64 61 74 61 20 77 65 20 6e 65 65 64 20 66 6f 72 20 64 6f 69 6e 67 ut.of.the.data.we.need.for.doing
13c00 20 74 68 65 20 73 63 61 6e 6e 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c .the.scanning...........internal
13c20 20 73 74 72 75 63 74 20 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 4c 69 73 74 65 6e .struct.StateChangeMonitorListen
13c40 65 72 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 er..........{..............publi
13c60 63 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 20 63 6f 6e 74 72 6f 6c 3b 0d 0a 20 20 20 20 20 20 20 c.InputControl.control;.........
13c80 20 20 20 20 20 70 75 62 6c 69 63 20 49 49 6e 70 75 74 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e .....public.IInputStateChangeMon
13ca0 69 74 6f 72 20 6d 6f 6e 69 74 6f 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 itor.monitor;..............publi
13cc0 63 20 6c 6f 6e 67 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d c.long.monitorIndex;..........}.
13ce0 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 72 75 63 74 20 53 74 61 74 65 43 68 .........internal.struct.StateCh
13d00 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 46 6f 72 44 65 76 69 63 65 0d 0a 20 20 20 20 20 20 20 20 7b angeMonitorsForDevice..........{
13d20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 4d 65 6d 6f 72 79 48 65 6c 70 65 ..............public.MemoryHelpe
13d40 72 73 2e 42 69 74 52 65 67 69 6f 6e 5b 5d 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 73 3b 0d 0a 20 rs.BitRegion[].memoryRegions;...
13d60 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e ...........public.StateChangeMon
13d80 69 74 6f 72 4c 69 73 74 65 6e 65 72 5b 5d 20 6c 69 73 74 65 6e 65 72 73 3b 0d 0a 20 20 20 20 20 itorListener[].listeners;.......
13da0 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 44 79 6e 61 6d 69 63 42 69 74 66 69 65 6c 64 20 73 69 .......public.DynamicBitfield.si
13dc0 67 6e 61 6c 6c 65 64 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 69 gnalled;................public.i
13de0 6e 74 20 63 6f 75 6e 74 20 3d 3e 20 73 69 67 6e 61 6c 6c 65 64 2e 6c 65 6e 67 74 68 3b 0d 0a 0d nt.count.=>.signalled.length;...
13e00 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 41 64 64 28 49 6e 70 .............public.void.Add(Inp
13e20 75 74 43 6f 6e 74 72 6f 6c 20 63 6f 6e 74 72 6f 6c 2c 20 49 49 6e 70 75 74 53 74 61 74 65 43 68 utControl.control,.IInputStateCh
13e40 61 6e 67 65 4d 6f 6e 69 74 6f 72 20 6d 6f 6e 69 74 6f 72 2c 20 6c 6f 6e 67 20 6d 6f 6e 69 74 6f angeMonitor.monitor,.long.monito
13e60 72 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 rIndex)..............{..........
13e80 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d 65 74 68 6f 64 20 6d 75 73 ........//.NOTE:.This.method.mus
13ea0 74 20 6f 6e 6c 79 20 2a 61 70 70 65 6e 64 2a 20 74 6f 20 61 72 72 61 79 73 2e 20 54 68 69 73 20 t.only.*append*.to.arrays..This.
13ec0 77 61 79 20 77 65 20 63 61 6e 20 73 61 66 65 6c 79 20 61 64 64 20 64 61 74 61 20 77 68 69 6c 65 way.we.can.safely.add.data.while
13ee0 20 74 72 61 76 65 72 73 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 .traversing..................//.
13f00 20 20 20 20 20 20 74 68 65 20 61 72 72 61 79 73 20 69 6e 20 46 69 72 65 53 74 61 74 65 43 68 61 ......the.arrays.in.FireStateCha
13f20 6e 67 65 4e 6f 74 69 66 69 63 61 74 69 6f 6e 73 2e 20 4e 6f 74 65 20 74 68 61 74 20 61 70 70 65 ngeNotifications..Note.that.appe
13f40 6e 64 69 6e 67 20 2a 6d 61 79 2a 20 6d 65 61 6e 20 74 68 61 74 20 74 68 65 20 61 72 72 61 79 73 nding.*may*.mean.that.the.arrays
13f60 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 61 72 65 20 73 ..................//.......are.s
13f80 77 69 74 63 68 65 64 20 74 6f 20 6c 61 72 67 65 72 20 61 72 72 61 79 73 2e 0d 0a 0d 0a 20 20 20 witched.to.larger.arrays........
13fa0 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 63 6f 72 64 20 6c 69 73 74 65 6e 65 72 2e .............//.Record.listener.
13fc0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 69 73 74 65 6e 65 72 43 6f ..................var.listenerCo
13fe0 75 6e 74 20 3d 20 73 69 67 6e 61 6c 6c 65 64 2e 6c 65 6e 67 74 68 3b 0d 0a 20 20 20 20 20 20 20 unt.=.signalled.length;.........
14000 20 20 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 .........ArrayHelpers.AppendWith
14020 43 61 70 61 63 69 74 79 28 72 65 66 20 6c 69 73 74 65 6e 65 72 73 2c 20 72 65 66 20 6c 69 73 74 Capacity(ref.listeners,.ref.list
14040 65 6e 65 72 43 6f 75 6e 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 enerCount,......................
14060 6e 65 77 20 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 4c 69 73 74 65 6e 65 72 20 7b new.StateChangeMonitorListener.{
14080 6d 6f 6e 69 74 6f 72 20 3d 20 6d 6f 6e 69 74 6f 72 2c 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 20 monitor.=.monitor,.monitorIndex.
140a0 3d 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 2c 20 63 6f 6e 74 72 6f 6c 20 3d 20 63 6f 6e 74 72 6f =.monitorIndex,.control.=.contro
140c0 6c 7d 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 63 6f 72 l});....................//.Recor
140e0 64 20 6d 65 6d 6f 72 79 20 72 65 67 69 6f 6e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d.memory.region.................
14100 20 20 72 65 66 20 76 61 72 20 63 6f 6e 74 72 6f 6c 53 74 61 74 65 42 6c 6f 63 6b 20 3d 20 72 65 ..ref.var.controlStateBlock.=.re
14120 66 20 63 6f 6e 74 72 6f 6c 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 3b 0d 0a 20 20 20 20 20 20 20 f.control.m_StateBlock;.........
14140 20 20 20 20 20 20 20 20 20 76 61 72 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 43 6f 75 6e 74 20 3d .........var.memoryRegionCount.=
14160 20 73 69 67 6e 61 6c 6c 65 64 2e 6c 65 6e 67 74 68 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .signalled.length;..............
14180 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 ....ArrayHelpers.AppendWithCapac
141a0 69 74 79 28 72 65 66 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 73 2c 20 72 65 66 20 6d 65 6d 6f 72 ity(ref.memoryRegions,.ref.memor
141c0 79 52 65 67 69 6f 6e 43 6f 75 6e 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 yRegionCount,...................
141e0 20 20 20 6e 65 77 20 4d 65 6d 6f 72 79 48 65 6c 70 65 72 73 2e 42 69 74 52 65 67 69 6f 6e 28 63 ...new.MemoryHelpers.BitRegion(c
14200 6f 6e 74 72 6f 6c 53 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 2d 20 63 6f ontrolStateBlock.byteOffset.-.co
14220 6e 74 72 6f 6c 2e 64 65 76 69 63 65 2e 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 ntrol.device.stateBlock.byteOffs
14240 65 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e et,..........................con
14260 74 72 6f 6c 53 74 61 74 65 42 6c 6f 63 6b 2e 62 69 74 4f 66 66 73 65 74 2c 20 63 6f 6e 74 72 6f trolStateBlock.bitOffset,.contro
14280 6c 53 74 61 74 65 42 6c 6f 63 6b 2e 73 69 7a 65 49 6e 42 69 74 73 29 29 3b 0d 0a 0d 0a 20 20 20 lStateBlock.sizeInBits));.......
142a0 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 6e 61 6c 6c 65 64 2e 53 65 74 4c 65 6e 67 74 68 .............signalled.SetLength
142c0 28 73 69 67 6e 61 6c 6c 65 64 2e 6c 65 6e 67 74 68 20 2b 20 31 29 3b 0d 0a 20 20 20 20 20 20 20 (signalled.length.+.1);.........
142e0 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 .....}................public.voi
14300 64 20 52 65 6d 6f 76 65 28 49 49 6e 70 75 74 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f d.Remove(IInputStateChangeMonito
14320 72 20 6d 6f 6e 69 74 6f 72 2c 20 6c 6f 6e 67 20 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 29 0d 0a 20 r.monitor,.long.monitorIndex)...
14340 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f ...........{..................//
14360 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d 75 73 74 20 2a 6e 6f 74 2a 20 61 63 74 75 61 6c 6c 79 20 .NOTE:.This.must.*not*.actually.
14380 64 65 73 74 72 6f 79 20 74 68 65 20 72 65 63 6f 72 64 20 66 6f 72 20 74 68 65 20 6d 6f 6e 69 74 destroy.the.record.for.the.monit
143a0 6f 72 20 61 73 20 77 65 20 6d 61 79 20 63 75 72 72 65 6e 74 6c 79 20 62 65 20 74 72 61 76 65 72 or.as.we.may.currently.be.traver
143c0 73 69 6e 67 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 sing.the..................//....
143e0 20 20 20 61 72 72 61 79 73 20 69 6e 20 46 69 72 65 53 74 61 74 65 43 68 61 6e 67 65 4e 6f 74 69 ...arrays.in.FireStateChangeNoti
14400 66 69 63 61 74 69 6f 6e 73 2e 20 49 6e 73 74 65 61 64 2c 20 77 65 20 6f 6e 6c 79 20 69 6e 76 61 fications..Instead,.we.only.inva
14420 6c 69 64 61 74 65 20 65 6e 74 72 69 65 73 20 68 65 72 65 20 61 6e 64 20 6c 65 61 76 65 20 69 74 lidate.entries.here.and.leave.it
14440 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 50 72 .to..................//.......Pr
14460 6f 63 65 73 73 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 20 74 6f 20 63 6f 6d 70 ocessStateChangeMonitors.to.comp
14480 61 63 74 20 61 72 72 61 79 73 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 act.arrays.....................i
144a0 66 20 28 6c 69 73 74 65 6e 65 72 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 f.(listeners.==.null)...........
144c0 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 ...........return;..............
144e0 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 73 69 67 6e 61 6c ......for.(var.i.=.0;.i.<.signal
14500 6c 65 64 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 led.length;.++i)................
14520 20 20 20 20 20 20 69 66 20 28 52 65 66 65 72 65 6e 63 65 45 71 75 61 6c 73 28 6c 69 73 74 65 6e ......if.(ReferenceEquals(listen
14540 65 72 73 5b 69 5d 2e 6d 6f 6e 69 74 6f 72 2c 20 6d 6f 6e 69 74 6f 72 29 20 26 26 20 6c 69 73 74 ers[i].monitor,.monitor).&&.list
14560 65 6e 65 72 73 5b 69 5d 2e 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 20 3d 3d 20 6d 6f 6e 69 74 6f 72 eners[i].monitorIndex.==.monitor
14580 49 6e 64 65 78 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 Index)......................{...
145a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6c 69 73 74 65 6e 65 72 73 .......................listeners
145c0 5b 69 5d 20 3d 20 64 65 66 61 75 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 [i].=.default;..................
145e0 20 20 20 20 20 20 20 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 73 5b 69 5d 20 3d 20 64 65 66 61 75 ........memoryRegions[i].=.defau
14600 6c 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 lt;..........................sig
14620 6e 61 6c 6c 65 64 2e 43 6c 65 61 72 42 69 74 28 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 nalled.ClearBit(i);.............
14640 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .............break;.............
14660 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .........}..............}.......
14680 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 43 6c 65 61 72 28 29 0d 0a 20 20 .........public.void.Clear()....
146a0 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 ..........{..................//.
146c0 57 65 20 64 6f 6e 27 74 20 61 63 74 75 61 6c 6c 79 20 72 65 6c 65 61 73 65 20 6d 65 6d 6f 72 79 We.don't.actually.release.memory
146e0 20 77 65 27 76 65 20 70 6f 74 65 6e 74 69 61 6c 6c 79 20 61 6c 6c 6f 63 61 74 65 64 20 62 75 74 .we've.potentially.allocated.but
14700 20 72 61 74 68 65 72 20 6a 75 73 74 20 72 65 73 65 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .rather.just.reset..............
14720 20 20 20 20 2f 2f 20 6f 75 72 20 63 6f 75 6e 74 20 74 6f 20 7a 65 72 6f 2e 0d 0a 20 20 20 20 20 ....//.our.count.to.zero........
14740 20 20 20 20 20 20 20 20 20 20 20 6c 69 73 74 65 6e 65 72 73 2e 43 6c 65 61 72 28 63 6f 75 6e 74 ...........listeners.Clear(count
14760 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 6e 61 6c 6c 65 64 2e 53 65 );..................signalled.Se
14780 74 4c 65 6e 67 74 68 28 30 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 tLength(0);..............}......
147a0 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 64 69 63 65 73 20 63 6f 72 72 ....}............//.Indices.corr
147c0 65 73 70 6f 6e 64 20 77 69 74 68 20 74 68 6f 73 65 20 69 6e 20 6d 5f 44 65 76 69 63 65 73 2e 0d espond.with.those.in.m_Devices..
147e0 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e .........internal.StateChangeMon
14800 69 74 6f 72 73 46 6f 72 44 65 76 69 63 65 5b 5d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f itorsForDevice[].m_StateChangeMo
14820 6e 69 74 6f 72 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e nitors;............///.<summary>
14840 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 52 65 63 6f 72 64 20 66 6f 72 20 61 20 74 69 6d 65 6f ..........///.Record.for.a.timeo
14860 75 74 20 69 6e 73 74 61 6c 6c 65 64 20 6f 6e 20 61 20 73 74 61 74 65 20 63 68 61 6e 67 65 20 6d ut.installed.on.a.state.change.m
14880 6f 6e 69 74 6f 72 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d onitor...........///.</summary>.
148a0 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 73 74 72 75 63 74 20 53 74 61 74 65 43 68 61 .........private.struct.StateCha
148c0 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 ngeMonitorTimeout..........{....
148e0 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 20 63 6f ..........public.InputControl.co
14900 6e 74 72 6f 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 64 6f 75 62 6c ntrol;..............public.doubl
14920 65 20 74 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 49 6e 70 e.time;..............public.IInp
14940 75 74 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 20 6d 6f 6e 69 74 6f 72 3b 0d 0a 20 utStateChangeMonitor.monitor;...
14960 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 6c 6f 6e 67 20 6d 6f 6e 69 74 6f 72 49 6e ...........public.long.monitorIn
14980 64 65 78 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 69 6e 74 20 74 69 6d dex;..............public.int.tim
149a0 65 72 49 6e 64 65 78 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 erIndex;..........}............p
149c0 72 69 76 61 74 65 20 49 6e 6c 69 6e 65 64 41 72 72 61 79 3c 53 74 61 74 65 43 68 61 6e 67 65 4d rivate.InlinedArray<StateChangeM
149e0 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 3e 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 onitorTimeout>.m_StateChangeMoni
14a00 74 6f 72 54 69 6d 65 6f 75 74 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 torTimeouts;............////REVI
14a20 45 57 3a 20 4d 61 6b 65 20 69 74 20 73 6f 20 74 68 61 74 20 64 65 76 69 63 65 20 6e 61 6d 65 73 EW:.Make.it.so.that.device.names
14a40 20 2a 61 6c 77 61 79 73 2a 20 68 61 76 65 20 61 20 6e 75 6d 62 65 72 20 61 70 70 65 6e 64 65 64 .*always*.have.a.number.appended
14a60 3f 20 28 69 2e 65 2e 20 47 61 6d 65 70 61 64 31 2c 20 47 61 6d 65 70 61 64 32 2c 20 65 74 63 2e ?.(i.e..Gamepad1,.Gamepad2,.etc.
14a80 20 69 6e 73 74 65 61 64 20 6f 66 20 47 61 6d 65 70 61 64 2c 20 47 61 6d 65 70 61 64 31 2c 20 65 .instead.of.Gamepad,.Gamepad1,.e
14aa0 74 63 29 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 4d 61 6b 65 tc)............private.void.Make
14ac0 44 65 76 69 63 65 4e 61 6d 65 55 6e 69 71 75 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 DeviceNameUnique(InputDevice.dev
14ae0 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 ice)..........{..............if.
14b00 28 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 (m_DevicesCount.==.0)...........
14b20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 .......return;................va
14b40 72 20 64 65 76 69 63 65 4e 61 6d 65 20 3d 20 53 74 72 69 6e 67 48 65 6c 70 65 72 73 2e 4d 61 6b r.deviceName.=.StringHelpers.Mak
14b60 65 55 6e 69 71 75 65 4e 61 6d 65 28 64 65 76 69 63 65 2e 6e 61 6d 65 2c 20 6d 5f 44 65 76 69 63 eUniqueName(device.name,.m_Devic
14b80 65 73 2c 20 78 20 3d 3e 20 78 20 21 3d 20 6e 75 6c 6c 20 3f 20 78 2e 6e 61 6d 65 20 3a 20 73 74 es,.x.=>.x.!=.null.?.x.name.:.st
14ba0 72 69 6e 67 2e 45 6d 70 74 79 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 ring.Empty);..............if.(de
14bc0 76 69 63 65 4e 61 6d 65 20 21 3d 20 64 65 76 69 63 65 2e 6e 61 6d 65 29 0d 0a 20 20 20 20 20 20 viceName.!=.device.name)........
14be0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 77 ......{..................//.If.w
14c00 65 20 68 61 76 65 20 63 68 61 6e 67 65 64 20 74 68 65 20 6e 61 6d 65 20 6f 66 20 74 68 65 20 64 e.have.changed.the.name.of.the.d
14c20 65 76 69 63 65 2c 20 6e 75 6b 65 20 61 6c 6c 20 70 61 74 68 20 73 74 72 69 6e 67 73 20 69 6e 20 evice,.nuke.all.path.strings.in.
14c40 74 68 65 20 63 6f 6e 74 72 6f 6c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 the.control..................//.
14c60 68 69 65 72 61 72 63 68 79 20 73 6f 20 74 68 61 74 20 74 68 65 79 20 77 69 6c 6c 20 67 65 74 20 hierarchy.so.that.they.will.get.
14c80 72 65 2d 72 65 63 72 65 61 74 65 64 20 77 68 65 6e 20 71 75 65 72 69 65 64 2e 0d 0a 20 20 20 20 re-recreated.when.queried.......
14ca0 20 20 20 20 20 20 20 20 20 20 20 20 52 65 73 65 74 43 6f 6e 74 72 6f 6c 50 61 74 68 73 52 65 63 ............ResetControlPathsRec
14cc0 75 72 73 69 76 65 28 64 65 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ursive(device);.................
14ce0 20 20 20 2f 2f 20 41 73 73 69 67 6e 20 6e 61 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ...//.Assign.name...............
14d00 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 4e 61 6d 65 20 3d 20 6e 65 77 20 49 6e 74 65 72 6e 65 64 ....device.m_Name.=.new.Interned
14d20 53 74 72 69 6e 67 28 64 65 76 69 63 65 4e 61 6d 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 String(deviceName);.............
14d40 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 .}..........}............private
14d60 20 73 74 61 74 69 63 20 76 6f 69 64 20 52 65 73 65 74 43 6f 6e 74 72 6f 6c 50 61 74 68 73 52 65 .static.void.ResetControlPathsRe
14d80 63 75 72 73 69 76 65 28 49 6e 70 75 74 43 6f 6e 74 72 6f 6c 20 63 6f 6e 74 72 6f 6c 29 0d 0a 20 cursive(InputControl.control)...
14da0 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 72 6f 6c 2e 6d 5f .......{..............control.m_
14dc0 50 61 74 68 20 3d 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 Path.=.null;................var.
14de0 63 68 69 6c 64 72 65 6e 20 3d 20 63 6f 6e 74 72 6f 6c 2e 63 68 69 6c 64 72 65 6e 3b 0d 0a 20 20 children.=.control.children;....
14e00 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 68 69 6c 64 43 6f 75 6e 74 20 3d 20 63 68 69 6c 64 ..........var.childCount.=.child
14e20 72 65 6e 2e 43 6f 75 6e 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 ren.Count;................for.(v
14e40 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 63 68 69 6c 64 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a ar.i.=.0;.i.<.childCount;.++i)..
14e60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 73 65 74 43 6f 6e 74 72 6f 6c 50 61 74 68 ................ResetControlPath
14e80 73 52 65 63 75 72 73 69 76 65 28 63 68 69 6c 64 72 65 6e 5b 69 5d 29 3b 0d 0a 20 20 20 20 20 20 sRecursive(children[i]);........
14ea0 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 41 73 73 69 ..}............private.void.Assi
14ec0 67 6e 55 6e 69 71 75 65 44 65 76 69 63 65 49 64 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 gnUniqueDeviceId(InputDevice.dev
14ee0 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 ice)..........{..............//.
14f00 49 66 20 74 68 65 20 64 65 76 69 63 65 20 61 6c 72 65 61 64 79 20 68 61 73 20 61 6e 20 49 44 2c If.the.device.already.has.an.ID,
14f20 20 6d 61 6b 65 20 73 75 72 65 20 69 74 27 73 20 75 6e 69 71 75 65 2e 0d 0a 20 20 20 20 20 20 20 .make.sure.it's.unique..........
14f40 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 64 65 76 69 63 65 49 64 20 21 3d 20 49 6e 70 75 .....if.(device.deviceId.!=.Inpu
14f60 74 44 65 76 69 63 65 2e 49 6e 76 61 6c 69 64 44 65 76 69 63 65 49 64 29 0d 0a 20 20 20 20 20 20 tDevice.InvalidDeviceId)........
14f80 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 61 66 65 ......{..................//.Safe
14fa0 74 79 20 63 68 65 63 6b 20 74 6f 20 6d 61 6b 65 20 73 75 72 65 20 6f 75 74 20 49 44 73 20 61 72 ty.check.to.make.sure.out.IDs.ar
14fc0 65 20 72 65 61 6c 6c 79 20 75 6e 69 71 75 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.really.unique.................
14fe0 20 20 2f 2f 20 47 69 76 65 6e 20 74 68 65 79 20 61 72 65 20 61 73 73 69 67 6e 65 64 20 62 79 20 ..//.Given.they.are.assigned.by.
15000 74 68 65 20 6e 61 74 69 76 65 20 73 79 73 74 65 6d 20 74 68 65 79 20 73 68 6f 75 6c 64 20 62 65 the.native.system.they.should.be
15020 20 66 69 6e 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 62 75 74 20 6c 65 .fine..................//.but.le
15040 74 27 73 20 6d 61 6b 65 20 73 75 72 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 t's.make.sure...................
15060 76 61 72 20 65 78 69 73 74 69 6e 67 44 65 76 69 63 65 57 69 74 68 49 64 20 3d 20 54 72 79 47 65 var.existingDeviceWithId.=.TryGe
15080 74 44 65 76 69 63 65 42 79 49 64 28 64 65 76 69 63 65 2e 64 65 76 69 63 65 49 64 29 3b 0d 0a 20 tDeviceById(device.deviceId);...
150a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 65 78 69 73 74 69 6e 67 44 65 76 69 63 ...............if.(existingDevic
150c0 65 57 69 74 68 49 64 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eWithId.!=.null)................
150e0 20 20 20 20 20 20 74 68 72 6f 77 20 6e 65 77 20 49 6e 76 61 6c 69 64 4f 70 65 72 61 74 69 6f 6e ......throw.new.InvalidOperation
15100 45 78 63 65 70 74 69 6f 6e 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Exception(......................
15120 20 20 20 20 24 22 44 75 70 6c 69 63 61 74 65 20 64 65 76 69 63 65 20 49 44 20 7b 64 65 76 69 63 ....$"Duplicate.device.ID.{devic
15140 65 2e 64 65 76 69 63 65 49 64 7d 20 64 65 74 65 63 74 65 64 20 66 6f 72 20 64 65 76 69 63 65 73 e.deviceId}.detected.for.devices
15160 20 27 7b 64 65 76 69 63 65 2e 6e 61 6d 65 7d 27 20 61 6e 64 20 27 7b 65 78 69 73 74 69 6e 67 44 .'{device.name}'.and.'{existingD
15180 65 76 69 63 65 57 69 74 68 49 64 2e 6e 61 6d 65 7d 27 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 eviceWithId.name}'");...........
151a0 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 ...}..............else..........
151c0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f ....{..................device.m_
151e0 44 65 76 69 63 65 49 64 20 3d 20 6d 5f 52 75 6e 74 69 6d 65 2e 41 6c 6c 6f 63 61 74 65 44 65 76 DeviceId.=.m_Runtime.AllocateDev
15200 69 63 65 49 64 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 iceId();..............}.........
15220 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 28 52 65 29 61 6c 6c 6f 63 61 74 65 73 20 73 .}............//.(Re)allocates.s
15240 74 61 74 65 20 62 75 66 66 65 72 73 20 61 6e 64 20 61 73 73 69 67 6e 73 20 65 61 63 68 20 64 65 tate.buffers.and.assigns.each.de
15260 76 69 63 65 20 74 68 61 74 27 73 20 62 65 65 6e 20 61 64 64 65 64 0d 0a 20 20 20 20 20 20 20 20 vice.that's.been.added..........
15280 2f 2f 20 61 20 73 65 67 6d 65 6e 74 20 6f 66 20 74 68 65 20 62 75 66 66 65 72 2e 20 50 72 65 73 //.a.segment.of.the.buffer..Pres
152a0 65 72 76 65 73 20 74 68 65 20 63 75 72 72 65 6e 74 20 73 74 61 74 65 20 6f 66 20 64 65 76 69 63 erves.the.current.state.of.devic
152c0 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 49 6e 73 74 61 6c 6c 73 20 74 es...........//.NOTE:.Installs.t
152e0 68 65 20 62 75 66 66 65 72 73 20 67 6c 6f 62 61 6c 6c 79 2e 0d 0a 20 20 20 20 20 20 20 20 70 72 he.buffers.globally...........pr
15300 69 76 61 74 65 20 75 6e 73 61 66 65 20 76 6f 69 64 20 52 65 61 6c 6c 6f 63 61 74 65 53 74 61 74 ivate.unsafe.void.ReallocateStat
15320 65 42 75 66 66 65 72 73 28 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 eBuffers()..........{...........
15340 20 20 20 76 61 72 20 6f 6c 64 42 75 66 66 65 72 73 20 3d 20 6d 5f 53 74 61 74 65 42 75 66 66 65 ...var.oldBuffers.=.m_StateBuffe
15360 72 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 6c 6c 6f 63 61 74 65 20 6e rs;................//.Allocate.n
15380 65 77 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 65 77 ew.buffers...............var.new
153a0 42 75 66 66 65 72 73 20 3d 20 6e 65 77 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 28 Buffers.=.new.InputStateBuffers(
153c0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 42 75 66 66 65 72 73 2e 41 6c 6c 6f 63 );..............newBuffers.Alloc
153e0 61 74 65 41 6c 6c 28 6d 5f 44 65 76 69 63 65 73 2c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 ateAll(m_Devices,.m_DevicesCount
15400 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4d 69 67 72 61 74 65 20 73 74 61 );................//.Migrate.sta
15420 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 42 75 66 66 65 72 73 2e 4d 69 67 72 te...............newBuffers.Migr
15440 61 74 65 41 6c 6c 28 6d 5f 44 65 76 69 63 65 73 2c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 ateAll(m_Devices,.m_DevicesCount
15460 2c 20 6f 6c 64 42 75 66 66 65 72 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f ,.oldBuffers);................//
15480 20 49 6e 73 74 61 6c 6c 20 74 68 65 20 6e 65 77 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 .Install.the.new.buffers........
154a0 20 20 20 20 20 20 20 6f 6c 64 42 75 66 66 65 72 73 2e 46 72 65 65 41 6c 6c 28 29 3b 0d 0a 20 20 .......oldBuffers.FreeAll();....
154c0 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 20 3d 20 6e 65 77 42 75 ..........m_StateBuffers.=.newBu
154e0 66 66 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 53 74 61 74 65 42 75 ffers;..............InputStateBu
15500 66 66 65 72 73 2e 73 5f 44 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 66 65 72 20 3d 20 6e 65 77 ffers.s_DefaultStateBuffer.=.new
15520 42 75 66 66 65 72 73 2e 64 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 66 65 72 3b 0d 0a 20 20 20 Buffers.defaultStateBuffer;.....
15540 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 73 5f 4e 6f 69 .........InputStateBuffers.s_Noi
15560 73 65 4d 61 73 6b 42 75 66 66 65 72 20 3d 20 6e 65 77 42 75 66 66 65 72 73 2e 6e 6f 69 73 65 4d seMaskBuffer.=.newBuffers.noiseM
15580 61 73 6b 42 75 66 66 65 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 77 69 askBuffer;................//.Swi
155a0 74 63 68 20 74 6f 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 tch.to.buffers...............Inp
155c0 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 53 77 69 74 63 68 54 6f 28 6d 5f 53 74 61 74 65 42 utStateBuffers.SwitchTo(m_StateB
155e0 75 66 66 65 72 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 uffers,..................InputUp
15600 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 74 65 54 79 70 65 20 21 3d 20 49 6e 70 75 74 55 70 date.s_LastUpdateType.!=.InputUp
15620 64 61 74 65 54 79 70 65 2e 4e 6f 6e 65 20 3f 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 dateType.None.?.InputUpdate.s_La
15640 73 74 55 70 64 61 74 65 54 79 70 65 20 3a 20 64 65 66 61 75 6c 74 55 70 64 61 74 65 54 79 70 65 stUpdateType.:.defaultUpdateType
15660 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 6e 65 65 64 );................////TODO:.need
15680 20 74 6f 20 75 70 64 61 74 65 20 73 74 61 74 65 20 63 68 61 6e 67 65 20 6d 6f 6e 69 74 6f 72 73 .to.update.state.change.monitors
156a0 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ..........}............///.<summ
156c0 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 49 6e 69 74 69 61 6c 69 7a 65 20 64 65 66 ary>..........///.Initialize.def
156e0 61 75 6c 74 20 73 74 61 74 65 20 66 6f 72 20 67 69 76 65 6e 20 64 65 76 69 63 65 2e 0d 0a 20 20 ault.state.for.given.device.....
15700 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f ......///.</summary>..........//
15720 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 64 65 76 69 63 65 22 3e 41 20 6e 65 77 6c 79 20 61 /.<param.name="device">A.newly.a
15740 64 64 65 64 20 69 6e 70 75 74 20 64 65 76 69 63 65 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 dded.input.device.</param>......
15760 20 20 20 20 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 46 ....///.<remarks>..........///.F
15780 6f 72 20 65 76 65 72 79 20 64 65 76 69 63 65 2c 20 6f 6e 65 20 63 6f 70 79 20 6f 66 20 69 74 73 or.every.device,.one.copy.of.its
157a0 20 73 74 61 74 65 20 69 73 20 6b 65 70 74 20 61 72 6f 75 6e 64 20 77 68 69 63 68 20 69 73 20 69 .state.is.kept.around.which.is.i
157c0 6e 69 74 69 61 6c 69 7a 65 64 20 77 69 74 68 20 74 68 65 20 64 65 66 61 75 6c 74 0d 0a 20 20 20 nitialized.with.the.default.....
157e0 20 20 20 20 20 2f 2f 2f 20 76 61 6c 75 65 73 20 66 6f 72 20 74 68 65 20 64 65 76 69 63 65 2e 20 .....///.values.for.the.device..
15800 49 66 20 74 68 65 20 64 65 76 69 63 65 20 68 61 73 20 6e 6f 20 63 6f 6e 74 72 6f 6c 20 74 68 61 If.the.device.has.no.control.tha
15820 74 20 68 61 73 20 61 6e 20 65 78 70 6c 69 63 69 74 6c 79 20 73 70 65 63 69 66 69 65 64 20 63 6f t.has.an.explicitly.specified.co
15840 6e 74 72 6f 6c 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 76 61 6c 75 65 2c 20 74 68 65 20 62 75 ntrol..........///.value,.the.bu
15860 66 66 65 72 20 73 69 6d 70 6c 79 20 63 6f 6e 74 61 69 6e 73 20 61 6c 6c 20 7a 65 72 6f 65 73 2e ffer.simply.contains.all.zeroes.
15880 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 54 68 65 20 64 ..........///..........///.The.d
158a0 65 66 61 75 6c 74 20 73 74 61 74 65 20 62 75 66 66 65 72 20 69 73 20 69 6e 69 74 69 61 6c 69 7a efault.state.buffer.is.initializ
158c0 65 64 20 6f 6e 63 65 20 77 68 65 6e 20 61 20 64 65 76 69 63 65 20 69 73 20 61 64 64 65 64 20 74 ed.once.when.a.device.is.added.t
158e0 6f 20 74 68 65 20 73 79 73 74 65 6d 20 61 6e 64 20 74 68 65 6e 0d 0a 20 20 20 20 20 20 20 20 2f o.the.system.and.then........../
15900 2f 2f 20 6d 69 67 72 61 74 65 64 20 62 79 20 3c 73 65 65 20 63 72 65 66 3d 22 49 6e 70 75 74 53 //.migrated.by.<see.cref="InputS
15920 74 61 74 65 42 75 66 66 65 72 73 22 2f 3e 20 6c 69 6b 65 20 6f 74 68 65 72 20 64 65 76 69 63 65 tateBuffers"/>.like.other.device
15940 20 73 74 61 74 65 20 61 6e 64 20 72 65 6d 6f 76 65 64 20 77 68 65 6e 20 74 68 65 20 64 65 76 69 .state.and.removed.when.the.devi
15960 63 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 69 73 20 72 65 6d 6f 76 65 64 20 66 72 6f 6d 20 ce..........///.is.removed.from.
15980 74 68 65 20 73 79 73 74 65 6d 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 6d 61 72 the.system...........///.</remar
159a0 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 75 6e 73 61 66 65 20 76 6f 69 64 ks>..........private.unsafe.void
159c0 20 49 6e 69 74 69 61 6c 69 7a 65 44 65 66 61 75 6c 74 53 74 61 74 65 28 49 6e 70 75 74 44 65 76 .InitializeDefaultState(InputDev
159e0 69 63 65 20 64 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 ice.device)..........{..........
15a00 20 20 20 20 2f 2f 20 4e 6f 74 68 69 6e 67 20 74 6f 20 64 6f 20 69 66 20 64 65 76 69 63 65 20 68 ....//.Nothing.to.do.if.device.h
15a20 61 73 20 61 20 64 65 66 61 75 6c 74 20 73 74 61 74 65 20 6f 66 20 61 6c 6c 20 7a 65 72 6f 65 73 as.a.default.state.of.all.zeroes
15a40 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 64 65 76 69 63 65 2e 68 61 73 43 6f ...............if.(!device.hasCo
15a60 6e 74 72 6f 6c 73 57 69 74 68 44 65 66 61 75 6c 74 53 74 61 74 65 29 0d 0a 20 20 20 20 20 20 20 ntrolsWithDefaultState).........
15a80 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .........return;................
15aa0 2f 2f 20 4f 74 68 65 72 77 69 73 65 20 67 6f 20 74 68 72 6f 75 67 68 20 65 61 63 68 20 63 6f 6e //.Otherwise.go.through.each.con
15ac0 74 72 6f 6c 20 61 6e 64 20 77 72 69 74 65 20 69 74 73 20 64 65 66 61 75 6c 74 20 76 61 6c 75 65 trol.and.write.its.default.value
15ae0 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 6f 6e 74 72 6f 6c 73 20 3d 20 64 65 ...............var.controls.=.de
15b00 76 69 63 65 2e 61 6c 6c 43 6f 6e 74 72 6f 6c 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 vice.allControls;..............v
15b20 61 72 20 63 6f 6e 74 72 6f 6c 43 6f 75 6e 74 20 3d 20 63 6f 6e 74 72 6f 6c 73 2e 43 6f 75 6e 74 ar.controlCount.=.controls.Count
15b40 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 66 61 75 6c 74 53 74 61 74 65 42 ;..............var.defaultStateB
15b60 75 66 66 65 72 20 3d 20 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 64 65 66 61 75 6c 74 53 74 uffer.=.m_StateBuffers.defaultSt
15b80 61 74 65 42 75 66 66 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 ateBuffer;..............for.(var
15ba0 20 6e 20 3d 20 30 3b 20 6e 20 3c 20 63 6f 6e 74 72 6f 6c 43 6f 75 6e 74 3b 20 2b 2b 6e 29 0d 0a .n.=.0;.n.<.controlCount;.++n)..
15bc0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 ............{..................v
15be0 61 72 20 63 6f 6e 74 72 6f 6c 20 3d 20 63 6f 6e 74 72 6f 6c 73 5b 6e 5d 3b 0d 0a 20 20 20 20 20 ar.control.=.controls[n];.......
15c00 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 63 6f 6e 74 72 6f 6c 2e 68 61 73 44 65 66 61 75 ...........if.(!control.hasDefau
15c20 6c 74 53 74 61 74 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f ltState)......................co
15c40 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 72 ntinue;....................contr
15c60 6f 6c 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 2e 57 72 69 74 65 28 64 65 66 61 75 6c 74 53 74 61 ol.m_StateBlock.Write(defaultSta
15c80 74 65 42 75 66 66 65 72 2c 20 63 6f 6e 74 72 6f 6c 2e 6d 5f 44 65 66 61 75 6c 74 53 74 61 74 65 teBuffer,.control.m_DefaultState
15ca0 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 );..............}...............
15cc0 20 2f 2f 20 43 6f 70 79 20 64 65 66 61 75 6c 74 20 73 74 61 74 65 20 74 6f 20 61 6c 6c 20 66 72 .//.Copy.default.state.to.all.fr
15ce0 6f 6e 74 20 61 6e 64 20 62 61 63 6b 20 62 75 66 66 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 ont.and.back.buffers............
15d00 20 20 20 76 61 72 20 73 74 61 74 65 42 6c 6f 63 6b 20 3d 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 ...var.stateBlock.=.device.m_Sta
15d20 74 65 42 6c 6f 63 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 teBlock;..............var.device
15d40 49 6e 64 65 78 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 3b 0d 0a 20 Index.=.device.m_DeviceIndex;...
15d60 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f ...........if.(m_StateBuffers.m_
15d80 50 6c 61 79 65 72 53 74 61 74 65 42 75 66 66 65 72 73 2e 76 61 6c 69 64 29 0d 0a 20 20 20 20 20 PlayerStateBuffers.valid).......
15da0 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 42 .......{..................stateB
15dc0 6c 6f 63 6b 2e 43 6f 70 79 54 6f 46 72 6f 6d 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d lock.CopyToFrom(m_StateBuffers.m
15de0 5f 50 6c 61 79 65 72 53 74 61 74 65 42 75 66 66 65 72 73 2e 47 65 74 46 72 6f 6e 74 42 75 66 66 _PlayerStateBuffers.GetFrontBuff
15e00 65 72 28 64 65 76 69 63 65 49 6e 64 65 78 29 2c 20 64 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 er(deviceIndex),.defaultStateBuf
15e20 66 65 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 42 6c 6f 63 fer);..................stateBloc
15e40 6b 2e 43 6f 70 79 54 6f 46 72 6f 6d 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f 50 6c k.CopyToFrom(m_StateBuffers.m_Pl
15e60 61 79 65 72 53 74 61 74 65 42 75 66 66 65 72 73 2e 47 65 74 42 61 63 6b 42 75 66 66 65 72 28 64 ayerStateBuffers.GetBackBuffer(d
15e80 65 76 69 63 65 49 6e 64 65 78 29 2c 20 64 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 66 65 72 29 eviceIndex),.defaultStateBuffer)
15ea0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ;..............}................
15ec0 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 #if.UNITY_EDITOR..............if
15ee0 20 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f 45 64 69 74 6f 72 53 74 61 74 65 42 75 .(m_StateBuffers.m_EditorStateBu
15f00 66 66 65 72 73 2e 76 61 6c 69 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 ffers.valid)..............{.....
15f20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 42 6c 6f 63 6b 2e 43 6f 70 79 54 6f 46 72 .............stateBlock.CopyToFr
15f40 6f 6d 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f 45 64 69 74 6f 72 53 74 61 74 65 42 om(m_StateBuffers.m_EditorStateB
15f60 75 66 66 65 72 73 2e 47 65 74 46 72 6f 6e 74 42 75 66 66 65 72 28 64 65 76 69 63 65 49 6e 64 65 uffers.GetFrontBuffer(deviceInde
15f80 78 29 2c 20 64 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 66 65 72 29 3b 0d 0a 20 20 20 20 20 20 x),.defaultStateBuffer);........
15fa0 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 42 6c 6f 63 6b 2e 43 6f 70 79 54 6f 46 72 6f 6d 28 ..........stateBlock.CopyToFrom(
15fc0 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f 45 64 69 74 6f 72 53 74 61 74 65 42 75 66 66 m_StateBuffers.m_EditorStateBuff
15fe0 65 72 73 2e 47 65 74 42 61 63 6b 42 75 66 66 65 72 28 64 65 76 69 63 65 49 6e 64 65 78 29 2c 20 ers.GetBackBuffer(deviceIndex),.
16000 64 65 66 61 75 6c 74 53 74 61 74 65 42 75 66 66 65 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 defaultStateBuffer);............
16020 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 ..}..............#endif.........
16040 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 75 6e 73 61 66 65 20 76 6f 69 .}............private.unsafe.voi
16060 64 20 49 6e 69 74 69 61 6c 69 7a 65 4e 6f 69 73 65 4d 61 73 6b 28 49 6e 70 75 74 44 65 76 69 63 d.InitializeNoiseMask(InputDevic
16080 65 20 64 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 e.device)..........{............
160a0 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 64 65 76 69 63 65 20 21 3d 20 6e 75 6c 6c 2c 20 22 ..Debug.Assert(device.!=.null,."
160c0 44 65 76 69 63 65 20 6d 75 73 74 20 6e 6f 74 20 62 65 20 6e 75 6c 6c 22 29 3b 0d 0a 20 20 20 20 Device.must.not.be.null");......
160e0 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 64 65 76 69 63 65 2e 61 64 64 65 ........Debug.Assert(device.adde
16100 64 2c 20 22 44 65 76 69 63 65 20 6d 75 73 74 20 68 61 76 65 20 62 65 65 6e 20 61 64 64 65 64 22 d,."Device.must.have.been.added"
16120 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 64 65 76 );..............Debug.Assert(dev
16140 69 63 65 2e 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 21 3d 20 49 6e 70 ice.stateBlock.byteOffset.!=.Inp
16160 75 74 53 74 61 74 65 42 6c 6f 63 6b 2e 49 6e 76 61 6c 69 64 4f 66 66 73 65 74 2c 20 22 44 65 76 utStateBlock.InvalidOffset,."Dev
16180 69 63 65 20 73 74 61 74 65 20 62 6c 6f 63 6b 20 6f 66 66 73 65 74 20 69 73 20 69 6e 76 61 6c 69 ice.state.block.offset.is.invali
161a0 64 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 0d d");..............Debug.Assert(.
161c0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 73 74 61 74 65 42 6c 6f .................device.stateBlo
161e0 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 2b 20 64 65 76 69 63 65 2e 73 74 61 74 65 42 6c 6f 63 ck.byteOffset.+.device.stateBloc
16200 6b 2e 61 6c 69 67 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 20 3c 3d 20 6d 5f 53 74 61 74 65 42 k.alignedSizeInBytes.<=.m_StateB
16220 75 66 66 65 72 73 2e 73 69 7a 65 50 65 72 42 75 66 66 65 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 uffers.sizePerBuffer,...........
16240 20 20 20 20 20 20 20 22 44 65 76 69 63 65 20 73 74 61 74 65 20 62 6c 6f 63 6b 20 69 73 20 6e 6f ......."Device.state.block.is.no
16260 74 20 63 6f 6e 74 61 69 6e 65 64 20 69 6e 20 73 74 61 74 65 20 62 75 66 66 65 72 22 29 3b 0d 0a t.contained.in.state.buffer");..
16280 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 6f 6e 74 72 6f 6c 73 20 3d 20 64 65 76 ..............var.controls.=.dev
162a0 69 63 65 2e 61 6c 6c 43 6f 6e 74 72 6f 6c 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 ice.allControls;..............va
162c0 72 20 63 6f 6e 74 72 6f 6c 43 6f 75 6e 74 20 3d 20 63 6f 6e 74 72 6f 6c 73 2e 43 6f 75 6e 74 3b r.controlCount.=.controls.Count;
162e0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 73 73 75 6d 65 20 74 68 61 74 20 65 ................//.Assume.that.e
16300 76 65 72 79 74 68 69 6e 67 20 69 6e 20 74 68 65 20 64 65 76 69 63 65 20 69 73 20 6e 6f 69 73 65 verything.in.the.device.is.noise
16320 2e 20 54 68 69 73 20 77 61 79 20 77 65 20 61 6c 73 6f 20 63 61 74 63 68 20 6d 65 6d 6f 72 79 20 ..This.way.we.also.catch.memory.
16340 72 65 67 69 6f 6e 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 61 74 20 61 72 65 regions..............//.that.are
16360 20 6e 6f 74 20 61 63 74 75 61 6c 6c 79 20 63 6f 76 65 72 65 64 20 62 79 20 61 20 63 6f 6e 74 72 .not.actually.covered.by.a.contr
16380 6f 6c 20 61 6e 64 20 69 6d 70 6c 69 63 69 74 6c 79 20 6d 61 72 6b 20 74 68 65 6d 20 61 73 20 6e ol.and.implicitly.mark.them.as.n
163a0 6f 69 73 65 20 28 65 2e 67 2e 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 72 oise.(e.g..the..............//.r
163c0 65 70 6f 72 74 20 49 44 20 69 6e 20 48 49 44 20 69 6e 70 75 74 20 72 65 70 6f 72 74 73 29 2e 0d eport.ID.in.HID.input.reports)..
163e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 .............//..............//.
16400 4e 4f 54 45 3a 20 4e 6f 69 73 65 20 69 73 20 69 6e 64 69 63 61 74 65 64 20 62 79 20 2a 75 6e 73 NOTE:.Noise.is.indicated.by.*uns
16420 65 74 2a 20 62 69 74 73 20 73 6f 20 77 65 20 64 6f 6e 27 74 20 68 61 76 65 20 74 6f 20 64 6f 20 et*.bits.so.we.don't.have.to.do.
16440 61 6e 79 74 68 69 6e 67 20 68 65 72 65 20 74 6f 20 73 74 61 72 74 0d 0a 20 20 20 20 20 20 20 20 anything.here.to.start..........
16460 20 20 20 20 2f 2f 20 20 20 20 20 20 20 77 69 74 68 20 61 6c 6c 2d 6e 6f 69 73 65 20 61 73 20 77 ....//.......with.all-noise.as.w
16480 65 20 65 78 70 65 63 74 20 6e 6f 69 73 65 20 6d 61 73 6b 20 6d 65 6d 6f 72 79 20 74 6f 20 62 65 e.expect.noise.mask.memory.to.be
164a0 20 63 6c 65 61 72 65 64 20 6f 6e 20 61 6c 6c 6f 63 61 74 69 6f 6e 2e 0d 0a 0d 0a 20 20 20 20 20 .cleared.on.allocation..........
164c0 20 20 20 20 20 20 20 76 61 72 20 6e 6f 69 73 65 4d 61 73 6b 42 75 66 66 65 72 20 3d 20 6d 5f 53 .......var.noiseMaskBuffer.=.m_S
164e0 74 61 74 65 42 75 66 66 65 72 73 2e 6e 6f 69 73 65 4d 61 73 6b 42 75 66 66 65 72 3b 0d 0a 0d 0a tateBuffers.noiseMaskBuffer;....
16500 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 46 49 58 4d 45 3a 20 74 68 69 73 20 6e 65 65 64 ............////FIXME:.this.need
16520 73 20 74 6f 20 70 72 6f 70 65 72 6c 79 20 74 61 6b 65 20 6c 65 61 66 20 76 73 20 6e 6f 6e 2d 6c s.to.properly.take.leaf.vs.non-l
16540 65 61 66 20 63 6f 6e 74 72 6f 6c 73 20 69 6e 74 6f 20 61 63 63 6f 75 6e 74 0d 0a 0d 0a 20 20 20 eaf.controls.into.account.......
16560 20 20 20 20 20 20 20 20 20 2f 2f 20 47 6f 20 74 68 72 6f 75 67 68 20 63 6f 6e 74 72 6f 6c 73 20 .........//.Go.through.controls.
16580 61 6e 64 20 66 6f 72 20 65 61 63 68 20 6f 6e 65 20 74 68 61 74 20 69 73 6e 27 74 20 6e 6f 69 73 and.for.each.one.that.isn't.nois
165a0 79 2c 20 73 65 74 20 74 68 65 20 63 6f 6e 74 72 6f 6c 27 73 0d 0a 20 20 20 20 20 20 20 20 20 20 y,.set.the.control's............
165c0 20 20 2f 2f 20 62 69 74 73 20 69 6e 20 74 68 65 20 6d 61 73 6b 2e 0d 0a 20 20 20 20 20 20 20 20 ..//.bits.in.the.mask...........
165e0 20 20 20 20 66 6f 72 20 28 76 61 72 20 6e 20 3d 20 30 3b 20 6e 20 3c 20 63 6f 6e 74 72 6f 6c 43 ....for.(var.n.=.0;.n.<.controlC
16600 6f 75 6e 74 3b 20 2b 2b 6e 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 ount;.++n)..............{.......
16620 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 6f 6e 74 72 6f 6c 20 3d 20 63 6f 6e 74 72 6f 6c ...........var.control.=.control
16640 73 5b 6e 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 63 6f 6e 74 72 s[n];..................if.(contr
16660 6f 6c 2e 6e 6f 69 73 79 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 ol.noisy)......................c
16680 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 ontinue;....................ref.
166a0 76 61 72 20 73 74 61 74 65 42 6c 6f 63 6b 20 3d 20 72 65 66 20 63 6f 6e 74 72 6f 6c 2e 6d 5f 53 var.stateBlock.=.ref.control.m_S
166c0 74 61 74 65 42 6c 6f 63 6b 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 tateBlock;....................De
166e0 62 75 67 2e 41 73 73 65 72 74 28 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 bug.Assert(stateBlock.byteOffset
16700 20 21 3d 20 49 6e 70 75 74 53 74 61 74 65 42 6c 6f 63 6b 2e 49 6e 76 61 6c 69 64 4f 66 66 73 65 .!=.InputStateBlock.InvalidOffse
16720 74 2c 20 22 42 79 74 65 20 6f 66 66 73 65 74 20 69 73 20 69 6e 76 61 6c 69 64 20 6f 6e 20 63 6f t,."Byte.offset.is.invalid.on.co
16740 6e 74 72 6f 6c 27 73 20 73 74 61 74 65 20 62 6c 6f 63 6b 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 ntrol's.state.block");..........
16760 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 73 74 61 74 65 42 6c 6f 63 6b 2e ........Debug.Assert(stateBlock.
16780 62 69 74 4f 66 66 73 65 74 20 21 3d 20 49 6e 70 75 74 53 74 61 74 65 42 6c 6f 63 6b 2e 49 6e 76 bitOffset.!=.InputStateBlock.Inv
167a0 61 6c 69 64 4f 66 66 73 65 74 2c 20 22 42 69 74 20 6f 66 66 73 65 74 20 69 73 20 69 6e 76 61 6c alidOffset,."Bit.offset.is.inval
167c0 69 64 20 6f 6e 20 63 6f 6e 74 72 6f 6c 27 73 20 73 74 61 74 65 20 62 6c 6f 63 6b 22 29 3b 0d 0a id.on.control's.state.block");..
167e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 73 74 61 ................Debug.Assert(sta
16800 74 65 42 6c 6f 63 6b 2e 73 69 7a 65 49 6e 42 69 74 73 20 21 3d 20 49 6e 70 75 74 53 74 61 74 65 teBlock.sizeInBits.!=.InputState
16820 42 6c 6f 63 6b 2e 49 6e 76 61 6c 69 64 4f 66 66 73 65 74 2c 20 22 53 69 7a 65 20 69 73 20 69 6e Block.InvalidOffset,."Size.is.in
16840 76 61 6c 69 64 20 6f 6e 20 63 6f 6e 74 72 6f 6c 27 73 20 73 74 61 74 65 20 62 6c 6f 63 6b 22 29 valid.on.control's.state.block")
16860 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 ;..................Debug.Assert(
16880 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 3e 3d 20 64 65 76 69 63 65 2e stateBlock.byteOffset.>=.device.
168a0 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 2c 20 22 43 6f 6e 74 72 6f 6c 27 stateBlock.byteOffset,."Control'
168c0 73 20 6f 66 66 73 65 74 20 69 73 20 6c 6f 63 61 74 65 64 20 62 65 6c 6f 77 20 64 65 76 69 63 65 s.offset.is.located.below.device
168e0 27 73 20 6f 66 66 73 65 74 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 's.offset");..................De
16900 62 75 67 2e 41 73 73 65 72 74 28 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 bug.Assert(stateBlock.byteOffset
16920 20 2b 20 73 74 61 74 65 42 6c 6f 63 6b 2e 61 6c 69 67 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 .+.stateBlock.alignedSizeInBytes
16940 20 3c 3d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e .<=......................device.
16960 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 2b 20 64 65 76 69 63 65 2e 73 stateBlock.byteOffset.+.device.s
16980 74 61 74 65 42 6c 6f 63 6b 2e 61 6c 69 67 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 2c 20 22 43 tateBlock.alignedSizeInBytes,."C
169a0 6f 6e 74 72 6f 6c 20 73 74 61 74 65 20 62 6c 6f 63 6b 20 6c 69 65 73 20 6f 75 74 73 69 64 65 20 ontrol.state.block.lies.outside.
169c0 6f 66 20 73 74 61 74 65 20 62 75 66 66 65 72 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 of.state.buffer");..............
169e0 20 20 20 20 20 20 4d 65 6d 6f 72 79 48 65 6c 70 65 72 73 2e 53 65 74 42 69 74 73 49 6e 42 75 66 ......MemoryHelpers.SetBitsInBuf
16a00 66 65 72 28 6e 6f 69 73 65 4d 61 73 6b 42 75 66 66 65 72 2c 20 28 69 6e 74 29 73 74 61 74 65 42 fer(noiseMaskBuffer,.(int)stateB
16a20 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 2c 20 28 69 6e 74 29 73 74 61 74 65 42 6c 6f 63 6b lock.byteOffset,.(int)stateBlock
16a40 2e 62 69 74 4f 66 66 73 65 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .bitOffset,.....................
16a60 20 28 69 6e 74 29 73 74 61 74 65 42 6c 6f 63 6b 2e 73 69 7a 65 49 6e 42 69 74 73 2c 20 74 72 75 .(int)stateBlock.sizeInBits,.tru
16a80 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d e);..............}..........}...
16aa0 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 4f 6e 4e 61 74 69 76 65 44 65 .........private.void.OnNativeDe
16ac0 76 69 63 65 44 69 73 63 6f 76 65 72 65 64 28 69 6e 74 20 64 65 76 69 63 65 49 64 2c 20 73 74 72 viceDiscovered(int.deviceId,.str
16ae0 69 6e 67 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 29 0d 0a 20 20 20 20 20 20 20 20 7b ing.deviceDescriptor)..........{
16b00 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 6b 65 20 73 75 72 65 20 77 65 27 72 65 ..............//.Make.sure.we're
16b20 20 6e 6f 74 20 61 64 64 69 6e 67 20 74 6f 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 .not.adding.to.m_AvailableDevice
16b40 73 20 62 65 66 6f 72 65 20 77 65 20 72 65 73 74 6f 72 65 64 20 77 68 61 74 20 77 65 0d 0a 20 20 s.before.we.restored.what.we....
16b60 20 20 20 20 20 20 20 20 20 20 2f 2f 20 68 61 64 20 62 65 66 6f 72 65 20 61 20 64 6f 6d 61 69 6e ..........//.had.before.a.domain
16b80 20 72 65 6c 6f 61 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 73 74 6f 72 65 44 65 76 .reload...............RestoreDev
16ba0 69 63 65 73 41 66 74 65 72 44 6f 6d 61 69 6e 52 65 6c 6f 61 64 49 66 4e 65 63 65 73 73 61 72 79 icesAfterDomainReloadIfNecessary
16bc0 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 65 20 69 66 20 77 65 20 ();................//.See.if.we.
16be0 68 61 76 65 20 61 20 64 69 73 63 6f 6e 6e 65 63 74 65 64 20 64 65 76 69 63 65 20 77 65 20 63 61 have.a.disconnected.device.we.ca
16c00 6e 20 72 65 76 69 76 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 n.revive...............//.NOTE:.
16c20 57 65 20 64 6f 20 74 68 69 73 20 61 6c 6c 20 74 68 65 20 77 61 79 20 75 70 20 68 65 72 65 20 61 We.do.this.all.the.way.up.here.a
16c40 73 20 74 68 65 20 66 69 72 73 74 20 74 68 69 6e 67 20 62 65 66 6f 72 65 20 77 65 20 65 76 65 6e s.the.first.thing.before.we.even
16c60 20 70 61 72 73 65 20 74 68 65 20 4a 53 4f 4e 20 64 65 73 63 72 69 70 74 6f 72 20 73 6f 0d 0a 20 .parse.the.JSON.descriptor.so...
16c80 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 69 66 20 77 65 20 64 6f 20 68 61 76 ...........//.......if.we.do.hav
16ca0 65 20 61 20 64 65 76 69 63 65 20 77 65 20 63 61 6e 20 72 65 76 69 76 65 2c 20 77 65 20 63 61 6e e.a.device.we.can.revive,.we.can
16cc0 20 64 6f 20 73 6f 20 77 69 74 68 6f 75 74 20 61 6c 6c 6f 63 61 74 69 6e 67 20 61 6e 79 20 47 43 .do.so.without.allocating.any.GC
16ce0 20 6d 65 6d 6f 72 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 .memory...............var.device
16d00 20 3d 20 54 72 79 4d 61 74 63 68 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 28 64 65 .=.TryMatchDisconnectedDevice(de
16d20 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 viceDescriptor);................
16d40 2f 2f 20 50 61 72 73 65 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 69 66 20 6e 65 65 64 20 62 65 //.Parse.description,.if.need.be
16d60 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 73 63 72 69 70 74 69 6f 6e 20 3d ...............var.description.=
16d80 20 64 65 76 69 63 65 3f 2e 64 65 73 63 72 69 70 74 69 6f 6e 20 3f 3f 20 49 6e 70 75 74 44 65 76 .device?.description.??.InputDev
16da0 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2e 46 72 6f 6d 4a 73 6f 6e 28 64 65 76 69 63 65 44 65 iceDescription.FromJson(deviceDe
16dc0 73 63 72 69 70 74 6f 72 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 64 64 scriptor);................//.Add
16de0 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6d 61 72 6b 41 73 52 65 6d 6f .it...............var.markAsRemo
16e00 76 65 64 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 ved.=.false;..............try...
16e20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f ...........{..................//
16e40 20 49 66 20 77 65 20 68 61 76 65 20 61 20 72 65 73 74 72 69 63 74 65 64 20 73 65 74 20 6f 66 20 .If.we.have.a.restricted.set.of.
16e60 73 75 70 70 6f 72 74 65 64 20 64 65 76 69 63 65 73 2c 20 66 69 72 73 74 20 63 68 65 63 6b 20 69 supported.devices,.first.check.i
16e80 66 20 69 74 27 73 20 61 20 64 65 76 69 63 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 f.it's.a.device.................
16ea0 20 2f 2f 20 77 65 20 73 68 6f 75 6c 64 20 73 75 70 70 6f 72 74 2e 0d 0a 20 20 20 20 20 20 20 20 .//.we.should.support...........
16ec0 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 65 74 74 69 6e 67 73 2e 73 75 70 70 6f 72 74 65 64 ........if.(m_Settings.supported
16ee0 44 65 76 69 63 65 73 2e 43 6f 75 6e 74 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 Devices.Count.>.0)..............
16f00 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c ....{......................var.l
16f20 61 79 6f 75 74 20 3d 20 64 65 76 69 63 65 20 21 3d 20 6e 75 6c 6c 20 3f 20 64 65 76 69 63 65 2e ayout.=.device.!=.null.?.device.
16f40 6d 5f 4c 61 79 6f 75 74 20 3a 20 54 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 72 6f m_Layout.:.TryFindMatchingContro
16f60 6c 4c 61 79 6f 75 74 28 72 65 66 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 64 65 76 69 63 65 49 lLayout(ref.description,.deviceI
16f80 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 49 73 d);......................if.(!Is
16fa0 44 65 76 69 63 65 4c 61 79 6f 75 74 4d 61 72 6b 65 64 41 73 53 75 70 70 6f 72 74 65 64 49 6e 53 DeviceLayoutMarkedAsSupportedInS
16fc0 65 74 74 69 6e 67 73 28 6c 61 79 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ettings(layout))................
16fe0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ......{.........................
17000 20 2f 2f 20 4e 6f 74 20 73 75 70 70 6f 72 74 65 64 2e 20 49 67 6e 6f 72 65 20 64 65 76 69 63 65 .//.Not.supported..Ignore.device
17020 2e 20 53 74 69 6c 6c 20 77 69 6c 6c 20 67 65 74 20 61 64 64 65 64 20 74 6f 20 6d 5f 41 76 61 69 ..Still.will.get.added.to.m_Avai
17040 6c 61 62 6c 65 44 65 76 69 63 65 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 lableDevices....................
17060 20 20 20 20 20 20 2f 2f 20 6c 69 73 74 20 69 6e 20 66 69 6e 61 6c 6c 79 20 63 6c 61 75 73 65 20 ......//.list.in.finally.clause.
17080 62 65 6c 6f 77 2e 20 49 66 20 6c 61 74 65 72 20 74 68 65 20 73 65 74 20 6f 66 20 73 75 70 70 6f below..If.later.the.set.of.suppo
170a0 72 74 65 64 20 64 65 76 69 63 65 73 20 63 68 61 6e 67 65 73 0d 0a 20 20 20 20 20 20 20 20 20 20 rted.devices.changes............
170c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 73 6f 20 74 68 61 74 20 74 68 65 20 64 65 76 ..............//.so.that.the.dev
170e0 69 63 65 20 69 73 20 6e 6f 77 20 73 75 70 70 6f 72 74 65 64 2c 20 41 70 70 6c 79 53 65 74 74 69 ice.is.now.supported,.ApplySetti
17100 6e 67 73 28 29 20 77 69 6c 6c 20 70 75 6c 6c 20 69 74 20 62 61 63 6b 20 6f 75 74 0d 0a 20 20 20 ngs().will.pull.it.back.out.....
17120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 6e 64 20 63 72 65 61 .....................//.and.crea
17140 74 65 20 74 68 65 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 te.the.device...................
17160 20 20 20 20 20 20 20 20 6d 61 72 6b 41 73 52 65 6d 6f 76 65 64 20 3d 20 74 72 75 65 3b 0d 0a 20 ........markAsRemoved.=.true;...
17180 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a .......................return;..
171a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 ....................}...........
171c0 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 .......}....................if.(
171e0 64 65 76 69 63 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 device.!=.null).................
17200 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 74 27 73 20 .{......................//.It's.
17220 61 20 64 65 76 69 63 65 20 77 65 20 70 75 6c 6c 65 64 20 66 72 6f 6d 20 74 68 65 20 64 69 73 63 a.device.we.pulled.from.the.disc
17240 6f 6e 6e 65 63 74 65 64 20 6c 69 73 74 2e 20 55 70 64 61 74 65 20 74 68 65 20 64 65 76 69 63 65 onnected.list..Update.the.device
17260 20 77 69 74 68 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f .with.the....................../
17280 2f 20 6e 65 77 20 49 44 2c 20 72 65 2d 61 64 64 20 69 74 20 61 6e 64 20 6e 6f 74 69 66 79 20 74 /.new.ID,.re-add.it.and.notify.t
172a0 68 61 74 20 77 65 27 76 65 20 72 65 63 6f 6e 6e 65 63 74 65 64 2e 0d 0a 0d 0a 20 20 20 20 20 20 hat.we've.reconnected...........
172c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 64 20 ..............device.m_DeviceId.
172e0 3d 20 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 =.deviceId;.....................
17300 20 41 64 64 44 65 76 69 63 65 28 64 65 76 69 63 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 .AddDevice(device);.............
17320 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d ...........for.(var.i.=.0;.i.<.m
17340 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b _DeviceChangeListeners.length;.+
17360 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 +i)..........................m_D
17380 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 76 69 63 65 2c 20 eviceChangeListeners[i](device,.
173a0 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 52 65 63 6f 6e 6e 65 63 74 65 64 29 3b 0d InputDeviceChange.Reconnected);.
173c0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
173e0 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 ....else..................{.....
17400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 47 6f 20 74 68 72 6f 75 67 68 20 6e .................//.Go.through.n
17420 6f 72 6d 61 6c 20 6d 61 63 68 69 6e 65 72 79 20 74 6f 20 74 72 79 20 74 6f 20 63 72 65 61 74 65 ormal.machinery.to.try.to.create
17440 20 61 20 6e 65 77 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .a.new.device...................
17460 20 20 20 20 41 64 64 44 65 76 69 63 65 28 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 74 68 72 6f 77 ....AddDevice(description,.throw
17480 49 66 4e 6f 4c 61 79 6f 75 74 46 6f 75 6e 64 3a 20 66 61 6c 73 65 2c 20 64 65 76 69 63 65 49 64 IfNoLayoutFound:.false,.deviceId
174a0 3a 20 64 65 76 69 63 65 49 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 :.deviceId,.....................
174c0 20 20 20 20 20 64 65 76 69 63 65 46 6c 61 67 73 3a 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 .....deviceFlags:.InputDevice.De
174e0 76 69 63 65 46 6c 61 67 73 2e 4e 61 74 69 76 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 viceFlags.Native);..............
17500 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 ....}..............}............
17520 20 20 2f 2f 20 57 65 27 72 65 20 63 61 74 63 68 69 6e 67 20 65 78 63 65 70 74 69 6f 6e 73 20 76 ..//.We're.catching.exceptions.v
17540 65 72 79 20 61 67 67 72 65 73 73 69 76 65 6c 79 20 68 65 72 65 2e 20 54 68 65 20 72 65 61 73 6f ery.aggressively.here..The.reaso
17560 6e 20 69 73 20 74 68 61 74 20 77 65 20 64 6f 6e 27 74 20 77 61 6e 74 0d 0a 20 20 20 20 20 20 20 n.is.that.we.don't.want.........
17580 20 20 20 20 20 2f 2f 20 65 78 63 65 70 74 69 6f 6e 73 20 74 68 72 6f 77 6e 20 61 73 20 61 20 72 .....//.exceptions.thrown.as.a.r
175a0 65 73 75 6c 74 20 6f 66 20 74 72 79 69 6e 67 20 74 6f 20 63 72 65 61 74 65 20 64 65 76 69 63 65 esult.of.trying.to.create.device
175c0 73 20 66 72 6f 6d 20 64 65 76 69 63 65 20 64 69 73 63 6f 76 65 72 69 65 73 20 72 65 70 6f 72 74 s.from.device.discoveries.report
175e0 65 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 62 79 20 6e 61 74 69 76 65 20 74 6f 20 ed..............//.by.native.to.
17600 62 72 65 61 6b 20 74 68 65 20 73 79 73 74 65 6d 20 61 73 20 61 20 77 68 6f 6c 65 2e 20 49 6e 73 break.the.system.as.a.whole..Ins
17620 74 65 61 64 2c 20 77 65 20 77 61 6e 74 20 74 6f 20 6d 61 6b 65 20 74 68 65 20 65 72 72 6f 72 20 tead,.we.want.to.make.the.error.
17640 76 69 73 69 62 6c 65 20 62 75 74 20 74 68 65 6e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f visible.but.then..............//
17660 20 67 6f 20 61 6e 64 20 77 6f 72 6b 20 77 69 74 68 20 77 68 61 74 65 76 65 72 20 64 65 76 69 63 .go.and.work.with.whatever.devic
17680 65 73 20 77 65 20 2a 64 69 64 2a 20 6d 61 6e 61 67 65 20 74 6f 20 63 72 65 61 74 65 20 73 75 63 es.we.*did*.manage.to.create.suc
176a0 63 65 73 73 66 75 6c 6c 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 cessfully...............catch.(E
176c0 78 63 65 70 74 69 6f 6e 20 65 78 63 65 70 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 xception.exception).............
176e0 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 4c 6f 67 45 72 72 .{..................Debug.LogErr
17700 6f 72 28 24 22 43 6f 75 6c 64 20 6e 6f 74 20 63 72 65 61 74 65 20 61 20 64 65 76 69 63 65 20 66 or($"Could.not.create.a.device.f
17720 6f 72 20 27 7b 64 65 73 63 72 69 70 74 69 6f 6e 7d 27 20 28 65 78 63 65 70 74 69 6f 6e 3a 20 7b or.'{description}'.(exception:.{
17740 65 78 63 65 70 74 69 6f 6e 7d 29 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 exception})");..............}...
17760 20 20 20 20 20 20 20 20 20 20 20 66 69 6e 61 6c 6c 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ...........finally..............
17780 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 65 6d 62 65 72 20 69 {..................//.Remember.i
177a0 74 2e 20 44 6f 20 74 68 69 73 20 2a 61 66 74 65 72 2a 20 74 68 65 20 41 64 64 44 65 76 69 63 65 t..Do.this.*after*.the.AddDevice
177c0 28 29 20 63 61 6c 6c 20 61 62 6f 76 65 20 73 6f 20 74 68 61 74 20 69 66 20 74 68 65 72 65 27 73 ().call.above.so.that.if.there's
177e0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 20 6c 69 73 74 65 6e 65 72 20 ..................//.a.listener.
17800 63 72 65 61 74 69 6e 67 20 6c 61 79 6f 75 74 73 20 6f 6e 20 74 68 65 20 66 6c 79 20 77 65 20 77 creating.layouts.on.the.fly.we.w
17820 6f 6e 27 74 20 65 6e 64 20 75 70 20 6d 61 74 63 68 69 6e 67 20 74 68 69 73 20 64 65 76 69 63 65 on't.end.up.matching.this.device
17840 20 61 6e 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 63 72 65 61 74 65 20 .and..................//.create.
17860 61 6e 20 49 6e 70 75 74 44 65 76 69 63 65 20 72 69 67 68 74 20 61 77 61 79 20 28 77 68 69 63 68 an.InputDevice.right.away.(which
17880 20 77 6f 75 6c 64 20 74 68 65 6e 20 63 6f 6e 66 6c 69 63 74 20 77 69 74 68 20 74 68 65 20 6f 6e .would.then.conflict.with.the.on
178a0 65 20 77 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 63 72 65 61 74 65 20 e.we..................//.create.
178c0 69 6e 20 41 64 64 44 65 76 69 63 65 29 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 in.AddDevice)...................
178e0 41 72 72 61 79 48 65 6c 70 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 61 70 61 63 69 74 79 28 ArrayHelpers.AppendWithCapacity(
17900 72 65 66 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 2c 20 72 65 66 20 6d 5f 41 76 ref.m_AvailableDevices,.ref.m_Av
17920 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ailableDeviceCount,.............
17940 20 20 20 20 20 20 20 20 20 6e 65 77 20 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 0d 0a 20 20 .........new.AvailableDevice....
17960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ..................{.............
17980 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 73 63 72 69 70 74 69 6f 6e 20 3d 20 64 65 73 63 72 .............description.=.descr
179a0 69 70 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 iption,.........................
179c0 20 64 65 76 69 63 65 49 64 20 3d 20 64 65 76 69 63 65 49 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 .deviceId.=.deviceId,...........
179e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 73 4e 61 74 69 76 65 20 3d 20 74 72 75 65 2c 0d ...............isNative.=.true,.
17a00 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 73 52 65 6d 6f 76 .........................isRemov
17a20 65 64 20 3d 20 6d 61 72 6b 41 73 52 65 6d 6f 76 65 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ed.=.markAsRemoved,.............
17a40 20 20 20 20 20 20 20 20 20 7d 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 .........});..............}.....
17a60 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 49 6e 70 75 74 44 .....}............private.InputD
17a80 65 76 69 63 65 20 54 72 79 4d 61 74 63 68 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 evice.TryMatchDisconnectedDevice
17aa0 28 73 74 72 69 6e 67 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 29 0d 0a 20 20 20 20 20 (string.deviceDescriptor).......
17ac0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 ...{..............for.(var.i.=.0
17ae0 3b 20 69 20 3c 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 43 6f 75 6e 74 ;.i.<.m_DisconnectedDevicesCount
17b00 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 ;.++i)..............{...........
17b20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 .......var.device.=.m_Disconnect
17b40 65 64 44 65 76 69 63 65 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 edDevices[i];..................v
17b60 61 72 20 64 65 73 63 72 69 70 74 69 6f 6e 20 3d 20 64 65 76 69 63 65 2e 64 65 73 63 72 69 70 74 ar.description.=.device.descript
17b80 69 6f 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 64 6f ion;....................//.We.do
17ba0 6e 27 74 20 70 61 72 73 65 20 74 68 65 20 66 75 6c 6c 20 64 65 73 63 72 69 70 74 69 6f 6e 20 62 n't.parse.the.full.description.b
17bc0 75 74 20 72 61 74 68 65 72 20 67 6f 20 70 72 6f 70 65 72 74 79 20 62 79 20 70 72 6f 70 65 72 74 ut.rather.go.property.by.propert
17be0 79 20 69 6e 20 6f 72 64 65 72 20 74 6f 20 6e 6f 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 y.in.order.to.not...............
17c00 20 20 20 2f 2f 20 61 6c 6c 6f 63 61 74 65 20 47 43 20 6d 65 6d 6f 72 79 20 69 66 20 77 65 20 63 ...//.allocate.GC.memory.if.we.c
17c20 61 6e 20 61 76 6f 69 64 20 69 74 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 an.avoid.it.....................
17c40 69 66 20 28 21 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 73 63 72 69 if.(!string.IsNullOrEmpty(descri
17c60 70 74 69 6f 6e 2e 69 6e 74 65 72 66 61 63 65 4e 61 6d 65 29 20 26 26 0d 0a 20 20 20 20 20 20 20 ption.interfaceName).&&.........
17c80 20 20 20 20 20 20 20 20 20 20 20 20 20 21 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 .............!InputDeviceDescrip
17ca0 74 69 6f 6e 2e 43 6f 6d 70 61 72 65 50 72 6f 70 65 72 74 79 54 6f 44 65 76 69 63 65 44 65 73 63 tion.ComparePropertyToDeviceDesc
17cc0 72 69 70 74 6f 72 28 22 69 6e 74 65 72 66 61 63 65 22 2c 20 64 65 73 63 72 69 70 74 69 6f 6e 2e riptor("interface",.description.
17ce0 69 6e 74 65 72 66 61 63 65 4e 61 6d 65 2c 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 29 interfaceName,.deviceDescriptor)
17d00 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b )......................continue;
17d20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 74 72 69 6e 67 2e 49 73 ..................if.(!string.Is
17d40 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 73 63 72 69 70 74 69 6f 6e 2e 70 72 6f 64 75 63 74 29 NullOrEmpty(description.product)
17d60 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 21 49 6e 70 75 74 44 .&&......................!InputD
17d80 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2e 43 6f 6d 70 61 72 65 50 72 6f 70 65 72 74 79 eviceDescription.CompareProperty
17da0 54 6f 44 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 28 22 70 72 6f 64 75 63 74 22 2c 20 64 65 ToDeviceDescriptor("product",.de
17dc0 73 63 72 69 70 74 69 6f 6e 2e 70 72 6f 64 75 63 74 2c 20 64 65 76 69 63 65 44 65 73 63 72 69 70 scription.product,.deviceDescrip
17de0 74 6f 72 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 tor))......................conti
17e00 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 74 72 69 6e nue;..................if.(!strin
17e20 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 74 79 28 64 65 73 63 72 69 70 74 69 6f 6e 2e 6d 61 6e 75 g.IsNullOrEmpty(description.manu
17e40 66 61 63 74 75 72 65 72 29 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 facturer).&&....................
17e60 20 20 21 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 2e 43 6f 6d 70 61 72 ..!InputDeviceDescription.Compar
17e80 65 50 72 6f 70 65 72 74 79 54 6f 44 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 28 22 6d 61 6e ePropertyToDeviceDescriptor("man
17ea0 75 66 61 63 74 75 72 65 72 22 2c 20 64 65 73 63 72 69 70 74 69 6f 6e 2e 6d 61 6e 75 66 61 63 74 ufacturer",.description.manufact
17ec0 75 72 65 72 2c 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 29 29 0d 0a 20 20 20 20 20 20 urer,.deviceDescriptor))........
17ee0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 ..............continue;.........
17f00 20 20 20 20 20 20 20 20 20 69 66 20 28 21 73 74 72 69 6e 67 2e 49 73 4e 75 6c 6c 4f 72 45 6d 70 .........if.(!string.IsNullOrEmp
17f20 74 79 28 64 65 73 63 72 69 70 74 69 6f 6e 2e 64 65 76 69 63 65 43 6c 61 73 73 29 20 26 26 0d 0a ty(description.deviceClass).&&..
17f40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 21 49 6e 70 75 74 44 65 76 69 63 65 ....................!InputDevice
17f60 44 65 73 63 72 69 70 74 69 6f 6e 2e 43 6f 6d 70 61 72 65 50 72 6f 70 65 72 74 79 54 6f 44 65 76 Description.ComparePropertyToDev
17f80 69 63 65 44 65 73 63 72 69 70 74 6f 72 28 22 74 79 70 65 22 2c 20 64 65 73 63 72 69 70 74 69 6f iceDescriptor("type",.descriptio
17fa0 6e 2e 64 65 76 69 63 65 43 6c 61 73 73 2c 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 6f 72 29 n.deviceClass,.deviceDescriptor)
17fc0 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b )......................continue;
17fe0 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 69 67 6e 6f 72 65 ....................//.We.ignore
18000 20 63 61 70 61 62 69 6c 69 74 69 65 73 20 68 65 72 65 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 .capabilities.here..............
18020 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 45 72 61 73 65 41 74 57 69 74 68 43 .......ArrayHelpers.EraseAtWithC
18040 61 70 61 63 69 74 79 28 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 2c 20 72 apacity(m_DisconnectedDevices,.r
18060 65 66 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 43 6f 75 6e 74 2c 20 69 ef.m_DisconnectedDevicesCount,.i
18080 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 64 65 76 69 63 );..................return.devic
180a0 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e;..............}...............
180c0 20 72 65 74 75 72 6e 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 .return.null;..........}........
180e0 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 49 6e 73 74 61 6c 6c 42 65 66 6f 72 65 55 70 ....private.void.InstallBeforeUp
18100 64 61 74 65 48 6f 6f 6b 49 66 4e 65 63 65 73 73 61 72 79 28 29 0d 0a 20 20 20 20 20 20 20 20 7b dateHookIfNecessary()..........{
18120 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 4e 61 74 69 76 65 42 65 66 6f 72 65 ..............if.(m_NativeBefore
18140 55 70 64 61 74 65 48 6f 6f 6b 65 64 20 7c 7c 20 6d 5f 52 75 6e 74 69 6d 65 20 3d 3d 20 6e 75 6c UpdateHooked.||.m_Runtime.==.nul
18160 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a 20 l)..................return;.....
18180 20 20 20 20 20 20 20 20 20 20 20 6d 5f 52 75 6e 74 69 6d 65 2e 6f 6e 42 65 66 6f 72 65 55 70 64 ...........m_Runtime.onBeforeUpd
181a0 61 74 65 20 3d 20 4f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 ate.=.OnBeforeUpdate;...........
181c0 20 20 20 6d 5f 4e 61 74 69 76 65 42 65 66 6f 72 65 55 70 64 61 74 65 48 6f 6f 6b 65 64 20 3d 20 ...m_NativeBeforeUpdateHooked.=.
181e0 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 true;..........}............priv
18200 61 74 65 20 76 6f 69 64 20 52 65 73 74 6f 72 65 44 65 76 69 63 65 73 41 66 74 65 72 44 6f 6d 61 ate.void.RestoreDevicesAfterDoma
18220 69 6e 52 65 6c 6f 61 64 49 66 4e 65 63 65 73 73 61 72 79 28 29 0d 0a 20 20 20 20 20 20 20 20 7b inReloadIfNecessary()..........{
18240 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a ..............#if.UNITY_EDITOR..
18260 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 ............if.(m_SavedDeviceSta
18280 74 65 73 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 tes.!=.null)..................Re
182a0 73 74 6f 72 65 44 65 76 69 63 65 73 41 66 74 65 72 44 6f 6d 61 69 6e 52 65 6c 6f 61 64 28 29 3b storeDevicesAfterDomainReload();
182c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d ..............#endif..........}.
182e0 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 57 61 72 6e 41 62 6f 75 ...........private.void.WarnAbou
18300 74 44 65 76 69 63 65 73 46 61 69 6c 69 6e 67 54 6f 52 65 63 72 65 61 74 65 41 66 74 65 72 44 6f tDevicesFailingToRecreateAfterDo
18320 6d 61 69 6e 52 65 6c 6f 61 64 28 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 mainReload()..........{.........
18340 20 20 20 20 20 2f 2f 20 49 66 20 77 65 20 73 74 69 6c 6c 20 68 61 76 65 20 61 6e 79 20 73 61 76 .....//.If.we.still.have.any.sav
18360 65 64 20 64 65 76 69 63 65 20 73 74 61 74 65 73 2c 20 77 65 20 68 61 76 65 20 64 65 76 69 63 65 ed.device.states,.we.have.device
18380 73 20 74 68 61 74 20 77 65 20 63 6f 75 6c 64 6e 27 74 20 66 69 67 75 72 65 0d 0a 20 20 20 20 20 s.that.we.couldn't.figure.......
183a0 20 20 20 20 20 20 20 2f 2f 20 6f 75 74 20 68 6f 77 20 74 6f 20 72 65 63 72 65 61 74 65 20 61 66 .......//.out.how.to.recreate.af
183c0 74 65 72 20 61 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 2e 20 4c 6f 67 20 61 20 77 61 72 6e 69 ter.a.domain.reload..Log.a.warni
183e0 6e 67 20 66 6f 72 20 65 61 63 68 20 6f 66 20 74 68 65 6d 20 61 6e 64 0d 0a 20 20 20 20 20 20 20 ng.for.each.of.them.and.........
18400 20 20 20 20 20 2f 2f 20 6c 65 74 20 67 6f 20 6f 66 20 74 68 65 6d 2e 0d 0a 20 20 20 20 20 20 20 .....//.let.go.of.them..........
18420 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 .....#if.UNITY_EDITOR...........
18440 20 20 20 69 66 20 28 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 20 3d 3d 20 6e 75 ...if.(m_SavedDeviceStates.==.nu
18460 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d 0a ll)..................return;....
18480 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 ............for.(var.i.=.0;.i.<.
184a0 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 2e 4c 65 6e 67 74 68 3b 20 2b 2b 69 29 m_SavedDeviceStates.Length;.++i)
184c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..............{.................
184e0 20 72 65 66 20 76 61 72 20 73 74 61 74 65 20 3d 20 72 65 66 20 6d 5f 53 61 76 65 64 44 65 76 69 .ref.var.state.=.ref.m_SavedDevi
18500 63 65 53 74 61 74 65 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 ceStates[i];..................De
18520 62 75 67 2e 4c 6f 67 57 61 72 6e 69 6e 67 28 24 22 43 6f 75 6c 64 20 6e 6f 74 20 72 65 63 72 65 bug.LogWarning($"Could.not.recre
18540 61 74 65 20 64 65 76 69 63 65 20 27 7b 73 74 61 74 65 2e 6e 61 6d 65 7d 27 20 77 69 74 68 20 6c ate.device.'{state.name}'.with.l
18560 61 79 6f 75 74 20 27 7b 73 74 61 74 65 2e 6c 61 79 6f 75 74 7d 27 20 61 66 74 65 72 20 64 6f 6d ayout.'{state.layout}'.after.dom
18580 61 69 6e 20 72 65 6c 6f 61 64 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a ain.reload");..............}....
185a0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 41 74 20 74 68 69 73 20 70 6f 69 6e 74 2c 20 77 65 ............//.At.this.point,.we
185c0 20 74 68 72 6f 77 20 74 68 65 20 64 65 76 69 63 65 20 73 74 61 74 65 73 20 61 77 61 79 20 61 6e .throw.the.device.states.away.an
185e0 64 20 66 6f 72 67 65 74 20 61 62 6f 75 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 77 d.forget.about..............//.w
18600 68 61 74 20 77 65 20 68 61 64 20 62 65 66 6f 72 65 20 74 68 65 20 64 6f 6d 61 69 6e 20 72 65 6c hat.we.had.before.the.domain.rel
18620 6f 61 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 oad...............m_SavedDeviceS
18640 74 61 74 65 73 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 tates.=.null;..............#endi
18660 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 f..........}............private.
18680 76 6f 69 64 20 4f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 28 49 6e 70 75 74 55 70 64 61 74 65 54 void.OnBeforeUpdate(InputUpdateT
186a0 79 70 65 20 75 70 64 61 74 65 54 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 ype.updateType)..........{......
186c0 20 20 20 20 20 20 20 20 2f 2f 20 52 65 73 74 6f 72 65 20 64 65 76 69 63 65 73 20 62 65 66 6f 72 ........//.Restore.devices.befor
186e0 65 20 63 68 65 63 6b 69 6e 67 20 75 70 64 61 74 65 20 6d 61 73 6b 2e 20 53 65 65 20 49 6e 70 75 e.checking.update.mask..See.Inpu
18700 74 53 79 73 74 65 6d 2e 52 75 6e 49 6e 69 74 69 61 6c 55 70 64 61 74 65 28 29 2e 0d 0a 20 20 20 tSystem.RunInitialUpdate()......
18720 20 20 20 20 20 20 20 20 20 52 65 73 74 6f 72 65 44 65 76 69 63 65 73 41 66 74 65 72 44 6f 6d 61 .........RestoreDevicesAfterDoma
18740 69 6e 52 65 6c 6f 61 64 49 66 4e 65 63 65 73 73 61 72 79 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 inReloadIfNecessary();..........
18760 20 20 20 20 20 20 69 66 20 28 28 75 70 64 61 74 65 54 79 70 65 20 26 20 6d 5f 55 70 64 61 74 65 ......if.((updateType.&.m_Update
18780 4d 61 73 6b 29 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 Mask).==.0)..................ret
187a0 75 72 6e 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 53 74 61 74 65 42 75 urn;................InputStateBu
187c0 66 66 65 72 73 2e 53 77 69 74 63 68 54 6f 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2c 20 75 ffers.SwitchTo(m_StateBuffers,.u
187e0 70 64 61 74 65 54 79 70 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 6f pdateType);................//.Fo
18800 72 20 64 65 76 69 63 65 73 20 74 68 61 74 20 68 61 76 65 20 73 74 61 74 65 20 63 61 6c 6c 62 61 r.devices.that.have.state.callba
18820 63 6b 73 2c 20 74 65 6c 6c 20 74 68 65 6d 20 77 65 27 72 65 20 63 61 72 72 79 69 6e 67 20 73 74 cks,.tell.them.we're.carrying.st
18840 61 74 65 20 6f 76 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 74 6f 20 74 68 ate.over..............//.into.th
18860 65 20 6e 65 78 74 20 66 72 61 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d e.next.frame...............if.(m
18880 5f 48 61 76 65 44 65 76 69 63 65 73 57 69 74 68 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 _HaveDevicesWithStateCallbackRec
188a0 65 69 76 65 72 73 20 26 26 20 75 70 64 61 74 65 54 79 70 65 20 21 3d 20 49 6e 70 75 74 55 70 64 eivers.&&.updateType.!=.InputUpd
188c0 61 74 65 54 79 70 65 2e 42 65 66 6f 72 65 52 65 6e 64 65 72 29 20 2f 2f 2f 2f 52 45 56 49 45 57 ateType.BeforeRender).////REVIEW
188e0 3a 20 62 65 66 6f 72 65 2d 72 65 6e 64 65 72 20 68 61 6e 64 6c 69 6e 67 20 69 73 20 70 72 6f 62 :.before-render.handling.is.prob
18900 61 62 6c 79 20 77 72 6f 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 ably.wrong..............{.......
18920 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 68 61 76 65 20 74 6f 20 68 61 6e ...........////TODO:.have.to.han
18940 64 6c 65 20 75 70 64 61 74 65 63 6f 75 6e 74 20 68 65 72 65 2c 20 74 6f 6f 0d 0a 20 20 20 20 20 dle.updatecount.here,.too.......
18960 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 ...........InputUpdate.s_LastUpd
18980 61 74 65 54 79 70 65 20 3d 20 75 70 64 61 74 65 54 79 70 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ateType.=.updateType;...........
189a0 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 .........for.(var.i.=.0;.i.<.m_D
189c0 65 76 69 63 65 73 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 evicesCount;.++i)...............
189e0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 ...{......................var.de
18a00 76 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 vice.=.m_Devices[i];............
18a20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 46 6c ..........if.((device.m_DeviceFl
18a40 61 67 73 20 26 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 2e 48 61 ags.&.InputDevice.DeviceFlags.Ha
18a60 73 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 73 29 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 sStateCallbacks).==.0)..........
18a80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 ................continue;.......
18aa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 57 65 20 64 6f 20 .................//.NOTE:.We.do.
18ac0 2a 6e 6f 74 2a 20 70 65 72 66 6f 72 6d 20 61 20 62 75 66 66 65 72 20 66 6c 69 70 20 68 65 72 65 *not*.perform.a.buffer.flip.here
18ae0 20 61 73 20 77 65 20 64 6f 20 6e 6f 74 20 77 61 6e 74 20 74 6f 20 63 68 61 6e 67 65 20 77 68 61 .as.we.do.not.want.to.change.wha
18b00 74 20 69 73 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f t.is.the......................//
18b20 20 20 20 20 20 20 20 63 75 72 72 65 6e 74 20 61 6e 64 20 77 68 61 74 20 69 73 20 74 68 65 20 70 .......current.and.what.is.the.p
18b40 72 65 76 69 6f 75 73 20 73 74 61 74 65 20 77 68 65 6e 20 77 65 20 63 61 72 72 79 20 73 74 61 74 revious.state.when.we.carry.stat
18b60 65 20 66 6f 72 77 61 72 64 2e 20 52 61 74 68 65 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 e.forward..Rather,..............
18b80 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 4f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 2c ........//.......OnBeforeUpdate,
18ba0 20 69 66 20 69 74 20 6d 6f 64 69 66 69 65 73 20 73 74 61 74 65 2c 20 69 74 20 6d 6f 64 69 66 69 .if.it.modifies.state,.it.modifi
18bc0 65 73 20 74 68 65 20 63 75 72 72 65 6e 74 20 73 74 61 74 65 20 64 69 72 65 63 74 6c 79 2e 0d 0a es.the.current.state.directly...
18be0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 41 6c 73 ....................//.......Als
18c00 6f 2c 20 66 6f 72 20 74 68 65 20 73 61 6d 65 20 72 65 61 73 6f 6e 73 2c 20 77 65 20 64 6f 20 6e o,.for.the.same.reasons,.we.do.n
18c20 6f 74 20 6d 6f 64 69 66 79 20 74 68 65 20 64 79 6e 61 6d 69 63 2f 66 69 78 65 64 20 75 70 64 61 ot.modify.the.dynamic/fixed.upda
18c40 74 65 20 63 6f 75 6e 74 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f te.counts....................../
18c60 2f 20 20 20 20 20 20 20 6f 6e 20 74 68 65 20 64 65 76 69 63 65 2e 20 49 66 20 61 6e 20 65 76 65 /.......on.the.device..If.an.eve
18c80 6e 74 20 63 6f 6d 65 73 20 69 6e 20 69 6e 20 74 68 65 20 75 70 63 6f 6d 69 6e 67 20 75 70 64 61 nt.comes.in.in.the.upcoming.upda
18ca0 74 65 2c 20 69 74 20 73 68 6f 75 6c 64 20 6c 65 61 64 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 20 te,.it.should.lead.to...........
18cc0 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 61 20 62 75 66 66 65 72 20 66 6c 69 ...........//.......a.buffer.fli
18ce0 70 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 28 49 49 6e 70 p.........................((IInp
18d00 75 74 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 29 64 65 76 69 63 65 29 2e utStateCallbackReceiver)device).
18d20 4f 6e 4e 65 78 74 55 70 64 61 74 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 OnNextUpdate();.................
18d40 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .}..............}...............
18d60 20 44 65 6c 65 67 61 74 65 48 65 6c 70 65 72 73 2e 49 6e 76 6f 6b 65 43 61 6c 6c 62 61 63 6b 73 .DelegateHelpers.InvokeCallbacks
18d80 53 61 66 65 28 72 65 66 20 6d 5f 42 65 66 6f 72 65 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 Safe(ref.m_BeforeUpdateListeners
18da0 2c 20 22 6f 6e 42 65 66 6f 72 65 55 70 64 61 74 65 22 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d ,."onBeforeUpdate");..........}.
18dc0 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 ...........///.<summary>........
18de0 20 20 2f 2f 2f 20 41 70 70 6c 79 20 74 68 65 20 73 65 74 74 69 6e 67 73 20 69 6e 20 3c 73 65 65 ..///.Apply.the.settings.in.<see
18e00 20 63 72 65 66 3d 22 6d 5f 53 65 74 74 69 6e 67 73 22 2f 3e 2e 0d 0a 20 20 20 20 20 20 20 20 2f .cref="m_Settings"/>.........../
18e20 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 //.</summary>..........internal.
18e40 76 6f 69 64 20 41 70 70 6c 79 53 65 74 74 69 6e 67 73 28 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d void.ApplySettings()..........{.
18e60 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 79 6e 63 20 75 70 64 61 74 65 20 6d 61 73 6b .............//.Sync.update.mask
18e80 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 65 77 55 70 64 61 74 65 4d 61 73 6b ...............var.newUpdateMask
18ea0 20 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 3b 0d 0a 20 20 20 20 .=.InputUpdateType.Editor;......
18ec0 20 20 20 20 20 20 20 20 69 66 20 28 28 6d 5f 55 70 64 61 74 65 4d 61 73 6b 20 26 20 49 6e 70 75 ........if.((m_UpdateMask.&.Inpu
18ee0 74 55 70 64 61 74 65 54 79 70 65 2e 42 65 66 6f 72 65 52 65 6e 64 65 72 29 20 21 3d 20 30 29 0d tUpdateType.BeforeRender).!=.0).
18f00 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .............{..................
18f20 2f 2f 20 42 65 66 6f 72 65 52 65 6e 64 65 72 20 75 70 64 61 74 65 73 20 61 72 65 20 65 6e 61 62 //.BeforeRender.updates.are.enab
18f40 6c 65 64 20 69 6e 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 64 65 76 69 63 65 73 20 6e 65 65 64 69 led.in.response.to.devices.needi
18f60 6e 67 20 42 65 66 6f 72 65 52 65 6e 64 65 72 20 75 70 64 61 74 65 73 0d 0a 20 20 20 20 20 20 20 ng.BeforeRender.updates.........
18f80 20 20 20 20 20 20 20 20 20 2f 2f 20 73 6f 20 77 65 20 61 6c 77 61 79 73 20 70 72 65 73 65 72 76 .........//.so.we.always.preserv
18fa0 65 20 74 68 69 73 20 69 66 20 73 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.this.if.set...................
18fc0 6e 65 77 55 70 64 61 74 65 4d 61 73 6b 20 7c 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 newUpdateMask.|=.InputUpdateType
18fe0 2e 42 65 66 6f 72 65 52 65 6e 64 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 .BeforeRender;..............}...
19000 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 65 74 74 69 6e 67 73 2e 75 70 64 61 74 65 ...........if.(m_Settings.update
19020 4d 6f 64 65 20 3d 3d 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 2e 73 5f 4f 6c 64 55 6e 73 75 70 Mode.==.InputSettings.s_OldUnsup
19040 70 6f 72 74 65 64 46 69 78 65 64 41 6e 64 44 79 6e 61 6d 69 63 55 70 64 61 74 65 53 65 74 74 69 portedFixedAndDynamicUpdateSetti
19060 6e 67 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 65 74 74 69 6e 67 73 2e ng)..................m_Settings.
19080 75 70 64 61 74 65 4d 6f 64 65 20 3d 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 2e 55 70 64 61 74 updateMode.=.InputSettings.Updat
190a0 65 4d 6f 64 65 2e 50 72 6f 63 65 73 73 45 76 65 6e 74 73 49 6e 44 79 6e 61 6d 69 63 55 70 64 61 eMode.ProcessEventsInDynamicUpda
190c0 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 77 69 74 63 68 20 28 6d 5f 53 65 74 74 69 te;..............switch.(m_Setti
190e0 6e 67 73 2e 75 70 64 61 74 65 4d 6f 64 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a ngs.updateMode)..............{..
19100 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 49 6e 70 75 74 53 65 74 74 69 6e ................case.InputSettin
19120 67 73 2e 55 70 64 61 74 65 4d 6f 64 65 2e 50 72 6f 63 65 73 73 45 76 65 6e 74 73 49 6e 44 79 6e gs.UpdateMode.ProcessEventsInDyn
19140 61 6d 69 63 55 70 64 61 74 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 amicUpdate:.....................
19160 20 6e 65 77 55 70 64 61 74 65 4d 61 73 6b 20 7c 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 .newUpdateMask.|=.InputUpdateTyp
19180 65 2e 44 79 6e 61 6d 69 63 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.Dynamic;......................
191a0 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 49 6e 70 break;..................case.Inp
191c0 75 74 53 65 74 74 69 6e 67 73 2e 55 70 64 61 74 65 4d 6f 64 65 2e 50 72 6f 63 65 73 73 45 76 65 utSettings.UpdateMode.ProcessEve
191e0 6e 74 73 49 6e 46 69 78 65 64 55 70 64 61 74 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ntsInFixedUpdate:...............
19200 20 20 20 20 20 20 20 6e 65 77 55 70 64 61 74 65 4d 61 73 6b 20 7c 3d 20 49 6e 70 75 74 55 70 64 .......newUpdateMask.|=.InputUpd
19220 61 74 65 54 79 70 65 2e 46 69 78 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ateType.Fixed;..................
19240 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 ....break;..................case
19260 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 2e 55 70 64 61 74 65 4d 6f 64 65 2e 50 72 6f 63 65 73 .InputSettings.UpdateMode.Proces
19280 73 45 76 65 6e 74 73 4d 61 6e 75 61 6c 6c 79 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 sEventsManually:................
192a0 20 20 20 20 20 20 6e 65 77 55 70 64 61 74 65 4d 61 73 6b 20 7c 3d 20 49 6e 70 75 74 55 70 64 61 ......newUpdateMask.|=.InputUpda
192c0 74 65 54 79 70 65 2e 4d 61 6e 75 61 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 teType.Manual;..................
192e0 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 66 61 ....break;..................defa
19300 75 6c 74 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 68 72 6f 77 20 ult:......................throw.
19320 6e 65 77 20 4e 6f 74 53 75 70 70 6f 72 74 65 64 45 78 63 65 70 74 69 6f 6e 28 22 49 6e 76 61 6c new.NotSupportedException("Inval
19340 69 64 20 69 6e 70 75 74 20 75 70 64 61 74 65 20 6d 6f 64 65 3a 20 22 20 2b 20 6d 5f 53 65 74 74 id.input.update.mode:.".+.m_Sett
19360 69 6e 67 73 2e 75 70 64 61 74 65 4d 6f 64 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d ings.updateMode);..............}
19380 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 ................#if.UNITY_EDITOR
193a0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 20 74 68 65 20 65 64 69 74 6f 72 2c 20 ..............//.In.the.editor,.
193c0 77 65 20 66 6f 72 63 65 20 65 64 69 74 6f 72 20 75 70 64 61 74 65 73 20 74 6f 20 62 65 20 6f 6e we.force.editor.updates.to.be.on
193e0 20 65 76 65 6e 20 69 66 20 49 6e 70 75 74 45 64 69 74 6f 72 55 73 65 72 53 65 74 74 69 6e 67 73 .even.if.InputEditorUserSettings
19400 2e 6c 6f 63 6b 49 6e 70 75 74 54 6f 47 61 6d 65 56 69 65 77 20 69 73 0d 0a 20 20 20 20 20 20 20 .lockInputToGameView.is.........
19420 20 20 20 20 20 2f 2f 20 6f 6e 20 61 73 20 6f 74 68 65 72 77 69 73 65 20 77 65 27 6c 6c 20 65 6e .....//.on.as.otherwise.we'll.en
19440 64 20 75 70 20 61 63 63 75 6d 75 6c 61 74 69 6e 67 20 65 76 65 6e 74 73 20 69 6e 20 65 64 69 74 d.up.accumulating.events.in.edit
19460 20 6d 6f 64 65 20 77 69 74 68 6f 75 74 20 61 6e 79 6f 6e 65 20 66 6c 75 73 68 69 6e 67 20 74 68 .mode.without.anyone.flushing.th
19480 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 71 75 65 75 65 20 6f 75 74 20 72 65 67 75 e..............//.queue.out.regu
194a0 6c 61 72 6c 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 55 70 64 61 74 65 4d 61 73 larly...............newUpdateMas
194c0 6b 20 7c 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 3b 0d 0a 20 20 k.|=.InputUpdateType.Editor;....
194e0 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 75 70 ..........#endif..............up
19500 64 61 74 65 4d 61 73 6b 20 3d 20 6e 65 77 55 70 64 61 74 65 4d 61 73 6b 3b 0d 0a 0d 0a 20 20 20 dateMask.=.newUpdateMask;.......
19520 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 6f 70 74 69 6d 69 7a 65 20 74 68 69 73 .........////TODO:.optimize.this
19540 20 73 6f 20 74 68 61 74 20 77 65 20 64 6f 6e 27 74 20 72 65 70 65 61 74 65 64 6c 79 20 72 65 63 .so.that.we.don't.repeatedly.rec
19560 72 65 61 74 65 20 73 74 61 74 65 20 69 66 20 77 65 20 61 64 64 2f 72 65 6d 6f 76 65 20 6d 75 6c reate.state.if.we.add/remove.mul
19580 74 69 70 6c 65 20 64 65 76 69 63 65 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 tiple.devices..............////.
195a0 20 20 20 20 20 28 73 61 6d 65 20 67 6f 65 73 20 66 6f 72 20 6e 6f 74 20 72 65 73 6f 6c 76 69 6e .....(same.goes.for.not.resolvin
195c0 67 20 61 63 74 69 6f 6e 73 20 72 65 70 65 61 74 65 64 6c 79 29 0d 0a 0d 0a 20 20 20 20 20 20 20 g.actions.repeatedly)...........
195e0 20 20 20 20 20 2f 2f 20 43 68 65 63 6b 20 69 66 20 74 68 65 72 65 27 73 20 61 6e 79 20 6e 61 74 .....//.Check.if.there's.any.nat
19600 69 76 65 20 64 65 76 69 63 65 20 77 65 20 61 72 65 6e 27 74 20 75 73 69 6e 67 20 41 54 4d 20 77 ive.device.we.aren't.using.ATM.w
19620 68 69 63 68 20 6e 6f 77 20 66 69 74 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 hich.now.fits..............//.th
19640 65 20 73 65 74 20 6f 66 20 73 75 70 70 6f 72 74 65 64 20 64 65 76 69 63 65 73 2e 0d 0a 20 20 20 e.set.of.supported.devices......
19660 20 20 20 20 20 20 20 20 20 41 64 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 54 68 61 74 .........AddAvailableDevicesThat
19680 41 72 65 4e 6f 77 52 65 63 6f 67 6e 69 7a 65 64 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 AreNowRecognized();.............
196a0 20 20 20 2f 2f 20 49 66 20 74 68 65 20 73 65 74 74 69 6e 67 73 20 72 65 73 74 72 69 63 74 20 74 ...//.If.the.settings.restrict.t
196c0 68 65 20 73 65 74 20 6f 66 20 73 75 70 70 6f 72 74 65 64 20 64 65 76 69 63 65 73 2c 20 64 65 6d he.set.of.supported.devices,.dem
196e0 6f 74 65 20 61 6e 79 20 6e 61 74 69 76 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 ote.any.native..............//.d
19700 65 76 69 63 65 20 77 65 20 63 75 72 72 65 6e 74 6c 79 20 68 61 76 65 20 74 68 61 74 20 64 6f 65 evice.we.currently.have.that.doe
19720 73 6e 27 74 20 66 69 74 20 74 68 65 20 72 65 71 75 69 72 65 6d 65 6e 74 73 2e 0d 0a 20 20 20 20 sn't.fit.the.requirements.......
19740 20 20 20 20 20 20 20 20 69 66 20 28 73 65 74 74 69 6e 67 73 2e 73 75 70 70 6f 72 74 65 64 44 65 ........if.(settings.supportedDe
19760 76 69 63 65 73 2e 43 6f 75 6e 74 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d vices.Count.>.0)..............{.
19780 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b .................for.(var.i.=.0;
197a0 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 .i.<.m_DevicesCount;.++i).......
197c0 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...........{....................
197e0 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d 3b 0d 0a 20 20 ..var.device.=.m_Devices[i];....
19800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 20 3d 20 64 ..................var.layout.=.d
19820 65 76 69 63 65 2e 6d 5f 4c 61 79 6f 75 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 evice.m_Layout;.................
19840 20 20 20 20 20 20 20 2f 2f 20 49 66 20 69 74 27 73 20 6e 6f 74 20 69 6e 20 6d 5f 41 76 61 69 6c .......//.If.it's.not.in.m_Avail
19860 61 62 6c 65 44 65 76 69 63 65 73 2c 20 77 65 20 64 6f 6e 27 74 20 61 75 74 6f 6d 61 74 69 63 61 ableDevices,.we.don't.automatica
19880 6c 6c 79 20 72 65 6d 6f 76 65 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 lly.remove.it...................
198a0 20 20 20 20 2f 2f 20 57 68 61 74 65 76 65 72 20 68 61 73 20 62 65 65 6e 20 61 64 64 65 64 20 64 ....//.Whatever.has.been.added.d
198c0 69 72 65 63 74 6c 79 20 74 68 72 6f 75 67 68 20 41 64 64 44 65 76 69 63 65 28 29 2c 20 77 65 20 irectly.through.AddDevice(),.we.
198e0 6b 65 65 70 20 61 6e 64 20 64 6f 6e 27 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 keep.and.don't..................
19900 20 20 20 20 2f 2f 20 72 65 73 74 72 69 63 74 20 62 79 20 60 73 75 70 70 6f 72 74 44 65 76 69 63 ....//.restrict.by.`supportDevic
19920 65 73 60 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 73 es`.......................var.is
19940 49 6e 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 InAvailableDevices.=.false;.....
19960 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 6e 20 3d 20 30 3b .................for.(var.n.=.0;
19980 20 6e 20 3c 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 6e .n.<.m_AvailableDeviceCount;.++n
199a0 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 )......................{........
199c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 41 76 61 69 6c 61 62 6c ..................if.(m_Availabl
199e0 65 44 65 76 69 63 65 73 5b 6e 5d 2e 64 65 76 69 63 65 49 64 20 3d 3d 20 64 65 76 69 63 65 2e 64 eDevices[n].deviceId.==.device.d
19a00 65 76 69 63 65 49 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eviceId)........................
19a20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..{.............................
19a40 20 69 73 49 6e 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 20 3d 20 74 72 75 65 3b 0d 0a 20 .isInAvailableDevices.=.true;...
19a60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b ...........................break
19a80 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 ;..........................}....
19aa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ..................}.............
19ac0 20 20 20 20 20 20 20 20 20 69 66 20 28 21 69 73 49 6e 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 .........if.(!isInAvailableDevic
19ae0 65 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e es)..........................con
19b00 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f tinue;........................//
19b20 20 49 66 20 74 68 65 20 64 65 76 69 63 65 20 6c 61 79 6f 75 74 20 69 73 6e 27 74 20 73 75 70 70 .If.the.device.layout.isn't.supp
19b40 6f 72 74 65 64 20 61 63 63 6f 72 64 69 6e 67 20 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 20 73 orted.according.to.the.current.s
19b60 65 74 74 69 6e 67 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f ettings,......................//
19b80 20 72 65 6d 6f 76 65 20 74 68 65 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .remove.the.device..............
19ba0 20 20 20 20 20 20 20 20 20 69 66 20 28 21 49 73 44 65 76 69 63 65 4c 61 79 6f 75 74 4d 61 72 6b .........if.(!IsDeviceLayoutMark
19bc0 65 64 41 73 53 75 70 70 6f 72 74 65 64 49 6e 53 65 74 74 69 6e 67 73 28 6c 61 79 6f 75 74 29 29 edAsSupportedInSettings(layout))
19be0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 ......................{.........
19c00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 6d 6f 76 65 44 65 76 69 63 65 28 64 65 .................RemoveDevice(de
19c20 76 69 63 65 2c 20 6b 65 65 70 4f 6e 4c 69 73 74 4f 66 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 vice,.keepOnListOfAvailableDevic
19c40 65 73 3a 20 74 72 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 es:.true);......................
19c60 20 20 20 20 2d 2d 69 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d ....--i;......................}.
19c80 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
19ca0 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 61 63 68 65 20 73 6f 6d 65 20 76 }................//.Cache.some.v
19cc0 61 6c 75 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 54 6f 75 63 68 73 63 72 65 65 6e 2e alues...............Touchscreen.
19ce0 73 5f 54 61 70 54 69 6d 65 20 3d 20 73 65 74 74 69 6e 67 73 2e 64 65 66 61 75 6c 74 54 61 70 54 s_TapTime.=.settings.defaultTapT
19d00 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 54 6f 75 63 68 73 63 72 65 65 6e 2e 73 5f ime;..............Touchscreen.s_
19d20 54 61 70 44 65 6c 61 79 54 69 6d 65 20 3d 20 73 65 74 74 69 6e 67 73 2e 6d 75 6c 74 69 54 61 70 TapDelayTime.=.settings.multiTap
19d40 44 65 6c 61 79 54 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 54 6f 75 63 68 73 63 72 DelayTime;..............Touchscr
19d60 65 65 6e 2e 73 5f 54 61 70 52 61 64 69 75 73 53 71 75 61 72 65 64 20 3d 20 73 65 74 74 69 6e 67 een.s_TapRadiusSquared.=.setting
19d80 73 2e 74 61 70 52 61 64 69 75 73 20 2a 20 73 65 74 74 69 6e 67 73 2e 74 61 70 52 61 64 69 75 73 s.tapRadius.*.settings.tapRadius
19da0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 42 75 74 74 6f 6e 43 6f 6e 74 72 6f 6c 2e 73 5f 47 ;..............ButtonControl.s_G
19dc0 6c 6f 62 61 6c 44 65 66 61 75 6c 74 42 75 74 74 6f 6e 50 72 65 73 73 50 6f 69 6e 74 20 3d 20 73 lobalDefaultButtonPressPoint.=.s
19de0 65 74 74 69 6e 67 73 2e 64 65 66 61 75 6c 74 42 75 74 74 6f 6e 50 72 65 73 73 50 6f 69 6e 74 3b ettings.defaultButtonPressPoint;
19e00 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4c 65 74 20 6c 69 73 74 65 6e 65 72 73 ................//.Let.listeners
19e20 20 6b 6e 6f 77 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d .know...............for.(var.i.=
19e40 20 30 3b 20 69 20 3c 20 6d 5f 53 65 74 74 69 6e 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e 65 .0;.i.<.m_SettingsChangedListene
19e60 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 rs.length;.++i).................
19e80 20 6d 5f 53 65 74 74 69 6e 67 73 43 68 61 6e 67 65 64 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 29 .m_SettingsChangedListeners[i]()
19ea0 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c ;..........}............internal
19ec0 20 76 6f 69 64 20 41 64 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 54 68 61 74 41 72 65 .void.AddAvailableDevicesThatAre
19ee0 4e 6f 77 52 65 63 6f 67 6e 69 7a 65 64 28 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 NowRecognized()..........{......
19f00 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 41 76 ........for.(var.i.=.0;.i.<.m_Av
19f20 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 ailableDeviceCount;.++i)........
19f40 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 64 20 ......{..................var.id.
19f60 3d 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 76 69 63 65 49 64 =.m_AvailableDevices[i].deviceId
19f80 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 54 72 79 47 65 74 44 65 76 ;..................if.(TryGetDev
19fa0 69 63 65 42 79 49 64 28 69 64 29 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 iceById(id).!=.null)............
19fc0 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ..........continue;.............
19fe0 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 20 3d 20 54 72 79 46 69 6e 64 4d 61 74 63 68 .......var.layout.=.TryFindMatch
1a000 69 6e 67 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 72 65 66 20 6d 5f 41 76 61 69 6c 61 62 6c 65 ingControlLayout(ref.m_Available
1a020 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 69 64 29 3b 0d 0a 20 20 Devices[i].description,.id);....
1a040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 49 73 44 65 76 69 63 65 4c 61 79 6f 75 74 ..............if.(IsDeviceLayout
1a060 4d 61 72 6b 65 64 41 73 53 75 70 70 6f 72 74 65 64 49 6e 53 65 74 74 69 6e 67 73 28 6c 61 79 6f MarkedAsSupportedInSettings(layo
1a080 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 ut))..................{.........
1a0a0 20 20 20 20 20 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .............try................
1a0c0 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ......{.........................
1a0e0 20 41 64 64 44 65 76 69 63 65 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d .AddDevice(m_AvailableDevices[i]
1a100 2e 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 66 61 6c 73 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 .description,.false,............
1a120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 49 64 3a 20 69 64 2c 0d ..................deviceId:.id,.
1a140 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 .............................dev
1a160 69 63 65 46 6c 61 67 73 3a 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e iceFlags:.m_AvailableDevices[i].
1a180 69 73 4e 61 74 69 76 65 20 3f 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 isNative.?.InputDevice.DeviceFla
1a1a0 67 73 2e 4e 61 74 69 76 65 20 3a 20 30 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 gs.Native.:.0);.................
1a1c0 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 74 63 .....}......................catc
1a1e0 68 20 28 45 78 63 65 70 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 h.(Exception)...................
1a200 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 ...{......................}.....
1a220 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 .............}..............}...
1a240 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 75 6e 73 61 .......}............private.unsa
1a260 66 65 20 76 6f 69 64 20 4f 6e 46 6f 63 75 73 43 68 61 6e 67 65 64 28 62 6f 6f 6c 20 66 6f 63 75 fe.void.OnFocusChanged(bool.focu
1a280 73 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 s)..........{..............////R
1a2a0 45 56 49 45 57 3a 20 73 68 6f 75 6c 64 20 77 65 20 61 6c 73 6f 20 66 6c 75 73 68 20 74 68 65 20 EVIEW:.should.we.also.flush.the.
1a2c0 65 76 65 6e 74 20 71 75 65 75 65 20 6f 6e 20 66 6f 63 75 73 20 6c 6f 73 73 3f 0d 0a 0d 0a 20 20 event.queue.on.focus.loss?......
1a2e0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4f 6e 20 66 6f 63 75 73 20 6c 6f 73 73 2c 20 72 65 73 65 ..........//.On.focus.loss,.rese
1a300 74 20 64 65 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 66 6f 63 t.devices...............if.(!foc
1a320 75 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 us)..............{..............
1a340 20 20 20 20 2f 2f 20 57 68 65 6e 20 72 75 6e 6e 69 6e 67 20 69 6e 20 62 61 63 6b 67 72 6f 75 6e ....//.When.running.in.backgroun
1a360 64 20 69 73 20 65 6e 61 62 6c 65 64 20 66 6f 72 20 74 68 65 20 61 70 70 6c 69 63 61 74 69 6f 6e d.is.enabled.for.the.application
1a380 2c 20 77 65 20 6f 6e 6c 79 20 72 65 73 65 74 20 64 65 76 69 63 65 73 20 74 68 61 74 20 61 72 65 ,.we.only.reset.devices.that.are
1a3a0 6e 27 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6d 61 72 6b 65 64 20 61 n't..................//.marked.a
1a3c0 73 20 63 61 6e 52 75 6e 49 6e 42 61 63 6b 67 72 6f 75 6e 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 s.canRunInBackground............
1a3e0 20 20 20 20 20 20 20 76 61 72 20 72 75 6e 49 6e 42 61 63 6b 67 72 6f 75 6e 64 20 3d 20 6d 5f 52 .......var.runInBackground.=.m_R
1a400 75 6e 74 69 6d 65 2e 72 75 6e 49 6e 42 61 63 6b 67 72 6f 75 6e 64 3b 0d 0a 0d 0a 20 20 20 20 20 untime.runInBackground;.........
1a420 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 69 6e 64 20 74 68 65 20 73 69 7a 65 20 6f 66 20 74 ...........//.Find.the.size.of.t
1a440 68 65 20 6c 61 72 67 65 73 74 20 73 74 61 74 65 20 62 6c 6f 63 6b 2e 20 54 68 69 73 20 64 65 74 he.largest.state.block..This.det
1a460 65 72 6d 69 6e 65 73 20 74 68 65 20 61 6d 6f 75 6e 74 20 6f 66 20 74 65 6d 70 6f 72 61 72 79 20 ermines.the.amount.of.temporary.
1a480 6d 65 6d 6f 72 79 20 77 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6e 65 memory.we..................//.ne
1a4a0 65 64 20 74 6f 20 61 6c 6c 6f 63 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ed.to.allocate..................
1a4c0 20 76 61 72 20 6c 61 72 67 65 73 74 44 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 20 3d 20 30 .var.largestDeviceStateBlock.=.0
1a4e0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 43 6f 75 ;..................var.deviceCou
1a500 6e 74 20 3d 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 nt.=.m_DevicesCount;............
1a520 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 64 65 76 69 63 65 ......for.(var.i.=.0;.i.<.device
1a540 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Count;.++i).....................
1a560 20 6c 61 72 67 65 73 74 44 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 20 3d 20 4d 61 74 68 2e .largestDeviceStateBlock.=.Math.
1a580 4d 61 78 28 6c 61 72 67 65 73 74 44 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 2c 20 28 69 6e Max(largestDeviceStateBlock,.(in
1a5a0 74 29 6d 5f 44 65 76 69 63 65 73 5b 69 5d 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 2e 61 6c 69 67 t)m_Devices[i].m_StateBlock.alig
1a5c0 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 nedSizeInBytes);................
1a5e0 20 20 20 20 2f 2f 20 41 6c 6c 6f 63 61 74 65 20 74 65 6d 70 20 6d 65 6d 6f 72 79 20 74 6f 20 68 ....//.Allocate.temp.memory.to.h
1a600 6f 6c 64 20 6f 6e 65 20 73 74 61 74 65 20 65 76 65 6e 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 old.one.state.event.............
1a620 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 74 68 65 20 6e 65 65 64 20 66 6f 72 20 61 ......////REVIEW:.the.need.for.a
1a640 6e 20 65 76 65 6e 74 20 68 65 72 65 20 69 73 20 73 75 66 66 69 63 69 65 6e 74 6c 79 20 6f 62 73 n.event.here.is.sufficiently.obs
1a660 63 75 72 65 20 74 6f 20 77 61 72 72 61 6e 74 20 73 63 72 75 74 69 6e 79 3b 20 6c 69 6b 65 6c 79 cure.to.warrant.scrutiny;.likely
1a680 2c 20 74 68 65 72 65 27 73 20 61 20 62 65 74 74 65 72 20 77 61 79 0d 0a 20 20 20 20 20 20 20 20 ,.there's.a.better.way..........
1a6a0 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 20 74 6f 20 74 65 6c 6c 20 73 79 6e 74 ........////........to.tell.synt
1a6c0 68 65 74 69 63 20 69 6e 70 75 74 20 28 6f 72 20 69 6e 70 75 74 20 73 6f 75 72 63 65 73 20 69 6e hetic.input.(or.input.sources.in
1a6e0 20 67 65 6e 65 72 61 6c 29 20 61 70 61 72 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .general).apart.................
1a700 20 2f 2f 20 4e 4f 54 45 3a 20 57 65 20 77 72 61 70 20 74 68 65 20 72 65 73 65 74 20 69 6e 20 61 .//.NOTE:.We.wrap.the.reset.in.a
1a720 6e 20 61 72 74 69 66 69 63 69 61 6c 20 73 74 61 74 65 20 65 76 65 6e 74 20 73 6f 20 74 68 61 74 n.artificial.state.event.so.that
1a740 20 69 74 20 61 70 70 65 61 72 73 20 74 6f 20 74 68 65 20 72 65 73 74 20 6f 66 20 74 68 65 20 73 .it.appears.to.the.rest.of.the.s
1a760 79 73 74 65 6d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 ystem..................//.......
1a780 6c 69 6b 65 20 61 6e 79 20 6f 74 68 65 72 20 69 6e 70 75 74 2e 20 49 66 20 77 65 20 64 6f 6e 27 like.any.other.input..If.we.don'
1a7a0 74 20 64 6f 20 74 68 61 74 20 62 75 74 20 72 61 74 68 65 72 20 6a 75 73 74 20 63 61 6c 6c 20 55 t.do.that.but.rather.just.call.U
1a7c0 70 64 61 74 65 53 74 61 74 65 28 29 20 77 69 74 68 20 61 20 6e 75 6c 6c 20 65 76 65 6e 74 0d 0a pdateState().with.a.null.event..
1a7e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 70 6f 69 6e 74 65 72 ................//.......pointer
1a800 2c 20 74 68 65 20 63 68 61 6e 67 65 20 77 69 6c 6c 20 62 65 20 63 6f 6e 73 69 64 65 72 65 64 20 ,.the.change.will.be.considered.
1a820 61 6e 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 65 20 63 68 61 6e 67 65 20 61 6e 64 20 77 69 6c an.internal.state.change.and.wil
1a840 6c 20 67 65 74 20 69 67 6e 6f 72 65 64 20 62 79 20 73 6f 6d 65 0d 0a 20 20 20 20 20 20 20 20 20 l.get.ignored.by.some...........
1a860 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 70 69 65 63 65 73 20 6f 66 20 63 6f 64 65 20 28 .......//.......pieces.of.code.(
1a880 73 75 63 68 20 61 73 20 45 6e 68 61 6e 63 65 64 54 6f 75 63 68 20 77 68 69 63 68 20 66 69 6c 74 such.as.EnhancedTouch.which.filt
1a8a0 65 72 73 20 6f 75 74 20 69 6e 74 65 72 6e 61 6c 20 73 74 61 74 65 20 63 68 61 6e 67 65 73 20 6f ers.out.internal.state.changes.o
1a8c0 66 20 54 6f 75 63 68 73 63 72 65 65 6e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f f.Touchscreen................../
1a8e0 2f 20 20 20 20 20 20 20 62 79 20 69 67 6e 6f 72 69 6e 67 20 61 6e 79 20 63 68 61 6e 67 65 20 74 /.......by.ignoring.any.change.t
1a900 68 61 74 20 69 73 20 6e 6f 74 20 63 6f 6d 69 6e 67 20 66 72 6f 6d 20 61 6e 20 69 6e 70 75 74 20 hat.is.not.coming.from.an.input.
1a920 65 76 65 6e 74 29 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 73 69 6e 67 20 28 event)...................using.(
1a940 76 61 72 20 74 65 6d 70 42 75 66 66 65 72 20 3d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 var.tempBuffer.=................
1a960 20 20 20 20 20 20 20 20 20 20 20 20 20 6e 65 77 20 4e 61 74 69 76 65 41 72 72 61 79 3c 62 79 74 .............new.NativeArray<byt
1a980 65 3e 28 49 6e 70 75 74 45 76 65 6e 74 2e 6b 42 61 73 65 45 76 65 6e 74 53 69 7a 65 20 2b 20 73 e>(InputEvent.kBaseEventSize.+.s
1a9a0 69 7a 65 6f 66 28 69 6e 74 29 20 2b 20 6c 61 72 67 65 73 74 44 65 76 69 63 65 53 74 61 74 65 42 izeof(int).+.largestDeviceStateB
1a9c0 6c 6f 63 6b 2c 20 41 6c 6c 6f 63 61 74 6f 72 2e 54 65 6d 70 29 29 0d 0a 20 20 20 20 20 20 20 20 lock,.Allocator.Temp))..........
1a9e0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 ........{......................v
1aa00 61 72 20 73 74 61 74 65 45 76 65 6e 74 50 74 72 20 3d 20 28 53 74 61 74 65 45 76 65 6e 74 2a 29 ar.stateEventPtr.=.(StateEvent*)
1aa20 74 65 6d 70 42 75 66 66 65 72 2e 47 65 74 55 6e 73 61 66 65 50 74 72 28 29 3b 0d 0a 20 20 20 20 tempBuffer.GetUnsafePtr();......
1aa40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 73 74 61 74 65 50 74 72 20 3d 20 73 ................var.statePtr.=.s
1aa60 74 61 74 65 45 76 65 6e 74 50 74 72 2d 3e 73 74 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 tateEventPtr->state;............
1aa80 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e 74 54 69 6d 65 20 3d 20 6d 5f 52 75 ..........var.currentTime.=.m_Ru
1aaa0 6e 74 69 6d 65 2e 63 75 72 72 65 6e 74 54 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ntime.currentTime;..............
1aac0 20 20 20 20 20 20 20 20 76 61 72 20 75 70 64 61 74 65 54 79 70 65 20 3d 20 64 65 66 61 75 6c 74 ........var.updateType.=.default
1aae0 55 70 64 61 74 65 54 79 70 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 UpdateType;.....................
1ab00 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 64 65 76 69 63 65 43 6f 75 ...for.(var.i.=.0;.i.<.deviceCou
1ab20 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d nt;.++i)......................{.
1ab40 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 .........................var.dev
1ab60 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 ice.=.m_Devices[i];.............
1ab80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 6b 69 70 20 64 69 73 61 62 6c 65 64 20 ...............//.Skip.disabled.
1aba0 64 65 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 devices.........................
1abc0 20 20 69 66 20 28 21 64 65 76 69 63 65 2e 65 6e 61 62 6c 65 64 29 0d 0a 20 20 20 20 20 20 20 20 ..if.(!device.enabled)..........
1abe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d ....................continue;...
1ac00 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 74 .........................//.If.t
1ac20 68 65 20 61 70 70 20 77 69 6c 6c 20 6b 65 65 70 20 72 75 6e 6e 69 6e 67 20 69 6e 20 74 68 65 20 he.app.will.keep.running.in.the.
1ac40 62 61 63 6b 67 72 6f 75 6e 64 20 61 6e 64 20 74 68 65 20 64 65 76 69 63 65 20 69 73 20 6d 61 72 background.and.the.device.is.mar
1ac60 6b 65 64 20 61 73 20 62 65 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ked.as.being....................
1ac80 20 20 20 20 20 20 2f 2f 20 61 62 6c 65 20 74 6f 20 72 75 6e 20 69 6e 20 74 68 65 20 62 61 63 6b ......//.able.to.run.in.the.back
1aca0 67 72 6f 75 6e 64 2c 20 64 6f 6e 27 74 20 74 6f 75 63 68 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 ground,.don't.touch.it..........
1acc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 75 6e 49 6e 42 61 63 6b 67 72 .................if.(runInBackgr
1ace0 6f 75 6e 64 20 26 26 20 64 65 76 69 63 65 2e 63 61 6e 52 75 6e 49 6e 42 61 63 6b 67 72 6f 75 6e ound.&&.device.canRunInBackgroun
1ad00 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d)..............................
1ad20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 continue;.......................
1ad40 20 20 20 20 20 2f 2f 20 53 65 74 20 75 70 20 74 68 65 20 73 74 61 74 65 20 65 76 65 6e 74 2e 0d .....//.Set.up.the.state.event..
1ad60 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 76 61 72 .........................ref.var
1ad80 20 73 74 61 74 65 42 6c 6f 63 6b 20 3d 20 72 65 66 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 .stateBlock.=.ref.device.m_State
1ada0 42 6c 6f 63 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Block;..........................
1adc0 76 61 72 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 20 3d 20 73 74 61 74 65 var.deviceStateBlockSize.=.state
1ade0 42 6c 6f 63 6b 2e 61 6c 69 67 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 3b 0d 0a 20 20 20 20 20 Block.alignedSizeInBytes;.......
1ae00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 45 76 65 6e 74 50 74 72 ...................stateEventPtr
1ae20 2d 3e 62 61 73 65 45 76 65 6e 74 2e 74 79 70 65 20 3d 20 53 74 61 74 65 45 76 65 6e 74 2e 54 79 ->baseEvent.type.=.StateEvent.Ty
1ae40 70 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 pe;..........................sta
1ae60 74 65 45 76 65 6e 74 50 74 72 2d 3e 62 61 73 65 45 76 65 6e 74 2e 73 69 7a 65 49 6e 42 79 74 65 teEventPtr->baseEvent.sizeInByte
1ae80 73 20 3d 20 49 6e 70 75 74 45 76 65 6e 74 2e 6b 42 61 73 65 45 76 65 6e 74 53 69 7a 65 20 2b 20 s.=.InputEvent.kBaseEventSize.+.
1aea0 73 69 7a 65 6f 66 28 69 6e 74 29 20 2b 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 53 69 sizeof(int).+.deviceStateBlockSi
1aec0 7a 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 ze;..........................sta
1aee0 74 65 45 76 65 6e 74 50 74 72 2d 3e 62 61 73 65 45 76 65 6e 74 2e 74 69 6d 65 20 3d 20 63 75 72 teEventPtr->baseEvent.time.=.cur
1af00 72 65 6e 74 54 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 rentTime;.......................
1af20 20 20 20 73 74 61 74 65 45 76 65 6e 74 50 74 72 2d 3e 62 61 73 65 45 76 65 6e 74 2e 64 65 76 69 ...stateEventPtr->baseEvent.devi
1af40 63 65 49 64 20 3d 20 64 65 76 69 63 65 2e 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 ceId.=.device.deviceId;.........
1af60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 45 76 65 6e 74 50 74 72 2d 3e .................stateEventPtr->
1af80 62 61 73 65 45 76 65 6e 74 2e 65 76 65 6e 74 49 64 20 3d 20 2d 31 3b 0d 0a 20 20 20 20 20 20 20 baseEvent.eventId.=.-1;.........
1afa0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 61 74 65 45 76 65 6e 74 50 74 72 2d 3e .................stateEventPtr->
1afc0 73 74 61 74 65 46 6f 72 6d 61 74 20 3d 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 stateFormat.=.device.m_StateBloc
1afe0 6b 2e 66 6f 72 6d 61 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 k.format;.......................
1b000 20 20 20 20 20 2f 2f 20 53 65 74 20 75 70 20 6e 65 77 20 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 .....//.Set.up.new.state........
1b020 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 66 61 75 6c 74 53 74 ...................var.defaultSt
1b040 61 74 65 50 74 72 20 3d 20 64 65 76 69 63 65 2e 64 65 66 61 75 6c 74 53 74 61 74 65 50 74 72 3b atePtr.=.device.defaultStatePtr;
1b060 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 ..........................if.(de
1b080 76 69 63 65 2e 6e 6f 69 73 79 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 vice.noisy).....................
1b0a0 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .....{..........................
1b0c0 20 20 20 20 2f 2f 20 54 68 65 20 64 65 76 69 63 65 20 68 61 73 20 6e 6f 69 73 79 20 63 6f 6e 74 ....//.The.device.has.noisy.cont
1b0e0 72 6f 6c 73 2e 20 57 65 20 64 6f 6e 27 74 20 77 61 6e 74 20 74 6f 20 72 65 73 65 74 20 74 68 6f rols..We.don't.want.to.reset.tho
1b100 73 65 20 61 73 20 74 68 65 79 20 6d 6f 73 74 6c 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 se.as.they.mostly...............
1b120 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 72 65 70 72 65 73 65 6e 74 20 73 65 6e 73 ...............//.represent.sens
1b140 6f 72 20 69 6e 70 75 74 20 61 6e 64 20 72 65 73 65 74 74 69 6e 67 20 73 65 6e 73 6f 72 20 73 61 or.input.and.resetting.sensor.sa
1b160 6d 70 6c 65 73 20 74 6f 20 64 65 66 61 75 6c 74 20 76 61 6c 75 65 73 20 69 73 6e 27 74 20 61 20 mples.to.default.values.isn't.a.
1b180 67 6f 6f 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 good............................
1b1a0 20 20 2f 2f 20 61 20 67 6f 6f 64 20 69 64 65 61 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ..//.a.good.idea................
1b1c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ...............//...............
1b1e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 6f 70 79 20 65 76 65 72 79 74 68 69 6e ...............//.Copy.everythin
1b200 67 20 66 72 6f 6d 20 64 65 66 61 75 6c 74 53 74 61 74 65 50 74 72 20 65 78 63 65 70 74 20 66 6f g.from.defaultStatePtr.except.fo
1b220 72 20 74 68 65 20 62 69 74 73 20 74 68 61 74 20 61 72 65 20 66 6c 61 67 67 65 64 20 69 6e 20 74 r.the.bits.that.are.flagged.in.t
1b240 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 he..............................
1b260 2f 2f 20 64 65 76 69 63 65 27 73 20 6e 6f 69 73 65 20 6d 61 73 6b 2e 0d 0a 0d 0a 20 20 20 20 20 //.device's.noise.mask..........
1b280 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 .......................var.curre
1b2a0 6e 74 53 74 61 74 65 50 74 72 20 3d 20 64 65 76 69 63 65 2e 63 75 72 72 65 6e 74 53 74 61 74 65 ntStatePtr.=.device.currentState
1b2c0 50 74 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Ptr;............................
1b2e0 20 20 76 61 72 20 6e 6f 69 73 65 4d 61 73 6b 50 74 72 20 3d 20 64 65 76 69 63 65 2e 6e 6f 69 73 ..var.noiseMaskPtr.=.device.nois
1b300 65 4d 61 73 6b 50 74 72 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eMaskPtr;.......................
1b320 20 20 20 20 20 20 20 20 20 2f 2f 20 54 6f 20 70 72 65 73 65 72 76 65 20 76 61 6c 75 65 73 20 66 .........//.To.preserve.values.f
1b340 72 6f 6d 20 6e 6f 69 73 79 20 63 6f 6e 74 72 6f 6c 73 2c 20 77 65 20 6e 65 65 64 20 74 6f 20 66 rom.noisy.controls,.we.need.to.f
1b360 69 72 73 74 20 63 6f 70 79 20 74 68 65 69 72 20 63 75 72 72 65 6e 74 20 76 61 6c 75 65 73 2e 0d irst.copy.their.current.values..
1b380 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 55 6e 73 .............................Uns
1b3a0 61 66 65 55 74 69 6c 69 74 79 2e 4d 65 6d 43 70 79 28 73 74 61 74 65 50 74 72 2c 0d 0a 20 20 20 afeUtility.MemCpy(statePtr,.....
1b3c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 62 79 .............................(by
1b3e0 74 65 2a 29 63 75 72 72 65 6e 74 53 74 61 74 65 50 74 72 20 2b 20 73 74 61 74 65 42 6c 6f 63 6b te*)currentStatePtr.+.stateBlock
1b400 2e 62 79 74 65 4f 66 66 73 65 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .byteOffset,....................
1b420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 53 69 ..............deviceStateBlockSi
1b440 7a 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ze);............................
1b460 20 20 20 20 2f 2f 20 41 6e 64 20 74 68 65 6e 20 77 65 20 63 6f 70 79 20 6f 76 65 72 20 64 65 66 ....//.And.then.we.copy.over.def
1b480 61 75 6c 74 20 76 61 6c 75 65 73 20 6d 61 73 6b 65 64 20 62 79 20 6e 6f 69 73 65 20 62 69 74 73 ault.values.masked.by.noise.bits
1b4a0 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4d ...............................M
1b4c0 65 6d 6f 72 79 48 65 6c 70 65 72 73 2e 4d 65 6d 43 70 79 4d 61 73 6b 65 64 28 73 74 61 74 65 50 emoryHelpers.MemCpyMasked(stateP
1b4e0 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tr,.............................
1b500 20 20 20 20 20 28 62 79 74 65 2a 29 64 65 66 61 75 6c 74 53 74 61 74 65 50 74 72 20 2b 20 73 74 .....(byte*)defaultStatePtr.+.st
1b520 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 ateBlock.byteOffset,............
1b540 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 69 6e 74 29 64 65 76 69 63 ......................(int)devic
1b560 65 53 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eStateBlockSize,................
1b580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 62 79 74 65 2a 29 6e 6f 69 73 65 4d 61 ..................(byte*)noiseMa
1b5a0 73 6b 50 74 72 20 2b 20 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 29 3b 0d skPtr.+.stateBlock.byteOffset);.
1b5c0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 .........................}......
1b5e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 ....................else........
1b600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ..................{.............
1b620 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 20 6e 6f 69 73 79 20 63 6f 6e .................//.No.noisy.con
1b640 74 72 6f 6c 73 20 69 6e 20 64 65 76 69 63 65 2e 20 4a 75 73 74 20 74 61 6b 65 20 74 68 65 20 64 trols.in.device..Just.take.the.d
1b660 65 66 61 75 6c 74 20 73 74 61 74 65 20 61 6e 64 20 70 75 74 20 69 74 20 69 6e 20 74 68 65 20 65 efault.state.and.put.it.in.the.e
1b680 76 65 6e 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 vent............................
1b6a0 20 20 2f 2f 20 61 73 20 69 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..//.as.is......................
1b6c0 20 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 55 74 69 6c 69 74 79 2e 4d 65 6d 43 70 79 28 73 74 .........UnsafeUtility.MemCpy(st
1b6e0 61 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 atePtr,.........................
1b700 20 20 20 20 20 20 20 20 20 28 62 79 74 65 2a 29 64 65 66 61 75 6c 74 53 74 61 74 65 50 74 72 20 .........(byte*)defaultStatePtr.
1b720 2b 20 73 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 2c 0d 0a 20 20 20 20 20 20 +.stateBlock.byteOffset,........
1b740 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 ..........................device
1b760 53 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 StateBlockSize);................
1b780 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..........}.....................
1b7a0 20 20 20 20 20 20 20 2f 2f 20 50 65 72 66 6f 72 6d 20 74 68 65 20 72 65 73 65 74 2e 0d 0a 20 20 .......//.Perform.the.reset.....
1b7c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 55 70 64 61 74 65 53 74 61 74 ......................UpdateStat
1b7e0 65 28 64 65 76 69 63 65 2c 20 75 70 64 61 74 65 54 79 70 65 2c 20 73 74 61 74 65 50 74 72 2c 20 e(device,.updateType,.statePtr,.
1b800 30 2c 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 2c 20 63 75 72 72 65 6e 74 0,.deviceStateBlockSize,.current
1b820 54 69 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Time,...........................
1b840 20 20 20 6e 65 77 20 49 6e 70 75 74 45 76 65 6e 74 50 74 72 28 28 49 6e 70 75 74 45 76 65 6e 74 ...new.InputEventPtr((InputEvent
1b860 2a 29 73 74 61 74 65 45 76 65 6e 74 50 74 72 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 *)stateEventPtr));..............
1b880 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 65 6c 6c 20 74 68 65 20 62 61 63 6b 65 6e ..............//.Tell.the.backen
1b8a0 64 20 74 6f 20 72 65 73 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d.to.reset......................
1b8c0 20 20 20 20 20 64 65 76 69 63 65 2e 52 65 71 75 65 73 74 52 65 73 65 74 28 29 3b 0d 0a 20 20 20 .....device.RequestReset();.....
1b8e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
1b900 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ....}..............}............
1b920 20 20 20 20 2f 2f 20 57 65 20 73 65 74 20 74 68 69 73 20 2a 61 66 74 65 72 2a 20 74 68 65 20 62 ....//.We.set.this.*after*.the.b
1b940 6c 6f 63 6b 20 61 62 6f 76 65 20 61 73 20 64 65 66 61 75 6c 74 55 70 64 61 74 65 54 79 70 65 20 lock.above.as.defaultUpdateType.
1b960 69 73 20 69 6e 66 6c 75 65 6e 63 65 64 20 62 79 20 74 68 65 20 73 65 74 74 69 6e 67 2e 0d 0a 20 is.influenced.by.the.setting....
1b980 20 20 20 20 20 20 20 20 20 20 20 6d 5f 48 61 73 46 6f 63 75 73 20 3d 20 66 6f 63 75 73 3b 0d 0a ...........m_HasFocus.=.focus;..
1b9a0 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f 6f ........}............private.boo
1b9c0 6c 20 53 68 6f 75 6c 64 52 75 6e 55 70 64 61 74 65 28 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 l.ShouldRunUpdate(InputUpdateTyp
1b9e0 65 20 75 70 64 61 74 65 54 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 e.updateType)..........{........
1ba00 20 20 20 20 20 20 2f 2f 20 57 65 20 70 65 72 66 6f 72 6d 20 61 20 22 6e 75 6c 6c 22 20 75 70 64 ......//.We.perform.a."null".upd
1ba20 61 74 65 20 61 66 74 65 72 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 73 20 61 6e 64 20 6f 6e 20 ate.after.domain.reloads.and.on.
1ba40 73 74 61 72 74 75 70 20 74 6f 20 67 65 74 20 6f 75 72 20 64 65 76 69 63 65 73 0d 0a 20 20 20 20 startup.to.get.our.devices......
1ba60 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 20 70 6c 61 63 65 20 62 65 66 6f 72 65 20 74 68 65 20 72 ........//.in.place.before.the.r
1ba80 75 6e 74 69 6d 65 20 63 61 6c 6c 73 20 4d 6f 6e 6f 42 65 68 61 76 69 6f 75 72 20 63 61 6c 6c 62 untime.calls.MonoBehaviour.callb
1baa0 61 63 6b 73 2e 20 53 65 65 20 49 6e 70 75 74 53 79 73 74 65 6d 2e 52 75 6e 49 6e 69 74 69 61 6c acks..See.InputSystem.RunInitial
1bac0 55 70 64 61 74 65 28 29 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 75 70 64 61 74 Update()...............if.(updat
1bae0 65 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 4e 6f 6e 65 29 0d 0a eType.==.InputUpdateType.None)..
1bb00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 0d 0a ................return.true;....
1bb20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6d 61 73 6b 20 3d 20 6d 5f 55 70 64 61 74 65 4d ............var.mask.=.m_UpdateM
1bb40 61 73 6b 3b 0d 0a 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 ask;..#if.UNITY_EDITOR..........
1bb60 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 20 65 64 69 74 6f 72 20 75 70 64 61 74 65 73 20 77 68 65 ....//.Ignore.editor.updates.whe
1bb80 6e 20 74 68 65 20 67 61 6d 65 20 69 73 20 70 6c 61 79 69 6e 67 20 61 6e 64 20 68 61 73 20 66 6f n.the.game.is.playing.and.has.fo
1bba0 63 75 73 2e 20 41 6c 6c 20 69 6e 70 75 74 20 67 6f 65 73 20 74 6f 20 70 6c 61 79 65 72 2e 0d 0a cus..All.input.goes.to.player...
1bbc0 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 67 61 6d 65 49 73 50 6c 61 79 69 6e 67 41 6e 64 ............if.(gameIsPlayingAnd
1bbe0 48 61 73 46 6f 63 75 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 61 73 6b 20 HasFocus)..................mask.
1bc00 26 3d 20 7e 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 3b 0d 0a 20 20 20 &=.~InputUpdateType.Editor;.....
1bc20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 74 68 65 20 70 6c 61 79 65 72 20 69 73 6e 27 74 20 .........//.If.the.player.isn't.
1bc40 72 75 6e 6e 69 6e 67 2c 20 74 68 65 20 6f 6e 6c 79 20 74 68 69 6e 67 20 77 65 20 72 75 6e 20 69 running,.the.only.thing.we.run.i
1bc60 73 20 65 64 69 74 6f 72 20 75 70 64 61 74 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 s.editor.updates...............e
1bc80 6c 73 65 20 69 66 20 28 75 70 64 61 74 65 54 79 70 65 20 21 3d 20 49 6e 70 75 74 55 70 64 61 74 lse.if.(updateType.!=.InputUpdat
1bca0 65 54 79 70 65 2e 45 64 69 74 6f 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 eType.Editor)..................r
1bcc0 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 eturn.false;..#endif............
1bce0 20 20 72 65 74 75 72 6e 20 28 75 70 64 61 74 65 54 79 70 65 20 26 20 6d 61 73 6b 29 20 21 3d 20 ..return.(updateType.&.mask).!=.
1bd00 30 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 0;..........}............///.<su
1bd20 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 50 72 6f 63 65 73 73 20 69 6e 70 75 mmary>..........///.Process.inpu
1bd40 74 20 65 76 65 6e 74 73 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 t.events...........///.</summary
1bd60 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 75 70 64 61 >..........///.<param.name="upda
1bd80 74 65 54 79 70 65 22 3e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 70 teType"></param>..........///.<p
1bda0 61 72 61 6d 20 6e 61 6d 65 3d 22 65 76 65 6e 74 42 75 66 66 65 72 22 3e 3c 2f 70 61 72 61 6d 3e aram.name="eventBuffer"></param>
1bdc0 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 ..........///.<remarks>.........
1bde0 20 2f 2f 2f 20 54 68 69 73 20 6d 65 74 68 6f 64 20 69 73 20 74 68 65 20 63 6f 72 65 20 77 6f 72 .///.This.method.is.the.core.wor
1be00 6b 68 6f 72 73 65 20 6f 66 20 74 68 65 20 69 6e 70 75 74 20 73 79 73 74 65 6d 2e 20 49 74 20 69 khorse.of.the.input.system..It.i
1be20 73 20 63 61 6c 6c 65 64 20 66 72 6f 6d 20 3c 73 65 65 20 63 72 65 66 3d 22 55 6e 69 74 79 45 6e s.called.from.<see.cref="UnityEn
1be40 67 69 6e 65 49 6e 74 65 72 6e 61 6c 2e 49 6e 70 75 74 2e 4e 61 74 69 76 65 49 6e 70 75 74 53 79 gineInternal.Input.NativeInputSy
1be60 73 74 65 6d 22 2f 3e 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 55 73 75 61 6c 6c 79 20 74 68 stem"/>...........///.Usually.th
1be80 69 73 20 68 61 70 70 65 6e 73 20 69 6e 20 72 65 73 70 6f 6e 73 65 20 74 6f 20 74 68 65 20 70 6c is.happens.in.response.to.the.pl
1bea0 61 79 65 72 20 6c 6f 6f 70 20 72 75 6e 6e 69 6e 67 20 61 6e 64 20 74 72 69 67 67 65 72 69 6e 67 ayer.loop.running.and.triggering
1bec0 20 75 70 64 61 74 65 73 20 61 74 20 73 65 74 20 70 6f 69 6e 74 73 2e 20 48 6f 77 65 76 65 72 2c .updates.at.set.points..However,
1bee0 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 75 70 64 61 74 65 73 20 63 61 6e 20 61 6c 73 6f 20 62 ..........///.updates.can.also.b
1bf00 65 20 6d 61 6e 75 61 6c 6c 79 20 74 72 69 67 67 65 72 65 64 20 74 68 72 6f 75 67 68 20 3c 73 65 e.manually.triggered.through.<se
1bf20 65 20 63 72 65 66 3d 22 49 6e 70 75 74 53 79 73 74 65 6d 2e 55 70 64 61 74 65 22 2f 3e 2e 0d 0a e.cref="InputSystem.Update"/>...
1bf40 20 20 20 20 20 20 20 20 2f 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 54 68 65 20 6d 65 74 ........///..........///.The.met
1bf60 68 6f 64 20 72 65 63 65 69 76 65 73 20 74 68 65 20 65 76 65 6e 74 20 62 75 66 66 65 72 20 75 73 hod.receives.the.event.buffer.us
1bf80 65 64 20 69 6e 74 65 72 6e 61 6c 6c 79 20 62 79 20 74 68 65 20 72 75 6e 74 69 6d 65 20 74 6f 20 ed.internally.by.the.runtime.to.
1bfa0 63 6f 6c 6c 65 63 74 20 65 76 65 6e 74 73 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 0d 0a 20 20 collect.events...........///....
1bfc0 20 20 20 20 20 20 2f 2f 2f 20 4e 6f 74 65 20 74 68 61 74 20 75 70 64 61 74 65 20 74 79 70 65 73 ......///.Note.that.update.types
1bfe0 20 64 6f 20 2a 4e 4f 54 2a 20 73 61 79 20 77 68 61 74 20 74 68 65 20 65 76 65 6e 74 73 20 77 65 .do.*NOT*.say.what.the.events.we
1c000 20 72 65 63 65 69 76 65 20 61 72 65 20 66 6f 72 2e 20 54 68 65 20 75 70 64 61 74 65 20 74 79 70 .receive.are.for..The.update.typ
1c020 65 20 6f 6e 6c 79 20 69 6e 64 69 63 61 74 65 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 77 68 e.only.indicates..........///.wh
1c040 65 72 65 20 69 6e 20 74 68 65 20 55 6e 69 74 79 27 73 20 61 70 70 6c 69 63 61 74 69 6f 6e 20 6c ere.in.the.Unity's.application.l
1c060 6f 6f 70 20 77 65 20 67 6f 74 20 63 61 6c 6c 65 64 20 66 72 6f 6d 2e 20 57 68 65 72 65 20 74 68 oop.we.got.called.from..Where.th
1c080 65 20 65 76 65 6e 74 20 64 61 74 61 20 67 6f 65 73 20 64 65 70 65 6e 64 73 20 77 68 6f 6c 6c 79 e.event.data.goes.depends.wholly
1c0a0 20 6f 6e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 77 68 69 63 68 20 62 75 66 66 65 72 73 20 77 .on..........///.which.buffers.w
1c0c0 65 20 61 63 74 69 76 61 74 65 20 69 6e 20 74 68 65 20 75 70 64 61 74 65 20 61 6e 64 20 77 72 69 e.activate.in.the.update.and.wri
1c0e0 74 65 20 74 68 65 20 65 76 65 6e 74 20 64 61 74 61 20 69 6e 74 6f 2e 0d 0a 20 20 20 20 20 20 20 te.the.event.data.into..........
1c100 20 2f 2f 2f 20 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 5b 53 79 73 74 65 6d .///.</remarks>..........[System
1c120 2e 44 69 61 67 6e 6f 73 74 69 63 73 2e 43 6f 64 65 41 6e 61 6c 79 73 69 73 2e 53 75 70 70 72 65 .Diagnostics.CodeAnalysis.Suppre
1c140 73 73 4d 65 73 73 61 67 65 28 22 4d 69 63 72 6f 73 6f 66 74 2e 50 65 72 66 6f 72 6d 61 6e 63 65 ssMessage("Microsoft.Performance
1c160 22 2c 20 22 43 41 31 38 30 39 3a 41 76 6f 69 64 45 78 63 65 73 73 69 76 65 4c 6f 63 61 6c 73 22 ",."CA1809:AvoidExcessiveLocals"
1c180 2c 20 4a 75 73 74 69 66 69 63 61 74 69 6f 6e 20 3d 20 22 54 4f 44 4f 3a 20 52 65 66 61 63 74 6f ,.Justification.=."TODO:.Refacto
1c1a0 72 20 6c 61 74 65 72 2e 22 29 5d 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 75 6e 73 r.later.")]..........private.uns
1c1c0 61 66 65 20 76 6f 69 64 20 4f 6e 55 70 64 61 74 65 28 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 afe.void.OnUpdate(InputUpdateTyp
1c1e0 65 20 75 70 64 61 74 65 54 79 70 65 2c 20 72 65 66 20 49 6e 70 75 74 45 76 65 6e 74 42 75 66 66 e.updateType,.ref.InputEventBuff
1c200 65 72 20 65 76 65 6e 74 42 75 66 66 65 72 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 er.eventBuffer)..........{......
1c220 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 73 77 69 74 63 68 20 66 72 6f 6d 20 50 72 ........////TODO:.switch.from.Pr
1c240 6f 66 69 6c 65 72 20 74 6f 20 43 75 73 74 6f 6d 53 61 6d 70 6c 65 72 20 41 50 49 0d 0a 20 20 20 ofiler.to.CustomSampler.API.....
1c260 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 54 68 69 73 20 69 73 20 2a 6e 6f 74 2a 20 .........//.NOTE:.This.is.*not*.
1c280 75 73 69 6e 67 20 74 72 79 2f 66 69 6e 61 6c 6c 79 20 61 73 20 77 65 27 76 65 20 73 65 65 6e 20 using.try/finally.as.we've.seen.
1c2a0 75 6e 72 65 6c 69 61 62 69 6c 69 74 79 20 69 6e 20 74 68 65 20 45 6e 64 53 61 6d 70 6c 65 28 29 unreliability.in.the.EndSample()
1c2c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 65 78 65 63 75 74 69 6f 6e ..............//.......execution
1c2e0 20 28 61 6e 64 20 77 65 27 72 65 20 6e 6f 74 20 73 75 72 65 20 77 68 65 72 65 20 69 74 27 73 20 .(and.we're.not.sure.where.it's.
1c300 63 6f 6d 69 6e 67 20 66 72 6f 6d 29 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 69 coming.from)...............Profi
1c320 6c 65 72 2e 42 65 67 69 6e 53 61 6d 70 6c 65 28 22 49 6e 70 75 74 55 70 64 61 74 65 22 29 3b 0d ler.BeginSample("InputUpdate");.
1c340 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 73 74 6f 72 65 20 64 65 76 69 63 65 ...............//.Restore.device
1c360 73 20 62 65 66 6f 72 65 20 63 68 65 63 6b 69 6e 67 20 75 70 64 61 74 65 20 6d 61 73 6b 2e 20 53 s.before.checking.update.mask..S
1c380 65 65 20 49 6e 70 75 74 53 79 73 74 65 6d 2e 52 75 6e 49 6e 69 74 69 61 6c 55 70 64 61 74 65 28 ee.InputSystem.RunInitialUpdate(
1c3a0 29 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 52 65 73 74 6f 72 65 44 65 76 69 63 65 73 41 66 )...............RestoreDevicesAf
1c3c0 74 65 72 44 6f 6d 61 69 6e 52 65 6c 6f 61 64 49 66 4e 65 63 65 73 73 61 72 79 28 29 3b 0d 0a 0d terDomainReloadIfNecessary();...
1c3e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 75 70 64 61 74 65 54 79 70 65 20 26 20 6d .............if.((updateType.&.m
1c400 5f 55 70 64 61 74 65 4d 61 73 6b 29 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 _UpdateMask).==.0)..............
1c420 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 69 6c 65 72 2e 45 6e 64 53 {..................Profiler.EndS
1c440 61 6d 70 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e ample();..................return
1c460 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ;..............}................
1c480 57 61 72 6e 41 62 6f 75 74 44 65 76 69 63 65 73 46 61 69 6c 69 6e 67 54 6f 52 65 63 72 65 61 74 WarnAboutDevicesFailingToRecreat
1c4a0 65 41 66 74 65 72 44 6f 6d 61 69 6e 52 65 6c 6f 61 64 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 eAfterDomainReload();...........
1c4c0 20 20 20 20 20 2f 2f 20 46 69 72 73 74 20 75 70 64 61 74 65 20 73 65 6e 64 73 20 6f 75 74 20 73 .....//.First.update.sends.out.s
1c4e0 74 61 72 74 75 70 20 61 6e 61 6c 79 74 69 63 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 tartup.analytics...............#
1c500 69 66 20 55 4e 49 54 59 5f 41 4e 41 4c 59 54 49 43 53 20 7c 7c 20 55 4e 49 54 59 5f 45 44 49 54 if.UNITY_ANALYTICS.||.UNITY_EDIT
1c520 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 21 6d 5f 48 61 76 65 53 65 6e 74 53 OR..............if.(!m_HaveSentS
1c540 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d tartupAnalytics)..............{.
1c560 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 41 6e 61 6c 79 74 69 63 73 2e .................InputAnalytics.
1c580 4f 6e 53 74 61 72 74 75 70 28 74 68 69 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 OnStartup(this);................
1c5a0 20 20 6d 5f 48 61 76 65 53 65 6e 74 53 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 20 3d 20 74 ..m_HaveSentStartupAnalytics.=.t
1c5c0 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 rue;..............}.............
1c5e0 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a .#endif................////TODO:
1c600 20 6d 61 6e 75 61 6c 20 6d 6f 64 65 20 6d 75 73 74 20 62 65 20 74 72 65 61 74 65 64 20 6c 69 6b .manual.mode.must.be.treated.lik
1c620 65 20 6c 6f 63 6b 49 6e 70 75 74 54 6f 47 61 6d 65 56 69 65 77 20 69 6e 20 65 64 69 74 6f 72 0d e.lockInputToGameView.in.editor.
1c640 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 6d 65 74 72 69 63 73 ...............//.Update.metrics
1c660 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4d 65 74 72 69 63 73 2e 74 6f 74 61 6c 45 76 ...............m_Metrics.totalEv
1c680 65 6e 74 43 6f 75 6e 74 20 2b 3d 20 65 76 65 6e 74 42 75 66 66 65 72 2e 65 76 65 6e 74 43 6f 75 entCount.+=.eventBuffer.eventCou
1c6a0 6e 74 20 2d 20 28 69 6e 74 29 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 nt.-.(int)InputUpdate.s_LastUpda
1c6c0 74 65 52 65 74 61 69 6e 65 64 45 76 65 6e 74 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 teRetainedEventCount;...........
1c6e0 20 20 20 6d 5f 4d 65 74 72 69 63 73 2e 74 6f 74 61 6c 45 76 65 6e 74 42 79 74 65 73 20 2b 3d 20 ...m_Metrics.totalEventBytes.+=.
1c700 28 69 6e 74 29 65 76 65 6e 74 42 75 66 66 65 72 2e 73 69 7a 65 49 6e 42 79 74 65 73 20 2d 20 28 (int)eventBuffer.sizeInBytes.-.(
1c720 69 6e 74 29 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 74 65 52 65 74 61 int)InputUpdate.s_LastUpdateReta
1c740 69 6e 65 64 45 76 65 6e 74 42 79 74 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2b 2b 6d inedEventBytes;..............++m
1c760 5f 4d 65 74 72 69 63 73 2e 74 6f 74 61 6c 55 70 64 61 74 65 43 6f 75 6e 74 3b 0d 0a 0d 0a 20 20 _Metrics.totalUpdateCount;......
1c780 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 ..........InputUpdate.s_LastUpda
1c7a0 74 65 52 65 74 61 69 6e 65 64 45 76 65 6e 74 43 6f 75 6e 74 20 3d 20 30 3b 0d 0a 20 20 20 20 20 teRetainedEventCount.=.0;.......
1c7c0 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 74 65 52 .......InputUpdate.s_LastUpdateR
1c7e0 65 74 61 69 6e 65 64 45 76 65 6e 74 42 79 74 65 73 20 3d 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 etainedEventBytes.=.0;..........
1c800 20 20 20 20 20 20 2f 2f 20 53 74 6f 72 65 20 63 75 72 72 65 6e 74 20 74 69 6d 65 20 6f 66 66 73 ......//.Store.current.time.offs
1c820 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 52 75 6e 74 69 6d 65 2e 73 5f et...............InputRuntime.s_
1c840 43 75 72 72 65 6e 74 54 69 6d 65 4f 66 66 73 65 74 54 6f 52 65 61 6c 74 69 6d 65 53 69 6e 63 65 CurrentTimeOffsetToRealtimeSince
1c860 53 74 61 72 74 75 70 20 3d 20 6d 5f 52 75 6e 74 69 6d 65 2e 63 75 72 72 65 6e 74 54 69 6d 65 4f Startup.=.m_Runtime.currentTimeO
1c880 66 66 73 65 74 54 6f 52 65 61 6c 74 69 6d 65 53 69 6e 63 65 53 74 61 72 74 75 70 3b 0d 0a 0d 0a ffsetToRealtimeSinceStartup;....
1c8a0 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 ............InputUpdate.s_LastUp
1c8c0 64 61 74 65 54 79 70 65 20 3d 20 75 70 64 61 74 65 54 79 70 65 3b 0d 0a 20 20 20 20 20 20 20 20 dateType.=.updateType;..........
1c8e0 20 20 20 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 53 77 69 74 63 68 54 6f 28 6d ....InputStateBuffers.SwitchTo(m
1c900 5f 53 74 61 74 65 42 75 66 66 65 72 73 2c 20 75 70 64 61 74 65 54 79 70 65 29 3b 0d 0a 0d 0a 20 _StateBuffers,.updateType);.....
1c920 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 73 42 65 66 6f 72 65 52 65 6e 64 65 72 55 70 64 ...........var.isBeforeRenderUpd
1c940 61 74 65 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 75 70 ate.=.false;..............if.(up
1c960 64 61 74 65 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 44 79 6e 61 dateType.==.InputUpdateType.Dyna
1c980 6d 69 63 20 7c 7c 20 75 70 64 61 74 65 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 mic.||.updateType.==.InputUpdate
1c9a0 54 79 70 65 2e 4d 61 6e 75 61 6c 20 7c 7c 20 75 70 64 61 74 65 54 79 70 65 20 3d 3d 20 49 6e 70 Type.Manual.||.updateType.==.Inp
1c9c0 75 74 55 70 64 61 74 65 54 79 70 65 2e 46 69 78 65 64 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 utUpdateType.Fixed).............
1c9e0 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2b 2b 49 6e 70 75 74 55 70 64 61 74 .{..................++InputUpdat
1ca00 65 2e 73 5f 55 70 64 61 74 65 53 74 65 70 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 e.s_UpdateStepCount;............
1ca20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 20 69 66 20 28 75 70 64 61 74 65 ..}..............else.if.(update
1ca40 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 42 65 66 6f 72 65 52 65 Type.==.InputUpdateType.BeforeRe
1ca60 6e 64 65 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 nder)..............{............
1ca80 20 20 20 20 20 20 69 73 42 65 66 6f 72 65 52 65 6e 64 65 72 55 70 64 61 74 65 20 3d 20 74 72 75 ......isBeforeRenderUpdate.=.tru
1caa0 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 e;..............}...............
1cac0 20 2f 2f 20 53 65 65 20 69 66 20 77 65 27 72 65 20 73 75 70 70 6f 73 65 64 20 74 6f 20 6f 6e 6c .//.See.if.we're.supposed.to.onl
1cae0 79 20 74 61 6b 65 20 65 76 65 6e 74 73 20 75 70 20 74 6f 20 61 20 63 65 72 74 61 69 6e 20 74 69 y.take.events.up.to.a.certain.ti
1cb00 6d 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 57 65 20 64 6f 20 me...............//.NOTE:.We.do.
1cb20 6e 6f 74 20 72 65 71 75 69 72 65 20 74 68 65 20 65 76 65 6e 74 73 20 69 6e 20 74 68 65 20 71 75 not.require.the.events.in.the.qu
1cb40 65 75 65 20 74 6f 20 62 65 20 73 6f 72 74 65 64 2e 20 49 6e 73 74 65 61 64 2c 20 77 65 20 77 69 eue.to.be.sorted..Instead,.we.wi
1cb60 6c 6c 20 77 61 6c 6b 20 6f 76 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 ll.walk.over..............//....
1cb80 20 20 20 61 6c 6c 20 65 76 65 6e 74 73 20 69 6e 20 74 68 65 20 62 75 66 66 65 72 20 65 61 63 68 ...all.events.in.the.buffer.each
1cba0 20 74 69 6d 65 2e 20 4e 6f 74 65 20 74 68 61 74 20 69 66 20 74 68 65 72 65 20 61 72 65 20 6d 75 .time..Note.that.if.there.are.mu
1cbc0 6c 74 69 70 6c 65 20 65 76 65 6e 74 73 20 66 6f 72 20 74 68 65 20 73 61 6d 65 0d 0a 20 20 20 20 ltiple.events.for.the.same......
1cbe0 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 64 65 76 69 63 65 2c 20 69 74 20 64 65 70 65 ........//.......device,.it.depe
1cc00 6e 64 73 20 6f 6e 20 74 68 65 20 70 72 6f 64 75 63 65 72 20 6f 66 20 74 68 65 73 65 20 65 76 65 nds.on.the.producer.of.these.eve
1cc20 6e 74 73 20 74 6f 20 71 75 65 75 65 20 74 68 65 6d 20 69 6e 20 63 6f 72 72 65 63 74 20 6f 72 64 nts.to.queue.them.in.correct.ord
1cc40 65 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 4f 74 68 65 72 77 er...............//.......Otherw
1cc60 69 73 65 2c 20 6f 6e 63 65 20 61 6e 20 65 76 65 6e 74 20 77 69 74 68 20 61 20 6e 65 77 65 72 20 ise,.once.an.event.with.a.newer.
1cc80 74 69 6d 65 73 74 61 6d 70 20 68 61 73 20 62 65 65 6e 20 70 72 6f 63 65 73 73 65 64 2c 20 65 76 timestamp.has.been.processed,.ev
1cca0 65 6e 74 73 20 63 6f 6d 69 6e 67 20 6c 61 74 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f ents.coming.later............../
1ccc0 2f 20 20 20 20 20 20 20 69 6e 20 74 68 65 20 62 75 66 66 65 72 20 61 6e 64 20 68 61 76 69 6e 67 /.......in.the.buffer.and.having
1cce0 20 6f 6c 64 65 72 20 74 69 6d 65 73 74 61 6d 70 73 20 77 69 6c 6c 20 67 65 74 20 72 65 6a 65 63 .older.timestamps.will.get.rejec
1cd00 74 65 64 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e 74 54 ted.................var.currentT
1cd20 69 6d 65 20 3d 20 75 70 64 61 74 65 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 ime.=.updateType.==.InputUpdateT
1cd40 79 70 65 2e 46 69 78 65 64 20 3f 20 6d 5f 52 75 6e 74 69 6d 65 2e 63 75 72 72 65 6e 74 54 69 6d ype.Fixed.?.m_Runtime.currentTim
1cd60 65 46 6f 72 46 69 78 65 64 55 70 64 61 74 65 20 3a 20 6d 5f 52 75 6e 74 69 6d 65 2e 63 75 72 72 eForFixedUpdate.:.m_Runtime.curr
1cd80 65 6e 74 54 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 74 69 6d 65 73 6c entTime;..............var.timesl
1cda0 69 63 65 45 76 65 6e 74 73 20 3d 20 67 61 6d 65 49 73 50 6c 61 79 69 6e 67 41 6e 64 48 61 73 46 iceEvents.=.gameIsPlayingAndHasF
1cdc0 6f 63 75 73 20 26 26 20 49 6e 70 75 74 53 79 73 74 65 6d 2e 73 65 74 74 69 6e 67 73 2e 75 70 64 ocus.&&.InputSystem.settings.upd
1cde0 61 74 65 4d 6f 64 65 20 3d 3d 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 2e 55 70 64 61 74 65 4d ateMode.==.InputSettings.UpdateM
1ce00 6f 64 65 2e 50 72 6f 63 65 73 73 45 76 65 6e 74 73 49 6e 46 69 78 65 64 55 70 64 61 74 65 3b 0d ode.ProcessEventsInFixedUpdate;.
1ce20 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 45 61 72 6c 79 20 6f 75 74 20 69 66 20 74 ...............//.Early.out.if.t
1ce40 68 65 72 65 27 73 20 6e 6f 20 65 76 65 6e 74 73 20 74 6f 20 70 72 6f 63 65 73 73 2e 0d 0a 20 20 here's.no.events.to.process.....
1ce60 20 20 20 20 20 20 20 20 20 20 69 66 20 28 65 76 65 6e 74 42 75 66 66 65 72 2e 65 76 65 6e 74 43 ..........if.(eventBuffer.eventC
1ce80 6f 75 6e 74 20 3c 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 ount.<=.0)..............{.......
1cea0 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 72 6d 61 6c 6c 79 2c 20 77 65 20 70 72 6f 63 65 ...........//.Normally,.we.proce
1cec0 73 73 20 61 63 74 69 6f 6e 20 74 69 6d 65 6f 75 74 73 20 61 66 74 65 72 20 66 69 72 73 74 20 70 ss.action.timeouts.after.first.p
1cee0 72 6f 63 65 73 73 69 6e 67 20 61 6c 6c 20 65 76 65 6e 74 73 2e 20 49 66 20 77 65 20 68 61 76 65 rocessing.all.events..If.we.have
1cf00 20 6e 6f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 65 76 65 6e 74 73 2c 20 .no..................//.events,.
1cf20 77 65 20 73 74 69 6c 6c 20 6e 65 65 64 20 74 6f 20 63 68 65 63 6b 20 74 69 6d 65 6f 75 74 73 2e we.still.need.to.check.timeouts.
1cf40 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 67 61 6d 65 49 73 50 6c 61 79 ..................if.(gameIsPlay
1cf60 69 6e 67 41 6e 64 48 61 73 46 6f 63 75 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ingAndHasFocus).................
1cf80 20 20 20 20 20 50 72 6f 63 65 73 73 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 .....ProcessStateChangeMonitorTi
1cfa0 6d 65 6f 75 74 73 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 meouts();....................#if
1cfc0 20 45 4e 41 42 4c 45 5f 50 52 4f 46 49 4c 45 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .ENABLE_PROFILER................
1cfe0 20 20 50 72 6f 66 69 6c 65 72 2e 45 6e 64 53 61 6d 70 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 ..Profiler.EndSample();.........
1d000 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .........#endif.................
1d020 20 49 6e 76 6f 6b 65 41 66 74 65 72 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 28 29 3b 0d 0a 20 .InvokeAfterUpdateCallback();...
1d040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 76 65 6e 74 42 75 66 66 65 72 2e 52 65 73 65 74 ...............eventBuffer.Reset
1d060 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 20 20 ();..................return;....
1d080 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 ..........}................var.c
1d0a0 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 20 3d 0d 0a 20 20 20 20 20 20 20 20 20 20 urrentEventReadPtr.=............
1d0c0 20 20 20 20 20 20 28 49 6e 70 75 74 45 76 65 6e 74 2a 29 4e 61 74 69 76 65 41 72 72 61 79 55 6e ......(InputEvent*)NativeArrayUn
1d0e0 73 61 66 65 55 74 69 6c 69 74 79 2e 47 65 74 55 6e 73 61 66 65 42 75 66 66 65 72 50 6f 69 6e 74 safeUtility.GetUnsafeBufferPoint
1d100 65 72 57 69 74 68 6f 75 74 43 68 65 63 6b 73 28 65 76 65 6e 74 42 75 66 66 65 72 2e 64 61 74 61 erWithoutChecks(eventBuffer.data
1d120 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 72 65 6d 61 69 6e 69 6e 67 45 76 65 );..............var.remainingEve
1d140 6e 74 43 6f 75 6e 74 20 3d 20 65 76 65 6e 74 42 75 66 66 65 72 2e 65 76 65 6e 74 43 6f 75 6e 74 ntCount.=.eventBuffer.eventCount
1d160 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 70 72 6f 63 65 73 73 69 6e 67 53 74 61 ;..............var.processingSta
1d180 72 74 54 69 6d 65 20 3d 20 54 69 6d 65 2e 72 65 61 6c 74 69 6d 65 53 69 6e 63 65 53 74 61 72 74 rtTime.=.Time.realtimeSinceStart
1d1a0 75 70 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 68 65 6e 20 74 69 6d 65 73 up;................//.When.times
1d1c0 6c 69 63 69 6e 67 20 65 76 65 6e 74 73 20 6f 72 20 69 6e 20 62 65 66 6f 72 65 2d 72 65 6e 64 65 licing.events.or.in.before-rende
1d1e0 72 20 75 70 64 61 74 65 73 2c 20 77 65 20 6d 61 79 20 62 65 20 6c 65 61 76 69 6e 67 20 65 76 65 r.updates,.we.may.be.leaving.eve
1d200 6e 74 73 20 69 6e 20 74 68 65 20 62 75 66 66 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f nts.in.the.buffer............../
1d220 2f 20 66 6f 72 20 6c 61 74 65 72 20 70 72 6f 63 65 73 73 69 6e 67 2e 20 57 65 20 64 6f 20 74 68 /.for.later.processing..We.do.th
1d240 69 73 20 62 79 20 63 6f 6d 70 61 63 74 69 6e 67 20 74 68 65 20 65 76 65 6e 74 20 62 75 66 66 65 is.by.compacting.the.event.buffe
1d260 72 20 61 6e 64 20 6d 6f 76 69 6e 67 20 65 76 65 6e 74 73 20 64 6f 77 6e 20 73 75 63 68 0d 0a 20 r.and.moving.events.down.such...
1d280 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 61 74 20 74 68 65 20 65 76 65 6e 74 73 20 77 65 ...........//.that.the.events.we
1d2a0 20 6c 65 61 76 65 20 69 6e 20 74 68 65 20 62 75 66 66 65 72 20 66 6f 72 6d 20 6f 6e 65 20 63 6f .leave.in.the.buffer.form.one.co
1d2c0 6e 74 69 67 75 6f 75 73 20 63 68 75 6e 6b 20 6f 66 20 6d 65 6d 6f 72 79 20 61 74 20 74 68 65 20 ntiguous.chunk.of.memory.at.the.
1d2e0 62 65 67 69 6e 6e 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6f 66 20 74 68 65 beginning..............//.of.the
1d300 20 62 75 66 66 65 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e .buffer...............var.curren
1d320 74 45 76 65 6e 74 57 72 69 74 65 50 74 72 20 3d 20 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 tEventWritePtr.=.currentEventRea
1d340 64 50 74 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 75 6d 45 76 65 6e 74 73 dPtr;..............var.numEvents
1d360 52 65 74 61 69 6e 65 64 49 6e 42 75 66 66 65 72 20 3d 20 30 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 RetainedInBuffer.=.0;...........
1d380 20 20 20 20 20 76 61 72 20 74 6f 74 61 6c 45 76 65 6e 74 4c 61 67 20 3d 20 30 2e 30 3b 0d 0a 0d .....var.totalEventLag.=.0.0;...
1d3a0 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 48 61 6e 64 6c 65 20 65 76 65 6e 74 73 2e 0d 0a .............//.Handle.events...
1d3c0 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 6c 65 20 28 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e ............while.(remainingEven
1d3e0 74 43 6f 75 6e 74 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 tCount.>.0)..............{......
1d400 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 20 3d ............InputDevice.device.=
1d420 20 6e 75 6c 6c 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e .null;....................Debug.
1d440 41 73 73 65 72 74 28 21 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 68 61 6e Assert(!currentEventReadPtr->han
1d460 64 6c 65 64 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 20 dled);....................//.In.
1d480 62 65 66 6f 72 65 20 72 65 6e 64 65 72 20 75 70 64 61 74 65 73 2c 20 77 65 20 6f 6e 6c 79 20 74 before.render.updates,.we.only.t
1d4a0 61 6b 65 20 73 74 61 74 65 20 65 76 65 6e 74 73 20 61 6e 64 20 6f 6e 6c 79 20 74 68 6f 73 65 20 ake.state.events.and.only.those.
1d4c0 66 6f 72 20 64 65 76 69 63 65 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 for.devices..................//.
1d4e0 74 68 61 74 20 68 61 76 65 20 62 65 66 6f 72 65 20 72 65 6e 64 65 72 20 75 70 64 61 74 65 73 20 that.have.before.render.updates.
1d500 65 6e 61 62 6c 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 69 73 enabled...................if.(is
1d520 42 65 66 6f 72 65 52 65 6e 64 65 72 55 70 64 61 74 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 BeforeRenderUpdate).............
1d540 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 77 68 69 6c .....{......................whil
1d560 65 20 28 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e 74 43 6f 75 6e 74 20 3e 20 30 29 0d 0a 20 20 20 e.(remainingEventCount.>.0).....
1d580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................{..............
1d5a0 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 21 63 75 72 72 65 6e ............Debug.Assert(!curren
1d5c0 74 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 68 61 6e 64 6c 65 64 29 3b 0d 0a 0d 0a 20 20 20 20 tEventReadPtr->handled);........
1d5e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 20 3d 20 54 72 79 ....................device.=.Try
1d600 47 65 74 44 65 76 69 63 65 42 79 49 64 28 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 GetDeviceById(currentEventReadPt
1d620 72 2d 3e 64 65 76 69 63 65 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 r->deviceId);...................
1d640 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 21 3d 20 6e 75 6c 6c 20 26 26 20 64 65 76 .......if.(device.!=.null.&&.dev
1d660 69 63 65 2e 75 70 64 61 74 65 42 65 66 6f 72 65 52 65 6e 64 65 72 20 26 26 0d 0a 20 20 20 20 20 ice.updateBeforeRender.&&.......
1d680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 63 75 72 72 65 6e 74 45 .......................(currentE
1d6a0 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 74 79 70 65 20 3d 3d 20 53 74 61 74 65 45 76 65 6e 74 2e ventReadPtr->type.==.StateEvent.
1d6c0 54 79 70 65 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 Type.||.........................
1d6e0 20 20 20 20 20 20 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 74 79 70 65 20 ......currentEventReadPtr->type.
1d700 3d 3d 20 44 65 6c 74 61 53 74 61 74 65 45 76 65 6e 74 2e 54 79 70 65 29 29 0d 0a 20 20 20 20 20 ==.DeltaStateEvent.Type)).......
1d720 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 0d .......................break;...
1d740 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 76 65 6e 74 42 75 .........................eventBu
1d760 66 66 65 72 2e 41 64 76 61 6e 63 65 54 6f 4e 65 78 74 45 76 65 6e 74 28 72 65 66 20 63 75 72 72 ffer.AdvanceToNextEvent(ref.curr
1d780 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 72 65 66 20 63 75 72 72 65 6e 74 45 76 65 6e entEventReadPtr,.ref.currentEven
1d7a0 74 57 72 69 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tWritePtr,......................
1d7c0 20 20 20 20 20 20 20 20 72 65 66 20 6e 75 6d 45 76 65 6e 74 73 52 65 74 61 69 6e 65 64 49 6e 42 ........ref.numEventsRetainedInB
1d7e0 75 66 66 65 72 2c 20 72 65 66 20 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e 74 43 6f 75 6e 74 2c 20 uffer,.ref.remainingEventCount,.
1d800 6c 65 61 76 65 45 76 65 6e 74 49 6e 42 75 66 66 65 72 3a 20 74 72 75 65 29 3b 0d 0a 20 20 20 20 leaveEventInBuffer:.true);......
1d820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ................}...............
1d840 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 72 65 6d 61 69 6e ...}..................if.(remain
1d860 69 6e 67 45 76 65 6e 74 43 6f 75 6e 74 20 3d 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ingEventCount.==.0).............
1d880 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 .........break;.................
1d8a0 20 20 20 76 61 72 20 63 75 72 72 65 6e 74 45 76 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 ...var.currentEventTimeInternal.
1d8c0 3d 20 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 69 6e 74 65 72 6e 61 6c 54 =.currentEventReadPtr->internalT
1d8e0 69 6d 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 6e 20 74 68 ime;....................//.In.th
1d900 65 20 65 64 69 74 6f 72 2c 20 77 65 20 64 69 73 63 61 72 64 20 61 6c 6c 20 69 6e 70 75 74 20 65 e.editor,.we.discard.all.input.e
1d920 76 65 6e 74 73 20 74 68 61 74 20 6f 63 63 75 72 20 69 6e 2d 62 65 74 77 65 65 6e 20 65 78 69 74 vents.that.occur.in-between.exit
1d940 69 6e 67 20 65 64 69 74 20 6d 6f 64 65 20 61 6e 64 20 68 61 76 69 6e 67 0d 0a 20 20 20 20 20 20 ing.edit.mode.and.having........
1d960 20 20 20 20 20 20 20 20 20 20 2f 2f 20 65 6e 74 65 72 65 64 20 70 6c 61 79 20 6d 6f 64 65 20 61 ..........//.entered.play.mode.a
1d980 73 20 6f 74 68 65 72 77 69 73 65 20 77 65 27 6c 6c 20 73 70 69 6c 6c 20 61 20 62 75 6e 63 68 20 s.otherwise.we'll.spill.a.bunch.
1d9a0 6f 66 20 55 49 20 65 76 65 6e 74 73 20 74 68 61 74 20 68 61 76 65 20 6f 63 63 75 72 72 65 64 20 of.UI.events.that.have.occurred.
1d9c0 77 68 69 6c 65 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 49 while.the..................//.UI
1d9e0 20 77 61 73 20 73 6f 72 74 20 6f 66 20 6e 65 69 74 68 65 72 20 69 6e 20 74 68 69 73 20 6d 6f 64 .was.sort.of.neither.in.this.mod
1da00 65 20 6e 6f 72 20 69 6e 20 74 68 61 74 20 6d 6f 64 65 2e 20 54 68 69 73 20 77 6f 75 6c 64 20 75 e.nor.in.that.mode..This.would.u
1da20 73 75 61 6c 6c 79 20 6c 65 61 64 20 74 6f 20 74 68 65 20 67 61 6d 65 20 72 65 63 65 69 76 69 6e sually.lead.to.the.game.receivin
1da40 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 6e 20 61 63 63 75 6d 75 6c g..................//.an.accumul
1da60 61 74 69 6f 6e 20 6f 66 20 73 70 75 72 69 6f 75 73 20 69 6e 70 75 74 73 20 72 69 67 68 74 20 69 ation.of.spurious.inputs.right.i
1da80 6e 20 6f 6e 65 20 6f 66 20 69 74 73 20 66 69 72 73 74 20 75 70 64 61 74 65 73 2e 0d 0a 20 20 20 n.one.of.its.first.updates......
1daa0 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .............//.................
1dac0 20 2f 2f 20 4e 4f 54 45 3a 20 54 68 65 72 65 27 73 20 61 20 63 68 61 6e 63 65 20 74 68 65 20 73 .//.NOTE:.There's.a.chance.the.s
1dae0 6f 6c 75 74 69 6f 6e 20 68 65 72 65 20 77 69 6c 6c 20 70 72 6f 76 65 20 69 6e 61 64 65 71 75 61 olution.here.will.prove.inadequa
1db00 74 65 20 6f 6e 20 74 68 65 20 6c 6f 6e 67 20 72 75 6e 2e 20 57 65 20 6d 61 79 20 64 6f 20 74 68 te.on.the.long.run..We.may.do.th
1db20 69 6e 67 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 68 ings..................//.......h
1db40 65 72 65 20 73 75 63 68 20 61 73 20 74 68 72 6f 77 69 6e 67 20 70 61 72 74 69 61 6c 20 74 6f 75 ere.such.as.throwing.partial.tou
1db60 63 68 65 73 20 61 77 61 79 20 61 6e 64 20 74 68 65 6e 20 6c 65 74 74 69 6e 67 20 74 68 65 20 72 ches.away.and.then.letting.the.r
1db80 65 73 74 20 6f 66 20 61 20 74 6f 75 63 68 20 67 6f 20 74 68 72 6f 75 67 68 2e 0d 0a 20 20 20 20 est.of.a.touch.go.through.......
1dba0 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 43 6f 75 6c 64 20 62 65 20 74 68 ............//.......Could.be.th
1dbc0 61 74 20 75 6c 74 69 6d 61 74 65 6c 79 20 77 65 20 6e 65 65 64 20 74 6f 20 69 73 73 75 65 20 61 at.ultimately.we.need.to.issue.a
1dbe0 20 66 75 6c 6c 20 72 65 73 65 74 20 6f 66 20 61 6c 6c 20 64 65 76 69 63 65 73 20 61 74 20 74 68 .full.reset.of.all.devices.at.th
1dc00 65 20 62 65 67 69 6e 6e 69 6e 67 20 6f 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.beginning.of..................
1dc20 2f 2f 20 20 20 20 20 20 20 70 6c 61 79 20 6d 6f 64 65 20 69 6e 20 74 68 65 20 65 64 69 74 6f 72 //.......play.mode.in.the.editor
1dc40 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 ...................#if.UNITY_EDI
1dc60 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 28 75 70 64 61 74 65 TOR..................if.((update
1dc80 54 79 70 65 20 26 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 29 20 3d Type.&.InputUpdateType.Editor).=
1dca0 3d 20 30 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 75 =.0.&&......................Inpu
1dcc0 74 53 79 73 74 65 6d 2e 73 5f 53 79 73 74 65 6d 4f 62 6a 65 63 74 2e 65 78 69 74 45 64 69 74 4d tSystem.s_SystemObject.exitEditM
1dce0 6f 64 65 54 69 6d 65 20 3e 20 30 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 odeTime.>.0.&&..................
1dd00 20 20 20 20 63 75 72 72 65 6e 74 45 76 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 3e 3d 20 ....currentEventTimeInternal.>=.
1dd20 49 6e 70 75 74 53 79 73 74 65 6d 2e 73 5f 53 79 73 74 65 6d 4f 62 6a 65 63 74 2e 65 78 69 74 45 InputSystem.s_SystemObject.exitE
1dd40 64 69 74 4d 6f 64 65 54 69 6d 65 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ditModeTime.&&..................
1dd60 20 20 20 20 28 63 75 72 72 65 6e 74 45 76 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 3c 20 ....(currentEventTimeInternal.<.
1dd80 49 6e 70 75 74 53 79 73 74 65 6d 2e 73 5f 53 79 73 74 65 6d 4f 62 6a 65 63 74 2e 65 6e 74 65 72 InputSystem.s_SystemObject.enter
1dda0 50 6c 61 79 4d 6f 64 65 54 69 6d 65 20 7c 7c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 PlayModeTime.||.................
1ddc0 20 20 20 20 20 20 49 6e 70 75 74 53 79 73 74 65 6d 2e 73 5f 53 79 73 74 65 6d 4f 62 6a 65 63 74 ......InputSystem.s_SystemObject
1dde0 2e 65 6e 74 65 72 50 6c 61 79 4d 6f 64 65 54 69 6d 65 20 3d 3d 20 30 29 29 0d 0a 20 20 20 20 20 .enterPlayModeTime.==.0)).......
1de00 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...........{....................
1de20 20 20 65 76 65 6e 74 42 75 66 66 65 72 2e 41 64 76 61 6e 63 65 54 6f 4e 65 78 74 45 76 65 6e 74 ..eventBuffer.AdvanceToNextEvent
1de40 28 72 65 66 20 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 72 65 66 20 63 75 (ref.currentEventReadPtr,.ref.cu
1de60 72 72 65 6e 74 45 76 65 6e 74 57 72 69 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 rrentEventWritePtr,.............
1de80 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 6e 75 6d 45 76 65 6e 74 73 52 65 74 61 69 6e .............ref.numEventsRetain
1dea0 65 64 49 6e 42 75 66 66 65 72 2c 20 72 65 66 20 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e 74 43 6f edInBuffer,.ref.remainingEventCo
1dec0 75 6e 74 2c 20 6c 65 61 76 65 45 76 65 6e 74 49 6e 42 75 66 66 65 72 3a 20 66 61 6c 73 65 29 3b unt,.leaveEventInBuffer:.false);
1dee0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d ......................continue;.
1df00 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
1df20 20 20 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f ....#endif....................//
1df40 20 49 66 20 77 65 27 72 65 20 74 69 6d 65 73 6c 69 63 69 6e 67 2c 20 63 68 65 63 6b 20 69 66 20 .If.we're.timeslicing,.check.if.
1df60 74 68 65 20 65 76 65 6e 74 20 74 69 6d 65 20 69 73 20 77 69 74 68 69 6e 20 6c 69 6d 69 74 73 2e the.event.time.is.within.limits.
1df80 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 69 6d 65 73 6c 69 63 65 45 ..................if.(timesliceE
1dfa0 76 65 6e 74 73 20 26 26 20 63 75 72 72 65 6e 74 45 76 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 vents.&&.currentEventTimeInterna
1dfc0 6c 20 3e 3d 20 63 75 72 72 65 6e 74 54 69 6d 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 l.>=.currentTime)...............
1dfe0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 76 65 6e 74 42 ...{......................eventB
1e000 75 66 66 65 72 2e 41 64 76 61 6e 63 65 54 6f 4e 65 78 74 45 76 65 6e 74 28 72 65 66 20 63 75 72 uffer.AdvanceToNextEvent(ref.cur
1e020 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 72 65 66 20 63 75 72 72 65 6e 74 45 76 65 rentEventReadPtr,.ref.currentEve
1e040 6e 74 57 72 69 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ntWritePtr,.....................
1e060 20 20 20 20 20 72 65 66 20 6e 75 6d 45 76 65 6e 74 73 52 65 74 61 69 6e 65 64 49 6e 42 75 66 66 .....ref.numEventsRetainedInBuff
1e080 65 72 2c 20 72 65 66 20 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e 74 43 6f 75 6e 74 2c 20 6c 65 61 er,.ref.remainingEventCount,.lea
1e0a0 76 65 45 76 65 6e 74 49 6e 42 75 66 66 65 72 3a 20 74 72 75 65 29 3b 0d 0a 20 20 20 20 20 20 20 veEventInBuffer:.true);.........
1e0c0 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 .............continue;..........
1e0e0 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 ........}....................if.
1e100 28 63 75 72 72 65 6e 74 45 76 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 3c 3d 20 63 75 72 (currentEventTimeInternal.<=.cur
1e120 72 65 6e 74 54 69 6d 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 rentTime)......................t
1e140 6f 74 61 6c 45 76 65 6e 74 4c 61 67 20 2b 3d 20 63 75 72 72 65 6e 74 54 69 6d 65 20 2d 20 63 75 otalEventLag.+=.currentTime.-.cu
1e160 72 72 65 6e 74 45 76 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 6c 3b 0d 0a 0d 0a 20 20 20 20 20 rrentEventTimeInternal;.........
1e180 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 47 72 61 62 20 64 65 76 69 63 65 20 66 6f 72 20 65 76 ...........//.Grab.device.for.ev
1e1a0 65 6e 74 2e 20 49 6e 20 62 65 66 6f 72 65 2d 72 65 6e 64 65 72 20 75 70 64 61 74 65 73 2c 20 77 ent..In.before-render.updates,.w
1e1c0 65 20 61 6c 72 65 61 64 79 20 68 61 64 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e.already.had.to................
1e1e0 20 20 2f 2f 20 63 68 65 63 6b 20 74 68 65 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 ..//.check.the.device...........
1e200 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 ........if.(device.==.null).....
1e220 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 20 3d 20 54 72 79 47 65 74 .................device.=.TryGet
1e240 44 65 76 69 63 65 42 79 49 64 28 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e DeviceById(currentEventReadPtr->
1e260 64 65 76 69 63 65 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 deviceId);..................if.(
1e280 64 65 76 69 63 65 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 device.==.null).................
1e2a0 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 .{......................#if.UNIT
1e2c0 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f Y_EDITOR......................//
1e2e0 2f 2f 54 4f 44 4f 3a 20 73 65 65 20 69 66 20 74 68 69 73 20 69 73 20 61 20 64 65 76 69 63 65 20 //TODO:.see.if.this.is.a.device.
1e300 77 65 20 68 61 76 65 6e 27 74 20 63 72 65 61 74 65 64 20 61 6e 64 20 69 66 20 73 6f 2c 20 6a 75 we.haven't.created.and.if.so,.ju
1e320 73 74 20 69 67 6e 6f 72 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d st.ignore......................m
1e340 5f 44 69 61 67 6e 6f 73 74 69 63 73 3f 2e 4f 6e 43 61 6e 6e 6f 74 46 69 6e 64 44 65 76 69 63 65 _Diagnostics?.OnCannotFindDevice
1e360 46 6f 72 45 76 65 6e 74 28 6e 65 77 20 49 6e 70 75 74 45 76 65 6e 74 50 74 72 28 63 75 72 72 65 ForEvent(new.InputEventPtr(curre
1e380 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ntEventReadPtr));...............
1e3a0 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .......#endif...................
1e3c0 20 20 20 20 20 65 76 65 6e 74 42 75 66 66 65 72 2e 41 64 76 61 6e 63 65 54 6f 4e 65 78 74 45 76 .....eventBuffer.AdvanceToNextEv
1e3e0 65 6e 74 28 72 65 66 20 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 72 65 66 ent(ref.currentEventReadPtr,.ref
1e400 20 63 75 72 72 65 6e 74 45 76 65 6e 74 57 72 69 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 .currentEventWritePtr,..........
1e420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 6e 75 6d 45 76 65 6e 74 73 52 65 74 ................ref.numEventsRet
1e440 61 69 6e 65 64 49 6e 42 75 66 66 65 72 2c 20 72 65 66 20 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e ainedInBuffer,.ref.remainingEven
1e460 74 43 6f 75 6e 74 2c 20 6c 65 61 76 65 45 76 65 6e 74 49 6e 42 75 66 66 65 72 3a 20 66 61 6c 73 tCount,.leaveEventInBuffer:.fals
1e480 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f e);........................//.No
1e4a0 20 64 65 76 69 63 65 20 66 6f 75 6e 64 20 6d 61 74 63 68 69 6e 67 20 65 76 65 6e 74 2e 20 49 67 .device.found.matching.event..Ig
1e4c0 6e 6f 72 65 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f nore.it.......................co
1e4e0 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 ntinue;..................}......
1e500 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 47 69 76 65 20 6c 69 73 74 65 6e 65 72 73 20 ..............//.Give.listeners.
1e520 61 20 73 68 6f 74 20 61 74 20 74 68 65 20 65 76 65 6e 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 a.shot.at.the.event.............
1e540 20 20 20 20 20 20 69 66 20 28 6d 5f 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 ......if.(m_EventListeners.lengt
1e560 68 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 h.>.0)..................{.......
1e580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 ...............for.(var.i.=.0;.i
1e5a0 20 3c 20 6d 5f 45 76 65 6e 74 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 .<.m_EventListeners.length;.++i)
1e5c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 45 76 65 6e ..........................m_Even
1e5e0 74 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 6e 65 77 20 49 6e 70 75 74 45 76 65 6e 74 50 74 72 28 tListeners[i](new.InputEventPtr(
1e600 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 29 2c 20 64 65 76 69 63 65 29 3b 0d 0a currentEventReadPtr),.device);..
1e620 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 61 20 6c 69 ......................//.If.a.li
1e640 73 74 65 6e 65 72 20 6d 61 72 6b 73 20 74 68 65 20 65 76 65 6e 74 20 61 73 20 68 61 6e 64 6c 65 stener.marks.the.event.as.handle
1e660 64 2c 20 77 65 20 64 6f 6e 27 74 20 70 72 6f 63 65 73 73 20 69 74 20 66 75 72 74 68 65 72 2e 0d d,.we.don't.process.it.further..
1e680 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 63 75 72 72 65 6e 74 .....................if.(current
1e6a0 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 68 61 6e 64 6c 65 64 29 0d 0a 20 20 20 20 20 20 20 20 EventReadPtr->handled)..........
1e6c0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ............{...................
1e6e0 20 20 20 20 20 20 20 65 76 65 6e 74 42 75 66 66 65 72 2e 41 64 76 61 6e 63 65 54 6f 4e 65 78 74 .......eventBuffer.AdvanceToNext
1e700 45 76 65 6e 74 28 72 65 66 20 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 72 Event(ref.currentEventReadPtr,.r
1e720 65 66 20 63 75 72 72 65 6e 74 45 76 65 6e 74 57 72 69 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 ef.currentEventWritePtr,........
1e740 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 6e 75 6d 45 76 65 ......................ref.numEve
1e760 6e 74 73 52 65 74 61 69 6e 65 64 49 6e 42 75 66 66 65 72 2c 20 72 65 66 20 72 65 6d 61 69 6e 69 ntsRetainedInBuffer,.ref.remaini
1e780 6e 67 45 76 65 6e 74 43 6f 75 6e 74 2c 20 6c 65 61 76 65 45 76 65 6e 74 49 6e 42 75 66 66 65 72 ngEventCount,.leaveEventInBuffer
1e7a0 3a 20 66 61 6c 73 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 :.false);.......................
1e7c0 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...continue;....................
1e7e0 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 ..}..................}..........
1e800 20 20 20 20 20 20 20 20 20 20 2f 2f 20 50 72 6f 63 65 73 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 ..........//.Process............
1e820 20 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e 74 45 76 65 6e 74 54 79 70 65 20 3d 20 63 75 .......var.currentEventType.=.cu
1e840 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2d 3e 74 79 70 65 3b 0d 0a 20 20 20 20 20 20 rrentEventReadPtr->type;........
1e860 20 20 20 20 20 20 20 20 20 20 73 77 69 74 63 68 20 28 63 75 72 72 65 6e 74 45 76 65 6e 74 54 79 ..........switch.(currentEventTy
1e880 70 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 pe)..................{..........
1e8a0 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 53 74 61 74 65 45 76 65 6e 74 2e 54 79 70 65 ............case.StateEvent.Type
1e8c0 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 44 65 6c 74 :......................case.Delt
1e8e0 61 53 74 61 74 65 45 76 65 6e 74 2e 54 79 70 65 3a 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 aStateEvent.Type:...............
1e900 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 65 76 65 6e 74 50 74 72 20 3d 20 6e 65 77 20 .............var.eventPtr.=.new.
1e920 49 6e 70 75 74 45 76 65 6e 74 50 74 72 28 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 InputEventPtr(currentEventReadPt
1e940 72 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f r);............................/
1e960 2f 20 49 67 6e 6f 72 65 20 73 74 61 74 65 20 63 68 61 6e 67 65 73 20 69 66 20 64 65 76 69 63 65 /.Ignore.state.changes.if.device
1e980 20 69 73 20 64 69 73 61 62 6c 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .is.disabled....................
1e9a0 20 20 20 20 20 20 20 69 66 20 28 21 64 65 76 69 63 65 2e 65 6e 61 62 6c 65 64 29 0d 0a 20 20 20 .......if.(!device.enabled).....
1e9c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 .....................{..........
1e9e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 ....................#if.UNITY_ED
1ea00 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ITOR............................
1ea20 20 20 6d 5f 44 69 61 67 6e 6f 73 74 69 63 73 3f 2e 4f 6e 45 76 65 6e 74 46 6f 72 44 69 73 61 62 ..m_Diagnostics?.OnEventForDisab
1ea40 6c 65 64 44 65 76 69 63 65 28 65 76 65 6e 74 50 74 72 2c 20 64 65 76 69 63 65 29 3b 0d 0a 20 20 ledDevice(eventPtr,.device);....
1ea60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 ..........................#endif
1ea80 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 ..............................br
1eaa0 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d eak;..........................}.
1eac0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 ...........................var.d
1eae0 65 76 69 63 65 49 73 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 20 3d 20 28 eviceIsStateCallbackReceiver.=.(
1eb00 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 46 6c 61 67 73 20 26 20 49 6e 70 75 74 44 65 76 69 device.m_DeviceFlags.&.InputDevi
1eb20 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 2e 48 61 73 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 73 ce.DeviceFlags.HasStateCallbacks
1eb40 29 20 3d 3d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ).==............................
1eb60 20 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 2e 48 61 73 53 74 61 ..InputDevice.DeviceFlags.HasSta
1eb80 74 65 43 61 6c 6c 62 61 63 6b 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 teCallbacks;....................
1eba0 20 20 20 20 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 20 74 68 65 20 65 76 65 6e 74 20 69 66 20 74 ........//.Ignore.the.event.if.t
1ebc0 68 65 20 6c 61 73 74 20 73 74 61 74 65 20 75 70 64 61 74 65 20 77 65 20 72 65 63 65 69 76 65 64 he.last.state.update.we.received
1ebe0 20 66 6f 72 20 74 68 65 20 64 65 76 69 63 65 20 77 61 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 .for.the.device.was.............
1ec00 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6e 65 77 65 72 20 74 68 61 6e 20 74 68 69 73 20 .............//.newer.than.this.
1ec20 73 74 61 74 65 20 65 76 65 6e 74 20 69 73 2e 20 57 65 20 64 6f 6e 27 74 20 61 6c 6c 6f 77 20 64 state.event.is..We.don't.allow.d
1ec40 65 76 69 63 65 73 20 74 6f 20 67 6f 20 62 61 63 6b 20 69 6e 20 74 69 6d 65 2e 0d 0a 20 20 20 20 evices.to.go.back.in.time.......
1ec60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 ....................//..........
1ec80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 57 65 20 6d 61 6b 65 ................//.NOTE:.We.make
1eca0 20 61 6e 20 65 78 63 65 70 74 69 6f 6e 20 68 65 72 65 20 66 6f 72 20 64 65 76 69 63 65 73 20 74 .an.exception.here.for.devices.t
1ecc0 68 61 74 20 69 6d 70 6c 65 6d 65 6e 74 20 49 49 6e 70 75 74 53 74 61 74 65 43 61 6c 6c 62 61 63 hat.implement.IInputStateCallbac
1ece0 6b 52 65 63 65 69 76 65 72 20 28 73 75 63 68 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 kReceiver.(such.................
1ed00 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 61 73 20 54 6f 75 63 68 73 63 72 65 65 6e .........//.......as.Touchscreen
1ed20 29 2e 20 46 6f 72 20 64 65 76 69 63 65 73 20 74 68 61 74 20 64 79 6e 61 6d 69 63 61 6c 6c 79 20 )..For.devices.that.dynamically.
1ed40 69 6e 63 6f 72 70 6f 72 61 74 65 20 73 74 61 74 65 20 69 74 20 63 61 6e 20 62 65 20 68 61 72 64 incorporate.state.it.can.be.hard
1ed60 20 65 6e 73 75 72 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .ensuring.......................
1ed80 20 20 20 2f 2f 20 20 20 20 20 20 20 61 20 67 6c 6f 62 61 6c 20 6f 72 64 65 72 69 6e 67 20 6f 66 ...//.......a.global.ordering.of
1eda0 20 65 76 65 6e 74 73 20 61 73 20 74 68 65 72 65 20 6d 61 79 20 62 65 20 6d 75 6c 74 69 70 6c 65 .events.as.there.may.be.multiple
1edc0 20 73 75 62 73 74 72 65 61 6d 73 20 28 65 2e 67 2e 20 65 61 63 68 20 69 6e 64 69 76 69 64 75 61 .substreams.(e.g..each.individua
1ede0 6c 20 74 6f 75 63 68 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 l.touch)........................
1ee00 20 20 2f 2f 20 20 20 20 20 20 20 74 68 61 74 20 61 72 65 20 67 65 6e 65 72 61 74 65 64 20 69 6e ..//.......that.are.generated.in
1ee20 20 74 68 65 20 62 61 63 6b 65 6e 64 20 61 6e 64 20 77 6f 75 6c 64 20 72 65 71 75 69 72 65 20 63 .the.backend.and.would.require.c
1ee40 6f 6e 73 69 64 65 72 61 62 6c 65 20 77 6f 72 6b 20 74 6f 20 65 6e 73 75 72 65 20 6d 6f 6e 6f 74 onsiderable.work.to.ensure.monot
1ee60 6f 6e 69 63 61 6c 6c 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 onically........................
1ee80 20 20 2f 2f 20 20 20 20 20 20 20 69 6e 63 72 65 61 73 69 6e 67 20 74 69 6d 65 73 74 61 6d 70 73 ..//.......increasing.timestamps
1eea0 20 61 63 72 6f 73 73 20 61 6c 6c 20 73 75 63 68 20 73 74 72 65 61 6d 73 2e 0d 0a 20 20 20 20 20 .across.all.such.streams........
1eec0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 63 75 72 72 65 6e 74 45 76 ...................if.(currentEv
1eee0 65 6e 74 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 3c 20 64 65 76 69 63 65 2e 6d 5f 4c 61 73 74 55 entTimeInternal.<.device.m_LastU
1ef00 70 64 61 74 65 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 26 26 0d 0a 20 20 20 20 20 20 20 20 20 20 pdateTimeInternal.&&............
1ef20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 21 28 64 65 76 69 63 65 49 73 53 74 61 74 ..................!(deviceIsStat
1ef40 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 20 26 26 20 64 65 76 69 63 65 2e 73 74 61 74 eCallbackReceiver.&&.device.stat
1ef60 65 42 6c 6f 63 6b 2e 66 6f 72 6d 61 74 20 21 3d 20 65 76 65 6e 74 50 74 72 2e 73 74 61 74 65 46 eBlock.format.!=.eventPtr.stateF
1ef80 6f 72 6d 61 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ormat)).........................
1efa0 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .{..............................
1efc0 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 #if.UNITY_EDITOR................
1efe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 69 61 67 6e 6f 73 74 69 63 73 3f 2e 4f 6e 45 ..............m_Diagnostics?.OnE
1f000 76 65 6e 74 54 69 6d 65 73 74 61 6d 70 4f 75 74 64 61 74 65 64 28 6e 65 77 20 49 6e 70 75 74 45 ventTimestampOutdated(new.InputE
1f020 76 65 6e 74 50 74 72 28 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 29 2c 20 64 65 ventPtr(currentEventReadPtr),.de
1f040 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 vice);..........................
1f060 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ....#endif......................
1f080 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ........break;..................
1f0a0 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ........}.......................
1f0c0 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 74 68 65 20 73 74 61 74 65 20 6f 66 20 74 68 65 20 .....//.Update.the.state.of.the.
1f0e0 64 65 76 69 63 65 20 66 72 6f 6d 20 74 68 65 20 65 76 65 6e 74 2e 20 49 66 20 74 68 65 20 64 65 device.from.the.event..If.the.de
1f100 76 69 63 65 20 69 73 20 61 6e 20 49 49 6e 70 75 74 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 vice.is.an.IInputStateCallbackRe
1f120 63 65 69 76 65 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ceiver,.........................
1f140 20 2f 2f 20 6c 65 74 20 74 68 65 20 64 65 76 69 63 65 20 68 61 6e 64 6c 65 20 74 68 65 20 65 76 .//.let.the.device.handle.the.ev
1f160 65 6e 74 2e 20 49 66 20 6e 6f 74 2c 20 77 65 20 64 6f 20 69 74 20 6f 75 72 73 65 6c 76 65 73 2e ent..If.not,.we.do.it.ourselves.
1f180 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 68 61 ..........................var.ha
1f1a0 76 65 43 68 61 6e 67 65 64 53 74 61 74 65 4f 74 68 65 72 54 68 61 6e 4e 6f 69 73 65 20 3d 20 74 veChangedStateOtherThanNoise.=.t
1f1c0 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 rue;..........................if
1f1e0 20 28 64 65 76 69 63 65 49 73 53 74 61 74 65 43 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 29 .(deviceIsStateCallbackReceiver)
1f200 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 ..........................{.....
1f220 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 .........................//.NOTE
1f240 3a 20 57 65 20 6c 65 61 76 65 20 69 74 20 74 6f 20 74 68 65 20 64 65 76 69 63 65 20 74 6f 20 6d :.We.leave.it.to.the.device.to.m
1f260 61 6b 65 20 73 75 72 65 20 74 68 65 20 65 76 65 6e 74 20 68 61 73 20 74 68 65 20 72 69 67 68 74 ake.sure.the.event.has.the.right
1f280 20 66 6f 72 6d 61 74 2e 20 54 68 69 73 20 61 6c 6c 6f 77 73 20 74 68 65 0d 0a 20 20 20 20 20 20 .format..This.allows.the........
1f2a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 64 ......................//.......d
1f2c0 65 76 69 63 65 20 74 6f 20 68 61 6e 64 6c 65 20 6d 75 6c 74 69 70 6c 65 20 64 69 66 66 65 72 65 evice.to.handle.multiple.differe
1f2e0 6e 74 20 69 6e 63 6f 6d 69 6e 67 20 66 6f 72 6d 61 74 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 nt.incoming.formats.............
1f300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 28 49 49 6e 70 75 74 53 74 61 74 65 43 ..................((IInputStateC
1f320 61 6c 6c 62 61 63 6b 52 65 63 65 69 76 65 72 29 64 65 76 69 63 65 29 2e 4f 6e 53 74 61 74 65 45 allbackReceiver)device).OnStateE
1f340 76 65 6e 74 28 65 76 65 6e 74 50 74 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 vent(eventPtr);.................
1f360 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .........}......................
1f380 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ....else........................
1f3a0 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..{.............................
1f3c0 20 2f 2f 20 49 66 20 74 68 65 20 73 74 61 74 65 20 66 6f 72 6d 61 74 20 64 6f 65 73 6e 27 74 20 .//.If.the.state.format.doesn't.
1f3e0 6d 61 74 63 68 2c 20 69 67 6e 6f 72 65 20 74 68 65 20 65 76 65 6e 74 2e 0d 0a 20 20 20 20 20 20 match,.ignore.the.event.........
1f400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 ......................if.(device
1f420 2e 73 74 61 74 65 42 6c 6f 63 6b 2e 66 6f 72 6d 61 74 20 21 3d 20 65 76 65 6e 74 50 74 72 2e 73 .stateBlock.format.!=.eventPtr.s
1f440 74 61 74 65 46 6f 72 6d 61 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tateFormat).....................
1f460 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .........{......................
1f480 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 ............#if.UNITY_EDITOR....
1f4a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f ..............................m_
1f4c0 44 69 61 67 6e 6f 73 74 69 63 73 3f 2e 4f 6e 45 76 65 6e 74 46 6f 72 6d 61 74 4d 69 73 6d 61 74 Diagnostics?.OnEventFormatMismat
1f4e0 63 68 28 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 64 65 76 69 63 65 29 3b ch(currentEventReadPtr,.device);
1f500 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ................................
1f520 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..#endif........................
1f540 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..........break;................
1f560 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ..............}.................
1f580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 76 65 43 68 61 6e 67 65 64 53 74 61 74 65 4f ...............haveChangedStateO
1f5a0 74 68 65 72 54 68 61 6e 4e 6f 69 73 65 20 3d 20 55 70 64 61 74 65 53 74 61 74 65 28 64 65 76 69 therThanNoise.=.UpdateState(devi
1f5c0 63 65 2c 20 65 76 65 6e 74 50 74 72 2c 20 75 70 64 61 74 65 54 79 70 65 29 3b 0d 0a 20 20 20 20 ce,.eventPtr,.updateType);......
1f5e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 ....................}...........
1f600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 74 69 6d 65 73 .................//.Update.times
1f620 74 61 6d 70 20 6f 6e 20 64 65 76 69 63 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tamp.on.device..................
1f640 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 57 65 20 64 6f 20 74 68 69 73 20 68 65 72 .........//.NOTE:.We.do.this.her
1f660 65 20 61 6e 64 20 6e 6f 74 20 69 6e 20 55 70 64 61 74 65 53 74 61 74 65 28 29 20 73 6f 20 74 68 e.and.not.in.UpdateState().so.th
1f680 61 74 20 49 6e 70 75 74 53 74 61 74 65 2e 43 68 61 6e 67 65 28 29 20 77 69 6c 6c 20 2a 4e 4f 54 at.InputState.Change().will.*NOT
1f6a0 2a 20 63 68 61 6e 67 65 20 74 69 6d 65 73 74 61 6d 70 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 *.change.timestamps.............
1f6c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 4f 6e 6c 79 20 65 76 65 6e ..............//.......Only.even
1f6e0 74 73 20 73 68 6f 75 6c 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ts.should.......................
1f700 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 6d 5f 4c 61 73 74 55 70 64 61 74 65 54 69 6d 65 49 ....if.(device.m_LastUpdateTimeI
1f720 6e 74 65 72 6e 61 6c 20 3c 3d 20 65 76 65 6e 74 50 74 72 2e 69 6e 74 65 72 6e 61 6c 54 69 6d 65 nternal.<=.eventPtr.internalTime
1f740 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 )..............................d
1f760 65 76 69 63 65 2e 6d 5f 4c 61 73 74 55 70 64 61 74 65 54 69 6d 65 49 6e 74 65 72 6e 61 6c 20 3d evice.m_LastUpdateTimeInternal.=
1f780 20 65 76 65 6e 74 50 74 72 2e 69 6e 74 65 72 6e 61 6c 54 69 6d 65 3b 0d 0a 0d 0a 20 20 20 20 20 .eventPtr.internalTime;.........
1f7a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4d 61 6b 65 20 64 65 76 69 63 ...................//.Make.devic
1f7c0 65 20 63 75 72 72 65 6e 74 2e 20 41 67 61 69 6e 2c 20 6f 6e 6c 79 20 64 6f 20 74 68 69 73 20 77 e.current..Again,.only.do.this.w
1f7e0 68 65 6e 20 72 65 63 65 69 76 69 6e 67 20 65 76 65 6e 74 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 hen.receiving.events............
1f800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 68 61 76 65 43 68 61 6e 67 65 64 53 74 ...............if.(haveChangedSt
1f820 61 74 65 4f 74 68 65 72 54 68 61 6e 4e 6f 69 73 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ateOtherThanNoise)..............
1f840 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 4d 61 6b 65 43 75 72 72 65 ................device.MakeCurre
1f860 6e 74 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 nt();...........................
1f880 20 62 72 65 61 6b 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 .break;........................c
1f8a0 61 73 65 20 54 65 78 74 45 76 65 6e 74 2e 54 79 70 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ase.TextEvent.Type:.............
1f8c0 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .........{......................
1f8e0 20 20 20 20 76 61 72 20 74 65 78 74 45 76 65 6e 74 50 74 72 20 3d 20 28 54 65 78 74 45 76 65 6e ....var.textEventPtr.=.(TextEven
1f900 74 2a 29 63 75 72 72 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 3b 0d 0a 20 20 20 20 20 20 20 t*)currentEventReadPtr;.........
1f920 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 69 73 20 49 .................if.(device.is.I
1f940 54 65 78 74 49 6e 70 75 74 52 65 63 65 69 76 65 72 20 74 65 78 74 49 6e 70 75 74 52 65 63 65 69 TextInputReceiver.textInputRecei
1f960 76 65 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d ver)..........................{.
1f980 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 .............................var
1f9a0 20 75 74 66 33 32 43 68 61 72 20 3d 20 74 65 78 74 45 76 65 6e 74 50 74 72 2d 3e 63 68 61 72 61 .utf32Char.=.textEventPtr->chara
1f9c0 63 74 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 cter;...........................
1f9e0 20 20 20 69 66 20 28 75 74 66 33 32 43 68 61 72 20 3e 3d 20 30 78 31 30 30 30 30 29 0d 0a 20 20 ...if.(utf32Char.>=.0x10000)....
1fa00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 ..........................{.....
1fa20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 .............................//.
1fa40 53 65 6e 64 20 73 75 72 72 6f 67 61 74 65 20 70 61 69 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 Send.surrogate.pair.............
1fa60 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 74 66 33 32 43 68 61 72 20 ......................utf32Char.
1fa80 2d 3d 20 30 78 31 30 30 30 30 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 -=.0x10000;.....................
1faa0 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 68 69 67 68 53 75 72 72 6f 67 61 74 65 20 3d .............var.highSurrogate.=
1fac0 20 30 78 44 38 30 30 20 2b 20 28 28 75 74 66 33 32 43 68 61 72 20 3e 3e 20 31 30 29 20 26 20 30 .0xD800.+.((utf32Char.>>.10).&.0
1fae0 78 33 46 46 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 x3FF);..........................
1fb00 20 20 20 20 20 20 20 20 76 61 72 20 6c 6f 77 53 75 72 72 6f 67 61 74 65 20 3d 20 30 78 44 43 30 ........var.lowSurrogate.=.0xDC0
1fb20 30 20 2b 20 28 75 74 66 33 32 43 68 61 72 20 26 20 30 78 33 46 46 29 3b 0d 0a 0d 0a 20 20 20 20 0.+.(utf32Char.&.0x3FF);........
1fb40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 65 78 74 ............................text
1fb60 49 6e 70 75 74 52 65 63 65 69 76 65 72 2e 4f 6e 54 65 78 74 49 6e 70 75 74 28 28 63 68 61 72 29 InputReceiver.OnTextInput((char)
1fb80 68 69 67 68 53 75 72 72 6f 67 61 74 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 highSurrogate);.................
1fba0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 65 78 74 49 6e 70 75 74 52 65 63 65 69 76 .................textInputReceiv
1fbc0 65 72 2e 4f 6e 54 65 78 74 49 6e 70 75 74 28 28 63 68 61 72 29 6c 6f 77 53 75 72 72 6f 67 61 74 er.OnTextInput((char)lowSurrogat
1fbe0 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 e);.............................
1fc00 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .}..............................
1fc20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 else............................
1fc40 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..{.............................
1fc60 20 20 20 20 20 2f 2f 20 53 65 6e 64 20 73 69 6e 67 6c 65 2c 20 70 6c 61 69 6e 20 63 68 61 72 61 .....//.Send.single,.plain.chara
1fc80 63 74 65 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 cter............................
1fca0 20 20 20 20 20 20 20 74 65 78 74 49 6e 70 75 74 52 65 63 65 69 76 65 72 2e 4f 6e 54 65 78 74 49 .......textInputReceiver.OnTextI
1fcc0 6e 70 75 74 28 28 63 68 61 72 29 75 74 66 33 32 43 68 61 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 nput((char)utf32Char);..........
1fce0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 ....................}...........
1fd00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...............}................
1fd20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..........break;................
1fd40 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 ......}........................c
1fd60 61 73 65 20 49 4d 45 43 6f 6d 70 6f 73 69 74 69 6f 6e 45 76 65 6e 74 2e 54 79 70 65 3a 0d 0a 20 ase.IMECompositionEvent.Type:...
1fd80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 ...................{............
1fda0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 69 6d 65 45 76 65 6e 74 50 74 72 20 3d 20 ..............var.imeEventPtr.=.
1fdc0 28 49 4d 45 43 6f 6d 70 6f 73 69 74 69 6f 6e 45 76 65 6e 74 2a 29 63 75 72 72 65 6e 74 45 76 65 (IMECompositionEvent*)currentEve
1fde0 6e 74 52 65 61 64 50 74 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ntReadPtr;......................
1fe00 20 20 20 20 76 61 72 20 74 65 78 74 49 6e 70 75 74 52 65 63 65 69 76 65 72 20 3d 20 64 65 76 69 ....var.textInputReceiver.=.devi
1fe20 63 65 20 61 73 20 49 54 65 78 74 49 6e 70 75 74 52 65 63 65 69 76 65 72 3b 0d 0a 20 20 20 20 20 ce.as.ITextInputReceiver;.......
1fe40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 65 78 74 49 6e 70 75 74 52 65 63 65 ...................textInputRece
1fe60 69 76 65 72 3f 2e 4f 6e 49 4d 45 43 6f 6d 70 6f 73 69 74 69 6f 6e 43 68 61 6e 67 65 64 28 69 6d iver?.OnIMECompositionChanged(im
1fe80 65 45 76 65 6e 74 50 74 72 2d 3e 63 6f 6d 70 6f 73 69 74 69 6f 6e 53 74 72 69 6e 67 29 3b 0d 0a eEventPtr->compositionString);..
1fea0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a ........................break;..
1fec0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 ....................}...........
1fee0 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 44 65 76 69 63 65 52 65 6d 6f 76 65 45 76 .............case.DeviceRemoveEv
1ff00 65 6e 74 2e 54 79 70 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b ent.Type:......................{
1ff20 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 52 65 6d 6f 76 65 ..........................Remove
1ff40 44 65 76 69 63 65 28 64 65 76 69 63 65 2c 20 6b 65 65 70 4f 6e 4c 69 73 74 4f 66 41 76 61 69 6c Device(device,.keepOnListOfAvail
1ff60 61 62 6c 65 44 65 76 69 63 65 73 3a 20 66 61 6c 73 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ableDevices:.false);............
1ff80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 69 74 27 73 20 61 20 6e 61 74 ................//.If.it's.a.nat
1ffa0 69 76 65 20 64 65 76 69 63 65 20 77 69 74 68 20 61 20 64 65 73 63 72 69 70 74 69 6f 6e 2c 20 70 ive.device.with.a.description,.p
1ffc0 75 74 20 69 74 20 6f 6e 20 74 68 65 20 6c 69 73 74 20 6f 66 20 64 69 73 63 6f 6e 6e 65 63 74 65 ut.it.on.the.list.of.disconnecte
1ffe0 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 65 d..........................//.de
20000 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 vices...........................
20020 69 66 20 28 64 65 76 69 63 65 2e 6e 61 74 69 76 65 20 26 26 20 21 64 65 76 69 63 65 2e 64 65 73 if.(device.native.&&.!device.des
20040 63 72 69 70 74 69 6f 6e 2e 65 6d 70 74 79 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 cription.empty).................
20060 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .........{......................
20080 20 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 41 70 70 65 6e 64 57 69 74 68 43 ........ArrayHelpers.AppendWithC
200a0 61 70 61 63 69 74 79 28 72 65 66 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 apacity(ref.m_DisconnectedDevice
200c0 73 2c 20 72 65 66 20 6d 5f 44 69 73 63 6f 6e 6e 65 63 74 65 64 44 65 76 69 63 65 73 43 6f 75 6e s,.ref.m_DisconnectedDevicesCoun
200e0 74 2c 20 64 65 76 69 63 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 t,.device);.....................
20100 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 .........for.(var.i.=.0;.i.<.m_D
20120 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 eviceChangeListeners.length;.++i
20140 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 )...............................
20160 20 20 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 ...m_DeviceChangeListeners[i](de
20180 76 69 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 44 69 73 63 6f 6e 6e 65 vice,.InputDeviceChange.Disconne
201a0 63 74 65 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 cted);..........................
201c0 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b }..........................break
201e0 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ;......................}........
20200 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 73 65 20 44 65 76 69 63 65 43 6f 6e 66 69 ................case.DeviceConfi
20220 67 75 72 61 74 69 6f 6e 45 76 65 6e 74 2e 54 79 70 65 3a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 gurationEvent.Type:.............
20240 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 4f 6e 43 6f 6e 66 69 67 75 72 61 74 .............device.OnConfigurat
20260 69 6f 6e 43 68 61 6e 67 65 64 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ionChanged();...................
20280 20 20 20 20 20 20 20 49 6e 70 75 74 41 63 74 69 6f 6e 53 74 61 74 65 2e 4f 6e 44 65 76 69 63 65 .......InputActionState.OnDevice
202a0 43 68 61 6e 67 65 28 64 65 76 69 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 Change(device,.InputDeviceChange
202c0 2e 43 6f 6e 66 69 67 75 72 61 74 69 6f 6e 43 68 61 6e 67 65 64 29 3b 0d 0a 20 20 20 20 20 20 20 .ConfigurationChanged);.........
202e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b .................for.(var.i.=.0;
20300 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e .i.<.m_DeviceChangeListeners.len
20320 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 gth;.++i).......................
20340 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 43 68 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 5b 69 .......m_DeviceChangeListeners[i
20360 5d 28 64 65 76 69 63 65 2c 20 49 6e 70 75 74 44 65 76 69 63 65 43 68 61 6e 67 65 2e 43 6f 6e 66 ](device,.InputDeviceChange.Conf
20380 69 67 75 72 61 74 69 6f 6e 43 68 61 6e 67 65 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 igurationChanged);..............
203a0 20 20 20 20 20 20 20 20 20 20 20 20 62 72 65 61 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ............break;..............
203c0 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 76 65 6e 74 42 75 ....}....................eventBu
203e0 66 66 65 72 2e 41 64 76 61 6e 63 65 54 6f 4e 65 78 74 45 76 65 6e 74 28 72 65 66 20 63 75 72 72 ffer.AdvanceToNextEvent(ref.curr
20400 65 6e 74 45 76 65 6e 74 52 65 61 64 50 74 72 2c 20 72 65 66 20 63 75 72 72 65 6e 74 45 76 65 6e entEventReadPtr,.ref.currentEven
20420 74 57 72 69 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tWritePtr,......................
20440 72 65 66 20 6e 75 6d 45 76 65 6e 74 73 52 65 74 61 69 6e 65 64 49 6e 42 75 66 66 65 72 2c 20 72 ref.numEventsRetainedInBuffer,.r
20460 65 66 20 72 65 6d 61 69 6e 69 6e 67 45 76 65 6e 74 43 6f 75 6e 74 2c 20 6c 65 61 76 65 45 76 65 ef.remainingEventCount,.leaveEve
20480 6e 74 49 6e 42 75 66 66 65 72 3a 20 66 61 6c 73 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ntInBuffer:.false);.............
204a0 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4d 65 74 72 69 63 73 2e 74 6f 74 61 .}................m_Metrics.tota
204c0 6c 45 76 65 6e 74 50 72 6f 63 65 73 73 69 6e 67 54 69 6d 65 20 2b 3d 20 54 69 6d 65 2e 72 65 61 lEventProcessingTime.+=.Time.rea
204e0 6c 74 69 6d 65 53 69 6e 63 65 53 74 61 72 74 75 70 20 2d 20 70 72 6f 63 65 73 73 69 6e 67 53 74 ltimeSinceStartup.-.processingSt
20500 61 72 74 54 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 4d 65 74 72 69 63 73 2e artTime;..............m_Metrics.
20520 74 6f 74 61 6c 45 76 65 6e 74 4c 61 67 54 69 6d 65 20 2b 3d 20 74 6f 74 61 6c 45 76 65 6e 74 4c totalEventLagTime.+=.totalEventL
20540 61 67 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 52 65 6d 65 6d 62 65 72 20 68 ag;................//.Remember.h
20560 6f 77 20 6d 75 63 68 20 64 61 74 61 20 77 65 20 72 65 74 61 69 6e 65 64 20 73 6f 20 74 68 61 74 ow.much.data.we.retained.so.that
20580 20 77 65 20 64 6f 6e 27 74 20 63 6f 75 6e 74 20 69 74 20 61 67 61 69 6e 73 74 20 74 68 65 20 6e .we.don't.count.it.against.the.n
205a0 65 78 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 62 61 74 63 68 20 6f 66 20 65 76 65 ext..............//.batch.of.eve
205c0 6e 74 73 20 74 68 61 74 20 77 65 20 72 65 63 65 69 76 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 nts.that.we.receive.............
205e0 20 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 74 65 52 65 74 61 69 6e ..InputUpdate.s_LastUpdateRetain
20600 65 64 45 76 65 6e 74 43 6f 75 6e 74 20 3d 20 28 75 69 6e 74 29 6e 75 6d 45 76 65 6e 74 73 52 65 edEventCount.=.(uint)numEventsRe
20620 74 61 69 6e 65 64 49 6e 42 75 66 66 65 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e 70 tainedInBuffer;..............Inp
20640 75 74 55 70 64 61 74 65 2e 73 5f 4c 61 73 74 55 70 64 61 74 65 52 65 74 61 69 6e 65 64 45 76 65 utUpdate.s_LastUpdateRetainedEve
20660 6e 74 42 79 74 65 73 20 3d 20 28 75 69 6e 74 29 28 28 62 79 74 65 2a 29 63 75 72 72 65 6e 74 45 ntBytes.=.(uint)((byte*)currentE
20680 76 65 6e 74 57 72 69 74 65 50 74 72 20 2d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ventWritePtr.-..................
206a0 28 62 79 74 65 2a 29 4e 61 74 69 76 65 41 72 72 61 79 55 6e 73 61 66 65 55 74 69 6c 69 74 79 0d (byte*)NativeArrayUnsafeUtility.
206c0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2e 47 65 74 55 6e 73 61 66 65 42 ......................GetUnsafeB
206e0 75 66 66 65 72 50 6f 69 6e 74 65 72 57 69 74 68 6f 75 74 43 68 65 63 6b 73 28 65 76 65 6e 74 42 ufferPointerWithoutChecks(eventB
20700 75 66 66 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2e 64 61 74 61 uffer.......................data
20720 29 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 65 76 65 ));................//.Update.eve
20740 6e 74 20 62 75 66 66 65 72 2e 20 49 66 20 77 65 20 68 61 76 65 20 72 65 74 61 69 6e 65 64 20 65 nt.buffer..If.we.have.retained.e
20760 76 65 6e 74 73 2c 20 75 70 64 61 74 65 20 65 76 65 6e 74 20 63 6f 75 6e 74 0d 0a 20 20 20 20 20 vents,.update.event.count.......
20780 20 20 20 20 20 20 20 2f 2f 20 61 6e 64 20 62 75 66 66 65 72 20 73 69 7a 65 2e 20 49 66 20 6e 6f .......//.and.buffer.size..If.no
207a0 74 2c 20 6a 75 73 74 20 72 65 73 65 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 t,.just.reset...............if.(
207c0 6e 75 6d 45 76 65 6e 74 73 52 65 74 61 69 6e 65 64 49 6e 42 75 66 66 65 72 20 3e 20 30 29 0d 0a numEventsRetainedInBuffer.>.0)..
207e0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 ............{..................v
20800 61 72 20 62 75 66 66 65 72 50 74 72 20 3d 20 4e 61 74 69 76 65 41 72 72 61 79 55 6e 73 61 66 65 ar.bufferPtr.=.NativeArrayUnsafe
20820 55 74 69 6c 69 74 79 2e 47 65 74 55 6e 73 61 66 65 42 75 66 66 65 72 50 6f 69 6e 74 65 72 57 69 Utility.GetUnsafeBufferPointerWi
20840 74 68 6f 75 74 43 68 65 63 6b 73 28 65 76 65 6e 74 42 75 66 66 65 72 2e 64 61 74 61 29 3b 0d 0a thoutChecks(eventBuffer.data);..
20860 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 28 62 79 ................Debug.Assert((by
20880 74 65 2a 29 63 75 72 72 65 6e 74 45 76 65 6e 74 57 72 69 74 65 50 74 72 20 3e 20 28 62 79 74 65 te*)currentEventWritePtr.>.(byte
208a0 2a 29 62 75 66 66 65 72 50 74 72 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 *)bufferPtr);..................v
208c0 61 72 20 6e 65 77 42 75 66 66 65 72 53 69 7a 65 20 3d 20 28 62 79 74 65 2a 29 63 75 72 72 65 6e ar.newBufferSize.=.(byte*)curren
208e0 74 45 76 65 6e 74 57 72 69 74 65 50 74 72 20 2d 20 28 62 79 74 65 2a 29 62 75 66 66 65 72 50 74 tEventWritePtr.-.(byte*)bufferPt
20900 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 76 65 6e 74 42 75 66 66 65 72 20 r;..................eventBuffer.
20920 3d 20 6e 65 77 20 49 6e 70 75 74 45 76 65 6e 74 42 75 66 66 65 72 28 28 49 6e 70 75 74 45 76 65 =.new.InputEventBuffer((InputEve
20940 6e 74 2a 29 62 75 66 66 65 72 50 74 72 2c 20 6e 75 6d 45 76 65 6e 74 73 52 65 74 61 69 6e 65 64 nt*)bufferPtr,.numEventsRetained
20960 49 6e 42 75 66 66 65 72 2c 20 28 69 6e 74 29 6e 65 77 42 75 66 66 65 72 53 69 7a 65 2c 0d 0a 20 InBuffer,.(int)newBufferSize,...
20980 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 69 6e 74 29 65 76 65 6e 74 42 75 66 ...................(int)eventBuf
209a0 66 65 72 2e 63 61 70 61 63 69 74 79 49 6e 42 79 74 65 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 fer.capacityInBytes);...........
209c0 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 ...}..............else..........
209e0 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 76 65 6e 74 42 75 66 66 ....{..................eventBuff
20a00 65 72 2e 52 65 73 65 74 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 er.Reset();..............}......
20a20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 67 61 6d 65 49 73 50 6c 61 79 69 6e 67 41 6e 64 48 61 ..........if.(gameIsPlayingAndHa
20a40 73 46 6f 63 75 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 63 65 73 73 sFocus)..................Process
20a60 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 28 29 3b 0d 0a 0d StateChangeMonitorTimeouts();...
20a80 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 66 69 72 65 20 65 76 65 6e .............////TODO:.fire.even
20aa0 74 20 74 68 61 74 20 61 6c 6c 6f 77 73 20 63 6f 64 65 20 74 6f 20 75 70 64 61 74 65 20 73 74 61 t.that.allows.code.to.update.sta
20ac0 74 65 20 2a 66 72 6f 6d 2a 20 73 74 61 74 65 20 77 65 20 6a 75 73 74 20 75 70 64 61 74 65 64 0d te.*from*.state.we.just.updated.
20ae0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 69 6c 65 72 2e 45 6e 64 53 61 6d 70 6c ...............Profiler.EndSampl
20b00 65 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 46 49 58 4d 45 3a 20 6e e();................////FIXME:.n
20b20 65 65 64 20 74 6f 20 65 6e 73 75 72 65 20 74 68 61 74 20 69 66 20 73 6f 6d 65 6f 6e 65 20 63 61 eed.to.ensure.that.if.someone.ca
20b40 6c 6c 73 20 51 75 65 75 65 45 76 65 6e 74 28 29 20 66 72 6f 6d 20 61 6e 20 6f 6e 41 66 74 65 72 lls.QueueEvent().from.an.onAfter
20b60 55 70 64 61 74 65 20 63 61 6c 6c 62 61 63 6b 2c 20 77 65 20 64 6f 6e 27 74 20 65 6e 64 20 75 70 Update.callback,.we.don't.end.up
20b80 20 77 69 74 68 20 61 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 .with.a..............////.......
20ba0 6d 65 73 73 20 69 6e 20 74 68 65 20 65 76 65 6e 74 20 62 75 66 66 65 72 0d 0a 20 20 20 20 20 20 mess.in.the.event.buffer........
20bc0 20 20 20 20 20 20 2f 2f 2f 2f 20 20 20 20 20 20 20 73 61 6d 65 20 67 6f 65 73 20 66 6f 72 20 65 ......////.......same.goes.for.e
20be0 76 65 6e 74 73 20 74 68 61 74 20 73 6f 6d 65 6f 6e 65 20 6d 61 79 20 71 75 65 75 65 20 66 72 6f vents.that.someone.may.queue.fro
20c00 6d 20 61 20 63 68 61 6e 67 65 20 6d 6f 6e 69 74 6f 72 20 63 61 6c 6c 62 61 63 6b 0d 0a 20 20 20 m.a.change.monitor.callback.....
20c20 20 20 20 20 20 20 20 20 20 49 6e 76 6f 6b 65 41 66 74 65 72 55 70 64 61 74 65 43 61 6c 6c 62 61 .........InvokeAfterUpdateCallba
20c40 63 6b 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 63 68 65 ck();..............////TODO:.che
20c60 63 6b 20 69 66 20 74 68 65 72 65 27 73 20 6e 65 77 20 65 76 65 6e 74 73 20 69 6e 20 74 68 65 20 ck.if.there's.new.events.in.the.
20c80 65 76 65 6e 74 20 62 75 66 66 65 72 3b 20 69 66 20 73 6f 2c 20 64 6f 20 61 20 70 61 73 73 20 6f event.buffer;.if.so,.do.a.pass.o
20ca0 76 65 72 20 74 68 6f 73 65 20 65 76 65 6e 74 73 20 72 69 67 68 74 20 61 77 61 79 0d 0a 20 20 20 ver.those.events.right.away.....
20cc0 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 49 .....}............private.void.I
20ce0 6e 76 6f 6b 65 41 66 74 65 72 55 70 64 61 74 65 43 61 6c 6c 62 61 63 6b 28 29 0d 0a 20 20 20 20 nvokeAfterUpdateCallback()......
20d00 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 ....{..............for.(var.i.=.
20d20 30 3b 20 69 20 3c 20 6d 5f 41 66 74 65 72 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 0;.i.<.m_AfterUpdateListeners.le
20d40 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 41 66 ngth;.++i)..................m_Af
20d60 74 65 72 55 70 64 61 74 65 4c 69 73 74 65 6e 65 72 73 5b 69 5d 28 29 3b 0d 0a 20 20 20 20 20 20 terUpdateListeners[i]();........
20d80 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 27 6e 65 77 53 74 61 74 ..}............//.NOTE:.'newStat
20da0 65 27 20 63 61 6e 20 62 65 20 61 20 73 75 62 73 65 74 20 6f 66 20 74 68 65 20 66 75 6c 6c 20 73 e'.can.be.a.subset.of.the.full.s
20dc0 74 61 74 65 20 73 74 6f 72 65 64 20 61 74 20 27 6f 6c 64 53 74 61 74 65 27 2e 20 49 6e 20 74 68 tate.stored.at.'oldState'..In.th
20de0 69 73 20 63 61 73 65 2c 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 27 6e 65 77 53 is.case,..........//.......'newS
20e00 74 61 74 65 4f 66 66 73 65 74 49 6e 42 79 74 65 73 27 20 6d 75 73 74 20 67 69 76 65 20 74 68 65 tateOffsetInBytes'.must.give.the
20e20 20 6f 66 66 73 65 74 20 69 6e 74 6f 20 74 68 65 20 66 75 6c 6c 20 73 74 61 74 65 20 61 6e 64 20 .offset.into.the.full.state.and.
20e40 27 6e 65 77 53 74 61 74 65 53 69 7a 65 49 6e 42 79 74 65 73 27 20 6d 75 73 74 0d 0a 20 20 20 20 'newStateSizeInBytes'.must......
20e60 20 20 20 20 2f 2f 20 20 20 20 20 20 20 67 69 76 65 20 74 68 65 20 73 69 7a 65 20 6f 66 20 6d 65 ....//.......give.the.size.of.me
20e80 6d 6f 72 79 20 73 6c 69 63 65 20 74 6f 20 62 65 20 75 70 64 61 74 65 64 2e 0d 0a 20 20 20 20 20 mory.slice.to.be.updated........
20ea0 20 20 20 70 72 69 76 61 74 65 20 75 6e 73 61 66 65 20 62 6f 6f 6c 20 50 72 6f 63 65 73 73 53 74 ...private.unsafe.bool.ProcessSt
20ec0 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 28 69 6e 74 20 64 65 76 69 63 65 49 6e 64 65 ateChangeMonitors(int.deviceInde
20ee0 78 2c 20 76 6f 69 64 2a 20 6e 65 77 53 74 61 74 65 46 72 6f 6d 45 76 65 6e 74 2c 20 76 6f 69 64 x,.void*.newStateFromEvent,.void
20f00 2a 20 6f 6c 64 53 74 61 74 65 4f 66 44 65 76 69 63 65 2c 20 75 69 6e 74 20 6e 65 77 53 74 61 74 *.oldStateOfDevice,.uint.newStat
20f20 65 53 69 7a 65 49 6e 42 79 74 65 73 2c 20 75 69 6e 74 20 6e 65 77 53 74 61 74 65 4f 66 66 73 65 eSizeInBytes,.uint.newStateOffse
20f40 74 49 6e 42 79 74 65 73 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 tInBytes)..........{............
20f60 20 20 69 66 20 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 20 3d 3d 20 6e ..if.(m_StateChangeMonitors.==.n
20f80 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c ull)..................return.fal
20fa0 73 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 72 65 73 69 7a 65 20 se;................//.We.resize.
20fc0 74 68 65 20 6d 6f 6e 69 74 6f 72 20 61 72 72 61 79 73 20 6f 6e 6c 79 20 77 68 65 6e 20 73 6f 6d the.monitor.arrays.only.when.som
20fe0 65 6f 6e 65 20 61 64 64 73 20 74 6f 20 74 68 65 6d 20 73 6f 20 74 68 65 79 0d 0a 20 20 20 20 20 eone.adds.to.them.so.they.......
21000 20 20 20 20 20 20 20 2f 2f 20 6d 61 79 20 62 65 20 6f 75 74 20 6f 66 20 73 79 6e 63 20 77 69 74 .......//.may.be.out.of.sync.wit
21020 68 20 74 68 65 20 73 69 7a 65 20 6f 66 20 6d 5f 44 65 76 69 63 65 73 2e 0d 0a 20 20 20 20 20 20 h.the.size.of.m_Devices.........
21040 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 49 6e 64 65 78 20 3e 3d 20 6d 5f 53 74 61 74 65 ......if.(deviceIndex.>=.m_State
21060 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 2e 4c 65 6e 67 74 68 29 0d 0a 20 20 20 20 20 20 20 20 ChangeMonitors.Length)..........
21080 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ........return.false;...........
210a0 20 20 20 20 20 76 61 72 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 73 20 3d 20 6d 5f 53 74 61 74 65 .....var.memoryRegions.=.m_State
210c0 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 69 63 65 49 6e 64 65 78 5d 2e 6d 65 6d 6f ChangeMonitors[deviceIndex].memo
210e0 72 79 52 65 67 69 6f 6e 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 65 6d 6f ryRegions;..............if.(memo
21100 72 79 52 65 67 69 6f 6e 73 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ryRegions.==.null)..............
21120 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 20 2f 2f 20 4e 6f 20 6f 6e 65 20 63 61 72 65 ....return.false;.//.No.one.care
21140 73 20 61 62 6f 75 74 20 73 74 61 74 65 20 63 68 61 6e 67 65 73 20 6f 6e 20 74 68 69 73 20 64 65 s.about.state.changes.on.this.de
21160 76 69 63 65 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6e 75 6d 4d 6f 6e 69 vice.................var.numMoni
21180 74 6f 72 73 20 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 tors.=.m_StateChangeMonitors[dev
211a0 69 63 65 49 6e 64 65 78 5d 2e 63 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 iceIndex].count;..............va
211c0 72 20 73 69 67 6e 61 6c 6c 65 64 20 3d 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 r.signalled.=.false;............
211e0 20 20 76 61 72 20 73 69 67 6e 61 6c 73 20 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e ..var.signals.=.m_StateChangeMon
21200 69 74 6f 72 73 5b 64 65 76 69 63 65 49 6e 64 65 78 5d 2e 73 69 67 6e 61 6c 6c 65 64 3b 0d 0a 20 itors[deviceIndex].signalled;...
21220 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 68 61 76 65 43 68 61 6e 67 65 64 53 69 67 6e 61 6c ...........var.haveChangedSignal
21240 73 42 69 74 66 69 65 6c 64 20 3d 20 66 61 6c 73 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 sBitfield.=.false;..............
21260 20 20 2f 2f 20 46 6f 72 20 65 76 65 72 79 20 6d 65 6d 6f 72 79 20 72 65 67 69 6f 6e 20 74 68 61 ..//.For.every.memory.region.tha
21280 74 20 6f 76 65 72 6c 61 70 73 20 77 68 61 74 20 77 65 20 67 6f 74 20 69 6e 20 74 68 65 20 65 76 t.overlaps.what.we.got.in.the.ev
212a0 65 6e 74 2c 20 63 6f 6d 70 61 72 65 20 6d 65 6d 6f 72 79 20 63 6f 6e 74 65 6e 74 73 0d 0a 20 20 ent,.compare.memory.contents....
212c0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 62 65 74 77 65 65 6e 20 74 68 65 20 6f 6c 64 20 64 65 76 ..........//.between.the.old.dev
212e0 69 63 65 20 73 74 61 74 65 20 61 6e 64 20 77 68 61 74 27 73 20 69 6e 20 74 68 65 20 65 76 65 6e ice.state.and.what's.in.the.even
21300 74 2e 20 49 66 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 64 69 66 66 65 72 65 6e 74 2c 20 74 68 t..If.the.contents.different,.th
21320 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 72 65 73 70 65 63 74 69 76 65 20 73 74 61 e..............//.respective.sta
21340 74 65 20 6d 6f 6e 69 74 6f 72 20 73 69 67 6e 61 6c 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 te.monitor.signals..............
21360 20 76 61 72 20 6e 65 77 45 76 65 6e 74 4d 65 6d 6f 72 79 52 65 67 69 6f 6e 20 3d 20 6e 65 77 20 .var.newEventMemoryRegion.=.new.
21380 4d 65 6d 6f 72 79 48 65 6c 70 65 72 73 2e 42 69 74 52 65 67 69 6f 6e 28 6e 65 77 53 74 61 74 65 MemoryHelpers.BitRegion(newState
213a0 4f 66 66 73 65 74 49 6e 42 79 74 65 73 2c 20 30 2c 20 6e 65 77 53 74 61 74 65 53 69 7a 65 49 6e OffsetInBytes,.0,.newStateSizeIn
213c0 42 79 74 65 73 20 2a 20 38 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 Bytes.*.8);..............for.(va
213e0 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6e 75 6d 4d 6f 6e 69 74 6f 72 73 3b 20 2b 2b 69 29 0d 0a r.i.=.0;.i.<.numMonitors;.++i)..
21400 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 ............{..................v
21420 61 72 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 20 3d 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 73 5b ar.memoryRegion.=.memoryRegions[
21440 69 5d 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 68 65 63 6b 20 i];....................//.Check.
21460 69 66 20 74 68 65 20 6d 6f 6e 69 74 6f 72 20 72 65 63 6f 72 64 20 68 61 73 20 62 65 65 6e 20 77 if.the.monitor.record.has.been.w
21480 69 70 65 64 20 69 6e 20 74 68 65 20 6d 65 61 6e 74 69 6d 65 2e 20 49 66 20 73 6f 2c 20 72 65 6d iped.in.the.meantime..If.so,.rem
214a0 6f 76 65 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 65 6d ove.it...................if.(mem
214c0 6f 72 79 52 65 67 69 6f 6e 2e 73 69 7a 65 49 6e 42 69 74 73 20 3d 3d 20 30 29 0d 0a 20 20 20 20 oryRegion.sizeInBits.==.0)......
214e0 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ............{...................
21500 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 44 6f 20 77 65 20 72 65 61 6c 6c 79 20 63 61 72 65 ...////REVIEW:.Do.we.really.care
21520 3f 20 49 74 20 69 73 20 6e 69 63 65 20 74 68 61 74 20 69 74 27 73 20 70 72 65 64 69 63 74 61 62 ?.It.is.nice.that.it's.predictab
21540 6c 65 20 74 68 69 73 20 77 61 79 20 62 75 74 20 68 61 72 64 6c 79 20 61 20 68 61 72 64 20 72 65 le.this.way.but.hardly.a.hard.re
21560 71 75 69 72 65 6d 65 6e 74 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f quirement....................../
21580 2f 20 4e 4f 54 45 3a 20 57 65 27 72 65 20 75 73 69 6e 67 20 45 72 61 73 65 41 74 57 69 74 68 43 /.NOTE:.We're.using.EraseAtWithC
215a0 61 70 61 63 69 74 79 20 68 65 72 65 20 72 61 74 68 65 72 20 74 68 61 6e 20 45 72 61 73 65 41 74 apacity.here.rather.than.EraseAt
215c0 42 79 4d 6f 76 69 6e 67 54 61 69 6c 20 74 6f 20 70 72 65 73 65 72 76 65 0d 0a 20 20 20 20 20 20 ByMovingTail.to.preserve........
215e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 6f 72 64 65 72 20 77 68 69 ..............//.......order.whi
21600 63 68 20 6d 61 6b 65 73 20 74 68 65 20 6f 72 64 65 72 20 6f 66 20 63 61 6c 6c 62 61 63 6b 73 20 ch.makes.the.order.of.callbacks.
21620 73 6f 6d 65 77 68 61 74 20 6d 6f 72 65 20 70 72 65 64 69 63 74 61 62 6c 65 2e 0d 0a 0d 0a 20 20 somewhat.more.predictable.......
21640 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 69 73 74 65 6e 65 72 43 6f ..................var.listenerCo
21660 75 6e 74 20 3d 20 6e 75 6d 4d 6f 6e 69 74 6f 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 unt.=.numMonitors;..............
21680 20 20 20 20 20 20 20 20 76 61 72 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 43 6f 75 6e 74 20 3d 20 ........var.memoryRegionCount.=.
216a0 6e 75 6d 4d 6f 6e 69 74 6f 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 numMonitors;....................
216c0 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 45 72 61 73 65 41 74 57 69 74 68 43 61 70 61 63 69 ..ArrayHelpers.EraseAtWithCapaci
216e0 74 79 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 69 63 65 49 ty(m_StateChangeMonitors[deviceI
21700 6e 64 65 78 5d 2e 6c 69 73 74 65 6e 65 72 73 2c 20 72 65 66 20 6c 69 73 74 65 6e 65 72 43 6f 75 ndex].listeners,.ref.listenerCou
21720 6e 74 2c 20 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 72 72 nt,.i);......................Arr
21740 61 79 48 65 6c 70 65 72 73 2e 45 72 61 73 65 41 74 57 69 74 68 43 61 70 61 63 69 74 79 28 6d 65 ayHelpers.EraseAtWithCapacity(me
21760 6d 6f 72 79 52 65 67 69 6f 6e 73 2c 20 72 65 66 20 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 43 6f 75 moryRegions,.ref.memoryRegionCou
21780 6e 74 2c 20 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 nt,.i);......................sig
217a0 6e 61 6c 73 2e 53 65 74 4c 65 6e 67 74 68 28 6e 75 6d 4d 6f 6e 69 74 6f 72 73 20 2d 20 31 29 3b nals.SetLength(numMonitors.-.1);
217c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 76 65 43 68 61 6e 67 65 ......................haveChange
217e0 64 53 69 67 6e 61 6c 73 42 69 74 66 69 65 6c 64 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 dSignalsBitfield.=.true;........
21800 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 6e 75 6d 4d 6f 6e 69 74 6f 72 73 3b 0d 0a 20 20 ..............--numMonitors;....
21820 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 2d 69 3b 0d 0a 20 20 20 20 20 20 20 20 ..................--i;..........
21840 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 ............continue;...........
21860 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 .......}....................var.
21880 6f 76 65 72 6c 61 70 20 3d 20 6e 65 77 45 76 65 6e 74 4d 65 6d 6f 72 79 52 65 67 69 6f 6e 2e 4f overlap.=.newEventMemoryRegion.O
218a0 76 65 72 6c 61 70 28 6d 65 6d 6f 72 79 52 65 67 69 6f 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 verlap(memoryRegion);...........
218c0 20 20 20 20 20 20 20 69 66 20 28 6f 76 65 72 6c 61 70 2e 69 73 45 6d 70 74 79 20 7c 7c 20 4d 65 .......if.(overlap.isEmpty.||.Me
218e0 6d 6f 72 79 48 65 6c 70 65 72 73 2e 43 6f 6d 70 61 72 65 28 6f 6c 64 53 74 61 74 65 4f 66 44 65 moryHelpers.Compare(oldStateOfDe
21900 76 69 63 65 2c 20 28 62 79 74 65 2a 29 6e 65 77 53 74 61 74 65 46 72 6f 6d 45 76 65 6e 74 20 2d vice,.(byte*)newStateFromEvent.-
21920 20 6e 65 77 53 74 61 74 65 4f 66 66 73 65 74 49 6e 42 79 74 65 73 2c 20 6f 76 65 72 6c 61 70 29 .newStateOffsetInBytes,.overlap)
21940 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b )......................continue;
21960 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 6e 61 6c 73 2e 53 65 74 42 ....................signals.SetB
21980 69 74 28 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 68 61 76 65 43 68 61 6e it(i);..................haveChan
219a0 67 65 64 53 69 67 6e 61 6c 73 42 69 74 66 69 65 6c 64 20 3d 20 74 72 75 65 3b 0d 0a 20 20 20 20 gedSignalsBitfield.=.true;......
219c0 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 6e 61 6c 6c 65 64 20 3d 20 74 72 75 65 3b 0d 0a 20 ............signalled.=.true;...
219e0 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 ...........}................if.(
21a00 68 61 76 65 43 68 61 6e 67 65 64 53 69 67 6e 61 6c 73 42 69 74 66 69 65 6c 64 29 0d 0a 20 20 20 haveChangedSignalsBitfield).....
21a20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f .............m_StateChangeMonito
21a40 72 73 5b 64 65 76 69 63 65 49 6e 64 65 78 5d 2e 73 69 67 6e 61 6c 6c 65 64 20 3d 20 73 69 67 6e rs[deviceIndex].signalled.=.sign
21a60 61 6c 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 73 69 67 6e 61 als;................return.signa
21a80 6c 6c 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 lled;..........}............priv
21aa0 61 74 65 20 75 6e 73 61 66 65 20 76 6f 69 64 20 46 69 72 65 53 74 61 74 65 43 68 61 6e 67 65 4e ate.unsafe.void.FireStateChangeN
21ac0 6f 74 69 66 69 63 61 74 69 6f 6e 73 28 69 6e 74 20 64 65 76 69 63 65 49 6e 64 65 78 2c 20 64 6f otifications(int.deviceIndex,.do
21ae0 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 54 69 6d 65 2c 20 49 6e 70 75 74 45 76 65 6e 74 2a 20 65 uble.internalTime,.InputEvent*.e
21b00 76 65 6e 74 50 74 72 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ventPtr)..........{.............
21b20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 .Debug.Assert(m_StateChangeMonit
21b40 6f 72 73 20 21 3d 20 6e 75 6c 6c 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 ors.!=.null);..............Debug
21b60 2e 41 73 73 65 72 74 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 2e 4c 65 .Assert(m_StateChangeMonitors.Le
21b80 6e 67 74 68 20 3e 20 64 65 76 69 63 65 49 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ngth.>.deviceIndex);............
21ba0 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 54 68 69 73 20 6d 65 74 68 6f 64 20 6d 75 73 74 20 62 65 ....//.NOTE:.This.method.must.be
21bc0 20 73 61 66 65 20 66 6f 72 20 6d 75 74 61 74 69 6e 67 20 74 68 65 20 73 74 61 74 65 20 63 68 61 .safe.for.mutating.the.state.cha
21be0 6e 67 65 20 6d 6f 6e 69 74 6f 72 20 61 72 72 61 79 73 20 66 72 6f 6d 20 2a 77 69 74 68 69 6e 2a nge.monitor.arrays.from.*within*
21c00 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 4e 6f 74 69 66 79 43 6f 6e ..............//.......NotifyCon
21c20 74 72 6f 6c 53 74 61 74 65 43 68 61 6e 67 65 64 28 29 21 20 54 68 69 73 20 69 6e 63 6c 75 64 65 trolStateChanged()!.This.include
21c40 73 20 61 6c 6c 20 6d 6f 6e 69 74 6f 72 73 20 66 6f 72 20 74 68 65 20 64 65 76 69 63 65 20 62 65 s.all.monitors.for.the.device.be
21c60 69 6e 67 20 77 69 70 65 64 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 ing.wiped..............//.......
21c80 63 6f 6d 70 6c 65 74 65 6c 79 20 6f 72 20 61 72 62 69 74 72 61 72 79 20 61 64 64 69 74 69 6f 6e completely.or.arbitrary.addition
21ca0 73 20 61 6e 64 20 72 65 6d 6f 76 61 6c 73 20 68 61 76 69 6e 67 20 6f 63 63 75 72 72 65 64 2e 0d s.and.removals.having.occurred..
21cc0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 76 61 72 20 73 69 67 6e 61 6c 73 20 3d ...............ref.var.signals.=
21ce0 20 72 65 66 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 69 63 .ref.m_StateChangeMonitors[devic
21d00 65 49 6e 64 65 78 5d 2e 73 69 67 6e 61 6c 6c 65 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 eIndex].signalled;..............
21d20 72 65 66 20 76 61 72 20 6c 69 73 74 65 6e 65 72 73 20 3d 20 72 65 66 20 6d 5f 53 74 61 74 65 43 ref.var.listeners.=.ref.m_StateC
21d40 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 5b 64 65 76 69 63 65 49 6e 64 65 78 5d 2e 6c 69 73 74 65 hangeMonitors[deviceIndex].liste
21d60 6e 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 74 69 6d 65 20 3d 20 69 6e ners;..............var.time.=.in
21d80 74 65 72 6e 61 6c 54 69 6d 65 20 2d 20 49 6e 70 75 74 52 75 6e 74 69 6d 65 2e 73 5f 43 75 72 72 ternalTime.-.InputRuntime.s_Curr
21da0 65 6e 74 54 69 6d 65 4f 66 66 73 65 74 54 6f 52 65 61 6c 74 69 6d 65 53 69 6e 63 65 53 74 61 72 entTimeOffsetToRealtimeSinceStar
21dc0 74 75 70 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 43 61 6c 6c 20 49 53 74 61 tup;................//.Call.ISta
21de0 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 2e 4e 6f 74 69 66 79 43 6f 6e 74 72 6f 6c 53 74 61 teChangeMonitor.NotifyControlSta
21e00 74 65 43 68 61 6e 67 65 20 66 6f 72 20 65 76 65 72 79 20 6d 6f 6e 69 74 6f 72 20 74 68 61 74 20 teChange.for.every.monitor.that.
21e20 69 73 20 69 6e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 73 69 67 6e 61 6c 6c 65 64 20 is.in..............//.signalled.
21e40 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d state...............for.(var.i.=
21e60 20 30 3b 20 69 20 3c 20 73 69 67 6e 61 6c 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 .0;.i.<.signals.length;.++i)....
21e80 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 ..........{..................if.
21ea0 28 21 73 69 67 6e 61 6c 73 2e 54 65 73 74 42 69 74 28 69 29 29 0d 0a 20 20 20 20 20 20 20 20 20 (!signals.TestBit(i))...........
21ec0 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ...........continue;............
21ee0 20 20 20 20 20 20 20 20 76 61 72 20 6c 69 73 74 65 6e 65 72 20 3d 20 6c 69 73 74 65 6e 65 72 73 ........var.listener.=.listeners
21f00 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 [i];..................try.......
21f20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...........{....................
21f40 20 20 6c 69 73 74 65 6e 65 72 2e 6d 6f 6e 69 74 6f 72 2e 4e 6f 74 69 66 79 43 6f 6e 74 72 6f 6c ..listener.monitor.NotifyControl
21f60 53 74 61 74 65 43 68 61 6e 67 65 64 28 6c 69 73 74 65 6e 65 72 2e 63 6f 6e 74 72 6f 6c 2c 20 74 StateChanged(listener.control,.t
21f80 69 6d 65 2c 20 65 76 65 6e 74 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ime,.eventPtr,..................
21fa0 20 20 20 20 20 20 20 20 6c 69 73 74 65 6e 65 72 2e 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 29 3b 0d ........listener.monitorIndex);.
21fc0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
21fe0 20 20 20 20 63 61 74 63 68 20 28 45 78 63 65 70 74 69 6f 6e 20 65 78 63 65 70 74 69 6f 6e 29 0d ....catch.(Exception.exception).
22000 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................{..............
22020 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 4c 6f 67 45 72 72 6f 72 28 0d 0a 20 20 20 20 20 20 20 ........Debug.LogError(.........
22040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 24 22 45 78 63 65 70 74 69 6f 6e 20 27 7b 65 .................$"Exception.'{e
22060 78 63 65 70 74 69 6f 6e 2e 47 65 74 54 79 70 65 28 29 2e 4e 61 6d 65 7d 27 20 74 68 72 6f 77 6e xception.GetType().Name}'.thrown
22080 20 66 72 6f 6d 20 73 74 61 74 65 20 63 68 61 6e 67 65 20 6d 6f 6e 69 74 6f 72 20 27 7b 6c 69 73 .from.state.change.monitor.'{lis
220a0 74 65 6e 65 72 2e 6d 6f 6e 69 74 6f 72 2e 47 65 74 54 79 70 65 28 29 2e 4e 61 6d 65 7d 27 20 6f tener.monitor.GetType().Name}'.o
220c0 6e 20 27 7b 6c 69 73 74 65 6e 65 72 2e 63 6f 6e 74 72 6f 6c 7d 27 22 29 3b 0d 0a 20 20 20 20 20 n.'{listener.control}'");.......
220e0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 4c 6f 67 45 78 63 65 70 74 69 6f ...............Debug.LogExceptio
22100 6e 28 65 78 63 65 70 74 69 6f 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d n(exception);..................}
22120 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 67 6e 61 6c 73 2e 43 6c 65 61 ....................signals.Clea
22140 72 42 69 74 28 69 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 rBit(i);..............}.........
22160 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 76 6f 69 64 20 50 72 6f 63 65 .}............private.void.Proce
22180 73 73 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 28 29 0d 0a ssStateChangeMonitorTimeouts()..
221a0 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 53 74 61 ........{..............if.(m_Sta
221c0 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 2e 6c 65 6e 67 74 68 20 3d teChangeMonitorTimeouts.length.=
221e0 3d 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 3b 0d 0a 0d =.0)..................return;...
22200 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 47 6f 20 74 68 72 6f 75 67 68 20 74 68 65 20 6c .............//.Go.through.the.l
22220 69 73 74 20 61 6e 64 20 62 6f 74 68 20 74 72 69 67 67 65 72 20 65 78 70 69 72 65 64 20 74 69 6d ist.and.both.trigger.expired.tim
22240 65 72 73 20 61 6e 64 20 72 65 6d 6f 76 65 20 61 6e 79 20 69 72 72 65 6c 65 76 61 6e 74 0d 0a 20 ers.and.remove.any.irrelevant...
22260 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6f 6e 65 73 20 62 79 20 63 6f 6d 70 61 63 74 69 6e 67 ...........//.ones.by.compacting
22280 20 74 68 65 20 61 72 72 61 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 .the.array...............//.NOTE
222a0 3a 20 57 65 20 64 6f 20 6e 6f 74 20 61 63 74 75 61 6c 6c 79 20 72 65 6c 65 61 73 65 20 61 6e 79 :.We.do.not.actually.release.any
222c0 20 6d 65 6d 6f 72 79 20 77 65 20 6d 61 79 20 68 61 76 65 20 61 6c 6c 6f 63 61 74 65 64 2e 0d 0a .memory.we.may.have.allocated...
222e0 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 63 75 72 72 65 6e 74 54 69 6d 65 20 3d 20 6d 5f ............var.currentTime.=.m_
22300 52 75 6e 74 69 6d 65 2e 63 75 72 72 65 6e 74 54 69 6d 65 20 2d 20 49 6e 70 75 74 52 75 6e 74 69 Runtime.currentTime.-.InputRunti
22320 6d 65 2e 73 5f 43 75 72 72 65 6e 74 54 69 6d 65 4f 66 66 73 65 74 54 6f 52 65 61 6c 74 69 6d 65 me.s_CurrentTimeOffsetToRealtime
22340 53 69 6e 63 65 53 74 61 72 74 75 70 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 72 SinceStartup;..............var.r
22360 65 6d 61 69 6e 69 6e 67 54 69 6d 65 6f 75 74 43 6f 75 6e 74 20 3d 20 30 3b 0d 0a 20 20 20 20 20 emainingTimeoutCount.=.0;.......
22380 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 53 74 61 .......for.(var.i.=.0;.i.<.m_Sta
223a0 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 2e 6c 65 6e 67 74 68 3b 20 teChangeMonitorTimeouts.length;.
223c0 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ++i)..............{.............
223e0 20 20 20 20 20 2f 2f 20 49 66 20 77 65 20 68 61 76 65 20 72 65 73 65 74 20 74 68 69 73 20 65 6e .....//.If.we.have.reset.this.en
22400 74 72 79 20 69 6e 20 52 65 6d 6f 76 65 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 try.in.RemoveStateChangeMonitorT
22420 69 6d 65 6f 75 74 73 28 29 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 73 imeouts(),..................//.s
22440 6b 69 70 20 6f 76 65 72 20 69 74 20 61 6e 64 20 6c 65 74 20 63 6f 6d 70 61 63 74 69 6f 6e 20 67 kip.over.it.and.let.compaction.g
22460 65 74 20 72 69 64 20 6f 66 20 69 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 et.rid.of.it...................i
22480 66 20 28 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 5b f.(m_StateChangeMonitorTimeouts[
224a0 69 5d 2e 63 6f 6e 74 72 6f 6c 20 3d 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 i].control.==.null).............
224c0 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 .........continue;..............
224e0 20 20 20 20 20 20 76 61 72 20 74 69 6d 65 72 45 78 70 69 72 61 74 69 6f 6e 54 69 6d 65 20 3d 20 ......var.timerExpirationTime.=.
22500 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 5b 69 5d 2e m_StateChangeMonitorTimeouts[i].
22520 74 69 6d 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 74 69 6d 65 72 time;..................if.(timer
22540 45 78 70 69 72 61 74 69 6f 6e 54 69 6d 65 20 3c 3d 20 63 75 72 72 65 6e 74 54 69 6d 65 29 0d 0a ExpirationTime.<=.currentTime)..
22560 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ................{...............
22580 20 20 20 20 20 20 20 76 61 72 20 74 69 6d 65 6f 75 74 20 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e .......var.timeout.=.m_StateChan
225a0 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 geMonitorTimeouts[i];...........
225c0 20 20 20 20 20 20 20 20 20 20 20 74 69 6d 65 6f 75 74 2e 6d 6f 6e 69 74 6f 72 2e 4e 6f 74 69 66 ...........timeout.monitor.Notif
225e0 79 54 69 6d 65 72 45 78 70 69 72 65 64 28 74 69 6d 65 6f 75 74 2e 63 6f 6e 74 72 6f 6c 2c 0d 0a yTimerExpired(timeout.control,..
22600 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 75 72 72 65 6e 74 54 ........................currentT
22620 69 6d 65 2c 20 74 69 6d 65 6f 75 74 2e 6d 6f 6e 69 74 6f 72 49 6e 64 65 78 2c 20 74 69 6d 65 6f ime,.timeout.monitorIndex,.timeo
22640 75 74 2e 74 69 6d 65 72 49 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ut.timerIndex);.................
22660 20 20 20 20 20 20 20 2f 2f 20 43 6f 6d 70 61 63 74 69 6f 6e 20 77 69 6c 6c 20 67 65 74 20 72 69 .......//.Compaction.will.get.ri
22680 64 20 6f 66 20 74 68 65 20 65 6e 74 72 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 d.of.the.entry..................
226a0 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 .}..................else........
226c0 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..........{.....................
226e0 20 2f 2f 20 52 61 74 68 65 72 20 74 68 61 6e 20 72 65 70 65 61 74 65 64 6c 79 20 63 61 6c 6c 69 .//.Rather.than.repeatedly.calli
22700 6e 67 20 52 65 6d 6f 76 65 41 74 28 29 20 61 6e 64 20 74 68 75 73 20 70 6f 74 65 6e 74 69 61 6c ng.RemoveAt().and.thus.potential
22720 6c 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6d 6f 76 69 6e ly......................//.movin
22740 67 20 74 68 65 20 73 61 6d 65 20 64 61 74 61 20 6f 76 65 72 20 61 6e 64 20 6f 76 65 72 20 61 67 g.the.same.data.over.and.over.ag
22760 61 69 6e 2c 20 77 65 20 63 6f 6d 70 61 63 74 20 74 68 65 20 61 72 72 61 79 0d 0a 20 20 20 20 20 ain,.we.compact.the.array.......
22780 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6f 6e 20 74 68 65 20 66 6c 79 20 61 6e 64 ...............//.on.the.fly.and
227a0 20 6d 6f 76 65 20 65 6e 74 72 69 65 73 20 69 6e 20 74 68 65 20 61 72 72 61 79 20 64 6f 77 6e 20 .move.entries.in.the.array.down.
227c0 61 73 20 6e 65 65 64 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 as.needed.......................
227e0 69 66 20 28 69 20 21 3d 20 72 65 6d 61 69 6e 69 6e 67 54 69 6d 65 6f 75 74 43 6f 75 6e 74 29 0d if.(i.!=.remainingTimeoutCount).
22800 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 .........................m_State
22820 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 54 69 6d 65 6f 75 74 73 5b 72 65 6d 61 69 6e 69 6e 67 54 ChangeMonitorTimeouts[remainingT
22840 69 6d 65 6f 75 74 43 6f 75 6e 74 5d 20 3d 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 imeoutCount].=.m_StateChangeMoni
22860 74 6f 72 54 69 6d 65 6f 75 74 73 5b 69 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 torTimeouts[i];.................
22880 20 20 20 20 20 2b 2b 72 65 6d 61 69 6e 69 6e 67 54 69 6d 65 6f 75 74 43 6f 75 6e 74 3b 0d 0a 20 .....++remainingTimeoutCount;...
228a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d ...............}..............}.
228c0 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 ...............m_StateChangeMoni
228e0 74 6f 72 54 69 6d 65 6f 75 74 73 2e 53 65 74 4c 65 6e 67 74 68 28 72 65 6d 61 69 6e 69 6e 67 54 torTimeouts.SetLength(remainingT
22900 69 6d 65 6f 75 74 43 6f 75 6e 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 imeoutCount);..........}........
22920 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 75 6e 73 61 66 65 20 62 6f 6f 6c 20 55 70 64 61 74 65 53 ....internal.unsafe.bool.UpdateS
22940 74 61 74 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 2c 20 49 6e 70 75 74 45 76 tate(InputDevice.device,.InputEv
22960 65 6e 74 2a 20 65 76 65 6e 74 50 74 72 2c 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 20 75 ent*.eventPtr,.InputUpdateType.u
22980 70 64 61 74 65 54 79 70 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 pdateType)..........{...........
229a0 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 65 76 65 6e 74 50 74 72 20 21 3d 20 6e 75 6c 6c ...Debug.Assert(eventPtr.!=.null
229c0 2c 20 22 52 65 63 65 69 76 65 64 20 4e 55 4c 4c 20 65 76 65 6e 74 20 70 74 72 22 29 3b 0d 0a 0d ,."Received.NULL.event.ptr");...
229e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 73 74 61 74 65 42 6c 6f 63 6b 4f 66 44 65 76 .............var.stateBlockOfDev
22a00 69 63 65 20 3d 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 3b 0d 0a 20 20 20 20 ice.=.device.m_StateBlock;......
22a20 20 20 20 20 20 20 20 20 76 61 72 20 73 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 4f 66 44 65 76 69 ........var.stateBlockSizeOfDevi
22a40 63 65 20 3d 20 73 74 61 74 65 42 6c 6f 63 6b 4f 66 44 65 76 69 63 65 2e 73 69 7a 65 49 6e 42 69 ce.=.stateBlockOfDevice.sizeInBi
22a60 74 73 20 2f 20 38 3b 20 2f 2f 20 41 6c 77 61 79 73 20 62 79 74 65 2d 61 6c 69 67 6e 65 64 3b 20 ts./.8;.//.Always.byte-aligned;.
22a80 61 76 6f 69 64 20 63 61 6c 6c 69 6e 67 20 61 6c 69 67 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 avoid.calling.alignedSizeInBytes
22aa0 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6f 66 66 73 65 74 49 6e 44 65 76 69 63 ...............var.offsetInDevic
22ac0 65 53 74 61 74 65 54 6f 43 6f 70 79 54 6f 20 3d 20 30 75 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 eStateToCopyTo.=.0u;............
22ae0 20 20 75 69 6e 74 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 3b 0d 0a 20 20 20 20 20 ..uint.sizeOfStateToCopy;.......
22b00 20 20 20 20 20 20 20 75 69 6e 74 20 72 65 63 65 69 76 65 64 53 74 61 74 65 53 69 7a 65 3b 0d 0a .......uint.receivedStateSize;..
22b20 20 20 20 20 20 20 20 20 20 20 20 20 62 79 74 65 2a 20 70 74 72 54 6f 52 65 63 65 69 76 65 64 53 ............byte*.ptrToReceivedS
22b40 74 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 46 6f 75 72 43 43 20 72 65 63 65 69 76 tate;..............FourCC.receiv
22b60 65 64 53 74 61 74 65 46 6f 72 6d 61 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f edStateFormat;................//
22b80 20 47 72 61 62 20 73 74 61 74 65 20 64 61 74 61 20 66 72 6f 6d 20 65 76 65 6e 74 20 61 6e 64 20 .Grab.state.data.from.event.and.
22ba0 64 65 63 69 64 65 20 77 68 65 72 65 20 74 6f 20 63 6f 70 79 20 74 6f 20 61 6e 64 20 68 6f 77 20 decide.where.to.copy.to.and.how.
22bc0 6d 75 63 68 20 74 6f 20 63 6f 70 79 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 65 much.to.copy...............if.(e
22be0 76 65 6e 74 50 74 72 2d 3e 74 79 70 65 20 3d 3d 20 53 74 61 74 65 45 76 65 6e 74 2e 54 79 70 65 ventPtr->type.==.StateEvent.Type
22c00 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 )..............{................
22c20 20 20 76 61 72 20 73 74 61 74 65 45 76 65 6e 74 50 74 72 20 3d 20 28 53 74 61 74 65 45 76 65 6e ..var.stateEventPtr.=.(StateEven
22c40 74 2a 29 65 76 65 6e 74 50 74 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 t*)eventPtr;..................re
22c60 63 65 69 76 65 64 53 74 61 74 65 46 6f 72 6d 61 74 20 3d 20 73 74 61 74 65 45 76 65 6e 74 50 74 ceivedStateFormat.=.stateEventPt
22c80 72 2d 3e 73 74 61 74 65 46 6f 72 6d 61 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 r->stateFormat;.................
22ca0 20 72 65 63 65 69 76 65 64 53 74 61 74 65 53 69 7a 65 20 3d 20 73 74 61 74 65 45 76 65 6e 74 50 .receivedStateSize.=.stateEventP
22cc0 74 72 2d 3e 73 74 61 74 65 53 69 7a 65 49 6e 42 79 74 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 tr->stateSizeInBytes;...........
22ce0 20 20 20 20 20 20 20 70 74 72 54 6f 52 65 63 65 69 76 65 64 53 74 61 74 65 20 3d 20 28 62 79 74 .......ptrToReceivedState.=.(byt
22d00 65 2a 29 73 74 61 74 65 45 76 65 6e 74 50 74 72 2d 3e 73 74 61 74 65 3b 0d 0a 0d 0a 20 20 20 20 e*)stateEventPtr->state;........
22d20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 6e 6f 72 65 20 65 78 74 72 61 20 73 74 61 74 ............//.Ignore.extra.stat
22d40 65 20 61 74 20 65 6e 64 20 6f 66 20 65 76 65 6e 74 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 e.at.end.of.event...............
22d60 20 20 20 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 20 3d 20 72 65 63 65 69 76 65 64 ....sizeOfStateToCopy.=.received
22d80 53 74 61 74 65 53 69 7a 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 StateSize;..................if.(
22da0 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 20 3e 20 73 74 61 74 65 42 6c 6f 63 6b 53 69 sizeOfStateToCopy.>.stateBlockSi
22dc0 7a 65 4f 66 44 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 zeOfDevice).....................
22de0 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 20 3d 20 73 74 61 74 65 42 6c 6f 63 6b 53 .sizeOfStateToCopy.=.stateBlockS
22e00 69 7a 65 4f 66 44 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 izeOfDevice;..............}.....
22e20 20 20 20 20 20 20 20 20 20 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 .........else..............{....
22e40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 65 76 65 6e 74 ..............Debug.Assert(event
22e60 50 74 72 2d 3e 74 79 70 65 20 3d 3d 20 44 65 6c 74 61 53 74 61 74 65 45 76 65 6e 74 2e 54 79 70 Ptr->type.==.DeltaStateEvent.Typ
22e80 65 2c 20 22 47 69 76 65 6e 20 65 76 65 6e 74 20 6d 75 73 74 20 65 69 74 68 65 72 20 62 65 20 61 e,."Given.event.must.either.be.a
22ea0 20 53 74 61 74 65 45 76 65 6e 74 20 6f 72 20 61 20 44 65 6c 74 61 53 74 61 74 65 45 76 65 6e 74 .StateEvent.or.a.DeltaStateEvent
22ec0 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 6c 74 61 ");....................var.delta
22ee0 45 76 65 6e 74 50 74 72 20 3d 20 28 44 65 6c 74 61 53 74 61 74 65 45 76 65 6e 74 2a 29 65 76 65 EventPtr.=.(DeltaStateEvent*)eve
22f00 6e 74 50 74 72 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 63 65 69 76 65 64 ntPtr;..................received
22f20 53 74 61 74 65 46 6f 72 6d 61 74 20 3d 20 64 65 6c 74 61 45 76 65 6e 74 50 74 72 2d 3e 73 74 61 StateFormat.=.deltaEventPtr->sta
22f40 74 65 46 6f 72 6d 61 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 63 65 69 teFormat;..................recei
22f60 76 65 64 53 74 61 74 65 53 69 7a 65 20 3d 20 64 65 6c 74 61 45 76 65 6e 74 50 74 72 2d 3e 64 65 vedStateSize.=.deltaEventPtr->de
22f80 6c 74 61 53 74 61 74 65 53 69 7a 65 49 6e 42 79 74 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 ltaStateSizeInBytes;............
22fa0 20 20 20 20 20 20 70 74 72 54 6f 52 65 63 65 69 76 65 64 53 74 61 74 65 20 3d 20 28 62 79 74 65 ......ptrToReceivedState.=.(byte
22fc0 2a 29 64 65 6c 74 61 45 76 65 6e 74 50 74 72 2d 3e 64 65 6c 74 61 53 74 61 74 65 3b 0d 0a 20 20 *)deltaEventPtr->deltaState;....
22fe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6f 66 66 73 65 74 49 6e 44 65 76 69 63 65 53 74 61 74 ..............offsetInDeviceStat
23000 65 54 6f 43 6f 70 79 54 6f 20 3d 20 64 65 6c 74 61 45 76 65 6e 74 50 74 72 2d 3e 73 74 61 74 65 eToCopyTo.=.deltaEventPtr->state
23020 4f 66 66 73 65 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 67 Offset;....................//.Ig
23040 6e 6f 72 65 20 65 78 74 72 61 20 73 74 61 74 65 20 61 74 20 65 6e 64 20 6f 66 20 65 76 65 6e 74 nore.extra.state.at.end.of.event
23060 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f ...................sizeOfStateTo
23080 43 6f 70 79 20 3d 20 72 65 63 65 69 76 65 64 53 74 61 74 65 53 69 7a 65 3b 0d 0a 20 20 20 20 20 Copy.=.receivedStateSize;.......
230a0 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6f 66 66 73 65 74 49 6e 44 65 76 69 63 65 53 74 61 ...........if.(offsetInDeviceSta
230c0 74 65 54 6f 43 6f 70 79 54 6f 20 2b 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 20 3e teToCopyTo.+.sizeOfStateToCopy.>
230e0 20 73 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 4f 66 44 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 .stateBlockSizeOfDevice)........
23100 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ..........{.....................
23120 20 69 66 20 28 6f 66 66 73 65 74 49 6e 44 65 76 69 63 65 53 74 61 74 65 54 6f 43 6f 70 79 54 6f .if.(offsetInDeviceStateToCopyTo
23140 20 3e 3d 20 73 74 61 74 65 42 6c 6f 63 6b 53 69 7a 65 4f 66 44 65 76 69 63 65 29 0d 0a 20 20 20 .>=.stateBlockSizeOfDevice).....
23160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 .....................return.fals
23180 65 3b 20 2f 2f 20 45 6e 74 69 72 65 20 64 65 6c 74 61 20 73 74 61 74 65 20 69 73 20 6f 75 74 20 e;.//.Entire.delta.state.is.out.
231a0 6f 66 20 72 61 6e 67 65 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 of.range........................
231c0 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 20 3d 20 73 74 61 74 65 42 6c 6f 63 6b 53 .sizeOfStateToCopy.=.stateBlockS
231e0 69 7a 65 4f 66 44 65 76 69 63 65 20 2d 20 6f 66 66 73 65 74 49 6e 44 65 76 69 63 65 53 74 61 74 izeOfDevice.-.offsetInDeviceStat
23200 65 54 6f 43 6f 70 79 54 6f 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 eToCopyTo;..................}...
23220 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 ...........}................Debu
23240 67 2e 41 73 73 65 72 74 28 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 2e 66 6f 72 g.Assert(device.m_StateBlock.for
23260 6d 61 74 20 3d 3d 20 72 65 63 65 69 76 65 64 53 74 61 74 65 46 6f 72 6d 61 74 2c 20 22 52 65 63 mat.==.receivedStateFormat,."Rec
23280 65 69 76 65 64 20 73 74 61 74 65 20 66 6f 72 6d 61 74 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74 63 eived.state.format.does.not.matc
232a0 68 20 66 6f 72 6d 61 74 20 6f 66 20 64 65 76 69 63 65 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 h.format.of.device");...........
232c0 20 20 20 20 20 2f 2f 20 57 72 69 74 65 20 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 .....//.Write.state.............
232e0 20 20 72 65 74 75 72 6e 20 55 70 64 61 74 65 53 74 61 74 65 28 64 65 76 69 63 65 2c 20 75 70 64 ..return.UpdateState(device,.upd
23300 61 74 65 54 79 70 65 2c 20 70 74 72 54 6f 52 65 63 65 69 76 65 64 53 74 61 74 65 2c 20 6f 66 66 ateType,.ptrToReceivedState,.off
23320 73 65 74 49 6e 44 65 76 69 63 65 53 74 61 74 65 54 6f 43 6f 70 79 54 6f 2c 0d 0a 20 20 20 20 20 setInDeviceStateToCopyTo,.......
23340 20 20 20 20 20 20 20 20 20 20 20 73 69 7a 65 4f 66 53 74 61 74 65 54 6f 43 6f 70 79 2c 20 65 76 ...........sizeOfStateToCopy,.ev
23360 65 6e 74 50 74 72 2d 3e 69 6e 74 65 72 6e 61 6c 54 69 6d 65 2c 20 65 76 65 6e 74 50 74 72 29 3b entPtr->internalTime,.eventPtr);
23380 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d ..........}............///.<summ
233a0 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 6d 65 74 68 6f 64 20 69 73 ary>..........///.This.method.is
233c0 20 74 68 65 20 77 6f 72 6b 68 6f 72 73 65 20 66 6f 72 20 75 70 64 61 74 69 6e 67 20 69 6e 70 75 .the.workhorse.for.updating.inpu
233e0 74 20 73 74 61 74 65 20 69 6e 20 74 68 65 20 73 79 73 74 65 6d 2e 20 49 74 20 72 75 6e 73 20 61 t.state.in.the.system..It.runs.a
23400 6c 6c 20 74 68 65 20 6c 6f 67 69 63 20 6f 66 20 69 6e 63 6f 72 70 6f 72 61 74 69 6e 67 0d 0a 20 ll.the.logic.of.incorporating...
23420 20 20 20 20 20 20 20 2f 2f 2f 20 6e 65 77 20 73 74 61 74 65 20 69 6e 74 6f 20 64 65 76 69 63 65 .......///.new.state.into.device
23440 73 20 61 6e 64 20 74 72 69 67 67 65 72 69 6e 67 20 77 68 61 74 65 76 65 72 20 63 68 61 6e 67 65 s.and.triggering.whatever.change
23460 20 6d 6f 6e 69 74 6f 72 73 20 61 72 65 20 61 74 74 61 63 68 65 64 20 74 6f 20 74 68 65 20 73 74 .monitors.are.attached.to.the.st
23480 61 74 65 20 6d 65 6d 6f 72 79 20 74 68 61 74 20 67 65 74 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f ate.memory.that.gets..........//
234a0 2f 20 74 6f 75 63 68 65 64 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 /.touched...........///.</summar
234c0 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 y>..........///.<remarks>.......
234e0 20 20 20 2f 2f 2f 20 54 68 69 73 20 6d 65 74 68 6f 64 20 63 61 6e 20 62 65 20 69 6e 76 6f 6b 65 ...///.This.method.can.be.invoke
23500 64 20 66 72 6f 6d 20 6f 75 74 73 69 64 65 20 74 68 65 20 65 76 65 6e 74 20 70 72 6f 63 65 73 73 d.from.outside.the.event.process
23520 69 6e 67 20 6c 6f 6f 70 20 61 6e 64 20 74 68 65 20 67 69 76 65 6e 20 64 61 74 61 20 64 6f 65 73 ing.loop.and.the.given.data.does
23540 20 6e 6f 74 20 68 61 76 65 20 74 6f 20 63 6f 6d 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 66 .not.have.to.come..........///.f
23560 72 6f 6d 20 61 6e 20 65 76 65 6e 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 0d 0a 20 20 20 20 rom.an.event...........///......
23580 20 20 20 20 2f 2f 2f 20 54 68 69 73 20 6d 65 74 68 6f 64 20 64 6f 65 73 20 4e 4f 54 20 72 65 73 ....///.This.method.does.NOT.res
235a0 70 65 63 74 20 3c 73 65 65 20 63 72 65 66 3d 22 49 49 6e 70 75 74 53 74 61 74 65 43 61 6c 6c 62 pect.<see.cref="IInputStateCallb
235c0 61 63 6b 52 65 63 65 69 76 65 72 22 2f 3e 2e 20 54 68 69 73 20 6d 65 61 6e 73 20 74 68 61 74 20 ackReceiver"/>..This.means.that.
235e0 74 68 65 20 64 65 76 69 63 65 20 77 69 6c 6c 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 4e 4f 54 the.device.will..........///.NOT
23600 20 67 65 74 20 61 20 73 68 6f 74 20 61 74 20 69 6e 74 65 72 76 65 6e 69 6e 67 20 69 6e 20 74 68 .get.a.shot.at.intervening.in.th
23620 65 20 73 74 61 74 65 20 77 72 69 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 e.state.write...........///.</re
23640 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 70 61 72 61 6d 20 6e 61 6d 65 3d marks>..........///.<param.name=
23660 22 64 65 76 69 63 65 22 3e 44 65 76 69 63 65 20 74 6f 20 75 70 64 61 74 65 20 73 74 61 74 65 20 "device">Device.to.update.state.
23680 6f 6e 2e 20 3c 70 61 72 61 6d 72 65 66 20 6e 61 6d 65 3d 22 73 74 61 74 65 4f 66 66 73 65 74 49 on..<paramref.name="stateOffsetI
236a0 6e 44 65 76 69 63 65 22 2f 3e 20 69 73 20 72 65 6c 61 74 69 76 65 20 74 6f 20 64 65 76 69 63 65 nDevice"/>.is.relative.to.device
236c0 27 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 73 74 61 72 74 69 6e 67 20 6f 66 66 73 65 74 20 's..........///.starting.offset.
236e0 69 6e 20 6d 65 6d 6f 72 79 2e 3c 2f 70 61 72 61 6d 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 in.memory.</param>..........///.
23700 3c 70 61 72 61 6d 20 6e 61 6d 65 3d 22 65 76 65 6e 74 50 74 72 22 3e 50 6f 69 6e 74 65 72 20 74 <param.name="eventPtr">Pointer.t
23720 6f 20 73 74 61 74 65 20 65 76 65 6e 74 20 66 72 6f 6d 20 77 68 69 63 68 20 74 68 65 20 73 74 61 o.state.event.from.which.the.sta
23740 74 65 20 63 68 61 6e 67 65 20 77 61 73 20 69 6e 69 74 69 61 74 65 64 2e 20 4e 75 6c 6c 20 69 66 te.change.was.initiated..Null.if
23760 20 74 68 65 20 73 74 61 74 65 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 63 68 61 6e 67 65 20 69 .the.state..........///.change.i
23780 73 20 6e 6f 74 20 63 6f 6d 69 6e 67 20 66 72 6f 6d 20 61 6e 20 65 76 65 6e 74 2e 3c 2f 70 61 72 s.not.coming.from.an.event.</par
237a0 61 6d 3e 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 75 6e 73 61 66 65 20 62 6f 6f am>..........internal.unsafe.boo
237c0 6c 20 55 70 64 61 74 65 53 74 61 74 65 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 l.UpdateState(InputDevice.device
237e0 2c 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 20 75 70 64 61 74 65 54 79 70 65 2c 0d 0a 20 ,.InputUpdateType.updateType,...
23800 20 20 20 20 20 20 20 20 20 20 20 76 6f 69 64 2a 20 73 74 61 74 65 50 74 72 2c 20 75 69 6e 74 20 ...........void*.statePtr,.uint.
23820 73 74 61 74 65 4f 66 66 73 65 74 49 6e 44 65 76 69 63 65 2c 20 75 69 6e 74 20 73 74 61 74 65 53 stateOffsetInDevice,.uint.stateS
23840 69 7a 65 2c 20 64 6f 75 62 6c 65 20 69 6e 74 65 72 6e 61 6c 54 69 6d 65 2c 20 49 6e 70 75 74 45 ize,.double.internalTime,.InputE
23860 76 65 6e 74 50 74 72 20 65 76 65 6e 74 50 74 72 20 3d 20 64 65 66 61 75 6c 74 29 0d 0a 20 20 20 ventPtr.eventPtr.=.default).....
23880 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 49 6e .....{..............var.deviceIn
238a0 64 65 78 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 3b 0d 0a 20 20 20 dex.=.device.m_DeviceIndex;.....
238c0 20 20 20 20 20 20 20 20 20 72 65 66 20 76 61 72 20 73 74 61 74 65 42 6c 6f 63 6b 4f 66 44 65 76 .........ref.var.stateBlockOfDev
238e0 69 63 65 20 3d 20 72 65 66 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 3b 0d 0a ice.=.ref.device.m_StateBlock;..
23900 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 54 4f 44 4f 3a 20 6c 69 6d 69 74 20 73 74 ..............////TODO:.limit.st
23920 61 74 65 53 69 7a 65 20 61 6e 64 20 53 74 61 74 65 4f 66 66 73 65 74 20 62 79 20 74 68 65 20 64 ateSize.and.StateOffset.by.the.d
23940 65 76 69 63 65 27 73 20 73 74 61 74 65 20 6d 65 6d 6f 72 79 0d 0a 0d 0a 20 20 20 20 20 20 20 20 evice's.state.memory............
23960 20 20 20 20 76 61 72 20 64 65 76 69 63 65 42 75 66 66 65 72 20 3d 20 28 62 79 74 65 2a 29 49 6e ....var.deviceBuffer.=.(byte*)In
23980 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 47 65 74 46 72 6f 6e 74 42 75 66 66 65 72 46 6f putStateBuffers.GetFrontBufferFo
239a0 72 44 65 76 69 63 65 28 64 65 76 69 63 65 49 6e 64 65 78 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 rDevice(deviceIndex);...........
239c0 20 20 20 20 20 2f 2f 20 42 65 66 6f 72 65 20 77 65 20 75 70 64 61 74 65 20 73 74 61 74 65 2c 20 .....//.Before.we.update.state,.
239e0 6c 65 74 20 63 68 61 6e 67 65 20 6d 6f 6e 69 74 6f 72 73 20 63 6f 6d 70 61 72 65 20 74 68 65 20 let.change.monitors.compare.the.
23a00 6f 6c 64 20 61 6e 64 20 74 68 65 20 6e 65 77 20 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 old.and.the.new.state...........
23a20 20 20 20 20 2f 2f 20 57 65 20 64 6f 20 74 68 69 73 20 69 6e 73 74 65 61 64 20 6f 66 20 66 69 72 ....//.We.do.this.instead.of.fir
23a40 73 74 20 75 70 64 61 74 69 6e 67 20 74 68 65 20 66 72 6f 6e 74 20 62 75 66 66 65 72 20 61 6e 64 st.updating.the.front.buffer.and
23a60 20 74 68 65 6e 20 63 6f 6d 70 61 72 69 6e 67 20 74 6f 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 .then.comparing.to.the..........
23a80 20 20 20 20 2f 2f 20 62 61 63 6b 20 62 75 66 66 65 72 20 61 73 20 74 68 61 74 20 77 6f 75 6c 64 ....//.back.buffer.as.that.would
23aa0 20 72 65 71 75 69 72 65 20 61 20 62 75 66 66 65 72 20 66 6c 69 70 20 66 6f 72 20 65 61 63 68 20 .require.a.buffer.flip.for.each.
23ac0 73 74 61 74 65 20 63 68 61 6e 67 65 20 69 6e 20 6f 72 64 65 72 0d 0a 20 20 20 20 20 20 20 20 20 state.change.in.order...........
23ae0 20 20 20 2f 2f 20 66 6f 72 20 74 68 65 20 6d 6f 6e 69 74 6f 72 73 20 74 6f 20 77 6f 72 6b 20 72 ...//.for.the.monitors.to.work.r
23b00 65 6c 69 61 62 6c 79 2e 20 42 79 20 63 6f 6d 70 61 72 69 6e 67 20 74 68 65 20 2a 65 76 65 6e 74 eliably..By.comparing.the.*event
23b20 2a 20 64 61 74 61 20 74 6f 20 74 68 65 20 63 75 72 72 65 6e 74 0d 0a 20 20 20 20 20 20 20 20 20 *.data.to.the.current...........
23b40 20 20 20 2f 2f 20 73 74 61 74 65 2c 20 77 65 20 63 61 6e 20 68 61 76 65 20 6d 75 6c 74 69 70 6c ...//.state,.we.can.have.multipl
23b60 65 20 73 74 61 74 65 20 65 76 65 6e 74 73 20 69 6e 20 74 68 65 20 73 61 6d 65 20 66 72 61 6d 65 e.state.events.in.the.same.frame
23b80 20 79 65 74 20 73 74 69 6c 6c 20 67 65 74 20 72 65 6c 69 61 62 6c 65 0d 0a 20 20 20 20 20 20 20 .yet.still.get.reliable.........
23ba0 20 20 20 20 20 2f 2f 20 63 68 61 6e 67 65 20 6e 6f 74 69 66 69 63 61 74 69 6f 6e 73 2e 0d 0a 20 .....//.change.notifications....
23bc0 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 68 61 76 65 53 69 67 6e 61 6c 6c 65 64 4d 6f 6e 69 ...........var.haveSignalledMoni
23be0 74 6f 72 73 20 3d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 63 65 73 73 53 tors.=..................ProcessS
23c00 74 61 74 65 43 68 61 6e 67 65 4d 6f 6e 69 74 6f 72 73 28 64 65 76 69 63 65 49 6e 64 65 78 2c 20 tateChangeMonitors(deviceIndex,.
23c20 73 74 61 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 statePtr,......................d
23c40 65 76 69 63 65 42 75 66 66 65 72 20 2b 20 73 74 61 74 65 42 6c 6f 63 6b 4f 66 44 65 76 69 63 65 eviceBuffer.+.stateBlockOfDevice
23c60 2e 62 79 74 65 4f 66 66 73 65 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .byteOffset,....................
23c80 20 20 73 74 61 74 65 53 69 7a 65 2c 20 73 74 61 74 65 4f 66 66 73 65 74 49 6e 44 65 76 69 63 65 ..stateSize,.stateOffsetInDevice
23ca0 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 53 74 61 74 );................var.deviceStat
23cc0 65 4f 66 66 73 65 74 20 3d 20 64 65 76 69 63 65 2e 6d 5f 53 74 61 74 65 42 6c 6f 63 6b 2e 62 79 eOffset.=.device.m_StateBlock.by
23ce0 74 65 4f 66 66 73 65 74 20 2b 20 73 74 61 74 65 4f 66 66 73 65 74 49 6e 44 65 76 69 63 65 3b 0d teOffset.+.stateOffsetInDevice;.
23d00 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 53 74 61 74 65 50 74 72 20 .............var.deviceStatePtr.
23d20 3d 20 64 65 76 69 63 65 42 75 66 66 65 72 20 2b 20 64 65 76 69 63 65 53 74 61 74 65 4f 66 66 73 =.deviceBuffer.+.deviceStateOffs
23d40 65 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 53 et;................////REVIEW:.S
23d60 68 6f 75 6c 64 20 77 65 20 64 6f 20 74 68 69 73 20 6f 6e 6c 79 20 66 6f 72 20 65 76 65 6e 74 73 hould.we.do.this.only.for.events
23d80 20 62 75 74 20 6e 6f 74 20 66 6f 72 20 49 6e 70 75 74 53 74 61 74 65 2e 43 68 61 6e 67 65 28 29 .but.not.for.InputState.Change()
23da0 3f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 6e 6f 69 73 65 20 66 69 6c 74 65 ?..............//.If.noise.filte
23dc0 72 69 6e 67 20 6f 6e 20 2e 63 75 72 72 65 6e 74 20 69 73 20 74 75 72 6e 65 64 20 6f 6e 20 61 6e ring.on..current.is.turned.on.an
23de0 64 20 74 68 65 20 64 65 76 69 63 65 20 6d 61 79 20 68 61 76 65 20 6e 6f 69 73 65 2c 0d 0a 20 20 d.the.device.may.have.noise,....
23e00 20 20 20 20 20 20 20 20 20 20 2f 2f 20 64 65 74 65 72 6d 69 6e 65 20 69 66 20 74 68 65 20 65 76 ..........//.determine.if.the.ev
23e20 65 6e 74 20 63 61 72 72 69 65 73 20 73 69 67 6e 61 6c 20 6f 72 20 6e 6f 74 2e 0d 0a 20 20 20 20 ent.carries.signal.or.not.......
23e40 20 20 20 20 20 20 20 20 76 61 72 20 6d 61 6b 65 44 65 76 69 63 65 43 75 72 72 65 6e 74 20 3d 20 ........var.makeDeviceCurrent.=.
23e60 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 6e 6f true;..............if.(device.no
23e80 69 73 79 20 26 26 20 6d 5f 53 65 74 74 69 6e 67 73 2e 66 69 6c 74 65 72 4e 6f 69 73 65 4f 6e 43 isy.&&.m_Settings.filterNoiseOnC
23ea0 75 72 72 65 6e 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 urrent)..............{..........
23ec0 20 20 20 20 20 20 20 20 2f 2f 20 43 6f 6d 70 61 72 65 20 74 68 65 20 63 75 72 72 65 6e 74 20 73 ........//.Compare.the.current.s
23ee0 74 61 74 65 20 6f 66 20 74 68 65 20 64 65 76 69 63 65 20 74 6f 20 74 68 65 20 6e 65 77 6c 79 20 tate.of.the.device.to.the.newly.
23f00 72 65 63 65 69 76 65 64 20 73 74 61 74 65 20 62 75 74 20 6f 76 65 72 6c 61 79 0d 0a 20 20 20 20 received.state.but.overlay......
23f20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 65 20 63 6f 6d 70 61 72 69 73 6f 6e 20 62 79 ............//.the.comparison.by
23f40 20 74 68 65 20 6e 6f 69 73 65 20 6d 61 73 6b 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .the.noise.mask.................
23f60 20 20 20 20 76 61 72 20 6e 6f 69 73 65 4d 61 73 6b 20 3d 20 28 62 79 74 65 2a 29 49 6e 70 75 74 ....var.noiseMask.=.(byte*)Input
23f80 53 74 61 74 65 42 75 66 66 65 72 73 2e 73 5f 4e 6f 69 73 65 4d 61 73 6b 42 75 66 66 65 72 20 2b StateBuffers.s_NoiseMaskBuffer.+
23fa0 20 64 65 76 69 63 65 53 74 61 74 65 4f 66 66 73 65 74 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 .deviceStateOffset;.............
23fc0 20 20 20 20 20 20 20 6d 61 6b 65 44 65 76 69 63 65 43 75 72 72 65 6e 74 20 3d 0d 0a 20 20 20 20 .......makeDeviceCurrent.=......
23fe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 21 4d 65 6d 6f 72 79 48 65 6c 70 65 72 73 2e 4d ................!MemoryHelpers.M
24000 65 6d 43 6d 70 42 69 74 52 65 67 69 6f 6e 28 64 65 76 69 63 65 53 74 61 74 65 50 74 72 2c 20 73 emCmpBitRegion(deviceStatePtr,.s
24020 74 61 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tatePtr,........................
24040 20 20 30 2c 20 73 74 61 74 65 53 69 7a 65 20 2a 20 38 2c 20 6d 61 73 6b 3a 20 6e 6f 69 73 65 4d ..0,.stateSize.*.8,.mask:.noiseM
24060 61 73 6b 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 ask);..............}............
24080 20 20 20 20 2f 2f 20 42 75 66 66 65 72 20 66 6c 69 70 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 ....//.Buffer.flip..............
240a0 20 76 61 72 20 66 6c 69 70 70 65 64 20 3d 20 46 6c 69 70 42 75 66 66 65 72 73 46 6f 72 44 65 76 .var.flipped.=.FlipBuffersForDev
240c0 69 63 65 49 66 4e 65 63 65 73 73 61 72 79 28 64 65 76 69 63 65 2c 20 75 70 64 61 74 65 54 79 70 iceIfNecessary(device,.updateTyp
240e0 65 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 77 20 77 72 69 74 65 20 e);................//.Now.write.
24100 74 68 65 20 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 the.state...............#if.UNIT
24120 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 75 70 64 61 74 65 Y_EDITOR..............if.(update
24140 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 29 0d Type.==.InputUpdateType.Editor).
24160 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .............{..................
24180 57 72 69 74 65 53 74 61 74 65 43 68 61 6e 67 65 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e WriteStateChange(m_StateBuffers.
241a0 6d 5f 45 64 69 74 6f 72 53 74 61 74 65 42 75 66 66 65 72 73 2c 20 64 65 76 69 63 65 49 6e 64 65 m_EditorStateBuffers,.deviceInde
241c0 78 2c 20 72 65 66 20 73 74 61 74 65 42 6c 6f 63 6b 4f 66 44 65 76 69 63 65 2c 20 73 74 61 74 65 x,.ref.stateBlockOfDevice,.state
241e0 4f 66 66 73 65 74 49 6e 44 65 76 69 63 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 OffsetInDevice,.................
24200 20 20 20 20 20 73 74 61 74 65 50 74 72 2c 20 73 74 61 74 65 53 69 7a 65 2c 20 66 6c 69 70 70 65 .....statePtr,.stateSize,.flippe
24220 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 d);..............}..............
24240 65 6c 73 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 else..............#endif........
24260 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 57 72 69 74 65 53 74 ......{..................WriteSt
24280 61 74 65 43 68 61 6e 67 65 28 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f 50 6c 61 79 65 ateChange(m_StateBuffers.m_Playe
242a0 72 53 74 61 74 65 42 75 66 66 65 72 73 2c 20 64 65 76 69 63 65 49 6e 64 65 78 2c 20 72 65 66 20 rStateBuffers,.deviceIndex,.ref.
242c0 73 74 61 74 65 42 6c 6f 63 6b 4f 66 44 65 76 69 63 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 stateBlockOfDevice,.............
242e0 20 20 20 20 20 20 20 20 20 73 74 61 74 65 4f 66 66 73 65 74 49 6e 44 65 76 69 63 65 2c 20 73 74 .........stateOffsetInDevice,.st
24300 61 74 65 50 74 72 2c 20 73 74 61 74 65 53 69 7a 65 2c 20 66 6c 69 70 70 65 64 29 3b 0d 0a 20 20 atePtr,.stateSize,.flipped);....
24320 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f ..........}................//.No
24340 74 69 66 79 20 6c 69 73 74 65 6e 65 72 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 tify.listeners...............for
24360 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 44 65 76 69 63 65 53 74 61 74 65 43 68 .(var.i.=.0;.i.<.m_DeviceStateCh
24380 61 6e 67 65 4c 69 73 74 65 6e 65 72 73 2e 6c 65 6e 67 74 68 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 angeListeners.length;.++i)......
243a0 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 44 65 76 69 63 65 53 74 61 74 65 43 68 61 6e 67 65 4c ............m_DeviceStateChangeL
243c0 69 73 74 65 6e 65 72 73 5b 69 5d 28 64 65 76 69 63 65 2c 20 65 76 65 6e 74 50 74 72 29 3b 0d 0a isteners[i](device,.eventPtr);..
243e0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 6f 77 20 74 68 61 74 20 77 65 27 76 65 20 ..............//.Now.that.we've.
24400 63 6f 6d 6d 69 74 74 65 64 20 74 68 65 20 6e 65 77 20 73 74 61 74 65 20 74 6f 20 6d 65 6d 6f 72 committed.the.new.state.to.memor
24420 79 2c 20 69 66 20 61 6e 79 20 6f 66 20 74 68 65 20 63 68 61 6e 67 65 0d 0a 20 20 20 20 20 20 20 y,.if.any.of.the.change.........
24440 20 20 20 20 20 2f 2f 20 6d 6f 6e 69 74 6f 72 73 20 66 69 72 65 64 2c 20 6c 65 74 20 74 68 65 20 .....//.monitors.fired,.let.the.
24460 61 73 73 6f 63 69 61 74 65 64 20 61 63 74 69 6f 6e 73 20 6b 6e 6f 77 2e 0d 0a 20 20 20 20 20 20 associated.actions.know.........
24480 20 20 20 20 20 20 69 66 20 28 68 61 76 65 53 69 67 6e 61 6c 6c 65 64 4d 6f 6e 69 74 6f 72 73 29 ......if.(haveSignalledMonitors)
244a0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 46 69 72 65 53 74 61 74 65 43 68 61 6e 67 ..................FireStateChang
244c0 65 4e 6f 74 69 66 69 63 61 74 69 6f 6e 73 28 64 65 76 69 63 65 49 6e 64 65 78 2c 20 69 6e 74 65 eNotifications(deviceIndex,.inte
244e0 72 6e 61 6c 54 69 6d 65 2c 20 65 76 65 6e 74 50 74 72 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 rnalTime,.eventPtr);............
24500 20 20 20 20 72 65 74 75 72 6e 20 6d 61 6b 65 44 65 76 69 63 65 43 75 72 72 65 6e 74 3b 0d 0a 20 ....return.makeDeviceCurrent;...
24520 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 73 74 61 74 .......}............private.stat
24540 69 63 20 75 6e 73 61 66 65 20 76 6f 69 64 20 57 72 69 74 65 53 74 61 74 65 43 68 61 6e 67 65 28 ic.unsafe.void.WriteStateChange(
24560 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 2e 44 6f 75 62 6c 65 42 75 66 66 65 72 73 20 InputStateBuffers.DoubleBuffers.
24580 62 75 66 66 65 72 73 2c 20 69 6e 74 20 64 65 76 69 63 65 49 6e 64 65 78 2c 0d 0a 20 20 20 20 20 buffers,.int.deviceIndex,.......
245a0 20 20 20 20 20 20 20 72 65 66 20 49 6e 70 75 74 53 74 61 74 65 42 6c 6f 63 6b 20 64 65 76 69 63 .......ref.InputStateBlock.devic
245c0 65 53 74 61 74 65 42 6c 6f 63 6b 2c 20 75 69 6e 74 20 73 74 61 74 65 4f 66 66 73 65 74 49 6e 44 eStateBlock,.uint.stateOffsetInD
245e0 65 76 69 63 65 2c 20 76 6f 69 64 2a 20 73 74 61 74 65 50 74 72 2c 20 75 69 6e 74 20 73 74 61 74 evice,.void*.statePtr,.uint.stat
24600 65 53 69 7a 65 49 6e 42 79 74 65 73 2c 20 62 6f 6f 6c 20 66 6c 69 70 70 65 64 42 75 66 66 65 72 eSizeInBytes,.bool.flippedBuffer
24620 73 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 66 s)..........{..............var.f
24640 72 6f 6e 74 42 75 66 66 65 72 20 3d 20 62 75 66 66 65 72 73 2e 47 65 74 46 72 6f 6e 74 42 75 66 rontBuffer.=.buffers.GetFrontBuf
24660 66 65 72 28 64 65 76 69 63 65 49 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 44 fer(deviceIndex);..............D
24680 65 62 75 67 2e 41 73 73 65 72 74 28 66 72 6f 6e 74 42 75 66 66 65 72 20 21 3d 20 6e 75 6c 6c 29 ebug.Assert(frontBuffer.!=.null)
246a0 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 49 66 20 77 65 27 72 65 20 75 70 64 ;................//.If.we're.upd
246c0 61 74 69 6e 67 20 6c 65 73 73 20 74 68 61 6e 20 74 68 65 20 66 75 6c 6c 20 73 74 61 74 65 2c 20 ating.less.than.the.full.state,.
246e0 77 65 20 6e 65 65 64 20 74 6f 20 70 72 65 73 65 72 76 65 20 74 68 65 20 70 61 72 74 73 20 77 65 we.need.to.preserve.the.parts.we
24700 20 61 72 65 20 6e 6f 74 20 75 70 64 61 74 69 6e 67 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .are.not.updating...............
24720 2f 2f 20 49 6e 73 74 65 61 64 20 6f 66 20 74 72 79 69 6e 67 20 74 6f 20 6f 70 74 69 6d 69 7a 65 //.Instead.of.trying.to.optimize
24740 20 68 65 72 65 20 61 6e 64 20 6f 6e 6c 79 20 63 6f 70 79 20 77 68 61 74 20 77 65 20 72 65 61 6c .here.and.only.copy.what.we.real
24760 6c 79 20 6e 65 65 64 2c 20 77 65 20 6a 75 73 74 20 67 6f 20 61 6e 64 20 63 6f 70 79 20 74 68 65 ly.need,.we.just.go.and.copy.the
24780 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 65 6e 74 69 72 65 20 73 74 61 74 65 20 6f 66 ..............//.entire.state.of
247a0 20 74 68 65 20 64 65 76 69 63 65 20 6f 76 65 72 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f .the.device.over.............../
247c0 2f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4e 4f 54 45 3a 20 54 68 69 73 20 63 6f 70 /..............//.NOTE:.This.cop
247e0 79 69 6e 67 20 6d 75 73 74 20 6f 6e 6c 79 20 68 61 70 70 65 6e 20 6f 6e 63 65 2c 20 72 69 67 68 ying.must.only.happen.once,.righ
24800 74 20 61 66 74 65 72 20 61 20 62 75 66 66 65 72 20 66 6c 69 70 2e 20 4f 74 68 65 72 77 69 73 65 t.after.a.buffer.flip..Otherwise
24820 20 77 65 20 6d 61 79 20 63 6f 70 79 20 6f 6c 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f .we.may.copy.old,............../
24840 2f 20 20 20 20 20 20 20 73 74 61 6c 65 20 69 6e 70 75 74 20 73 74 61 74 65 20 66 72 6f 6d 20 74 /.......stale.input.state.from.t
24860 68 65 20 62 61 63 6b 20 62 75 66 66 65 72 20 6f 76 65 72 20 73 74 61 74 65 20 74 68 61 74 20 68 he.back.buffer.over.state.that.h
24880 61 73 20 61 6c 72 65 61 64 79 20 62 65 65 6e 20 75 70 64 61 74 65 64 20 77 69 74 68 20 6e 65 77 as.already.been.updated.with.new
248a0 65 72 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 20 20 20 20 20 20 64 61 74 61 2e 0d 0a er..............//.......data...
248c0 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 53 74 61 74 65 53 69 7a 65 20 ............var.deviceStateSize.
248e0 3d 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 2e 73 69 7a 65 49 6e 42 69 74 73 20 2f 20 =.deviceStateBlock.sizeInBits./.
24900 38 3b 20 2f 2f 20 41 6c 77 61 79 73 20 62 79 74 65 2d 61 6c 69 67 6e 65 64 3b 20 61 76 6f 69 64 8;.//.Always.byte-aligned;.avoid
24920 20 63 61 6c 6c 69 6e 67 20 61 6c 69 67 6e 65 64 53 69 7a 65 49 6e 42 79 74 65 73 2e 0d 0a 20 20 .calling.alignedSizeInBytes.....
24940 20 20 20 20 20 20 20 20 20 20 69 66 20 28 66 6c 69 70 70 65 64 42 75 66 66 65 72 73 20 26 26 20 ..........if.(flippedBuffers.&&.
24960 64 65 76 69 63 65 53 74 61 74 65 53 69 7a 65 20 21 3d 20 73 74 61 74 65 53 69 7a 65 49 6e 42 79 deviceStateSize.!=.stateSizeInBy
24980 74 65 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 tes)..............{.............
249a0 20 20 20 20 20 76 61 72 20 62 61 63 6b 42 75 66 66 65 72 20 3d 20 62 75 66 66 65 72 73 2e 47 65 .....var.backBuffer.=.buffers.Ge
249c0 74 42 61 63 6b 42 75 66 66 65 72 28 64 65 76 69 63 65 49 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 tBackBuffer(deviceIndex);.......
249e0 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 41 73 73 65 72 74 28 62 61 63 6b 42 75 66 66 ...........Debug.Assert(backBuff
24a00 65 72 20 21 3d 20 6e 75 6c 6c 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 er.!=.null);....................
24a20 55 6e 73 61 66 65 55 74 69 6c 69 74 79 2e 4d 65 6d 43 70 79 28 0d 0a 20 20 20 20 20 20 20 20 20 UnsafeUtility.MemCpy(...........
24a40 20 20 20 20 20 20 20 20 20 20 20 28 62 79 74 65 2a 29 66 72 6f 6e 74 42 75 66 66 65 72 20 2b 20 ...........(byte*)frontBuffer.+.
24a60 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 2c 0d 0a 20 20 deviceStateBlock.byteOffset,....
24a80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 62 79 74 65 2a 29 62 61 63 6b 42 75 66 ..................(byte*)backBuf
24aa0 66 65 72 20 2b 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f 63 6b 2e 62 79 74 65 4f 66 66 73 65 fer.+.deviceStateBlock.byteOffse
24ac0 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 53 74 t,......................deviceSt
24ae0 61 74 65 53 69 7a 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 ateSize);..............}........
24b00 20 20 20 20 20 20 20 20 55 6e 73 61 66 65 55 74 69 6c 69 74 79 2e 4d 65 6d 43 70 79 28 28 62 79 ........UnsafeUtility.MemCpy((by
24b20 74 65 2a 29 66 72 6f 6e 74 42 75 66 66 65 72 20 2b 20 64 65 76 69 63 65 53 74 61 74 65 42 6c 6f te*)frontBuffer.+.deviceStateBlo
24b40 63 6b 2e 62 79 74 65 4f 66 66 73 65 74 20 2b 20 73 74 61 74 65 4f 66 66 73 65 74 49 6e 44 65 76 ck.byteOffset.+.stateOffsetInDev
24b60 69 63 65 2c 20 73 74 61 74 65 50 74 72 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ice,.statePtr,..................
24b80 73 74 61 74 65 53 69 7a 65 49 6e 42 79 74 65 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d stateSizeInBytes);..........}...
24ba0 0a 20 20 20 20 20 20 20 20 2f 2f 20 46 6c 69 70 20 66 72 6f 6e 74 20 61 6e 64 20 62 61 63 6b 20 .........//.Flip.front.and.back.
24bc0 62 75 66 66 65 72 20 66 6f 72 20 64 65 76 69 63 65 2c 20 69 66 20 6e 65 63 65 73 73 61 72 79 2e buffer.for.device,.if.necessary.
24be0 20 4d 61 79 20 66 6c 69 70 20 62 75 66 66 65 72 73 20 66 6f 72 20 6d 6f 72 65 20 74 68 61 6e 20 .May.flip.buffers.for.more.than.
24c00 6a 75 73 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 74 68 65 20 67 69 76 65 6e 20 75 70 64 61 74 just..........//.the.given.updat
24c20 65 20 74 79 70 65 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 52 65 74 75 72 6e 73 20 74 72 75 65 e.type...........//.Returns.true
24c40 20 69 66 20 74 68 65 72 65 20 77 61 73 20 61 20 62 75 66 66 65 72 20 66 6c 69 70 2e 0d 0a 20 20 .if.there.was.a.buffer.flip.....
24c60 20 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f 6f 6c 20 46 6c 69 70 42 75 66 66 65 72 73 46 6f ......private.bool.FlipBuffersFo
24c80 72 44 65 76 69 63 65 49 66 4e 65 63 65 73 73 61 72 79 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 rDeviceIfNecessary(InputDevice.d
24ca0 65 76 69 63 65 2c 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 20 75 70 64 61 74 65 54 79 70 evice,.InputUpdateType.updateTyp
24cc0 65 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 75 e)..........{..............if.(u
24ce0 70 64 61 74 65 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 55 70 64 61 74 65 54 79 70 65 2e 42 65 66 pdateType.==.InputUpdateType.Bef
24d00 6f 72 65 52 65 6e 64 65 72 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 oreRender)..............{.......
24d20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 49 20 74 68 69 6e 6b 20 74 ...........////REVIEW:.I.think.t
24d40 68 69 73 20 69 73 20 77 72 6f 6e 67 3b 20 69 66 20 77 65 20 68 61 76 65 6e 27 74 20 66 6c 69 70 his.is.wrong;.if.we.haven't.flip
24d60 70 65 64 20 69 6e 20 74 68 65 20 63 75 72 72 65 6e 74 20 64 79 6e 61 6d 69 63 20 6f 72 20 66 69 ped.in.the.current.dynamic.or.fi
24d80 78 65 64 20 75 70 64 61 74 65 2c 20 77 65 20 73 68 6f 75 6c 64 20 64 6f 20 73 6f 20 6e 6f 77 0d xed.update,.we.should.do.so.now.
24da0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 6e 65 76 65 72 20 66 6c 69 .................//.We.never.fli
24dc0 70 20 62 75 66 66 65 72 73 20 66 6f 72 20 62 65 66 6f 72 65 20 72 65 6e 64 65 72 2e 20 49 6e 73 p.buffers.for.before.render..Ins
24de0 74 65 61 64 2c 20 77 65 20 61 6c 72 65 61 64 79 20 77 72 69 74 65 0d 0a 20 20 20 20 20 20 20 20 tead,.we.already.write..........
24e00 20 20 20 20 20 20 20 20 2f 2f 20 69 6e 74 6f 20 74 68 65 20 66 72 6f 6e 74 20 62 75 66 66 65 72 ........//.into.the.front.buffer
24e20 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b ...................return.false;
24e40 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 23 69 66 20 55 4e 49 54 59 5f 45 44 49 ..............}....#if.UNITY_EDI
24e60 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 45 56 49 45 57 3a 20 73 68 6f TOR..............////REVIEW:.sho
24e80 75 6c 64 20 74 68 69 73 20 75 73 65 20 74 68 65 20 65 64 69 74 6f 72 20 75 70 64 61 74 65 20 74 uld.this.use.the.editor.update.t
24ea0 69 63 6b 73 20 61 73 20 71 75 61 73 69 2d 66 72 61 6d 65 2d 62 6f 75 6e 64 61 72 69 65 73 3f 0d icks.as.quasi-frame-boundaries?.
24ec0 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 73 20 67 6f 20 74 6f 20 74 68 .............//.Updates.go.to.th
24ee0 65 20 65 64 69 74 6f 72 20 6f 6e 6c 79 20 69 66 20 74 68 65 20 67 61 6d 65 20 69 73 6e 27 74 20 e.editor.only.if.the.game.isn't.
24f00 70 6c 61 79 69 6e 67 20 6f 72 20 64 6f 65 73 20 6e 6f 74 20 68 61 76 65 20 66 6f 63 75 73 2e 0d playing.or.does.not.have.focus..
24f20 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 4f 74 68 65 72 77 69 73 65 20 77 65 20 66 61 6c .............//.Otherwise.we.fal
24f40 6c 20 74 68 72 6f 75 67 68 20 74 6f 20 74 68 65 20 6c 6f 67 69 63 20 74 68 61 74 20 66 6c 69 70 l.through.to.the.logic.that.flip
24f60 73 20 66 6f 72 20 74 68 65 20 2a 6e 65 78 74 2a 20 64 79 6e 61 6d 69 63 20 61 6e 64 0d 0a 20 20 s.for.the.*next*.dynamic.and....
24f80 20 20 20 20 20 20 20 20 20 20 2f 2f 20 66 69 78 65 64 20 75 70 64 61 74 65 73 2e 0d 0a 20 20 20 ..........//.fixed.updates......
24fa0 20 20 20 20 20 20 20 20 20 69 66 20 28 75 70 64 61 74 65 54 79 70 65 20 3d 3d 20 49 6e 70 75 74 .........if.(updateType.==.Input
24fc0 55 70 64 61 74 65 54 79 70 65 2e 45 64 69 74 6f 72 20 26 26 20 21 67 61 6d 65 49 73 50 6c 61 79 UpdateType.Editor.&&.!gameIsPlay
24fe0 69 6e 67 41 6e 64 48 61 73 46 6f 63 75 73 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a ingAndHasFocus)..............{..
25000 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 54 68 65 20 65 64 69 74 6f 72 20 64 6f ................//.The.editor.do
25020 65 73 6e 27 74 20 72 65 61 6c 6c 79 20 68 61 76 65 20 61 20 63 6f 6e 63 65 70 74 20 6f 66 20 66 esn't.really.have.a.concept.of.f
25040 72 61 6d 65 2d 74 6f 2d 66 72 61 6d 65 20 6f 70 65 72 61 74 69 6f 6e 20 74 68 65 0d 0a 20 20 20 rame-to-frame.operation.the.....
25060 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 73 61 6d 65 20 77 61 79 20 74 68 65 20 70 6c 61 .............//.same.way.the.pla
25080 79 65 72 20 64 6f 65 73 2e 20 53 6f 20 77 65 20 73 69 6d 70 6c 79 20 66 6c 69 70 20 62 75 66 66 yer.does..So.we.simply.flip.buff
250a0 65 72 73 20 6f 6e 20 61 20 64 65 76 69 63 65 20 77 68 65 6e 65 76 65 72 0d 0a 20 20 20 20 20 20 ers.on.a.device.whenever........
250c0 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 20 6e 65 77 20 73 74 61 74 65 20 65 76 65 6e 74 20 66 ..........//.a.new.state.event.f
250e0 6f 72 20 69 74 20 63 6f 6d 65 73 20 69 6e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 or.it.comes.in..................
25100 20 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2e 6d 5f 45 64 69 74 6f 72 53 74 61 74 65 42 75 66 .m_StateBuffers.m_EditorStateBuf
25120 66 65 72 73 2e 53 77 61 70 42 75 66 66 65 72 73 28 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 fers.SwapBuffers(device.m_Device
25140 49 6e 64 65 78 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 Index);..................return.
25160 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 23 65 6e 64 69 66 0d 0a 0d 0a true;..............}..#endif....
25180 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 46 6c 69 70 20 62 75 66 66 65 72 73 20 69 66 20 77 ............//.Flip.buffers.if.w
251a0 65 20 68 61 76 65 6e 27 74 20 61 6c 72 65 61 64 79 20 66 6f 72 20 74 68 69 73 20 66 72 61 6d 65 e.haven't.already.for.this.frame
251c0 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 2e 6d 5f 43 75 72 72 ...............if.(device.m_Curr
251e0 65 6e 74 55 70 64 61 74 65 53 74 65 70 43 6f 75 6e 74 20 21 3d 20 49 6e 70 75 74 55 70 64 61 74 entUpdateStepCount.!=.InputUpdat
25200 65 2e 73 5f 55 70 64 61 74 65 53 74 65 70 43 6f 75 6e 74 29 0d 0a 20 20 20 20 20 20 20 20 20 20 e.s_UpdateStepCount)............
25220 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 42 75 66 66 ..{..................m_StateBuff
25240 65 72 73 2e 6d 5f 50 6c 61 79 65 72 53 74 61 74 65 42 75 66 66 65 72 73 2e 53 77 61 70 42 75 66 ers.m_PlayerStateBuffers.SwapBuf
25260 66 65 72 73 28 64 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 49 6e 64 65 78 29 3b 0d 0a 20 20 20 fers(device.m_DeviceIndex);.....
25280 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 43 75 72 72 65 6e 74 55 70 64 .............device.m_CurrentUpd
252a0 61 74 65 53 74 65 70 43 6f 75 6e 74 20 3d 20 49 6e 70 75 74 55 70 64 61 74 65 2e 73 5f 55 70 64 ateStepCount.=.InputUpdate.s_Upd
252c0 61 74 65 53 74 65 70 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 ateStepCount;..................r
252e0 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 eturn.true;..............}......
25300 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 61 6c 73 65 3b 0d 0a 20 20 20 20 20 20 20 ..........return.false;.........
25320 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 44 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 20 73 .}............//.Domain.reload.s
25340 75 72 76 69 76 61 6c 20 6c 6f 67 69 63 2e 20 41 6c 73 6f 20 75 73 65 64 20 66 6f 72 20 70 75 73 urvival.logic..Also.used.for.pus
25360 68 69 6e 67 20 61 6e 64 20 70 6f 70 70 69 6e 67 20 69 6e 70 75 74 20 73 79 73 74 65 6d 0d 0a 20 hing.and.popping.input.system...
25380 20 20 20 20 20 20 20 2f 2f 20 73 74 61 74 65 20 66 6f 72 20 74 65 73 74 69 6e 67 2e 0d 0a 0d 0a .......//.state.for.testing.....
253a0 20 20 20 20 20 20 20 20 2f 2f 20 53 74 75 66 66 20 65 76 65 72 79 74 68 69 6e 67 20 74 68 61 74 ........//.Stuff.everything.that
253c0 20 77 65 20 77 61 6e 74 20 74 6f 20 73 75 72 76 69 76 65 20 61 20 64 6f 6d 61 69 6e 20 72 65 6c .we.want.to.survive.a.domain.rel
253e0 6f 61 64 20 69 6e 74 6f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 61 20 6d 5f 53 65 72 69 61 6c 69 oad.into..........//.a.m_Seriali
25400 7a 65 64 53 74 61 74 65 2e 0d 0a 23 69 66 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 20 7c 7c 20 44 zedState...#if.UNITY_EDITOR.||.D
25420 45 56 45 4c 4f 50 4d 45 4e 54 5f 42 55 49 4c 44 0d 0a 20 20 20 20 20 20 20 20 5b 53 65 72 69 61 EVELOPMENT_BUILD..........[Seria
25440 6c 69 7a 61 62 6c 65 5d 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 72 75 63 lizable]..........internal.struc
25460 74 20 44 65 76 69 63 65 53 74 61 74 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 t.DeviceState..........{........
25480 20 20 20 20 20 20 2f 2f 20 50 72 65 73 65 72 76 69 6e 67 20 49 6e 70 75 74 44 65 76 69 63 65 73 ......//.Preserving.InputDevices
254a0 20 69 73 20 73 6f 6d 65 77 68 61 74 20 74 72 69 63 6b 79 20 62 75 73 69 6e 65 73 73 2e 20 53 65 .is.somewhat.tricky.business..Se
254c0 72 69 61 6c 69 7a 69 6e 67 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 74 68 65 6d 20 69 rializing..............//.them.i
254e0 6e 20 66 75 6c 6c 20 77 6f 75 6c 64 20 69 6e 76 6f 6c 76 65 20 70 72 65 74 74 79 20 6e 61 73 74 n.full.would.involve.pretty.nast
25500 79 20 77 6f 72 6b 2e 20 57 65 20 68 61 76 65 20 74 68 65 20 72 65 73 74 72 69 63 74 69 6f 6e 2c y.work..We.have.the.restriction,
25520 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 68 6f 77 65 76 65 72 2c 20 74 68 61 74 20 65 ..............//.however,.that.e
25540 76 65 72 79 74 68 69 6e 67 20 6e 65 65 64 73 20 74 6f 20 62 65 20 63 72 65 61 74 65 64 20 66 72 verything.needs.to.be.created.fr
25560 6f 6d 20 6c 61 79 6f 75 74 73 20 28 69 74 20 70 61 72 74 6c 79 0d 0a 20 20 20 20 20 20 20 20 20 om.layouts.(it.partly...........
25580 20 20 20 2f 2f 20 65 78 69 73 74 73 20 66 6f 72 20 74 68 65 20 73 61 6b 65 20 6f 66 20 72 65 6c ...//.exists.for.the.sake.of.rel
255a0 6f 61 64 20 73 75 72 76 69 76 61 62 69 6c 69 74 79 29 2c 20 73 6f 20 77 65 20 73 68 6f 75 6c 64 oad.survivability),.so.we.should
255c0 20 62 65 20 61 62 6c 65 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 6a 75 73 74 .be.able.to..............//.just
255e0 20 67 6f 20 61 6e 64 20 72 65 63 72 65 61 74 65 20 74 68 65 20 64 65 76 69 63 65 20 66 72 6f 6d .go.and.recreate.the.device.from
25600 20 74 68 65 20 6c 61 79 6f 75 74 2e 20 54 68 69 73 20 61 6c 73 6f 20 68 61 73 20 74 68 65 0d 0a .the.layout..This.also.has.the..
25620 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 61 64 76 61 6e 74 61 67 65 20 74 68 61 74 20 69 66 ............//.advantage.that.if
25640 20 74 68 65 20 6c 61 79 6f 75 74 20 63 68 61 6e 67 65 73 20 62 65 74 77 65 65 6e 20 72 65 6c 6f .the.layout.changes.between.relo
25660 61 64 73 2c 20 74 68 65 20 63 68 61 6e 67 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 ads,.the.change..............//.
25680 61 75 74 6f 6d 61 74 69 63 61 6c 6c 79 20 74 61 6b 65 73 20 65 66 66 65 63 74 2e 0d 0a 20 20 20 automatically.takes.effect......
256a0 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 73 74 72 69 6e 67 20 6e 61 6d 65 3b 0d 0a 20 20 .........public.string.name;....
256c0 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 73 74 72 69 6e 67 20 6c 61 79 6f 75 74 3b 0d ..........public.string.layout;.
256e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 73 74 72 69 6e 67 20 76 61 72 69 61 .............public.string.varia
25700 6e 74 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 73 74 72 69 6e 67 5b nts;..............public.string[
25720 5d 20 75 73 61 67 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 69 6e ].usages;..............public.in
25740 74 20 64 65 76 69 63 65 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 t.deviceId;..............public.
25760 69 6e 74 20 70 61 72 74 69 63 69 70 61 6e 74 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 int.participantId;..............
25780 70 75 62 6c 69 63 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 65 76 69 63 65 46 6c 61 67 73 20 66 public.InputDevice.DeviceFlags.f
257a0 6c 61 67 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 44 lags;..............public.InputD
257c0 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 20 64 65 73 63 72 69 70 74 69 6f 6e 3b 0d 0a 0d eviceDescription.description;...
257e0 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 76 6f 69 64 20 52 65 73 74 6f 72 65 .............public.void.Restore
25800 28 49 6e 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 29 0d 0a 20 20 20 20 20 20 20 20 20 20 (InputDevice.device)............
25820 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 75 73 61 67 65 43 6f ..{..................var.usageCo
25840 75 6e 74 20 3d 20 75 73 61 67 65 73 2e 4c 65 6e 67 74 68 53 61 66 65 28 29 3b 0d 0a 20 20 20 20 unt.=.usages.LengthSafe();......
25860 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 ............for.(var.i.=.0;.i.<.
25880 75 73 61 67 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 usageCount;.++i)................
258a0 20 20 20 20 20 20 64 65 76 69 63 65 2e 41 64 64 44 65 76 69 63 65 55 73 61 67 65 28 6e 65 77 20 ......device.AddDeviceUsage(new.
258c0 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 75 73 61 67 65 73 5b 69 5d 29 29 3b 0d 0a 20 20 20 InternedString(usages[i]));.....
258e0 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 2e 6d 5f 50 61 72 74 69 63 69 70 61 6e .............device.m_Participan
25900 74 49 64 20 3d 20 70 61 72 74 69 63 69 70 61 6e 74 49 64 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 tId.=.participantId;............
25920 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 73 ..}..........}............///.<s
25940 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 53 74 61 74 65 20 77 65 20 74 61 ummary>..........///.State.we.ta
25960 6b 65 20 61 63 72 6f 73 73 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 73 2e 0d 0a 20 20 20 20 20 ke.across.domain.reloads........
25980 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c ...///.</summary>..........///.<
259a0 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 4d 6f 73 74 20 6f 66 20 74 68 remarks>..........///.Most.of.th
259c0 65 20 73 74 61 74 65 20 77 65 20 72 65 2d 72 65 63 72 65 61 74 65 20 69 6e 2d 62 65 74 77 65 65 e.state.we.re-recreate.in-betwee
259e0 6e 20 72 65 6c 6f 61 64 73 20 61 6e 64 20 64 6f 20 6e 6f 74 20 73 74 6f 72 65 0d 0a 20 20 20 20 n.reloads.and.do.not.store......
25a00 20 20 20 20 2f 2f 2f 20 69 6e 20 74 68 69 73 20 73 74 72 75 63 74 75 72 65 2e 20 49 6e 20 70 61 ....///.in.this.structure..In.pa
25a20 72 74 69 63 75 6c 61 72 2c 20 77 65 20 64 6f 20 6e 6f 74 20 70 72 65 73 65 72 76 65 20 61 6e 79 rticular,.we.do.not.preserve.any
25a40 74 68 69 6e 67 20 66 72 6f 6d 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 74 68 65 20 76 61 72 69 thing.from..........///.the.vari
25a60 6f 75 73 20 52 65 67 69 73 74 65 72 58 58 58 28 29 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 ous.RegisterXXX()...........///.
25a80 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 5b 53 65 72 69 61 6c 69 7a 61 62 6c </remarks>..........[Serializabl
25aa0 65 5d 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 73 74 72 75 63 74 20 53 65 72 69 e]..........internal.struct.Seri
25ac0 61 6c 69 7a 65 64 53 74 61 74 65 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 alizedState..........{..........
25ae0 20 20 20 20 70 75 62 6c 69 63 20 69 6e 74 20 6c 61 79 6f 75 74 52 65 67 69 73 74 72 61 74 69 6f ....public.int.layoutRegistratio
25b00 6e 56 65 72 73 69 6f 6e 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 66 6c nVersion;..............public.fl
25b20 6f 61 74 20 70 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 3b 0d 0a 20 20 20 20 20 20 20 20 20 oat.pollingFrequency;...........
25b40 20 20 20 70 75 62 6c 69 63 20 44 65 76 69 63 65 53 74 61 74 65 5b 5d 20 64 65 76 69 63 65 73 3b ...public.DeviceState[].devices;
25b60 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 41 76 61 69 6c 61 62 6c 65 44 65 ..............public.AvailableDe
25b80 76 69 63 65 5b 5d 20 61 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 3b 0d 0a 20 20 20 20 20 20 vice[].availableDevices;........
25ba0 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 53 74 61 74 65 42 75 66 66 65 72 73 20 62 ......public.InputStateBuffers.b
25bc0 75 66 66 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 uffers;..............public.Inpu
25be0 74 55 70 64 61 74 65 2e 53 65 72 69 61 6c 69 7a 65 64 53 74 61 74 65 20 75 70 64 61 74 65 53 74 tUpdate.SerializedState.updateSt
25c00 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 55 70 ate;..............public.InputUp
25c20 64 61 74 65 54 79 70 65 20 75 70 64 61 74 65 4d 61 73 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 dateType.updateMask;............
25c40 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 4d 65 74 72 69 63 73 20 6d 65 74 72 69 63 73 3b 0d 0a ..public.InputMetrics.metrics;..
25c60 20 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 49 6e 70 75 74 53 65 74 74 69 6e 67 73 ............public.InputSettings
25c80 20 73 65 74 74 69 6e 67 73 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e .settings;................#if.UN
25ca0 49 54 59 5f 41 4e 41 4c 59 54 49 43 53 20 7c 7c 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 ITY_ANALYTICS.||.UNITY_EDITOR...
25cc0 20 20 20 20 20 20 20 20 20 20 20 70 75 62 6c 69 63 20 62 6f 6f 6c 20 68 61 76 65 53 65 6e 74 53 ...........public.bool.haveSentS
25ce0 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 23 65 tartupAnalytics;..............#e
25d00 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 ndif..........}............inter
25d20 6e 61 6c 20 53 65 72 69 61 6c 69 7a 65 64 53 74 61 74 65 20 53 61 76 65 53 74 61 74 65 28 29 0d nal.SerializedState.SaveState().
25d40 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 65 76 69 63 .........{..............//.Devic
25d60 65 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 69 63 65 43 6f 75 6e 74 es...............var.deviceCount
25d80 20 3d 20 6d 5f 44 65 76 69 63 65 73 43 6f 75 6e 74 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .=.m_DevicesCount;..............
25da0 76 61 72 20 64 65 76 69 63 65 41 72 72 61 79 20 3d 20 6e 65 77 20 44 65 76 69 63 65 53 74 61 74 var.deviceArray.=.new.DeviceStat
25dc0 65 5b 64 65 76 69 63 65 43 6f 75 6e 74 5d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 e[deviceCount];..............for
25de0 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 64 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b .(var.i.=.0;.i.<.deviceCount;.++
25e00 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 i)..............{...............
25e20 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 6d 5f 44 65 76 69 63 65 73 5b 69 5d 3b 0d 0a 20 ...var.device.=.m_Devices[i];...
25e40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 69 6e 67 5b 5d 20 75 73 61 67 65 73 20 3d ...............string[].usages.=
25e60 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 .null;..................if.(devi
25e80 63 65 2e 75 73 61 67 65 73 2e 43 6f 75 6e 74 20 3e 20 30 29 0d 0a 20 20 20 20 20 20 20 20 20 20 ce.usages.Count.>.0)............
25ea0 20 20 20 20 20 20 20 20 20 20 75 73 61 67 65 73 20 3d 20 64 65 76 69 63 65 2e 75 73 61 67 65 73 ..........usages.=.device.usages
25ec0 2e 53 65 6c 65 63 74 28 78 20 3d 3e 20 78 2e 54 6f 53 74 72 69 6e 67 28 29 29 2e 54 6f 41 72 72 .Select(x.=>.x.ToString()).ToArr
25ee0 61 79 28 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 76 ay();....................var.dev
25f00 69 63 65 53 74 61 74 65 20 3d 20 6e 65 77 20 44 65 76 69 63 65 53 74 61 74 65 0d 0a 20 20 20 20 iceState.=.new.DeviceState......
25f20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ............{...................
25f40 20 20 20 6e 61 6d 65 20 3d 20 64 65 76 69 63 65 2e 6e 61 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 ...name.=.device.name,..........
25f60 20 20 20 20 20 20 20 20 20 20 20 20 6c 61 79 6f 75 74 20 3d 20 64 65 76 69 63 65 2e 6c 61 79 6f ............layout.=.device.layo
25f80 75 74 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 69 61 6e 74 ut,......................variant
25fa0 73 20 3d 20 64 65 76 69 63 65 2e 76 61 72 69 61 6e 74 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 s.=.device.variants,............
25fc0 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 49 64 20 3d 20 64 65 76 69 63 65 2e 64 65 76 69 ..........deviceId.=.device.devi
25fe0 63 65 49 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 61 72 74 69 ceId,......................parti
26000 63 69 70 61 6e 74 49 64 20 3d 20 64 65 76 69 63 65 2e 6d 5f 50 61 72 74 69 63 69 70 61 6e 74 49 cipantId.=.device.m_ParticipantI
26020 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 73 61 67 65 73 20 3d d,......................usages.=
26040 20 75 73 61 67 65 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 .usages,......................de
26060 73 63 72 69 70 74 69 6f 6e 20 3d 20 64 65 76 69 63 65 2e 6d 5f 44 65 73 63 72 69 70 74 69 6f 6e scription.=.device.m_Description
26080 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6c 61 67 73 20 3d 20 64 ,......................flags.=.d
260a0 65 76 69 63 65 2e 6d 5f 44 65 76 69 63 65 46 6c 61 67 73 0d 0a 20 20 20 20 20 20 20 20 20 20 20 evice.m_DeviceFlags.............
260c0 20 20 20 20 20 7d 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 41 .....};..................deviceA
260e0 72 72 61 79 5b 69 5d 20 3d 20 64 65 76 69 63 65 53 74 61 74 65 3b 0d 0a 20 20 20 20 20 20 20 20 rray[i].=.deviceState;..........
26100 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 6e 65 77 20 ....}................return.new.
26120 53 65 72 69 61 6c 69 7a 65 64 53 74 61 74 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a SerializedState..............{..
26140 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6c 61 79 6f 75 74 52 65 67 69 73 74 72 61 74 69 ................layoutRegistrati
26160 6f 6e 56 65 72 73 69 6f 6e 20 3d 20 6d 5f 4c 61 79 6f 75 74 52 65 67 69 73 74 72 61 74 69 6f 6e onVersion.=.m_LayoutRegistration
26180 56 65 72 73 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 6f 6c 6c 69 6e Version,..................pollin
261a0 67 46 72 65 71 75 65 6e 63 79 20 3d 20 6d 5f 50 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 2c gFrequency.=.m_PollingFrequency,
261c0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 73 20 3d 20 64 65 76 69 ..................devices.=.devi
261e0 63 65 41 72 72 61 79 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 61 76 61 69 6c 61 ceArray,..................availa
26200 62 6c 65 44 65 76 69 63 65 73 20 3d 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 3f bleDevices.=.m_AvailableDevices?
26220 2e 54 61 6b 65 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 6f 75 6e 74 29 2e 54 6f .Take(m_AvailableDeviceCount).To
26240 41 72 72 61 79 28 29 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 62 75 66 66 65 72 Array(),..................buffer
26260 73 20 3d 20 6d 5f 53 74 61 74 65 42 75 66 66 65 72 73 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 s.=.m_StateBuffers,.............
26280 20 20 20 20 20 75 70 64 61 74 65 53 74 61 74 65 20 3d 20 49 6e 70 75 74 55 70 64 61 74 65 2e 53 .....updateState.=.InputUpdate.S
262a0 61 76 65 28 29 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 75 70 64 61 74 65 4d 61 ave(),..................updateMa
262c0 73 6b 20 3d 20 6d 5f 55 70 64 61 74 65 4d 61 73 6b 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 sk.=.m_UpdateMask,..............
262e0 20 20 20 20 6d 65 74 72 69 63 73 20 3d 20 6d 5f 4d 65 74 72 69 63 73 2c 0d 0a 20 20 20 20 20 20 ....metrics.=.m_Metrics,........
26300 20 20 20 20 20 20 20 20 20 20 73 65 74 74 69 6e 67 73 20 3d 20 6d 5f 53 65 74 74 69 6e 67 73 2c ..........settings.=.m_Settings,
26320 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 41 4e ....................#if.UNITY_AN
26340 41 4c 59 54 49 43 53 20 7c 7c 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 ALYTICS.||.UNITY_EDITOR.........
26360 20 20 20 20 20 20 20 20 20 68 61 76 65 53 65 6e 74 53 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 .........haveSentStartupAnalytic
26380 73 20 3d 20 6d 5f 48 61 76 65 53 65 6e 74 53 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 2c 0d s.=.m_HaveSentStartupAnalytics,.
263a0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 20 20 20 20 20 20 20 .................#endif.........
263c0 20 20 20 20 20 7d 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 69 6e .....};..........}............in
263e0 74 65 72 6e 61 6c 20 76 6f 69 64 20 52 65 73 74 6f 72 65 53 74 61 74 65 57 69 74 68 6f 75 74 44 ternal.void.RestoreStateWithoutD
26400 65 76 69 63 65 73 28 53 65 72 69 61 6c 69 7a 65 64 53 74 61 74 65 20 73 74 61 74 65 29 0d 0a 20 evices(SerializedState.state)...
26420 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 53 74 61 74 65 42 75 66 .......{..............m_StateBuf
26440 66 65 72 73 20 3d 20 73 74 61 74 65 2e 62 75 66 66 65 72 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 fers.=.state.buffers;...........
26460 20 20 20 6d 5f 4c 61 79 6f 75 74 52 65 67 69 73 74 72 61 74 69 6f 6e 56 65 72 73 69 6f 6e 20 3d ...m_LayoutRegistrationVersion.=
26480 20 73 74 61 74 65 2e 6c 61 79 6f 75 74 52 65 67 69 73 74 72 61 74 69 6f 6e 56 65 72 73 69 6f 6e .state.layoutRegistrationVersion
264a0 20 2b 20 31 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 75 70 64 61 74 65 4d 61 73 6b 20 3d 20 .+.1;..............updateMask.=.
264c0 73 74 61 74 65 2e 75 70 64 61 74 65 4d 61 73 6b 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d state.updateMask;..............m
264e0 5f 4d 65 74 72 69 63 73 20 3d 20 73 74 61 74 65 2e 6d 65 74 72 69 63 73 3b 0d 0a 20 20 20 20 20 _Metrics.=.state.metrics;.......
26500 20 20 20 20 20 20 20 6d 5f 50 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 20 3d 20 73 74 61 74 .......m_PollingFrequency.=.stat
26520 65 2e 70 6f 6c 6c 69 6e 67 46 72 65 71 75 65 6e 63 79 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 e.pollingFrequency;.............
26540 20 20 20 69 66 20 28 6d 5f 53 65 74 74 69 6e 67 73 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 ...if.(m_Settings.!=.null)......
26560 20 20 20 20 20 20 20 20 20 20 20 20 4f 62 6a 65 63 74 2e 44 65 73 74 72 6f 79 49 6d 6d 65 64 69 ............Object.DestroyImmedi
26580 61 74 65 28 6d 5f 53 65 74 74 69 6e 67 73 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f ate(m_Settings);..............m_
265a0 53 65 74 74 69 6e 67 73 20 3d 20 73 74 61 74 65 2e 73 65 74 74 69 6e 67 73 3b 0d 0a 0d 0a 20 20 Settings.=.state.settings;......
265c0 20 20 20 20 20 20 20 20 20 20 23 69 66 20 55 4e 49 54 59 5f 41 4e 41 4c 59 54 49 43 53 20 7c 7c ..........#if.UNITY_ANALYTICS.||
265e0 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 48 61 76 .UNITY_EDITOR..............m_Hav
26600 65 53 65 6e 74 53 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 20 3d 20 73 74 61 74 65 2e 68 61 eSentStartupAnalytics.=.state.ha
26620 76 65 53 65 6e 74 53 74 61 72 74 75 70 41 6e 61 6c 79 74 69 63 73 3b 0d 0a 20 20 20 20 20 20 20 veSentStartupAnalytics;.........
26640 20 20 20 20 20 23 65 6e 64 69 66 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 2f 2f 52 .....#endif................////R
26660 45 56 49 45 57 3a 20 69 6e 73 74 65 61 64 20 6f 66 20 61 63 63 65 73 73 69 6e 67 20 67 6c 6f 62 EVIEW:.instead.of.accessing.glob
26680 61 6c 73 20 68 65 72 65 2c 20 77 65 20 63 6f 75 6c 64 20 6d 6f 76 65 20 74 68 69 73 20 74 6f 20 als.here,.we.could.move.this.to.
266a0 77 68 65 6e 20 77 65 20 72 65 2d 63 72 65 61 74 65 20 64 65 76 69 63 65 73 0d 0a 0d 0a 20 20 20 when.we.re-create.devices.......
266c0 20 20 20 20 20 20 20 20 20 2f 2f 20 55 70 64 61 74 65 20 73 74 61 74 65 2e 0d 0a 20 20 20 20 20 .........//.Update.state........
266e0 20 20 20 20 20 20 20 49 6e 70 75 74 55 70 64 61 74 65 2e 52 65 73 74 6f 72 65 28 73 74 61 74 65 .......InputUpdate.Restore(state
26700 2e 75 70 64 61 74 65 53 74 61 74 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 .updateState);..........}.......
26720 20 20 20 20 20 2f 2f 20 49 66 20 74 68 65 73 65 20 61 72 65 20 73 65 74 2c 20 77 65 20 63 6c 65 .....//.If.these.are.set,.we.cle
26740 61 72 20 74 68 65 6d 20 6f 75 74 20 6f 6e 20 74 68 65 20 66 69 72 73 74 20 69 6e 70 75 74 20 75 ar.them.out.on.the.first.input.u
26760 70 64 61 74 65 2e 0d 0a 20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 44 65 76 69 63 65 53 pdate...........internal.DeviceS
26780 74 61 74 65 5b 5d 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 3b 0d 0a 20 20 20 tate[].m_SavedDeviceStates;.....
267a0 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 5b 5d 20 .....internal.AvailableDevice[].
267c0 6d 5f 53 61 76 65 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 3b 0d 0a 0d 0a 20 20 20 20 m_SavedAvailableDevices;........
267e0 20 20 20 20 2f 2f 2f 20 3c 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 52 ....///.<summary>..........///.R
26800 65 63 72 65 61 74 65 20 64 65 76 69 63 65 73 20 62 61 73 65 64 20 6f 6e 20 74 68 65 20 64 65 76 ecreate.devices.based.on.the.dev
26820 69 63 65 73 20 77 65 20 68 61 64 20 62 65 66 6f 72 65 20 61 20 64 6f 6d 61 69 6e 20 72 65 6c 6f ices.we.had.before.a.domain.relo
26840 61 64 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 73 75 6d 6d 61 72 79 3e 0d 0a 20 20 20 ad...........///.</summary>.....
26860 20 20 20 20 20 2f 2f 2f 20 3c 72 65 6d 61 72 6b 73 3e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 .....///.<remarks>..........///.
26880 4e 6f 74 65 20 74 68 61 74 20 64 65 76 69 63 65 20 69 6e 64 69 63 65 73 20 6d 61 79 20 63 68 61 Note.that.device.indices.may.cha
268a0 6e 67 65 20 62 65 74 77 65 65 6e 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 73 2e 0d 0a 20 20 20 nge.between.domain.reloads......
268c0 20 20 20 20 20 2f 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 57 65 20 72 65 63 72 65 61 74 .....///..........///.We.recreat
268e0 65 20 64 65 76 69 63 65 73 20 75 73 69 6e 67 20 74 68 65 20 6c 61 79 6f 75 74 20 69 6e 66 6f 72 e.devices.using.the.layout.infor
26900 6d 61 74 69 6f 6e 20 61 73 20 69 74 20 65 78 69 73 74 73 20 6e 6f 77 20 61 73 20 6f 70 70 6f 73 mation.as.it.exists.now.as.oppos
26920 65 64 20 74 6f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 61 73 20 69 74 20 65 78 69 73 74 65 64 ed.to..........///.as.it.existed
26940 20 62 65 66 6f 72 65 20 74 68 65 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 2e 20 54 68 69 73 20 .before.the.domain.reload..This.
26960 6d 65 61 6e 73 20 77 65 27 6c 6c 20 62 65 20 70 69 63 6b 69 6e 67 20 75 70 20 61 6e 79 20 63 68 means.we'll.be.picking.up.any.ch
26980 61 6e 67 65 73 20 74 68 61 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 68 61 76 65 20 68 61 70 anges.that..........///.have.hap
269a0 70 65 6e 65 64 20 74 6f 20 6c 61 79 6f 75 74 73 20 61 73 20 70 61 72 74 20 6f 66 20 74 68 65 20 pened.to.layouts.as.part.of.the.
269c0 72 65 6c 6f 61 64 20 28 69 6e 63 6c 75 64 69 6e 67 20 6c 61 79 6f 75 74 73 20 68 61 76 69 6e 67 reload.(including.layouts.having
269e0 20 62 65 65 6e 20 72 65 6d 6f 76 65 64 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 65 6e 74 69 72 .been.removed..........///.entir
26a00 65 6c 79 29 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 2f 20 3c 2f 72 65 6d 61 72 6b 73 3e 0d 0a 20 ely)...........///.</remarks>...
26a20 20 20 20 20 20 20 20 69 6e 74 65 72 6e 61 6c 20 76 6f 69 64 20 52 65 73 74 6f 72 65 44 65 76 69 .......internal.void.RestoreDevi
26a40 63 65 73 41 66 74 65 72 44 6f 6d 61 69 6e 52 65 6c 6f 61 64 28 29 0d 0a 20 20 20 20 20 20 20 20 cesAfterDomainReload()..........
26a60 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 50 72 6f 66 69 6c 65 72 2e 42 65 67 69 6e 53 61 6d {..............Profiler.BeginSam
26a80 70 6c 65 28 22 49 6e 70 75 74 4d 61 6e 61 67 65 72 2e 52 65 73 74 6f 72 65 44 65 76 69 63 65 73 ple("InputManager.RestoreDevices
26aa0 41 66 74 65 72 44 6f 6d 61 69 6e 52 65 6c 6f 61 64 22 29 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 AfterDomainReload");............
26ac0 20 20 20 20 75 73 69 6e 67 20 28 49 6e 70 75 74 44 65 76 69 63 65 42 75 69 6c 64 65 72 2e 52 65 ....using.(InputDeviceBuilder.Re
26ae0 66 28 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 f())..............{.............
26b00 20 20 20 20 20 44 65 76 69 63 65 53 74 61 74 65 5b 5d 20 72 65 74 61 69 6e 65 64 44 65 76 69 63 .....DeviceState[].retainedDevic
26b20 65 53 74 61 74 65 73 20 3d 20 6e 75 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eStates.=.null;.................
26b40 20 76 61 72 20 64 65 76 69 63 65 53 74 61 74 65 73 20 3d 20 6d 5f 53 61 76 65 64 44 65 76 69 63 .var.deviceStates.=.m_SavedDevic
26b60 65 53 74 61 74 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 64 65 eStates;..................var.de
26b80 76 69 63 65 43 6f 75 6e 74 20 3d 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 2e viceCount.=.m_SavedDeviceStates.
26ba0 4c 65 6e 67 74 68 53 61 66 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d LengthSafe();..................m
26bc0 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 20 3d 20 6e 75 6c 6c 3b 20 2f 2f 20 50 72 _SavedDeviceStates.=.null;.//.Pr
26be0 65 76 65 6e 74 20 6c 61 79 6f 75 74 20 6d 61 74 63 68 65 72 20 72 65 67 69 73 74 65 72 69 6e 67 event.layout.matcher.registering
26c00 20 74 68 65 6d 73 65 6c 76 65 73 20 6f 6e 20 74 68 65 20 66 6c 79 20 66 72 6f 6d 20 70 69 63 6b .themselves.on.the.fly.from.pick
26c20 69 6e 67 20 61 6e 79 74 68 69 6e 67 20 6f 66 66 20 74 68 69 73 20 6c 69 73 74 2e 0d 0a 20 20 20 ing.anything.off.this.list......
26c40 20 20 20 20 20 20 20 20 20 20 20 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c .............for.(var.i.=.0;.i.<
26c60 20 64 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .deviceCount;.++i)..............
26c80 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 72 65 66 20 76 ....{......................ref.v
26ca0 61 72 20 64 65 76 69 63 65 53 74 61 74 65 20 3d 20 72 65 66 20 64 65 76 69 63 65 53 74 61 74 65 ar.deviceState.=.ref.deviceState
26cc0 73 5b 69 5d 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 s[i];........................var
26ce0 20 64 65 76 69 63 65 20 3d 20 54 72 79 47 65 74 44 65 76 69 63 65 42 79 49 64 28 64 65 76 69 63 .device.=.TryGetDeviceById(devic
26d00 65 53 74 61 74 65 2e 64 65 76 69 63 65 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 eState.deviceId);...............
26d20 20 20 20 20 20 20 20 69 66 20 28 64 65 76 69 63 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 .......if.(device.!=.null)......
26d40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d ....................continue;...
26d60 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f 75 74 20 .....................var.layout.
26d80 3d 20 54 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 28 72 =.TryFindMatchingControlLayout(r
26da0 65 66 20 64 65 76 69 63 65 53 74 61 74 65 2e 64 65 73 63 72 69 70 74 69 6f 6e 2c 0d 0a 20 20 20 ef.deviceState.description,.....
26dc0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 53 74 61 74 65 .....................deviceState
26de0 2e 64 65 76 69 63 65 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .deviceId);.....................
26e00 20 69 66 20 28 6c 61 79 6f 75 74 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 .if.(layout.IsEmpty())..........
26e20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ............{...................
26e40 20 20 20 20 20 20 20 76 61 72 20 70 72 65 76 69 6f 75 73 4c 61 79 6f 75 74 20 3d 20 6e 65 77 20 .......var.previousLayout.=.new.
26e60 49 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 64 65 76 69 63 65 53 74 61 74 65 2e 6c 61 79 6f 75 InternedString(deviceState.layou
26e80 74 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 t);..........................if.
26ea0 28 6d 5f 4c 61 79 6f 75 74 73 2e 48 61 73 4c 61 79 6f 75 74 28 70 72 65 76 69 6f 75 73 4c 61 79 (m_Layouts.HasLayout(previousLay
26ec0 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 out))...........................
26ee0 20 20 20 6c 61 79 6f 75 74 20 3d 20 70 72 65 76 69 6f 75 73 4c 61 79 6f 75 74 3b 0d 0a 20 20 20 ...layout.=.previousLayout;.....
26f00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 .................}..............
26f20 20 20 20 20 20 20 20 20 69 66 20 28 6c 61 79 6f 75 74 2e 49 73 45 6d 70 74 79 28 29 20 7c 7c 20 ........if.(layout.IsEmpty().||.
26f40 21 52 65 73 74 6f 72 65 44 65 76 69 63 65 46 72 6f 6d 53 61 76 65 64 53 74 61 74 65 28 72 65 66 !RestoreDeviceFromSavedState(ref
26f60 20 64 65 76 69 63 65 53 74 61 74 65 2c 20 6c 61 79 6f 75 74 29 29 0d 0a 20 20 20 20 20 20 20 20 .deviceState,.layout))..........
26f80 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 72 72 61 79 48 65 6c 70 65 72 73 2e 41 70 70 ................ArrayHelpers.App
26fa0 65 6e 64 28 72 65 66 20 72 65 74 61 69 6e 65 64 44 65 76 69 63 65 53 74 61 74 65 73 2c 20 64 65 end(ref.retainedDeviceStates,.de
26fc0 76 69 63 65 53 74 61 74 65 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a viceState);..................}..
26fe0 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 53 65 65 20 69 66 20 77 65 20 63 ..................//.See.if.we.c
27000 61 6e 20 6d 61 6b 65 20 73 65 6e 73 65 20 6f 66 20 61 6e 20 61 76 61 69 6c 61 62 6c 65 20 64 65 an.make.sense.of.an.available.de
27020 76 69 63 65 20 6e 6f 77 20 74 68 61 74 20 77 65 20 63 6f 75 6c 64 6e 27 74 20 6d 61 6b 65 20 73 vice.now.that.we.couldn't.make.s
27040 65 6e 73 65 20 6f 66 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 62 65 66 6f ense.of..................//.befo
27060 72 65 2e 20 54 68 69 73 20 63 61 6e 20 62 65 20 74 68 65 20 63 61 73 65 20 69 66 20 74 68 65 72 re..This.can.be.the.case.if.ther
27080 65 27 73 20 6e 65 77 20 6c 61 79 6f 75 74 20 69 6e 66 6f 72 6d 61 74 69 6f 6e 20 74 68 61 74 20 e's.new.layout.information.that.
270a0 77 61 73 6e 27 74 20 61 76 61 69 6c 61 62 6c 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 wasn't.available................
270c0 20 20 2f 2f 20 62 65 66 6f 72 65 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 ..//.before...................if
270e0 20 28 6d 5f 53 61 76 65 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 20 21 3d 20 6e 75 6c .(m_SavedAvailableDevices.!=.nul
27100 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 l)..................{...........
27120 20 20 20 20 20 20 20 20 20 20 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 20 3d 20 ...........m_AvailableDevices.=.
27140 6d 5f 53 61 76 65 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 3b 0d 0a 20 20 20 20 20 20 m_SavedAvailableDevices;........
27160 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 43 ..............m_AvailableDeviceC
27180 6f 75 6e 74 20 3d 20 6d 5f 53 61 76 65 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 2e 4c ount.=.m_SavedAvailableDevices.L
271a0 65 6e 67 74 68 53 61 66 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 engthSafe();....................
271c0 20 20 66 6f 72 20 28 76 61 72 20 69 20 3d 20 30 3b 20 69 20 3c 20 6d 5f 41 76 61 69 6c 61 62 6c ..for.(var.i.=.0;.i.<.m_Availabl
271e0 65 44 65 76 69 63 65 43 6f 75 6e 74 3b 20 2b 2b 69 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 eDeviceCount;.++i)..............
27200 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ........{.......................
27220 20 20 20 76 61 72 20 64 65 76 69 63 65 20 3d 20 54 72 79 47 65 74 44 65 76 69 63 65 42 79 49 64 ...var.device.=.TryGetDeviceById
27240 28 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 76 69 63 65 49 64 29 (m_AvailableDevices[i].deviceId)
27260 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 64 ;..........................if.(d
27280 65 76 69 63 65 20 21 3d 20 6e 75 6c 6c 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 evice.!=.null)..................
272a0 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a 20 20 20 20 20 20 20 ............continue;...........
272c0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 6d 5f 41 76 61 69 6c 61 62 6c 65 .................if.(m_Available
272e0 44 65 76 69 63 65 73 5b 69 5d 2e 69 73 52 65 6d 6f 76 65 64 29 0d 0a 20 20 20 20 20 20 20 20 20 Devices[i].isRemoved)...........
27300 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 3b 0d 0a 0d 0a ...................continue;....
27320 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 20 6c 61 79 6f ........................var.layo
27340 75 74 20 3d 20 54 72 79 46 69 6e 64 4d 61 74 63 68 69 6e 67 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 ut.=.TryFindMatchingControlLayou
27360 74 28 72 65 66 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 73 63 t(ref.m_AvailableDevices[i].desc
27380 72 69 70 74 69 6f 6e 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ription,........................
273a0 20 20 20 20 20 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 76 69 ......m_AvailableDevices[i].devi
273c0 63 65 49 64 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ceId);..........................
273e0 69 66 20 28 21 6c 61 79 6f 75 74 2e 49 73 45 6d 70 74 79 28 29 29 0d 0a 20 20 20 20 20 20 20 20 if.(!layout.IsEmpty())..........
27400 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ................{...............
27420 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 74 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ...............try..............
27440 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ................{...............
27460 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 41 64 64 44 65 76 69 63 65 28 6c 61 79 ...................AddDevice(lay
27480 6f 75 74 2c 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 76 69 63 out,.m_AvailableDevices[i].devic
274a0 65 49 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 eId,............................
274c0 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 44 65 73 63 72 69 70 74 69 6f 6e 3a 20 6d 5f 41 ..........deviceDescription:.m_A
274e0 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 5b 69 5d 2e 64 65 73 63 72 69 70 74 69 6f 6e 2c 0d vailableDevices[i].description,.
27500 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ................................
27520 20 20 20 20 20 64 65 76 69 63 65 46 6c 61 67 73 3a 20 6d 5f 41 76 61 69 6c 61 62 6c 65 44 65 76 .....deviceFlags:.m_AvailableDev
27540 69 63 65 73 5b 69 5d 2e 69 73 4e 61 74 69 76 65 20 3f 20 49 6e 70 75 74 44 65 76 69 63 65 2e 44 ices[i].isNative.?.InputDevice.D
27560 65 76 69 63 65 46 6c 61 67 73 2e 4e 61 74 69 76 65 20 3a 20 30 29 3b 0d 0a 20 20 20 20 20 20 20 eviceFlags.Native.:.0);.........
27580 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 .....................}..........
275a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 63 61 74 63 68 20 28 45 78 63 65 70 ....................catch.(Excep
275c0 74 69 6f 6e 29 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tion)...........................
275e0 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...{............................
27600 20 20 20 20 20 20 2f 2f 20 4a 75 73 74 20 69 67 6e 6f 72 65 2e 20 53 69 6d 70 6c 79 20 6d 65 61 ......//.Just.ignore..Simply.mea
27620 6e 73 20 77 65 20 73 74 69 6c 6c 20 63 61 6e 27 74 20 72 65 61 6c 6c 79 20 74 75 72 6e 20 74 68 ns.we.still.can't.really.turn.th
27640 65 20 64 65 76 69 63 65 20 69 6e 74 6f 20 73 6f 6d 65 74 68 69 6e 67 20 75 73 65 66 75 6c 2e 0d e.device.into.something.useful..
27660 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a .............................}..
27680 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 ........................}.......
276a0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...............}................
276c0 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 44 6f 6e 65 2e 20 ..}....................//.Done..
276e0 44 69 73 63 61 72 64 20 73 61 76 65 64 20 61 72 72 61 79 73 2e 0d 0a 20 20 20 20 20 20 20 20 20 Discard.saved.arrays............
27700 20 20 20 20 20 20 20 6d 5f 53 61 76 65 64 44 65 76 69 63 65 53 74 61 74 65 73 20 3d 20 72 65 74 .......m_SavedDeviceStates.=.ret
27720 61 69 6e 65 64 44 65 76 69 63 65 53 74 61 74 65 73 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 ainedDeviceStates;..............
27740 20 20 20 20 6d 5f 53 61 76 65 64 41 76 61 69 6c 61 62 6c 65 44 65 76 69 63 65 73 20 3d 20 6e 75 ....m_SavedAvailableDevices.=.nu
27760 6c 6c 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 ll;..............}..............
27780 20 20 50 72 6f 66 69 6c 65 72 2e 45 6e 64 53 61 6d 70 6c 65 28 29 3b 0d 0a 20 20 20 20 20 20 20 ..Profiler.EndSample();.........
277a0 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 68 61 76 65 20 74 77 6f 20 67 65 6e .}............//.We.have.two.gen
277c0 65 72 61 6c 20 74 79 70 65 73 20 6f 66 20 64 65 76 69 63 65 73 20 77 65 20 6e 65 65 64 20 74 6f eral.types.of.devices.we.need.to
277e0 20 63 61 72 65 20 61 62 6f 75 74 20 77 68 65 6e 20 72 65 63 72 65 61 74 69 6e 67 20 64 65 76 69 .care.about.when.recreating.devi
27800 63 65 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 61 66 74 65 72 20 64 6f 6d 61 69 6e 20 72 65 6c ces..........//.after.domain.rel
27820 6f 61 64 73 3a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 29 oads:..........//..........//.A)
27840 20 64 65 76 69 63 65 20 77 69 74 68 20 49 6e 70 75 74 44 65 76 69 63 65 44 65 73 63 72 69 70 74 .device.with.InputDeviceDescript
27860 69 6f 6e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 42 29 20 64 65 76 69 63 65 20 63 72 65 61 74 65 ion..........//.B).device.create
27880 64 20 64 69 72 65 63 74 6c 79 20 66 72 6f 6d 20 73 70 65 63 69 66 69 63 20 6c 61 79 6f 75 74 0d d.directly.from.specific.layout.
278a0 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 41 29 20 73 68 6f 75 6c .........//..........//.A).shoul
278c0 64 20 67 6f 20 74 68 72 6f 75 67 68 20 74 68 65 20 6e 6f 72 6d 61 6c 20 6d 61 74 63 68 69 6e 67 d.go.through.the.normal.matching
278e0 20 70 72 6f 63 65 73 73 20 77 68 65 72 65 61 73 20 42 29 20 73 68 6f 75 6c 64 20 67 65 74 20 72 .process.whereas.B).should.get.r
27900 65 63 72 65 61 74 65 64 20 77 69 74 68 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 6c 61 79 6f 75 74 ecreated.with..........//.layout
27920 20 6f 66 20 73 61 6d 65 20 6e 61 6d 65 20 28 69 66 20 73 74 69 6c 6c 20 61 76 61 69 6c 61 62 6c .of.same.name.(if.still.availabl
27940 65 29 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 53 6f 20 77 e)...........//..........//.So.w
27960 65 20 6b 69 63 6b 20 64 65 76 69 63 65 20 72 65 63 72 65 61 74 69 6f 6e 20 6f 66 66 20 66 72 6f e.kick.device.recreation.off.fro
27980 6d 20 74 77 6f 20 70 6f 69 6e 74 73 3a 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 m.two.points:..........//.......
279a0 20 20 20 2f 2f 20 31 29 20 46 72 6f 6d 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 ...//.1).From.RegisterControlLay
279c0 6f 75 74 4d 61 74 63 68 65 72 20 74 6f 20 63 61 74 63 68 20 41 29 0d 0a 20 20 20 20 20 20 20 20 outMatcher.to.catch.A)..........
279e0 2f 2f 20 32 29 20 46 72 6f 6d 20 52 65 67 69 73 74 65 72 43 6f 6e 74 72 6f 6c 4c 61 79 6f 75 74 //.2).From.RegisterControlLayout
27a00 20 74 6f 20 63 61 74 63 68 20 42 29 0d 0a 20 20 20 20 20 20 20 20 2f 2f 0d 0a 20 20 20 20 20 20 .to.catch.B)..........//........
27a20 20 20 2f 2f 20 41 64 64 69 74 69 6f 6e 61 6c 6c 79 2c 20 77 65 20 68 61 76 65 20 74 68 65 20 63 ..//.Additionally,.we.have.the.c
27a40 6f 6d 70 6c 69 63 61 74 69 6f 6e 20 74 68 61 74 20 61 20 6c 61 79 6f 75 74 20 61 20 64 65 76 69 omplication.that.a.layout.a.devi
27a60 63 65 20 77 61 73 20 75 73 69 6e 67 20 77 61 73 20 73 6f 6d 65 74 68 69 6e 67 0d 0a 20 20 20 20 ce.was.using.was.something......
27a80 20 20 20 20 2f 2f 20 64 79 6e 61 6d 69 63 61 6c 6c 79 20 72 65 67 69 73 74 65 72 65 64 20 66 72 ....//.dynamically.registered.fr
27aa0 6f 6d 20 6f 6e 46 69 6e 64 4c 61 79 6f 75 74 46 6f 72 44 65 76 69 63 65 2e 20 57 65 20 64 6f 6e om.onFindLayoutForDevice..We.don
27ac0 27 74 20 64 6f 20 61 6e 79 74 68 69 6e 67 20 73 70 65 63 69 61 6c 20 61 62 6f 75 74 20 74 68 61 't.do.anything.special.about.tha
27ae0 74 2e 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 54 68 65 20 66 69 72 73 74 20 66 75 6c 6c 20 69 6e t...........//.The.first.full.in
27b00 70 75 74 20 75 70 64 61 74 65 20 77 69 6c 6c 20 66 6c 75 73 68 20 6f 75 74 20 74 68 65 20 6c 69 put.update.will.flush.out.the.li
27b20 73 74 20 6f 66 20 73 61 76 65 64 20 64 65 76 69 63 65 20 73 74 61 74 65 73 20 61 6e 64 20 61 74 st.of.saved.device.states.and.at
27b40 20 74 68 61 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 70 6f 69 6e 74 2c 20 61 6e 79 20 6f 6e 46 .that..........//.point,.any.onF
27b60 69 6e 64 4c 61 79 6f 75 74 46 6f 72 44 65 76 69 63 65 20 68 6f 6f 6b 73 20 73 69 6d 70 6c 79 20 indLayoutForDevice.hooks.simply.
27b80 68 61 76 65 20 74 6f 20 62 65 20 69 6e 20 70 6c 61 63 65 2e 20 49 66 20 74 68 65 79 20 61 72 65 have.to.be.in.place..If.they.are
27ba0 2c 20 64 65 76 69 63 65 73 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 77 69 6c 6c 20 67 65 74 20 72 ,.devices..........//.will.get.r
27bc0 65 63 72 65 61 74 65 64 20 61 70 70 72 6f 70 72 69 61 74 65 6c 79 2e 0d 0a 20 20 20 20 20 20 20 ecreated.appropriately..........
27be0 20 2f 2f 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 49 74 20 77 6f 75 6c 64 20 62 65 20 6d 75 63 68 .//..........//.It.would.be.much
27c00 20 73 69 6d 70 6c 65 72 20 74 6f 20 72 65 63 72 65 61 74 65 20 61 6c 6c 20 64 65 76 69 63 65 73 .simpler.to.recreate.all.devices
27c20 20 61 73 20 74 68 65 20 66 69 72 73 74 20 74 68 69 6e 67 20 69 6e 20 74 68 65 20 66 69 72 73 74 .as.the.first.thing.in.the.first
27c40 20 66 75 6c 6c 20 69 6e 70 75 74 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 75 70 64 61 74 65 20 62 .full.input..........//.update.b
27c60 75 74 20 74 68 61 74 20 77 6f 75 6c 64 20 6d 65 61 6e 20 74 68 61 74 20 64 65 76 69 63 65 73 20 ut.that.would.mean.that.devices.
27c80 77 6f 75 6c 64 20 62 65 63 6f 6d 65 20 61 76 61 69 6c 61 62 6c 65 20 6f 6e 6c 79 20 76 65 72 79 would.become.available.only.very
27ca0 20 6c 61 74 65 2e 20 54 68 65 79 20 77 6f 75 6c 64 0d 0a 20 20 20 20 20 20 20 20 2f 2f 20 6e 6f .late..They.would..........//.no
27cc0 74 2c 20 66 6f 72 20 65 78 61 6d 70 6c 65 2c 20 62 65 20 61 76 61 69 6c 61 62 6c 65 20 77 68 65 t,.for.example,.be.available.whe
27ce0 6e 20 4d 6f 6e 6f 42 65 68 61 76 69 6f 75 72 2e 53 74 61 72 74 20 6d 65 74 68 6f 64 73 20 61 72 n.MonoBehaviour.Start.methods.ar
27d00 65 20 69 6e 76 6f 6b 65 64 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 70 72 69 76 61 74 65 20 62 6f e.invoked.............private.bo
27d20 6f 6c 20 52 65 73 74 6f 72 65 44 65 76 69 63 65 46 72 6f 6d 53 61 76 65 64 53 74 61 74 65 28 72 ol.RestoreDeviceFromSavedState(r
27d40 65 66 20 44 65 76 69 63 65 53 74 61 74 65 20 64 65 76 69 63 65 53 74 61 74 65 2c 20 49 6e 74 65 ef.DeviceState.deviceState,.Inte
27d60 72 6e 65 64 53 74 72 69 6e 67 20 6c 61 79 6f 75 74 29 0d 0a 20 20 20 20 20 20 20 20 7b 0d 0a 20 rnedString.layout)..........{...
27d80 20 20 20 20 20 20 20 20 20 20 20 2f 2f 20 57 65 20 61 73 73 69 67 6e 20 74 68 65 20 73 61 6d 65 ...........//.We.assign.the.same
27da0 20 64 65 76 69 63 65 20 49 44 73 20 68 65 72 65 20 74 6f 20 6e 65 77 6c 79 20 63 72 65 61 74 65 .device.IDs.here.to.newly.create
27dc0 64 20 64 65 76 69 63 65 73 20 74 68 61 74 20 74 68 65 79 20 68 61 64 0d 0a 20 20 20 20 20 20 20 d.devices.that.they.had.........
27de0 20 20 20 20 20 2f 2f 20 62 65 66 6f 72 65 20 74 68 65 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 .....//.before.the.domain.reload
27e00 2e 20 54 68 69 73 20 69 73 20 73 61 66 65 20 61 73 20 64 65 76 69 63 65 20 49 44 20 61 6c 6c 6f ..This.is.safe.as.device.ID.allo
27e20 63 61 74 69 6f 6e 20 69 73 20 75 6e 64 65 72 20 74 68 65 0d 0a 20 20 20 20 20 20 20 20 20 20 20 cation.is.under.the.............
27e40 20 2f 2f 20 63 6f 6e 74 72 6f 6c 20 6f 66 20 74 68 65 20 72 75 6e 74 69 6d 65 20 61 6e 64 20 6e .//.control.of.the.runtime.and.n
27e60 6f 74 20 65 78 70 65 63 74 65 64 20 74 6f 20 62 65 20 61 66 66 65 63 74 65 64 20 62 79 20 61 20 ot.expected.to.be.affected.by.a.
27e80 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 2e 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 49 6e domain.reload.................In
27ea0 70 75 74 44 65 76 69 63 65 20 64 65 76 69 63 65 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 74 putDevice.device;..............t
27ec0 72 79 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 ry..............{...............
27ee0 20 20 20 64 65 76 69 63 65 20 3d 20 41 64 64 44 65 76 69 63 65 28 6c 61 79 6f 75 74 2c 0d 0a 20 ...device.=.AddDevice(layout,...
27f00 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 44 65 73 63 72 69 70 ...................deviceDescrip
27f20 74 69 6f 6e 3a 20 64 65 76 69 63 65 53 74 61 74 65 2e 64 65 73 63 72 69 70 74 69 6f 6e 2c 0d 0a tion:.deviceState.description,..
27f40 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 49 64 3a 20 64 65 ....................deviceId:.de
27f60 76 69 63 65 53 74 61 74 65 2e 64 65 76 69 63 65 49 64 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 viceState.deviceId,.............
27f80 20 20 20 20 20 20 20 20 20 64 65 76 69 63 65 4e 61 6d 65 3a 20 64 65 76 69 63 65 53 74 61 74 65 .........deviceName:.deviceState
27fa0 2e 6e 61 6d 65 2c 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 65 76 69 .name,......................devi
27fc0 63 65 46 6c 61 67 73 3a 20 64 65 76 69 63 65 53 74 61 74 65 2e 66 6c 61 67 73 2c 0d 0a 20 20 20 ceFlags:.deviceState.flags,.....
27fe0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 76 61 72 69 61 6e 74 73 3a 20 6e 65 77 20 49 .................variants:.new.I
28000 6e 74 65 72 6e 65 64 53 74 72 69 6e 67 28 64 65 76 69 63 65 53 74 61 74 65 2e 76 61 72 69 61 6e nternedString(deviceState.varian
28020 74 73 29 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 20 20 20 20 20 20 20 20 20 20 ts));..............}............
28040 20 20 63 61 74 63 68 20 28 45 78 63 65 70 74 69 6f 6e 20 65 78 63 65 70 74 69 6f 6e 29 0d 0a 20 ..catch.(Exception.exception)...
28060 20 20 20 20 20 20 20 20 20 20 20 7b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 ...........{..................De
28080 62 75 67 2e 4c 6f 67 45 72 72 6f 72 28 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 bug.LogError(...................
280a0 20 20 20 24 22 43 6f 75 6c 64 20 6e 6f 74 20 72 65 63 72 65 61 74 65 20 69 6e 70 75 74 20 64 65 ...$"Could.not.recreate.input.de
280c0 76 69 63 65 20 27 7b 64 65 76 69 63 65 53 74 61 74 65 2e 64 65 73 63 72 69 70 74 69 6f 6e 7d 27 vice.'{deviceState.description}'
280e0 20 77 69 74 68 20 6c 61 79 6f 75 74 20 27 7b 64 65 76 69 63 65 53 74 61 74 65 2e 6c 61 79 6f 75 .with.layout.'{deviceState.layou
28100 74 7d 27 20 61 6e 64 20 76 61 72 69 61 6e 74 73 20 27 7b 64 65 76 69 63 65 53 74 61 74 65 2e 76 t}'.and.variants.'{deviceState.v
28120 61 72 69 61 6e 74 73 7d 27 20 61 66 74 65 72 20 64 6f 6d 61 69 6e 20 72 65 6c 6f 61 64 22 29 3b ariants}'.after.domain.reload");
28140 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 44 65 62 75 67 2e 4c 6f 67 45 78 63 65 70 ..................Debug.LogExcep
28160 74 69 6f 6e 28 65 78 63 65 70 74 69 6f 6e 29 3b 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 tion(exception);................
28180 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 20 2f 2f 20 44 6f 6e 27 74 20 74 72 79 20 61 67 61 69 ..return.true;.//.Don't.try.agai
281a0 6e 2e 0d 0a 20 20 20 20 20 20 20 20 20 20 20 20 7d 0d 0a 0d 0a 20 20 20 20 20 20 20 20 20 20 20 n...............}...............
281c0 20 64 65 76 69 63 65 53 74 61 74 65 2e 52 65 73 74 6f 72 65 28 64 65 76 69 63 65 29 3b 0d 0a 20 .deviceState.Restore(device);...
281e0 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 74 72 75 65 3b 0d 0a 20 20 20 20 20 20 20 ...........return.true;.........
28200 20 7d 0d 0a 0d 0a 23 65 6e 64 69 66 20 2f 2f 20 55 4e 49 54 59 5f 45 44 49 54 4f 52 20 7c 7c 20 .}....#endif.//.UNITY_EDITOR.||.
28220 44 45 56 45 4c 4f 50 4d 45 4e 54 5f 42 55 49 4c 44 0d 0a 20 20 20 20 7d 0d 0a 7d 0d 0a 00 00 00 DEVELOPMENT_BUILD......}..}.....
28240 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c 00 00 00 49 6e 70 75 74 4d 61 6e ........................InputMan
28260 61 67 65 72 17 00 00 00 55 6e 69 74 79 45 6e 67 69 6e 65 2e 49 6e 70 75 74 53 79 73 74 65 6d 00 ager....UnityEngine.InputSystem.