com.github.moaxcp.x11.protocol.xinput.DeviceTimeCoord Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of x11-protocol-xinput Show documentation
Show all versions of x11-protocol-xinput Show documentation
An implementation of the x11 xinput protocol in java
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 java.util.List;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@Value
@Builder
public class DeviceTimeCoord implements XStruct {
public static final String PLUGIN_NAME = "xinput";
private int time;
@NonNull
private List axisvalues;
public static DeviceTimeCoord readDeviceTimeCoord(byte numAxes, X11Input in) throws IOException {
DeviceTimeCoord.DeviceTimeCoordBuilder javaBuilder = DeviceTimeCoord.builder();
int time = in.readCard32();
List axisvalues = in.readInt32(numAxes);
javaBuilder.time(time);
javaBuilder.axisvalues(axisvalues);
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard32(time);
out.writeInt32(axisvalues);
}
@Override
public int getSize() {
return 4 + 4 * axisvalues.size();
}
public String getPluginName() {
return PLUGIN_NAME;
}
public static class DeviceTimeCoordBuilder {
public int getSize() {
return 4 + 4 * axisvalues.size();
}
}
}