mirror of
https://github.com/shadowfacts/jinput-arm64.git
synced 2025-12-06 08:01:59 +01:00
no message
This commit is contained in:
parent
61f8b10374
commit
c88f6ab0c6
|
|
@ -1,7 +1,5 @@
|
||||||
package net.java.games.input;
|
package net.java.games.input;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by IntelliJ IDEA.
|
* Created by IntelliJ IDEA.
|
||||||
* User: gpierce
|
* User: gpierce
|
||||||
|
|
@ -9,212 +7,7 @@ import java.util.HashMap;
|
||||||
* Time: 2:57:15 PM
|
* Time: 2:57:15 PM
|
||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class InputController
|
public interface InputController
|
||||||
{
|
{
|
||||||
private OSXEnvironmentPlugin plugin;
|
public void addControllerElement( InputControllerElement element );
|
||||||
private long lpDevice;
|
|
||||||
private long lpQueue;
|
|
||||||
private int queueDepth;
|
|
||||||
private String transportKey;
|
|
||||||
private int vendorID;
|
|
||||||
private int productID;
|
|
||||||
private int version;
|
|
||||||
private String manufacturer;
|
|
||||||
private String productName;
|
|
||||||
private String serialNumber;
|
|
||||||
private int usbLocationID;
|
|
||||||
private int usagePage;
|
|
||||||
private int usage;
|
|
||||||
|
|
||||||
private HashMap controllerElements = new HashMap();
|
|
||||||
|
|
||||||
public InputController( OSXEnvironmentPlugin plugin )
|
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputController(OSXEnvironmentPlugin plugin, long lpDevice, String productName, int usage)
|
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.lpDevice = lpDevice;
|
|
||||||
this.productName = productName;
|
|
||||||
this.usage = usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputController( OSXEnvironmentPlugin plugin, long lpDevice, String transportKey, int vendorID, int productID, int version, String manufacturer, String productName, String serialNumber, int usbLocationID, int usagePage, int usage)
|
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.lpDevice = lpDevice;
|
|
||||||
this.transportKey = transportKey;
|
|
||||||
this.vendorID = vendorID;
|
|
||||||
this.productID = productID;
|
|
||||||
this.version = version;
|
|
||||||
this.manufacturer = manufacturer;
|
|
||||||
this.productName = productName;
|
|
||||||
this.serialNumber = serialNumber;
|
|
||||||
this.usbLocationID = usbLocationID;
|
|
||||||
this.usagePage = usagePage;
|
|
||||||
this.usage = usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLpQueue()
|
|
||||||
{
|
|
||||||
return lpQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLpQueue(long lpQueue)
|
|
||||||
{
|
|
||||||
this.lpQueue = lpQueue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getQueueDepth()
|
|
||||||
{
|
|
||||||
return queueDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQueueDepth(int queueDepth)
|
|
||||||
{
|
|
||||||
this.queueDepth = queueDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getLpDevice()
|
|
||||||
{
|
|
||||||
return lpDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLpDevice(long lpDevice)
|
|
||||||
{
|
|
||||||
this.lpDevice = lpDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTransportKey()
|
|
||||||
{
|
|
||||||
return transportKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTransportKey(String transportKey)
|
|
||||||
{
|
|
||||||
this.transportKey = transportKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVendorID()
|
|
||||||
{
|
|
||||||
return vendorID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVendorID(int vendorID)
|
|
||||||
{
|
|
||||||
this.vendorID = vendorID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getProductID()
|
|
||||||
{
|
|
||||||
return productID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProductID(int productID)
|
|
||||||
{
|
|
||||||
this.productID = productID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getVersion()
|
|
||||||
{
|
|
||||||
return version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVersion(int version)
|
|
||||||
{
|
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getManufacturer()
|
|
||||||
{
|
|
||||||
return manufacturer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setManufacturer(String manufacturer)
|
|
||||||
{
|
|
||||||
this.manufacturer = manufacturer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProductName()
|
|
||||||
{
|
|
||||||
return productName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProductName(String productName)
|
|
||||||
{
|
|
||||||
this.productName = productName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSerialNumber()
|
|
||||||
{
|
|
||||||
return serialNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSerialNumber(String serialNumber)
|
|
||||||
{
|
|
||||||
this.serialNumber = serialNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUsbLocationID()
|
|
||||||
{
|
|
||||||
return usbLocationID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsbLocationID(int usbLocationID)
|
|
||||||
{
|
|
||||||
this.usbLocationID = usbLocationID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUsagePage()
|
|
||||||
{
|
|
||||||
return usagePage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsagePage(int usagePage)
|
|
||||||
{
|
|
||||||
this.usagePage = usagePage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUsage()
|
|
||||||
{
|
|
||||||
return usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsage(int usage)
|
|
||||||
{
|
|
||||||
this.usage = usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HashMap getControllerElements()
|
|
||||||
{
|
|
||||||
return controllerElements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addControllerElement( InputControllerElement controllerElement )
|
|
||||||
{
|
|
||||||
controllerElements.put( new Long(controllerElement.getHidCookie()), controllerElement );
|
|
||||||
}
|
|
||||||
|
|
||||||
public InputControllerElement getControllerElement( long hidCookie )
|
|
||||||
{
|
|
||||||
return (InputControllerElement) controllerElements.get( new Long( hidCookie ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void openDevice()
|
|
||||||
{
|
|
||||||
this.lpQueue = plugin.openDevice( this.lpDevice, 32 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeDevice()
|
|
||||||
{
|
|
||||||
plugin.closeDevice( this.lpDevice, this.lpQueue );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void pollDevice()
|
|
||||||
{
|
|
||||||
plugin.pollDevice( this.lpQueue );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ public class InputControllerElement
|
||||||
{
|
{
|
||||||
private long hidCookie;
|
private long hidCookie;
|
||||||
private int elementType;
|
private int elementType;
|
||||||
private String elementName;
|
private int usagePage;
|
||||||
|
private int usage;
|
||||||
|
|
||||||
private int rawMin;
|
private int rawMin;
|
||||||
private int rawMax;
|
private int rawMax;
|
||||||
|
|
@ -30,22 +31,23 @@ public class InputControllerElement
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputControllerElement(long hidCookie, int elementType, String elementName,
|
public InputControllerElement(long hidCookie, int elementType, int usage, int usagePage,
|
||||||
int rawMin, int rawMax, int scaledMin, int scaledMax,
|
int rawMin, int rawMax, int scaledMin, int scaledMax,
|
||||||
int dataBitSize, boolean relative, boolean wrapping,
|
int dataBitSize, boolean isRelative, boolean isWrapping,
|
||||||
boolean nonLinear, boolean hasPreferredState, boolean hasNullState )
|
boolean isNonLinear, boolean hasPreferredState, boolean hasNullState )
|
||||||
{
|
{
|
||||||
this.hidCookie = hidCookie;
|
this.hidCookie = hidCookie;
|
||||||
this.elementType = elementType;
|
this.elementType = elementType;
|
||||||
this.elementName = elementName;
|
this.usage = usage;
|
||||||
|
this.usagePage = usagePage;
|
||||||
this.rawMin = rawMin;
|
this.rawMin = rawMin;
|
||||||
this.rawMax = rawMax;
|
this.rawMax = rawMax;
|
||||||
this.scaledMin = scaledMin;
|
this.scaledMin = scaledMin;
|
||||||
this.scaledMax = scaledMax;
|
this.scaledMax = scaledMax;
|
||||||
this.dataBitSize = dataBitSize;
|
this.dataBitSize = dataBitSize;
|
||||||
isRelative = relative;
|
this.isRelative = isRelative;
|
||||||
isWrapping = wrapping;
|
this.isWrapping = isWrapping;
|
||||||
isNonLinear = nonLinear;
|
this.isNonLinear = isNonLinear;
|
||||||
this.hasPreferredState = hasPreferredState;
|
this.hasPreferredState = hasPreferredState;
|
||||||
this.hasNullState = hasNullState;
|
this.hasNullState = hasNullState;
|
||||||
}
|
}
|
||||||
|
|
@ -70,14 +72,24 @@ public class InputControllerElement
|
||||||
this.elementType = elementType;
|
this.elementType = elementType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getElementName()
|
public int getUsagePage()
|
||||||
{
|
{
|
||||||
return elementName;
|
return usagePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElementName(String elementName)
|
public void setUsagePage(int usagePage)
|
||||||
{
|
{
|
||||||
this.elementName = elementName;
|
this.usagePage = usagePage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUsage()
|
||||||
|
{
|
||||||
|
return usage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsage(int usage)
|
||||||
|
{
|
||||||
|
this.usage = usage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRawMin()
|
public int getRawMin()
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,60 @@ public class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugi
|
||||||
public native void closeDevice( long lpDevice, long lpInputQueue );
|
public native void closeDevice( long lpDevice, long lpInputQueue );
|
||||||
public native void pollDevice( long lpInputQueue );
|
public native void pollDevice( long lpInputQueue );
|
||||||
|
|
||||||
private static final int HID_DEVICE_MOUSE = 0x02;
|
public static final int HID_DEVICE_MOUSE = 0x02;
|
||||||
private static final int HID_DEVICE_JOYSTICK = 0x04;
|
public static final int HID_DEVICE_JOYSTICK = 0x04;
|
||||||
private static final int HID_DEVICE_GAMEPAD = 0x05;
|
public static final int HID_DEVICE_GAMEPAD = 0x05;
|
||||||
private static final int HID_DEVICE_KEYBOARD = 0x06;
|
public static final int HID_DEVICE_KEYBOARD = 0x06;
|
||||||
|
|
||||||
|
|
||||||
|
public static final int HID_USAGE_POINTER = 0x01;
|
||||||
|
public static final int HID_USAGE_XAXIS = 0x30;
|
||||||
|
public static final int HID_USAGE_YAXIS = 0x31;
|
||||||
|
public static final int HID_USAGE_ZAXIS = 0x32;
|
||||||
|
public static final int HID_USAGE_XAXIS_ROTATION = 0x33;
|
||||||
|
public static final int HID_USAGE_YAXIS_ROTATION = 0x34;
|
||||||
|
public static final int HID_USAGE_ZAXIS_ROTATION = 0x35;
|
||||||
|
public static final int HID_USAGE_SLIDER = 0x36;
|
||||||
|
public static final int HID_USAGE_DIAL = 0x37;
|
||||||
|
public static final int HID_USAGE_WHEEL = 0x38;
|
||||||
|
public static final int HID_USAGE_HAT = 0x39;
|
||||||
|
public static final int HID_USAGE_DPAD_UP = 0x90;
|
||||||
|
public static final int HID_USAGE_DPAD_DOWN = 0x91;
|
||||||
|
public static final int HID_USAGE_DPAD_LEFT = 0x92;
|
||||||
|
public static final int HID_USAGE_DPAD_RIGHT = 0x93;
|
||||||
|
|
||||||
|
public static final int HID_USAGEPAGE_UNDEFINED = 0x00;
|
||||||
|
public static final int HID_USAGEPAGE_GENERICDESKTOP = 0x01;
|
||||||
|
public static final int HID_USAGEPAGE_SIMULATION = 0x02;
|
||||||
|
public static final int HID_USAGEPAGE_VR = 0x03;
|
||||||
|
public static final int HID_USAGEPAGE_SPORT = 0x04;
|
||||||
|
public static final int HID_USAGEPAGE_GAME = 0x05;
|
||||||
|
public static final int HID_USAGEPAGE_KEYBOARD = 0x07; /* USB Device Class Definition for Human Interface Devices (HID). Note: the usage type for all key codes is Selector (Sel). */
|
||||||
|
public static final int HID_USAGEPAGE_LED = 0x08;
|
||||||
|
public static final int HID_USAGEPAGE_BUTTON = 0x09;
|
||||||
|
public static final int HID_USAGEPAGE_ORDINAL = 0x0A;
|
||||||
|
public static final int HID_USAGEPAGE_TELEPHONY = 0x0B;
|
||||||
|
public static final int HID_USAGEPAGE_CONSUMER = 0x0C;
|
||||||
|
public static final int HID_USAGEPAGE_DIGITIZER = 0x0D;
|
||||||
|
public static final int HID_USAGEPAGE_PID = 0x0F; /* USB Physical Interface Device definitions for force feedback and related devices. */
|
||||||
|
public static final int HID_USAGEPAGE_UNICODE = 0x10;
|
||||||
|
public static final int HID_USAGEPAGE_ALPHANUMERIC_DISPLAY = 0x14;
|
||||||
|
public static final int HID_USAGEPAGE_POWERDEVICE = 0x84; /* Power Device Page */
|
||||||
|
public static final int HID_USAGEPAGE_BATTERY_SYSTEM = 0x85; /* Battery System Page */
|
||||||
|
public static final int HID_USAGEPAGE_BARCODE_SCANNER = 0x8C; /* (Point of Sale) USB Device Class Definition for Bar Code Scanner Devices */
|
||||||
|
public static final int HID_USAGEPAGE_SCALE = 0x8D; /* (Point of Sale) USB Device Class Definition for Scale Devices */
|
||||||
|
public static final int HID_USAGEPAGE_CAMERA_CONTROL = 0x90; /* USB Device Class Definition for Image Class Devices */
|
||||||
|
public static final int HID_USAGEPAGE_ARCADE = 0x91; /* OAAF Definitions for arcade and coinop related Devices */
|
||||||
|
public static final int HID_USAGEPAGE_VENDOR_DEFINED_START = 0xFF00;
|
||||||
|
|
||||||
|
|
||||||
|
public static final int HID_ELEMENTTYPE_INPUT_MISC = 1;
|
||||||
|
public static final int HID_ELEMENTTYPE_INPUT_BUTTON = 2;
|
||||||
|
public static final int HID_ELEMENTTYPE_INPUT_AXIS = 3;
|
||||||
|
public static final int HID_ELEMENTTYPE_INPUT_SCANCODES = 4;
|
||||||
|
public static final int HID_ELEMENTTYPE_OUTPUT = 129;
|
||||||
|
public static final int HID_ELEMENTTYPE_FEATURE = 257;
|
||||||
|
public static final int HID_ELEMENTTYPE_COLLECTION = 513;
|
||||||
|
|
||||||
|
|
||||||
private HashMap devices = new HashMap();
|
private HashMap devices = new HashMap();
|
||||||
|
|
@ -88,66 +138,90 @@ public class OSXEnvironmentPlugin extends ControllerEnvironment implements Plugi
|
||||||
return (Controller[])devices.values().toArray();
|
return (Controller[])devices.values().toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputController createController( long lpDevice,
|
public Controller createController( long lpDevice, String productName, int usage )
|
||||||
String productName,
|
|
||||||
int usage )
|
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (usage)
|
switch (usage)
|
||||||
{
|
{
|
||||||
case (HID_DEVICE_MOUSE):
|
case (HID_DEVICE_MOUSE):
|
||||||
System.out.println("Found mouse [" + productName + "]");
|
System.out.println("Found mouse [" + productName + "] device address [" + lpDevice + "]");
|
||||||
return new OSXMouse( this, lpDevice, productName, usage );
|
return new OSXMouse( this, lpDevice, productName );
|
||||||
case (HID_DEVICE_JOYSTICK):
|
case (HID_DEVICE_JOYSTICK):
|
||||||
System.out.println("Found joystick [" + productName + "]");
|
System.out.println("Found joystick [" + productName + "] device address [" + lpDevice + "]");
|
||||||
return new OSXJoystick( this, lpDevice, productName, usage );
|
return new OSXJoystick( this, lpDevice, productName );
|
||||||
case (HID_DEVICE_GAMEPAD):
|
case (HID_DEVICE_GAMEPAD):
|
||||||
System.out.println("Found gamepad [" + productName + "]");
|
System.out.println("Found gamepad [" + productName + "] device address [" + lpDevice + "]");
|
||||||
return new OSXGamepad( this, lpDevice, productName, usage );
|
return new OSXGamepad( this, lpDevice, productName );
|
||||||
case (HID_DEVICE_KEYBOARD):
|
case (HID_DEVICE_KEYBOARD):
|
||||||
System.out.println("Found keyboard [" + productName + "]");
|
System.out.println("Found keyboard [" + productName + "] device address [" + lpDevice + "]");
|
||||||
return new OSXKeyboard( this, lpDevice, productName, usage );
|
return new OSXKeyboard( this, lpDevice, productName );
|
||||||
|
|
||||||
default:
|
default:
|
||||||
System.out.println("Found device of unknown type [" + usage + "],[" + productName + "] - ignoring");
|
System.out.println("Found device of unknown or unsupported type. Usage[" + usage + "], ProductName[" + productName + "] - ignoring");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addController( long lpDevice,
|
/**
|
||||||
String productName,
|
* Add a controller to the device list
|
||||||
int usage )
|
* @param lpDevice
|
||||||
|
* @param productName
|
||||||
|
* @param usage
|
||||||
|
*/
|
||||||
|
private void addController( long lpDevice, String productName, int usage )
|
||||||
{
|
{
|
||||||
InputController controller = null;
|
Controller controller = null;
|
||||||
|
|
||||||
controller = createController( lpDevice, productName, usage );
|
controller = createController( lpDevice, productName, usage );
|
||||||
|
|
||||||
if ( controller != null )
|
if ( controller != null )
|
||||||
{
|
{
|
||||||
devices.put( productName, controller );
|
devices.put( new Long(lpDevice), controller );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds an InputControllerElement to a device. This method is invoked from native code.
|
||||||
|
* @param lpDevice
|
||||||
|
* @param elementCookie
|
||||||
|
* @param elementType
|
||||||
|
* @param usage
|
||||||
|
* @param usagePage
|
||||||
|
* @param rawMin
|
||||||
|
* @param rawMax
|
||||||
|
* @param scaledMin
|
||||||
|
* @param scaledMax
|
||||||
|
* @param dataBitSize
|
||||||
|
* @param isRelative
|
||||||
|
* @param isWrapping
|
||||||
|
* @param isNonLinear
|
||||||
|
* @param hasPreferredState
|
||||||
|
* @param hasNullState
|
||||||
|
*/
|
||||||
private void addControllerElement( long lpDevice,
|
private void addControllerElement( long lpDevice,
|
||||||
long hidCookie,
|
long elementCookie,
|
||||||
int elementType,
|
int elementType,
|
||||||
String elementName,
|
int usage,
|
||||||
|
int usagePage,
|
||||||
int rawMin,
|
int rawMin,
|
||||||
int rawMax,
|
int rawMax,
|
||||||
int scaledMin,
|
int scaledMin,
|
||||||
int scaledMax,
|
int scaledMax,
|
||||||
int dataBitSize,
|
int dataBitSize,
|
||||||
boolean relative,
|
boolean isRelative,
|
||||||
boolean wrapping,
|
boolean isWrapping,
|
||||||
boolean nonLinear,
|
boolean isNonLinear,
|
||||||
boolean hasPreferredState,
|
boolean hasPreferredState,
|
||||||
boolean hasNullState)
|
boolean hasNullState)
|
||||||
{
|
{
|
||||||
|
InputControllerElement element = new InputControllerElement( elementCookie, usagePage, usage, usagePage,
|
||||||
System.out.println("Added new element [" + hidCookie + "] to controller [" + lpDevice + "]");
|
|
||||||
InputControllerElement element = new InputControllerElement( hidCookie, elementType, elementName,
|
|
||||||
rawMin, rawMax, scaledMin, scaledMax,
|
rawMin, rawMax, scaledMin, scaledMax,
|
||||||
dataBitSize, relative, wrapping, nonLinear,
|
dataBitSize, isRelative, isWrapping, isNonLinear,
|
||||||
hasPreferredState, hasNullState );
|
hasPreferredState, hasNullState );
|
||||||
|
|
||||||
|
|
||||||
|
InputController inputController = (InputController)devices.get( new Long( lpDevice) );
|
||||||
|
inputController.addControllerElement( element );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,76 @@ package net.java.games.input;
|
||||||
* Time: 3:59:09 PM
|
* Time: 3:59:09 PM
|
||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class OSXGamepad extends InputController
|
public class OSXGamepad extends AbstractController implements InputController
|
||||||
{
|
{
|
||||||
public OSXGamepad( OSXEnvironmentPlugin plugin )
|
private OSXEnvironmentPlugin plugin;
|
||||||
|
private long lpDevice;
|
||||||
|
private long lpQueue;
|
||||||
|
|
||||||
|
public OSXGamepad( OSXEnvironmentPlugin plugin, long lpDevice, String productName )
|
||||||
{
|
{
|
||||||
super( plugin );
|
super( productName );
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.lpDevice = lpDevice;
|
||||||
|
|
||||||
|
openDevice();
|
||||||
|
}
|
||||||
|
public boolean poll()
|
||||||
|
{
|
||||||
|
plugin.pollDevice( lpQueue );
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXGamepad( OSXEnvironmentPlugin plugin, long lpDevice, String productName, int usage )
|
public void openDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, productName, usage );
|
this.lpQueue = plugin.openDevice( this.lpDevice, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXGamepad( OSXEnvironmentPlugin plugin, long lpDevice, String transportKey, int vendorID, int productID, int version, String manufacturer, String productName, String serialNumber, int usbLocationID, int usagePage, int usage)
|
public void closeDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, transportKey, vendorID, productID, version, manufacturer, productName, serialNumber, usbLocationID, usagePage, usage );
|
plugin.closeDevice( this.lpDevice, this.lpQueue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pollDevice()
|
||||||
|
{
|
||||||
|
plugin.pollDevice( this.lpQueue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addControllerElement(InputControllerElement element)
|
||||||
|
{
|
||||||
|
switch ( element.getElementType() )
|
||||||
|
{
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_MISC:
|
||||||
|
System.out.println("*Adding misc component");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_BUTTON:
|
||||||
|
System.out.println("*Adding button");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_AXIS:
|
||||||
|
System.out.println("*Adding axis");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_SCANCODES:
|
||||||
|
System.out.println("*Adding scancode");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_OUTPUT:
|
||||||
|
System.out.println("*Adding forcefeedback");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_FEATURE:
|
||||||
|
|
||||||
|
System.out.println("*Adding feature");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_COLLECTION:
|
||||||
|
System.out.println("*Adding collection");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,77 @@ package net.java.games.input;
|
||||||
* Time: 3:58:45 PM
|
* Time: 3:58:45 PM
|
||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class OSXJoystick extends InputController
|
public class OSXJoystick extends AbstractController implements InputController
|
||||||
{
|
{
|
||||||
public OSXJoystick( OSXEnvironmentPlugin plugin )
|
private OSXEnvironmentPlugin plugin;
|
||||||
|
private long lpDevice;
|
||||||
|
private long lpQueue;
|
||||||
|
|
||||||
|
public OSXJoystick( OSXEnvironmentPlugin plugin, long lpDevice, String productName )
|
||||||
{
|
{
|
||||||
super( plugin );
|
super( productName );
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.lpDevice = lpDevice;
|
||||||
|
|
||||||
|
openDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXJoystick( OSXEnvironmentPlugin plugin, long lpDevice, String productName, int usage )
|
public boolean poll()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, productName, usage );
|
plugin.pollDevice( lpQueue );
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXJoystick( OSXEnvironmentPlugin plugin, long lpDevice, String transportKey, int vendorID, int productID, int version, String manufacturer, String productName, String serialNumber, int usbLocationID, int usagePage, int usage)
|
public void openDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, transportKey, vendorID, productID, version, manufacturer, productName, serialNumber, usbLocationID, usagePage, usage );
|
this.lpQueue = plugin.openDevice( this.lpDevice, 32 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeDevice()
|
||||||
|
{
|
||||||
|
plugin.closeDevice( this.lpDevice, this.lpQueue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pollDevice()
|
||||||
|
{
|
||||||
|
plugin.pollDevice( this.lpQueue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addControllerElement(InputControllerElement element)
|
||||||
|
{
|
||||||
|
switch ( element.getElementType() )
|
||||||
|
{
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_MISC:
|
||||||
|
System.out.println("*Adding misc component");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_BUTTON:
|
||||||
|
System.out.println("*Adding button");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_AXIS:
|
||||||
|
System.out.println("*Adding axis");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_SCANCODES:
|
||||||
|
System.out.println("*Adding scancode");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_OUTPUT:
|
||||||
|
System.out.println("*Adding forcefeedback");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_FEATURE:
|
||||||
|
|
||||||
|
System.out.println("*Adding feature");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_COLLECTION:
|
||||||
|
System.out.println("*Adding collection");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,89 @@ package net.java.games.input;
|
||||||
* Time: 3:57:58 PM
|
* Time: 3:57:58 PM
|
||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class OSXKeyboard extends InputController
|
public class OSXKeyboard extends StandardKeyboard implements InputController
|
||||||
{
|
{
|
||||||
public OSXKeyboard( OSXEnvironmentPlugin plugin )
|
private OSXEnvironmentPlugin plugin;
|
||||||
|
private long lpDevice;
|
||||||
|
private long lpQueue;
|
||||||
|
|
||||||
|
public OSXKeyboard( OSXEnvironmentPlugin plugin, long lpDevice, String productName )
|
||||||
{
|
{
|
||||||
super( plugin );
|
super( productName );
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.lpDevice = lpDevice;
|
||||||
|
|
||||||
|
openDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXKeyboard( OSXEnvironmentPlugin plugin, long lpDevice, String productName, int usage )
|
public void openDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, productName, usage );
|
this.lpQueue = plugin.openDevice( this.lpDevice, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXKeyboard( OSXEnvironmentPlugin plugin, long lpDevice, String transportKey, int vendorID, int productID, int version, String manufacturer, String productName, String serialNumber, int usbLocationID, int usagePage, int usage)
|
public void closeDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, transportKey, vendorID, productID, version, manufacturer, productName, serialNumber, usbLocationID, usagePage, usage );
|
plugin.closeDevice( this.lpDevice, this.lpQueue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void pollDevice()
|
||||||
|
{
|
||||||
|
plugin.pollDevice( this.lpQueue );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addControllerElement(InputControllerElement element)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
switch ( element.getElementType() )
|
||||||
|
{
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_MISC:
|
||||||
|
System.out.println("*Adding misc component");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_BUTTON:
|
||||||
|
System.out.println("*Adding button");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_AXIS:
|
||||||
|
System.out.println("*Adding axis");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_INPUT_SCANCODES:
|
||||||
|
System.out.println("*Adding scancode");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_OUTPUT:
|
||||||
|
System.out.println("*Adding forcefeedback");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_FEATURE:
|
||||||
|
|
||||||
|
System.out.println("*Adding feature");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_ELEMENTTYPE_COLLECTION:
|
||||||
|
System.out.println("*Adding collection");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println("Cookie [" + element.getHidCookie() + "]");
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean poll()
|
||||||
|
{
|
||||||
|
plugin.pollDevice( lpQueue );
|
||||||
|
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isKeyPressed(Keyboard.Key key)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,20 +7,273 @@ package net.java.games.input;
|
||||||
* Time: 3:57:00 PM
|
* Time: 3:57:00 PM
|
||||||
* To change this template use Options | File Templates.
|
* To change this template use Options | File Templates.
|
||||||
*/
|
*/
|
||||||
public class OSXMouse extends InputController
|
public class OSXMouse extends Mouse implements InputController
|
||||||
{
|
{
|
||||||
public OSXMouse( OSXEnvironmentPlugin plugin )
|
private OSXEnvironmentPlugin plugin;
|
||||||
|
private long lpDevice;
|
||||||
|
private long lpQueue;
|
||||||
|
private int buttonCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
public OSXMouse( OSXEnvironmentPlugin plugin, long lpDevice, String productName )
|
||||||
{
|
{
|
||||||
super( plugin );
|
super( productName );
|
||||||
|
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.lpDevice = lpDevice;
|
||||||
|
|
||||||
|
openDevice();
|
||||||
|
|
||||||
|
buttons = new ButtonsImpl();
|
||||||
|
ball = new BallImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXMouse( OSXEnvironmentPlugin plugin, long lpDevice, String productName, int usage )
|
public void openDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, productName, usage );
|
this.lpQueue = plugin.openDevice( this.lpDevice, 32 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OSXMouse( OSXEnvironmentPlugin plugin, long lpDevice, String transportKey, int vendorID, int productID, int version, String manufacturer, String productName, String serialNumber, int usbLocationID, int usagePage, int usage)
|
public void closeDevice()
|
||||||
{
|
{
|
||||||
super( plugin, lpDevice, transportKey, vendorID, productID, version, manufacturer, productName, serialNumber, usbLocationID, usagePage, usage );
|
plugin.closeDevice( this.lpDevice, this.lpQueue );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean poll()
|
||||||
|
{
|
||||||
|
plugin.pollDevice( this.lpQueue );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addControllerElement(InputControllerElement element)
|
||||||
|
{
|
||||||
|
|
||||||
|
switch ( element.getUsagePage() )
|
||||||
|
{
|
||||||
|
case OSXEnvironmentPlugin.HID_USAGEPAGE_BUTTON:
|
||||||
|
buttonCount ++;
|
||||||
|
System.out.println("Adding button [" + buttonCount + "]");
|
||||||
|
((ButtonsImpl)buttons).addButton(element);
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_USAGEPAGE_GENERICDESKTOP:
|
||||||
|
switch( element.getUsage() )
|
||||||
|
{
|
||||||
|
case OSXEnvironmentPlugin.HID_USAGE_POINTER:
|
||||||
|
System.out.println("Adding pointer - this will contain axis");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_USAGE_XAXIS:
|
||||||
|
((BallImpl)ball).addXAxis(element);
|
||||||
|
System.out.println("Adding X Axis") ;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_USAGE_YAXIS:
|
||||||
|
((BallImpl)ball).addYAxis(element);
|
||||||
|
System.out.println("Adding Y Axis");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OSXEnvironmentPlugin.HID_USAGE_WHEEL:
|
||||||
|
((BallImpl)ball).addWheelAxis(element);
|
||||||
|
System.out.println("Adding wheel");
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation class representing the mouse ball
|
||||||
|
*/
|
||||||
|
class BallImpl extends Ball
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Public constructor
|
||||||
|
*/
|
||||||
|
public BallImpl()
|
||||||
|
{
|
||||||
|
super(OSXMouse.this.getName() + " ball");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addXAxis( InputControllerElement element )
|
||||||
|
{
|
||||||
|
x = new BallAxis( Axis.Identifier.X, element );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addYAxis( InputControllerElement element )
|
||||||
|
{
|
||||||
|
y = new BallAxis( Axis.Identifier.Y, element );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addWheelAxis( InputControllerElement element )
|
||||||
|
{
|
||||||
|
wheel = new BallAxis( Axis.Identifier.SLIDER, element );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation class representing the mouse buttons
|
||||||
|
*/
|
||||||
|
class ButtonsImpl extends Buttons
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Public constructor
|
||||||
|
*/
|
||||||
|
public ButtonsImpl()
|
||||||
|
{
|
||||||
|
super(OSXMouse.this.getName() + " buttons");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addButton( InputControllerElement element )
|
||||||
|
{
|
||||||
|
if ( left == null )
|
||||||
|
{
|
||||||
|
left = new ButtonImpl( ButtonID.LEFT, element );
|
||||||
|
}
|
||||||
|
else if ( right == null )
|
||||||
|
{
|
||||||
|
right = new ButtonImpl( ButtonID.RIGHT, element );
|
||||||
|
}
|
||||||
|
else if ( middle == null )
|
||||||
|
{
|
||||||
|
middle = new ButtonImpl( ButtonID.MIDDLE, element );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mouse button axis implementation
|
||||||
|
*/
|
||||||
|
class ButtonImpl extends Button
|
||||||
|
{
|
||||||
|
|
||||||
|
private long hidCookie;
|
||||||
|
private boolean isRelative;
|
||||||
|
|
||||||
|
|
||||||
|
/** Public constructor
|
||||||
|
* @param id An ID of a button to create an obejct to represent.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public ButtonImpl(ButtonID id, InputControllerElement element)
|
||||||
|
{
|
||||||
|
super(id.getName(), id);
|
||||||
|
this.hidCookie = element.getHidCookie();
|
||||||
|
this.isRelative = element.isRelative();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the data from the last time the control has been polled.
|
||||||
|
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
|
||||||
|
* If this axis is normalized, the value returned will be between -1.0f and
|
||||||
|
* 1.0f.
|
||||||
|
* @return state of controller. (Note: DX8 mice actually
|
||||||
|
* queue state so what is returned is the next state,
|
||||||
|
* not necessarily the most current one.)
|
||||||
|
*/
|
||||||
|
public float getPollData()
|
||||||
|
{
|
||||||
|
/* // Mouse button
|
||||||
|
byte data = mouseData[index];
|
||||||
|
if ((data & 0x80) != 0)
|
||||||
|
{
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns <code>true</code> if data returned from <code>poll</code>
|
||||||
|
* is relative to the last call, or <code>false</code> if data
|
||||||
|
* is absolute.
|
||||||
|
* @return true if data is relative, otherwise false.
|
||||||
|
*/
|
||||||
|
public boolean isRelative()
|
||||||
|
{
|
||||||
|
return isRelative;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mouse ball axis implementation
|
||||||
|
*/
|
||||||
|
class BallAxis extends AbstractAxis
|
||||||
|
{
|
||||||
|
|
||||||
|
private long hidCookie;
|
||||||
|
private boolean isRelative;
|
||||||
|
|
||||||
|
/** Public constructor
|
||||||
|
* @param id An ID for a mouse axis to create an object to represent.
|
||||||
|
*/
|
||||||
|
public BallAxis(Identifier id, InputControllerElement element)
|
||||||
|
{
|
||||||
|
super(id.getName(), id);
|
||||||
|
|
||||||
|
this.hidCookie = element.getHidCookie();
|
||||||
|
this.isRelative = element.isRelative();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns the data from the last time the control has been polled.
|
||||||
|
* If this axis is a button, the value returned will be either 0.0f or 1.0f.
|
||||||
|
* If this axis is normalized, the value returned will be between -1.0f and
|
||||||
|
* 1.0f.
|
||||||
|
* @return data. (Note that mice queue state in DX8 so what
|
||||||
|
* is returned is the next stae in the queue, not
|
||||||
|
* necessarily the most current one.)
|
||||||
|
*/
|
||||||
|
public float getPollData()
|
||||||
|
{
|
||||||
|
/* int data = ((int) mouseData[index] << 12) |
|
||||||
|
((int) mouseData[index + 1] << 8) |
|
||||||
|
((int) mouseData[index + 2] << 4) |
|
||||||
|
((int) mouseData[index + 3]);
|
||||||
|
if (data == -1)
|
||||||
|
{
|
||||||
|
return -1.0f;
|
||||||
|
}
|
||||||
|
else if (data >= 1)
|
||||||
|
{
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns <code>true</code> if data returned from <code>poll</code>
|
||||||
|
* is relative to the last call, or <code>false</code> if data
|
||||||
|
* is absolute.
|
||||||
|
* @return true if relative, otherwise false.
|
||||||
|
*/
|
||||||
|
public boolean isRelative()
|
||||||
|
{
|
||||||
|
return isRelative;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Returns whether or not the axis is analog, or false if it is digital.
|
||||||
|
* @return true if analog, false if digital
|
||||||
|
*/
|
||||||
|
public boolean isAnalog()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,10 +74,11 @@ jmethodID MID_AddController = NULL;
|
||||||
jmethodID MID_AddControllerElement = NULL;
|
jmethodID MID_AddControllerElement = NULL;
|
||||||
mach_port_t masterPort = NULL;
|
mach_port_t masterPort = NULL;
|
||||||
io_iterator_t hidObjectIterator;
|
io_iterator_t hidObjectIterator;
|
||||||
int gElementIndex;
|
|
||||||
|
|
||||||
long elementCookie;
|
long elementCookie;
|
||||||
long collectionType;
|
long elementType;
|
||||||
|
long usage;
|
||||||
|
long usagePage;
|
||||||
long min;
|
long min;
|
||||||
long max;
|
long max;
|
||||||
long scaledMin;
|
long scaledMin;
|
||||||
|
|
@ -91,6 +92,7 @@ jboolean isNonLinear;
|
||||||
JNIEnv * lpEnv;
|
JNIEnv * lpEnv;
|
||||||
jlong lpDevice;
|
jlong lpDevice;
|
||||||
jobject lpObj;
|
jobject lpObj;
|
||||||
|
jboolean completeElement = JNI_FALSE;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -141,16 +143,10 @@ void CFObjectShow( CFTypeRef value )
|
||||||
CFTypeID type = CFGetTypeID(value);
|
CFTypeID type = CFGetTypeID(value);
|
||||||
if (type == CFArrayGetTypeID())
|
if (type == CFArrayGetTypeID())
|
||||||
{
|
{
|
||||||
|
|
||||||
printf("Array Type\n");
|
|
||||||
CFRange range = {0, CFArrayGetCount (value)};
|
CFRange range = {0, CFArrayGetCount (value)};
|
||||||
CFIndex savedIndex = gElementIndex;
|
|
||||||
|
|
||||||
//Show an element array containing one or more element dictionaries
|
//Show an element array containing one or more element dictionaries
|
||||||
gElementIndex = 0; //Reset index to zero
|
|
||||||
CFArrayApplyFunction (value, range, showCFArray, 0);
|
CFArrayApplyFunction (value, range, showCFArray, 0);
|
||||||
|
|
||||||
gElementIndex = savedIndex;
|
|
||||||
}
|
}
|
||||||
else if (type == CFBooleanGetTypeID())
|
else if (type == CFBooleanGetTypeID())
|
||||||
{
|
{
|
||||||
|
|
@ -239,7 +235,7 @@ Boolean init(JNIEnv* env)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MID_AddControllerElement = (*env)->GetMethodID(env, CLASS_JNIWrapper, "addControllerElement", "(JJILjava/lang/String;IIIIIZZZZZ)V");
|
MID_AddControllerElement = (*env)->GetMethodID(env, CLASS_JNIWrapper, "addControllerElement", "(JJIIIIIIIIZZZZZ)V");
|
||||||
if (MID_AddControllerElement == NULL)
|
if (MID_AddControllerElement == NULL)
|
||||||
{
|
{
|
||||||
printf("Method addControllerElement not found... \n");
|
printf("Method addControllerElement not found... \n");
|
||||||
|
|
@ -362,19 +358,14 @@ void CFObjectSend( CFTypeRef value )
|
||||||
CFTypeID type = CFGetTypeID(value);
|
CFTypeID type = CFGetTypeID(value);
|
||||||
if (type == CFArrayGetTypeID())
|
if (type == CFArrayGetTypeID())
|
||||||
{
|
{
|
||||||
printf("Array Type\n");
|
|
||||||
CFRange range = {0, CFArrayGetCount (value)};
|
CFRange range = {0, CFArrayGetCount (value)};
|
||||||
CFIndex savedIndex = gElementIndex;
|
|
||||||
|
|
||||||
//Show an element array containing one or more element dictionaries
|
//Show an element array containing one or more element dictionaries
|
||||||
gElementIndex = 0; //Reset index to zero
|
|
||||||
CFArrayApplyFunction (value, range, sendCFArray, 0);
|
CFArrayApplyFunction (value, range, sendCFArray, 0);
|
||||||
|
|
||||||
gElementIndex = savedIndex;
|
|
||||||
}
|
}
|
||||||
else if (type == CFDictionaryGetTypeID())
|
else if (type == CFDictionaryGetTypeID())
|
||||||
{
|
{
|
||||||
printf("Sending Map\n");
|
// printf("Sending Map\n");
|
||||||
|
|
||||||
|
|
||||||
CFTypeRef val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementCookieKey) );
|
CFTypeRef val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementCookieKey) );
|
||||||
|
|
@ -384,91 +375,128 @@ void CFObjectSend( CFTypeRef value )
|
||||||
printf("ElementCookie - 0x%lx (%ld) \n", elementCookie, elementCookie);
|
printf("ElementCookie - 0x%lx (%ld) \n", elementCookie, elementCookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementCollectionTypeKey) );
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementTypeKey) );
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
CFNumberGetValue ( val, kCFNumberLongType, &collectionType);
|
CFNumberGetValue ( val, kCFNumberLongType, &elementType);
|
||||||
printf("collection Type - 0x%lx (%ld) \n", collectionType, collectionType);
|
printf("element Type - 0x%lx (%ld) \n", elementType, elementType);
|
||||||
|
}
|
||||||
|
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementUsageKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
CFNumberGetValue ( val, kCFNumberLongType, &usage);
|
||||||
|
printf("usage - 0x%lx (%ld) \n", usage, usage);
|
||||||
|
}
|
||||||
|
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementUsagePageKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
CFNumberGetValue ( val, kCFNumberLongType, &usagePage);
|
||||||
|
printf("usage page- 0x%lx (%ld) \n", usagePage, usagePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementMinKey) );
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementMinKey) );
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
CFNumberGetValue ( val, kCFNumberLongType, &min);
|
CFNumberGetValue ( val, kCFNumberLongType, &min);
|
||||||
printf("min - 0x%lx (%ld) \n", min, min);
|
//printf("min - 0x%lx (%ld) \n", min, min);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementMaxKey) );
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementMaxKey) );
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
CFNumberGetValue ( val, kCFNumberLongType, &max);
|
CFNumberGetValue ( val, kCFNumberLongType, &max);
|
||||||
printf("max - 0x%lx (%ld) \n", max, max);
|
//printf("max - 0x%lx (%ld) \n", max, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementScaledMinKey) );
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementScaledMinKey) );
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
CFNumberGetValue ( val, kCFNumberLongType, &scaledMin);
|
CFNumberGetValue ( val, kCFNumberLongType, &scaledMin);
|
||||||
printf("scaledMin - 0x%lx (%ld) \n", scaledMin, scaledMin);
|
//printf("scaledMin - 0x%lx (%ld) \n", scaledMin, scaledMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementScaledMaxKey) );
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementScaledMaxKey) );
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
CFNumberGetValue ( val, kCFNumberLongType, &scaledMax);
|
CFNumberGetValue ( val, kCFNumberLongType, &scaledMax);
|
||||||
printf("scaledMax - 0x%lx (%ld) \n", scaledMax, scaledMax);
|
//printf("scaledMax - 0x%lx (%ld) \n", scaledMax, scaledMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementSizeKey) );
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementSizeKey) );
|
||||||
if ( val )
|
if ( val )
|
||||||
{
|
{
|
||||||
CFNumberGetValue ( val, kCFNumberLongType, &size);
|
CFNumberGetValue ( val, kCFNumberLongType, &size);
|
||||||
printf("Size - 0x%lx (%ld) \n", size, size);
|
//printf("Size - 0x%lx (%ld) \n", size, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
isRelative = JNI_FALSE;
|
jboolean isRelative = JNI_FALSE;
|
||||||
isWrapping = JNI_FALSE;
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementIsRelativeKey) );
|
||||||
isNonLinear = JNI_FALSE;
|
if ( val )
|
||||||
|
{
|
||||||
|
isRelative = (CFBooleanGetValue(val) ? JNI_TRUE : JNI_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jboolean isWrapping = JNI_FALSE;
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementIsWrappingKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
isWrapping = (CFBooleanGetValue(val) ? JNI_TRUE : JNI_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jboolean isNonLinear = JNI_FALSE;
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementIsNonLinearKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
isNonLinear = (CFBooleanGetValue(val) ? JNI_TRUE : JNI_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
jboolean hasPreferredState = JNI_FALSE;
|
jboolean hasPreferredState = JNI_FALSE;
|
||||||
|
#ifdef kIOHIDElementHasPreferredStateKey
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementHasPreferredStateKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
hasPreferredState = (CFBooleanGetValue(val) ? JNI_TRUE : JNI_FALSE);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementHasPreferedStateKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
hasPreferredState = (CFBooleanGetValue(val) ? JNI_TRUE : JNI_FALSE);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
jboolean hasNullState = JNI_FALSE;
|
jboolean hasNullState = JNI_FALSE;
|
||||||
|
val = CFDictionaryGetValue( value, CFSTR(kIOHIDElementHasNullStateKey) );
|
||||||
|
if ( val )
|
||||||
|
{
|
||||||
|
hasNullState = (CFBooleanGetValue(val) ? JNI_TRUE : JNI_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
(*lpEnv)->CallVoidMethod(lpEnv, lpObj, MID_AddControllerElement,
|
(*lpEnv)->CallVoidMethod(lpEnv, lpObj, MID_AddControllerElement,
|
||||||
lpDevice,
|
(jlong)(long)lpDevice,
|
||||||
(jlong)(long)elementCookie,
|
(jlong)(long)elementCookie,
|
||||||
(jlong)(long)collectionType,
|
(jint)(long)elementType,
|
||||||
(jlong)(long)min,
|
(jint)(long)usage,
|
||||||
(jlong)(long)max,
|
(jint)(long)usagePage,
|
||||||
(jlong)(long)scaledMin,
|
(jint)(long)min,
|
||||||
(jlong)(long)scaledMax,
|
(jint)(long)max,
|
||||||
(jlong)(long)size,
|
(jint)(long)scaledMin,
|
||||||
|
(jint)(long)scaledMax,
|
||||||
|
(jint)(long)size,
|
||||||
(jboolean)isRelative,
|
(jboolean)isRelative,
|
||||||
(jboolean)isWrapping,
|
(jboolean)isWrapping,
|
||||||
(jboolean)isNonLinear,
|
(jboolean)isNonLinear,
|
||||||
(jboolean)hasPreferredState,
|
(jboolean)hasPreferredState,
|
||||||
(jboolean)hasNullState);
|
(jboolean)hasNullState);
|
||||||
printf("End of element definition \n");
|
|
||||||
|
|
||||||
/*
|
// printf("End of element definition \n");
|
||||||
|
|
||||||
jboolean isRelative;
|
|
||||||
isRelative = (CFBooleanGetValue(value) ? JNI_TRUE : JNI_FALSE);
|
|
||||||
|
|
||||||
|
|
||||||
jboolean isWrapping;
|
|
||||||
isWrapping = (CFBooleanGetValue(value) ? JNI_TRUE : JNI_FALSE);
|
|
||||||
|
|
||||||
jboolean isNonLinear;
|
|
||||||
isNonLinear = (CFBooleanGetValue(value) ? JNI_TRUE : JNI_FALSE);
|
|
||||||
*/
|
|
||||||
#ifdef kIOHIDElementHasPreferredStateKey
|
|
||||||
//showDictionaryElement (value, CFSTR(kIOHIDElementHasPreferredStateKey));
|
|
||||||
#else
|
|
||||||
//showDictionaryElement (value, CFSTR(kIOHIDElementHasPreferedStateKey));
|
|
||||||
#endif
|
|
||||||
//showDictionaryElement (value, CFSTR(kIOHIDElementHasNullStateKey));
|
|
||||||
showDictionaryElement (value, CFSTR(kIOHIDElementVendorSpecificKey));
|
|
||||||
|
|
||||||
//showDictionaryElement (value, CFSTR(kIOHIDElementKey));
|
|
||||||
|
|
||||||
CFTypeRef object = CFDictionaryGetValue (value, CFSTR(kIOHIDElementKey));
|
CFTypeRef object = CFDictionaryGetValue (value, CFSTR(kIOHIDElementKey));
|
||||||
if (object)
|
if (object)
|
||||||
|
|
@ -487,16 +515,8 @@ void addControllerElements( CFMutableDictionaryRef dictionary, CFStringRef key )
|
||||||
CFTypeRef value = CFDictionaryGetValue (dictionary, key);
|
CFTypeRef value = CFDictionaryGetValue (dictionary, key);
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
CFTypeID type = CFGetTypeID(value);
|
|
||||||
|
|
||||||
CFRange range = {0, CFArrayGetCount (value)};
|
CFRange range = {0, CFArrayGetCount (value)};
|
||||||
CFIndex savedIndex = gElementIndex;
|
|
||||||
|
|
||||||
//Show an element array containing one or more element dictionaries
|
|
||||||
gElementIndex = 0; //Reset index to zero
|
|
||||||
CFArrayApplyFunction (value, range, sendCFArray, 0);
|
CFArrayApplyFunction (value, range, sendCFArray, 0);
|
||||||
|
|
||||||
gElementIndex = savedIndex;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue