Initial Commit

This commit is contained in:
Mark Milligan
2021-01-14 16:28:24 -06:00
parent 21c28201c5
commit 1334c110ff
318 changed files with 24160 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
package com.lanternsoftware.uirt;
import com.lanternsoftware.uirt.model.UIRTConfig;
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public class UsbUirt {
private static String off = "0000 006D 0000 00BF 0080 0040 0010 0030 0010 0030 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0030 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0030 0010 0010 0010 0030 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0030 0010 0010 0010 0030 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0030 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0030 0010 0010 0010 0030 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 01AF 007F 0040 0010 0030 0010 0030 0010 0010 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0030 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0030 0010 0010 0010 0030 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0030 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0010 0F85";
private UirtLibrary lib;
private Pointer handle;
public interface UirtLibrary extends Library {
interface ReceiveProc extends StdCallLibrary.StdCallCallback {
boolean callback(Pointer _event, Pointer _userData);
}
interface LearnProc extends StdCallLibrary.StdCallCallback {
boolean callback(int progress, int _sigQuality, long carrierFreq, Pointer _userData);
}
Pointer UUIRTOpen();
boolean UUIRTClose(Pointer _handle);
boolean UUIRTGetDrvVersion(IntByReference _version);
boolean UUIRTGetUUIRTConfig(Pointer _handle, UIRTConfig.ByReference _config);
boolean UUIRTSetReceiveCallback(Pointer _handle, ReceiveProc _proc, Pointer _userData);
boolean UUIRTSetRawReceiveCallback(Pointer _handle, ReceiveProc _proc, Pointer _userData);
boolean UUIRTLearnIR(Pointer _handle, int codeFormat, PointerByReference irCode, LearnProc progressProc, Pointer _userData, IntByReference _abort, int _param1, Pointer reserved0, Pointer reserved1);
boolean UUIRTTransmitIR(Pointer _handle, String _code, int _codeFormat, int repeatCount_, int _inactivityWaitTime, Pointer _event, Pointer reserved0, Pointer reserved1);
}
public void startup() {
lib = Native.load("uuirtdrv", UirtLibrary.class, W32APIOptions.ASCII_OPTIONS);
handle = lib.UUIRTOpen();
}
public void shutdown() {
if (isStarted())
lib.UUIRTClose(handle);
lib = null;
}
public int getDriverVersion() {
if (!isStarted())
return 0;
IntByReference version = new IntByReference();
lib.UUIRTGetDrvVersion(version);
return version.getValue();
}
public UIRTConfig getConfig() {
if (!isStarted())
return null;
UIRTConfig.ByReference configRef = new UIRTConfig.ByReference();
lib.UUIRTGetUUIRTConfig(handle, configRef);
return configRef;
}
public void setReceiveCallback(UirtLibrary.ReceiveProc _proc) {
if (isStarted())
lib.UUIRTSetReceiveCallback(handle, _proc, null);
}
public void setRawReceiveCallback(UirtLibrary.ReceiveProc _proc) {
if (isStarted())
lib.UUIRTSetRawReceiveCallback(handle, _proc, null);
}
public String learnCode(UirtLibrary.LearnProc _proc) {
PointerByReference codeRef = new PointerByReference();
lib.UUIRTLearnIR(handle, 0, codeRef, _proc, null, null, 0, null, null);
Pointer code = codeRef.getValue();
return code == null ? null : code.getString(0);
}
public boolean transmitIR(boolean _pronto, int _repeatCnt, int _inactivityWaitTime, String _code) {
PointerByReference result = new PointerByReference();
return lib.UUIRTTransmitIR(handle, _code, _pronto?0x0010:0x0000, _repeatCnt, _inactivityWaitTime, null, null, null);
}
private boolean isStarted() {
return (lib != null) && (handle != null);
}
public static void main(String[] args) {
UsbUirt uirt = new UsbUirt();
uirt.startup();
uirt.transmitIR(true, 3, 0, off);
uirt.shutdown();
}
}

View File

@@ -0,0 +1,51 @@
package com.lanternsoftware.uirt.model;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
public class UIRTConfig extends Structure {
public static class ByReference extends UIRTConfig implements Structure.ByReference {}
public boolean ledRX;
public boolean ledTX;
public boolean legacyRX;
public UIRTConfig() {
}
public UIRTConfig(Pointer _value) {
super(_value);
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList("ledRX", "ledTX", "legacyRX");
}
public boolean isLedRX() {
return ledRX;
}
public void setLedRX(boolean _ledRX) {
ledRX = _ledRX;
}
public boolean isLedTX() {
return ledTX;
}
public void setLedTX(boolean _ledTX) {
ledTX = _ledTX;
}
public boolean isLegacyRX() {
return legacyRX;
}
public void setLegacyRX(boolean _legacyRX) {
legacyRX = _legacyRX;
}
}

View File

@@ -0,0 +1,26 @@
package com.lanternsoftware.uirt.model;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import java.util.Arrays;
import java.util.List;
public class UIRTEvent extends Structure {
public static class ByReference extends UIRTEvent implements Structure.ByReference {}
public int code;
public String data;
public UIRTEvent() {
}
public UIRTEvent(Pointer p) {
super(p);
}
@Override
protected List<String> getFieldOrder() {
return Arrays.asList("code", "data");
}
}