protected void InitializeExtension() { try { WriteMemory(0x04a40040, 0); // Set the encryption-key to 0. } catch (TimeoutException) { if (IsConnected) { throw; } return; } byte[] extensionTypeBytes = ReadMemory(0x04a400fe, 2); extensionTypeBytes[0] = (byte)((extensionTypeBytes[0] ^ 0x17) + 0x17 & 0xFF); extensionTypeBytes[1] = (byte)((extensionTypeBytes[1] ^ 0x17) + 0x17 & 0xFF); ushort extensionType = (ushort)(extensionTypeBytes[1] << 8 | extensionTypeBytes[0]); IWiimoteExtension newExtension; switch (extensionType) { case 0x2e2e: newExtension = null; break; case 0xffff: newExtension = new InvalidExtension(this); break; default: IWiimoteExtensionFactory extensionFactory; if (WiimoteExtensionRegistry.TryGetValue(extensionType, out extensionFactory)) { newExtension = extensionFactory.Create(this); } else { newExtension = new UnknownExtension(this); } break; } ReportingMode = ReportingMode.None; _Extension = newExtension; if (_Extension != null) { if (ExtensionAttached != null) { ExtensionAttached(this, new WiimoteExtensionEventArgs(_Extension)); } } }
protected void InitializeExtension() { try { WriteMemory(0x04a40040, 0); // Set the encryption-key to 0. } catch (TimeoutException) { if (IsConnected) throw; return; } byte[] extensionTypeBytes = ReadMemory(0x04a400fe, 2); extensionTypeBytes[0] = (byte)((extensionTypeBytes[0] ^ 0x17) + 0x17 & 0xFF); extensionTypeBytes[1] = (byte)((extensionTypeBytes[1] ^ 0x17) + 0x17 & 0xFF); ushort extensionType = (ushort)(extensionTypeBytes[1] << 8 | extensionTypeBytes[0]); IWiimoteExtension newExtension; switch (extensionType) { case 0x2e2e: newExtension = null; break; case 0xffff: newExtension = new InvalidExtension(this); break; default: IWiimoteExtensionFactory extensionFactory; if (WiimoteExtensionRegistry.TryGetValue(extensionType, out extensionFactory)) newExtension = extensionFactory.Create(this); else newExtension = new UnknownExtension(this); break; } ReportingMode = ReportingMode.None; _Extension = newExtension; if(_Extension != null) { if(ExtensionAttached != null) ExtensionAttached(this, new WiimoteExtensionEventArgs(_Extension)); } }