Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add usage ID and fix getUsagePage() on macOS #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/purejavahidapi/HidDeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class HidDeviceInfo {
protected short m_ProductId;
protected short m_ReleaseNumber;
protected short m_UsagePage;
protected short m_UsageId;
protected String m_SerialNumberString;
protected String m_ManufactureString;
protected String m_ProductString;
Expand Down Expand Up @@ -122,6 +123,20 @@ public short getReleaseNumber() {
public short getUsagePage() {
return m_UsagePage;
}

/**
* This method returns the 16 bit Usage ID number of the device.
* <p>
* Note that the return type is <code>short</code> so when compared against
* literals or variables of type <code>int</code> sign extension interferes
* and thus it is necessary to cast the <code>int</code> type to
* <code>short</code>
*
* @return the 16 bit Usage Page number
*/
public short getUsageId() {
return m_UsageId;
}

/**
* This method returns the Manufacturer String if available otherwise null
Expand Down
4 changes: 2 additions & 2 deletions src/purejavahidapi/macosx/HidDeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public HidDeviceInfo(IOHIDDeviceRef dev) {
m_SerialNumberString = getStringProperty(dev, CFSTR(kIOHIDSerialNumberKey));
m_ProductString = getStringProperty(dev, CFSTR(kIOHIDProductKey));
m_ReleaseNumber = (short) getIntProperty(dev, CFSTR(kIOHIDVersionNumberKey));
m_UsagePage = (short) getIntProperty(dev, CFSTR(kIOHIDPrimaryUsageKey));

m_UsagePage = (short) getIntProperty(dev, CFSTR(kIOHIDPrimaryUsagePageKey));
m_UsageId = (short) getIntProperty(dev, CFSTR(kIOHIDPrimaryUsageKey));
}

}
1 change: 1 addition & 0 deletions src/purejavahidapi/windows/HidDeviceInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public HidDeviceInfo(String path, String deviceId, HANDLE handle, HIDD_ATTRIBUTE
if (HidD_GetPreparsedData(handle, ppd)) {
if (HidP_GetCaps(ppd[0], caps) == HIDP_STATUS_SUCCESS) {
m_UsagePage = caps.UsagePage;
m_UsageId = caps.Usage;
}

HidD_FreePreparsedData(ppd[0]);
Expand Down