com.github.moaxcp.x11.protocol.xkb.KeyVModMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of x11-protocol-xkb Show documentation
Show all versions of x11-protocol-xkb Show documentation
An implementation of the x11 xkb protocol in java
The newest version!
package com.github.moaxcp.x11.protocol.xkb;
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.NonNull;
import lombok.Value;
@Value
@Builder
public class KeyVModMap implements XStruct {
public static final String PLUGIN_NAME = "xkb";
private byte keycode;
private short vmods;
public static KeyVModMap readKeyVModMap(X11Input in) throws IOException {
KeyVModMap.KeyVModMapBuilder javaBuilder = KeyVModMap.builder();
byte keycode = in.readCard8();
byte[] pad1 = in.readPad(1);
short vmods = in.readCard16();
javaBuilder.keycode(keycode);
javaBuilder.vmods(vmods);
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard8(keycode);
out.writePad(1);
out.writeCard16(vmods);
}
public boolean isVmodsEnabled(@NonNull VMod... maskEnums) {
for(VMod m : maskEnums) {
if(!m.isEnabled(vmods)) {
return false;
}
}
return true;
}
@Override
public int getSize() {
return 4;
}
public String getPluginName() {
return PLUGIN_NAME;
}
public static class KeyVModMapBuilder {
public boolean isVmodsEnabled(@NonNull VMod... maskEnums) {
for(VMod m : maskEnums) {
if(!m.isEnabled(vmods)) {
return false;
}
}
return true;
}
public KeyVModMap.KeyVModMapBuilder vmodsEnable(VMod... maskEnums) {
for(VMod m : maskEnums) {
vmods((short) m.enableFor(vmods));
}
return this;
}
public KeyVModMap.KeyVModMapBuilder vmodsDisable(VMod... maskEnums) {
for(VMod m : maskEnums) {
vmods((short) m.disableFor(vmods));
}
return this;
}
public int getSize() {
return 4;
}
}
}