All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.moaxcp.x11.protocol.xinput.DeviceEnableCtrl Maven / Gradle / Ivy

There is a newer version: 0.18.2
Show newest version
package com.github.moaxcp.x11.protocol.xinput;

import com.github.moaxcp.x11.protocol.X11Input;
import com.github.moaxcp.x11.protocol.X11Output;
import com.github.moaxcp.x11.protocol.XStruct;
import java.io.IOException;
import lombok.Builder;
import lombok.Value;

@Value
@Builder
public class DeviceEnableCtrl implements XStruct {
  public static final String PLUGIN_NAME = "xinput";

  private short controlId;

  private short len;

  private byte enable;

  public static DeviceEnableCtrl readDeviceEnableCtrl(X11Input in) throws IOException {
    DeviceEnableCtrl.DeviceEnableCtrlBuilder javaBuilder = DeviceEnableCtrl.builder();
    short controlId = in.readCard16();
    short len = in.readCard16();
    byte enable = in.readCard8();
    byte[] pad3 = in.readPad(3);
    javaBuilder.controlId(controlId);
    javaBuilder.len(len);
    javaBuilder.enable(enable);
    return javaBuilder.build();
  }

  @Override
  public void write(X11Output out) throws IOException {
    out.writeCard16(controlId);
    out.writeCard16(len);
    out.writeCard8(enable);
    out.writePad(3);
  }

  @Override
  public int getSize() {
    return 8;
  }

  public String getPluginName() {
    return PLUGIN_NAME;
  }

  public static class DeviceEnableCtrlBuilder {
    public DeviceEnableCtrl.DeviceEnableCtrlBuilder controlId(DeviceControl controlId) {
      this.controlId = (short) controlId.getValue();
      return this;
    }

    public DeviceEnableCtrl.DeviceEnableCtrlBuilder controlId(short controlId) {
      this.controlId = controlId;
      return this;
    }

    public int getSize() {
      return 8;
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy