MOUSE_INPUT_DATA的Java等价物

Java Equivalent of MOUSE_INPUT_DATA

本文关键字:Java 等价物 DATA INPUT MOUSE      更新时间:2023-10-16

我正在尝试将C++MOUSE_INPUT_DATA结构转换为JNA。

typedef struct _MOUSE_INPUT_DATA {
  USHORT UnitId;
  USHORT Flags;
  union {
    ULONG  Buttons;
    struct {
      USHORT ButtonFlags;
      USHORT ButtonData;
    };
  };
  ULONG  RawButtons;
  LONG   LastX;
  LONG   LastY;
  ULONG  ExtraInformation;
} MOUSE_INPUT_DATA, *PMOUSE_INPUT_DATA;

我的最佳猜测

public static class _MOUSE_INPUT_DATA extends Structure {
        public static class ByReference extends _MOUSE_INPUT_DATA implements Structure.ByReference {
            public ByReference() {
            }
            public ByReference(Pointer memory) {
                super(memory);
            }
        }
        public _MOUSE_INPUT_DATA() {
        }
        public _MOUSE_INPUT_DATA(Pointer memory) {
            super(memory);
            read();
        }
        public WinDef.WORD unitId;
        public WinDef.WORD flags;
        public MOUSE_INPUT_DATA_UNION_STRUCT union = new MOUSE_INPUT_DATA_UNION_STRUCT();
        public WinDef.ULONG rawButtons;
        public WinDef.LONG lastX;
        public WinDef.LONG lastY;
        public BaseTSD.ULONG_PTR extraInformation;
        protected List getFieldOrder() {
            return Arrays.asList(new String[]{"unitId", "flags", "union", "rawButtons", "lastX", "lastY", "extraInformation"});
        }
    }
    public static class MOUSE_INPUT_DATA_UNION_STRUCT extends Structure {
        public static class ByReference extends MOUSE_INPUT_DATA_UNION_STRUCT implements Structure.ByReference {
            public ByReference() {
            }
            public ByReference(Pointer memory) {
                super(memory);
            }
        }
        public MOUSE_INPUT_DATA_UNION_STRUCT() {
        }
        public MOUSE_INPUT_DATA_UNION_STRUCT(Pointer memory) {
            super(memory);
            read();
        }
        public _MOUSE_INPUT_DATA_UNION_STUCT_DETAIL union = new _MOUSE_INPUT_DATA_UNION_STUCT_DETAIL();
        protected List getFieldOrder() {
            return Arrays.asList(new String[]{"union"});
        }
        public static class _MOUSE_INPUT_DATA_UNION_STUCT_DETAIL extends Union {
            public _MOUSE_INPUT_DATA_UNION_STUCT_DETAIL() {
            }
            public _MOUSE_INPUT_DATA_UNION_STUCT_DETAIL(Pointer memory) {
                super(memory);
                read();
            }
            public WinDef.ULONG buttons;
            public WinDef.ULONG flagsAndData;
        }
    }

我正在使用它在自定义驱动程序中传递这个结构。我有一个Delphi应用程序,它可以很好地使用驱动程序和这个结构,但JAVA不是。

有人能告诉我哪里错了吗?

Ок。我找到了中间结果。

public class MOUSE_INPUT_DATA extends Structure {
    public static class ByReference extends MOUSE_INPUT_DATA implements Structure.ByReference {
        public ByReference() {
        }
        public ByReference(Pointer memory) {
            super(memory);
        }
    }
    public MOUSE_INPUT_DATA() {
    }
    public MOUSE_INPUT_DATA(Pointer memory) {
        super(memory);
        read();
    }
    public WinDef.WORD UnitId;
    public WinDef.WORD Flags;
    public WinDef.DWORD Buttons;
    public WinDef.DWORD RawButtons;
    public WinDef.DWORD LastX;
    public WinDef.DWORD LastY;
    public WinDef.DWORD ExtraInformation;
    protected List getFieldOrder() {
        return Arrays.asList(new String[]{"UnitId", "Flags", "Buttons", "RawButtons", "LastX", "LastY", "ExtraInformation"});
    }
}