예제 #1
0
    public override void Load(InstrumentData d)
    {
        TouchPadData data = d as TouchPadData;

        base.Load(data);
        output.ID = data.jackOutID;
    }
예제 #2
0
    public override InstrumentData GetData()
    {
        TouchPadData data = new TouchPadData();

        data.deviceType = menuItem.deviceType.TouchPad;
        GetTransformData(data);

        data.jackOutID = output.transform.GetInstanceID();
        return(data);
    }
예제 #3
0
 public ControllerState(byte[] data, bool isUsb)
 {
     IsOk = false;
     var offset = 0;
     if(!isUsb)
         offset += 2;
     LeftX = data[offset + 1];
     LeftY = data[offset + 2];
     RightX = data[offset + 3];
     RightY = data[offset + 4];
     var main = (MainButtons)data[offset + 5];
     Triangle = (main & MainButtons.Triangle) == MainButtons.Triangle;
     Circle = (main & MainButtons.Circle) == MainButtons.Circle;
     Cross = (main & MainButtons.Cross) == MainButtons.Cross;
     Square = (main & MainButtons.Square) == MainButtons.Square;
     DpadUp = DpadDown = DpadLeft = DpadRight = false; // Default all dpad buttons to false
     switch((DpadButtons)(data[offset + 5] & 0x0F)) {
         case DpadButtons.Up:
             DpadUp = true;
             break;
         case DpadButtons.Down:
             DpadDown = true;
             break;
         case DpadButtons.Right:
             DpadRight = true;
             break;
         case DpadButtons.Left:
             DpadLeft = true;
             break;
         case DpadButtons.UpRight:
             DpadUp = true;
             DpadRight = true;
             break;
         case DpadButtons.UpLeft:
             DpadUp = true;
             DpadLeft = true;
             break;
         case DpadButtons.DownRight:
             DpadDown = true;
             DpadRight = true;
             break;
         case DpadButtons.DownLeft:
             DpadDown = true;
             DpadLeft = true;
             break;
     }
     var secondary = (SecondaryButtons)data[offset + 6];
     R3 = (secondary & SecondaryButtons.R3) == SecondaryButtons.R3;
     L3 = (secondary & SecondaryButtons.L3) == SecondaryButtons.L3;
     Options = (secondary & SecondaryButtons.Options) == SecondaryButtons.Options;
     Share = (secondary & SecondaryButtons.Share) == SecondaryButtons.Share;
     R1 = (secondary & SecondaryButtons.R1) == SecondaryButtons.R1;
     L1 = (secondary & SecondaryButtons.L1) == SecondaryButtons.L1;
     PlaystationButton = (data[offset + 7] & 0x1) != 0;
     TouchPadButton = (data[offset + 7] & 0x2) != 0;
     L2State = data[offset + 8];
     R2State = data[offset + 9];
     AccelX = BitConverter.ToInt16(data, offset + 13);
     AccelY = BitConverter.ToInt16(data, offset + 15);
     AccelZ = BitConverter.ToInt16(data, offset + 17);
     GyroX = BitConverter.ToInt16(data, offset + 19);
     GyroY = BitConverter.ToInt16(data, offset + 21);
     GyroZ = BitConverter.ToInt16(data, offset + 23);
     if(isUsb)
         BatteryLevel = (data[offset + 30] - 16) * 10;
     else
         BatteryLevel = (data[offset + 30] + 1) * 10;
     if(BatteryLevel > 100)
         BatteryLevel = 100;
     else if(BatteryLevel < 0)
         BatteryLevel = 0;
     TouchPad = new TouchPadData(data, isUsb);
     IsOk = TouchPad.IsOk;
 }