public void SetJoyconButton( HidControllerId ControllerId, HidControllerLayouts ControllerLayout, HidControllerButtons Buttons, HidJoystickPosition LeftStick, HidJoystickPosition RightStick) { Buttons |= UpdateStickButtons(LeftStick, RightStick); long ControllerOffset = HidPosition + HidControllersOffset; ControllerOffset += (int)ControllerId * HidControllerSize; ControllerOffset += HidControllerHeaderSize; ControllerOffset += (int)ControllerLayout * HidControllerLayoutsSize; long LastEntry = Device.Memory.ReadInt64(ControllerOffset + 0x10); long CurrEntry = (LastEntry + 1) % HidEntryCount; long Timestamp = GetTimestamp(); Device.Memory.WriteInt64(ControllerOffset + 0x0, Timestamp); Device.Memory.WriteInt64(ControllerOffset + 0x8, HidEntryCount); Device.Memory.WriteInt64(ControllerOffset + 0x10, CurrEntry); Device.Memory.WriteInt64(ControllerOffset + 0x18, HidEntryCount - 1); ControllerOffset += HidControllersLayoutHeaderSize; long LastEntryOffset = ControllerOffset + LastEntry * HidControllersInputEntrySize; ControllerOffset += CurrEntry * HidControllersInputEntrySize; long SampleCounter = Device.Memory.ReadInt64(LastEntryOffset) + 1; Device.Memory.WriteInt64(ControllerOffset + 0x0, SampleCounter); Device.Memory.WriteInt64(ControllerOffset + 0x8, SampleCounter); Device.Memory.WriteInt64(ControllerOffset + 0x10, (uint)Buttons); Device.Memory.WriteInt32(ControllerOffset + 0x18, LeftStick.DX); Device.Memory.WriteInt32(ControllerOffset + 0x1c, LeftStick.DY); Device.Memory.WriteInt32(ControllerOffset + 0x20, RightStick.DX); Device.Memory.WriteInt32(ControllerOffset + 0x24, RightStick.DY); Device.Memory.WriteInt64(ControllerOffset + 0x28, (uint)HidControllerConnState.Controller_State_Connected | (uint)HidControllerConnState.Controller_State_Wired); }
public HidControllerButtons UpdateStickButtons( HidJoystickPosition leftStick, HidJoystickPosition rightStick) { HidControllerButtons result = 0; if (rightStick.Dx < 0) { result |= HidControllerButtons.RStickLeft; } if (rightStick.Dx > 0) { result |= HidControllerButtons.RStickRight; } if (rightStick.Dy < 0) { result |= HidControllerButtons.RStickDown; } if (rightStick.Dy > 0) { result |= HidControllerButtons.RStickUp; } if (leftStick.Dx < 0) { result |= HidControllerButtons.LStickLeft; } if (leftStick.Dx > 0) { result |= HidControllerButtons.LStickRight; } if (leftStick.Dy < 0) { result |= HidControllerButtons.LStickDown; } if (leftStick.Dy > 0) { result |= HidControllerButtons.LStickUp; } return(result); }
private HidControllerButtons UpdateStickButtons( HidJoystickPosition LeftStick, HidJoystickPosition RightStick) { HidControllerButtons Result = 0; if (RightStick.DX < 0) { Result |= HidControllerButtons.KEY_RSTICK_LEFT; } if (RightStick.DX > 0) { Result |= HidControllerButtons.KEY_RSTICK_RIGHT; } if (RightStick.DY < 0) { Result |= HidControllerButtons.KEY_RSTICK_DOWN; } if (RightStick.DY > 0) { Result |= HidControllerButtons.KEY_RSTICK_UP; } if (LeftStick.DX < 0) { Result |= HidControllerButtons.KEY_LSTICK_LEFT; } if (LeftStick.DX > 0) { Result |= HidControllerButtons.KEY_LSTICK_RIGHT; } if (LeftStick.DY < 0) { Result |= HidControllerButtons.KEY_LSTICK_DOWN; } if (LeftStick.DY > 0) { Result |= HidControllerButtons.KEY_LSTICK_UP; } return(Result); }
private HidControllerButtons UpdateStickButtons( HidJoystickPosition LeftStick, HidJoystickPosition RightStick) { HidControllerButtons Result = 0; if (RightStick.DX < 0) { Result |= HidControllerButtons.RStickLeft; } if (RightStick.DX > 0) { Result |= HidControllerButtons.RStickRight; } if (RightStick.DY < 0) { Result |= HidControllerButtons.RStickDown; } if (RightStick.DY > 0) { Result |= HidControllerButtons.RStickUp; } if (LeftStick.DX < 0) { Result |= HidControllerButtons.LStickLeft; } if (LeftStick.DX > 0) { Result |= HidControllerButtons.LStickRight; } if (LeftStick.DY < 0) { Result |= HidControllerButtons.LStickDown; } if (LeftStick.DY > 0) { Result |= HidControllerButtons.LStickUp; } return(Result); }
protected long WriteInput( HidControllerButtons buttons, HidJoystickPosition leftStick, HidJoystickPosition rightStick, HidControllerLayouts controllerLayout) { long controllerOffset = Offset + HidControllerHeaderSize; controllerOffset += (int)controllerLayout * HidControllerLayoutsSize; long lastEntry = Device.Memory.ReadInt64(controllerOffset + 0x10); long currEntry = (lastEntry + 1) % HidEntryCount; long timestamp = GetTimestamp(); Device.Memory.WriteInt64(controllerOffset + 0x00, timestamp); Device.Memory.WriteInt64(controllerOffset + 0x08, HidEntryCount); Device.Memory.WriteInt64(controllerOffset + 0x10, currEntry); Device.Memory.WriteInt64(controllerOffset + 0x18, HidEntryCount - 1); controllerOffset += HidControllersLayoutHeaderSize; long lastEntryOffset = controllerOffset + lastEntry * HidControllersInputEntrySize; controllerOffset += currEntry * HidControllersInputEntrySize; long sampleCounter = Device.Memory.ReadInt64(lastEntryOffset) + 1; Device.Memory.WriteInt64(controllerOffset + 0x00, sampleCounter); Device.Memory.WriteInt64(controllerOffset + 0x08, sampleCounter); Device.Memory.WriteInt64(controllerOffset + 0x10, (uint)buttons); Device.Memory.WriteInt32(controllerOffset + 0x18, leftStick.Dx); Device.Memory.WriteInt32(controllerOffset + 0x1c, leftStick.Dy); Device.Memory.WriteInt32(controllerOffset + 0x20, rightStick.Dx); Device.Memory.WriteInt32(controllerOffset + 0x24, rightStick.Dy); return(controllerOffset); }
protected long WriteInput( HidControllerButtons Buttons, HidJoystickPosition LeftStick, HidJoystickPosition RightStick, HidControllerLayouts ControllerLayout) { long ControllerOffset = Offset + HidControllerHeaderSize; ControllerOffset += (int)ControllerLayout * HidControllerLayoutsSize; long LastEntry = Device.Memory.ReadInt64(ControllerOffset + 0x10); long CurrEntry = (LastEntry + 1) % HidEntryCount; long Timestamp = GetTimestamp(); Device.Memory.WriteInt64(ControllerOffset + 0x00, Timestamp); Device.Memory.WriteInt64(ControllerOffset + 0x08, HidEntryCount); Device.Memory.WriteInt64(ControllerOffset + 0x10, CurrEntry); Device.Memory.WriteInt64(ControllerOffset + 0x18, HidEntryCount - 1); ControllerOffset += HidControllersLayoutHeaderSize; long LastEntryOffset = ControllerOffset + LastEntry * HidControllersInputEntrySize; ControllerOffset += CurrEntry * HidControllersInputEntrySize; long SampleCounter = Device.Memory.ReadInt64(LastEntryOffset) + 1; Device.Memory.WriteInt64(ControllerOffset + 0x00, SampleCounter); Device.Memory.WriteInt64(ControllerOffset + 0x08, SampleCounter); Device.Memory.WriteInt64(ControllerOffset + 0x10, (uint)Buttons); Device.Memory.WriteInt32(ControllerOffset + 0x18, LeftStick.DX); Device.Memory.WriteInt32(ControllerOffset + 0x1c, LeftStick.DY); Device.Memory.WriteInt32(ControllerOffset + 0x20, RightStick.DX); Device.Memory.WriteInt32(ControllerOffset + 0x24, RightStick.DY); return(ControllerOffset); }
public abstract void SendInput( HidControllerButtons buttons, HidJoystickPosition leftStick, HidJoystickPosition rightStick);