• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java HIDDeviceInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.codeminders.hidapi.HIDDeviceInfo的典型用法代码示例。如果您正苦于以下问题:Java HIDDeviceInfo类的具体用法?Java HIDDeviceInfo怎么用?Java HIDDeviceInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HIDDeviceInfo类属于com.codeminders.hidapi包,在下文中一共展示了HIDDeviceInfo类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: listDaplugHIDDevice

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * List all HID device
 * String format in Vector :
 * HID, vid, pid, path, interface_number, manufactured
 * @return Vector<String> list of all HID Device
 * @author yassir
 */
private static Vector<String> listDaplugHIDDevice()
{
	Vector<String> hid = new Vector<String>();
	Vector <HIDDeviceInfo> listHID = new HIDExec().listAllDaplug();
	int i = 0;
	 for(HIDDeviceInfo dev : listHID) {
		 if(dev.getInterface_number() != 0) {
		 StringBuilder sb = new StringBuilder();
		 sb.append("Dongle "+i + ",").append("HID").append(",").
		 	append(dev.getPath()).append(",").
		 	append(dev.getManufacturer_string());
		 hid.add(sb.toString());
		}
	 }
	 return hid;
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:24,代码来源:DaplugEnumerator.java


示例2: findFirst

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/** 
 * Find first BlinkStick connected to the computer
 * 
 * @return BlinkStick object or null if no BlinkSticks are connected
 */
public static BlinkStick findFirst() {
	Initialize();

	HIDDeviceInfo[] infos = findAllDescriptors();

	if (infos.length > 0) {
		BlinkStick result = new BlinkStick();
		try {
			result.setDevice(infos[0].open());
			return result;
		} catch (Exception e) {
		}
	}
	return null;
}
 
开发者ID:arvydas,项目名称:blinkstick-processing,代码行数:21,代码来源:BlinkStick.java


示例3: findBySerial

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/** Find BlinkStick by serial number
 * 
 * @param serial	The serial number to search
 * 
 * @return			BlinkStick object or null if device was not found
 */
public static BlinkStick findBySerial(String serial) {
	Initialize();

	HIDDeviceInfo[] infos = findAllDescriptors();

	for (HIDDeviceInfo info : infos) {
		if (info.getSerial_number().equals(serial)) {
			BlinkStick result = new BlinkStick();
			try {
				result.setDevice(infos[0].open());
				return result;
			} catch (Exception e) {
			}
		}
	}

	return null;
}
 
开发者ID:arvydas,项目名称:blinkstick-processing,代码行数:25,代码来源:BlinkStick.java


示例4: findAllDescriptors

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/** 
 * Find all BlinkStick HIDDeviceInfo descriptions connected to the computer
 * 
 * @return an array of HIDDeviceInfo objects with VID and PID matching BlinkStick
 */
private static HIDDeviceInfo[] findAllDescriptors() {
	Initialize();

	List<HIDDeviceInfo> blinkstickList = new ArrayList<HIDDeviceInfo>();

	try {
		HIDManager hidManager = HIDManager.getInstance();

		HIDDeviceInfo[] infos = hidManager.listDevices();

		for (HIDDeviceInfo info : infos) {
			if (info.getVendor_id() == VENDOR_ID
					&& info.getProduct_id() == PRODUCT_ID) {
				blinkstickList.add(info);
			}
		}
	} catch (Exception e) {
	}

	return blinkstickList.toArray(new HIDDeviceInfo[blinkstickList.size()]);
}
 
开发者ID:arvydas,项目名称:blinkstick-processing,代码行数:27,代码来源:BlinkStick.java


示例5: findAll

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/** 
 * Find all BlinkSticks connected to the computer
 * 
 * @return an array of BlinkStick objects
 */
public static BlinkStick[] findAll() {
	List<BlinkStick> blinkstickList = new ArrayList<BlinkStick>();

	HIDDeviceInfo[] infos = findAllDescriptors();

	for (HIDDeviceInfo info : infos) {
		BlinkStick blinkstick = new BlinkStick();
		try {
			blinkstick.setDevice(info.open());
			blinkstickList.add(blinkstick);
		} catch (Exception e) {
		}
	}

	return blinkstickList.toArray(new BlinkStick[blinkstickList.size()]);
}
 
开发者ID:arvydas,项目名称:blinkstick-processing,代码行数:22,代码来源:BlinkStick.java


示例6: findFirst

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * Find first BlinkStick connected to the computer
 *
 * @return BlinkStick object or null if no BlinkSticks are connected
 */
public static BlinkStick findFirst() {
    Initialize();

    HIDDeviceInfo[] infos = findAllDescriptors();

    if (infos.length > 0) {
        BlinkStick result = new BlinkStick();
        try {
            result.setDevice(infos[0].open());
            return result;
        } catch (Exception e) {
        }
    }
    return null;
}
 
开发者ID:zutherb,项目名称:build-light,代码行数:21,代码来源:BlinkStick.java


示例7: findBySerial

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * Find BlinkStick by serial number
 *
 * @param serial The serial number to search
 * @return BlinkStick object or null if device was not found
 */
public static BlinkStick findBySerial(String serial) {
    Initialize();

    HIDDeviceInfo[] infos = findAllDescriptors();

    for (HIDDeviceInfo info : infos) {
        if (info.getSerial_number().equals(serial)) {
            BlinkStick result = new BlinkStick();
            try {
                result.setDevice(infos[0].open());
                return result;
            } catch (Exception e) {
            }
        }
    }

    return null;
}
 
开发者ID:zutherb,项目名称:build-light,代码行数:25,代码来源:BlinkStick.java


示例8: findAllDescriptors

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * Find all BlinkStick HIDDeviceInfo descriptions connected to the computer
 *
 * @return an array of HIDDeviceInfo objects with VID and PID matching BlinkStick
 */
private static HIDDeviceInfo[] findAllDescriptors() {
    Initialize();

    List<HIDDeviceInfo> blinkstickList = new ArrayList<>();

    try {
        HIDManager hidManager = HIDManager.getInstance();

        HIDDeviceInfo[] infos = hidManager.listDevices();

        for (HIDDeviceInfo info : infos) {
            if (info.getVendor_id() == VENDOR_ID
                    && info.getProduct_id() == PRODUCT_ID) {
                blinkstickList.add(info);
            }
        }
    } catch (Exception e) {
    }

    return blinkstickList.toArray(new HIDDeviceInfo[blinkstickList.size()]);
}
 
开发者ID:zutherb,项目名称:build-light,代码行数:27,代码来源:BlinkStick.java


示例9: findAll

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * Find all BlinkSticks connected to the computer
 *
 * @return an array of BlinkStick objects
 */
public static BlinkStick[] findAll() {
    List<BlinkStick> blinkStickList = new ArrayList<>();

    HIDDeviceInfo[] infos = findAllDescriptors();

    for (HIDDeviceInfo info : infos) {
        BlinkStick blinkStick = new BlinkStick();
        try {
            blinkStick.setDevice(info.open());
            blinkStickList.add(blinkStick);
        } catch (Exception e) {
        }
    }

    return blinkStickList.toArray(new BlinkStick[blinkStickList.size()]);
}
 
开发者ID:zutherb,项目名称:build-light,代码行数:22,代码来源:BlinkStick.java


示例10: readFromAll

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * Read a packet from each device that matches our vendor ID and product ID
 * filter.
 * 
 * @return A map with a data entry for each USB device handle.
 */
@SneakyThrows
public Map<HubHandle, byte[]> readFromAll() {
    final Map<HubHandle, byte[]> packets = new HashMap<>();
    for (final HIDDeviceInfo hidDeviceInfo : HIDManager.getInstance()
            .listDevices()) {
        if (hidDeviceInfo.getVendor_id() == VENDORID_LEGO
                && hidDeviceInfo.getProduct_id() == PRODUCTID_WEDOHUB) {
            read(hidDeviceInfo, packets);
        }
    }

    return packets;
}
 
开发者ID:kjkoster,项目名称:lego-wedo-java,代码行数:20,代码来源:Usb.java


示例11: read

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
private void read(final HIDDeviceInfo hidDeviceInfo,
        final Map<HubHandle, byte[]> packets) {
    try {
        final String productName = hidDeviceInfo.getProduct_string();
        if (productName == null) {
            // Typically a USB device permissions issue under Linux. If that
            // is the case, you may need udev rules.
            err.printf(
                    "unable to read product name from %s, permission issue?",
                    hidDeviceInfo.getPath());
            return;
        }
        final HubHandle hubHandle = new HubHandle(hidDeviceInfo.getPath(),
                productName);

        final byte[] buffer = new byte[PACKETSIZE];
        final int bytesRead = open(hubHandle).readTimeout(buffer,
                (int) MILLISECONDS.toMillis(100L));
        if (bytesRead != PACKETSIZE) {
            // there was a time-out, and we did not get a packet.
            err.printf(
                    "expected %d bytes but received %d reading %s, timeout?",
                    PACKETSIZE, bytesRead, hubHandle);
            return;
        }

        if (verbose) {
            out.printf(
                    "  USB read  %s: 0x%02x 0x%02x [value A: 0x%02x] [id A: 0x%02x] [value B: 0x%02x] [id B: 0x%02x] 0x%02x 0x%02x\n",
                    hubHandle, buffer[0], buffer[1], buffer[2], buffer[3],
                    buffer[4], buffer[5], buffer[6], buffer[7]);
        }

        packets.put(hubHandle, buffer);
    } catch (IOException e) {
        err.printf("unexpected exception reading from %s: %s",
                hidDeviceInfo.getPath(), e.getMessage());
        e.printStackTrace();
    }
}
 
开发者ID:kjkoster,项目名称:lego-wedo-java,代码行数:41,代码来源:Usb.java


示例12: closeAllDevice

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * close all devices whatever his pid and vid
 * @author yassir
 */
public void closeAllDevice() {
	try{
		HIDDeviceInfo[] devices = this.manager.listDevices();
		for(HIDDeviceInfo device : devices)
		{
			this.manager.openById(device.getVendor_id(),device.getProduct_id(),null).close(); 
		}
	}catch(IOException e){
		System.out.println("closeAllDevice() methode failed due to an IOException :\n" + e.getMessage());
	}
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:16,代码来源:HIDExec.java


示例13: listDevice

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 *  return all informations of all HID DEVICE on the computer
 * @return HIDDeviceInfo (is an array)
 * @author yassir
 */
public HIDDeviceInfo[] listDevice(){
	 HIDDeviceInfo[] infos = null;
	 try {
            infos = this.manager.listDevices();
        } catch (Exception e) {
        	System.out.println("listDevice methode failed :\n" + e.getMessage());
        }
	 return infos;
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:15,代码来源:HIDExec.java


示例14: locateTrezor

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
private Optional<HIDDeviceInfo> locateTrezor() throws IOException {

    // Get the HID manager
    HIDManager hidManager = HIDManager.getInstance();

    // Attempt to list the attached devices
    HIDDeviceInfo[] infos = hidManager.listDevices();
    if (infos == null) {
      throw new IllegalStateException("Unable to access connected device list. Check USB security policy for this account.");
    }

    Integer vendorId = vendorIdOptional.isPresent() ? vendorIdOptional.get() : DEFAULT_USB_VENDOR_ID;
    Integer productId = productIdOptional.isPresent() ? productIdOptional.get() : DEFAULT_USB_PRODUCT_ID;

    // Attempt to locate the required device
    Optional<HIDDeviceInfo> selectedInfo = Optional.absent();
    for (HIDDeviceInfo info : infos) {
      if (vendorId.equals(info.getVendor_id()) &&
        productId.equals(info.getProduct_id())) {
        // Allow a wildcard serial number
        if (serialNumberOptional.isPresent()) {
          if (serialNumberOptional.get().equals(info.getSerial_number())) {
            selectedInfo = Optional.of(info);
            break;
          }
        } else {
          // Any serial number is acceptable
          selectedInfo = Optional.of(info);
          break;
        }
      }
    }

    return selectedInfo;

  }
 
开发者ID:Multibit-Legacy,项目名称:trezorj,代码行数:37,代码来源:UsbTrezor.java


示例15: initializeJoystick

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
public boolean initializeJoystick(){
        
        //See if any joysticks are connected
        ClassPathLibraryLoader.loadNativeHIDLibrary();
        try {
            HIDDeviceInfo[] devices = HIDManager.getInstance().listDevices();
            for (HIDDeviceInfo hIDDeviceInfo : devices) {
                int usage = hIDDeviceInfo.getUsage(); 
                if ((usage == 4 ) || (usage == 5)){
                    
                    if (connectedJoysticks !=0){
                        System.out.println("Joystick found with productID " + hIDDeviceInfo.getProduct_id());
                        boolean alreadyUsed = false; 
                        for (int i = 0; i < connectedJoysticks; i++) {
                            if (connectedDeviceProductIDs[i] == hIDDeviceInfo.getProduct_id()){
                                if (connectedDevicePaths[i].equalsIgnoreCase(hIDDeviceInfo.getPath())){
                                    alreadyUsed = true; 
                                }
                                break;
                            }
                        }
                        if (alreadyUsed){ 
                            //Use a different device
                            hIDJoystickInfo = hIDDeviceInfo; 
//                    System.out.println("Joystick found with usage " + usage);
//                    System.out.println("Joystick found with device info " + hIDJoystickInfo);
                    
                            continue;
                        }
                    }
                    hIDJoystickInfo = hIDDeviceInfo; 
//                    System.out.println("Joystick found with usage " + usage);
//                    System.out.println("Joystick found with device info " + hIDJoystickInfo);
                    hIDJoystick = hIDJoystickInfo.open();
                    hIDJoystick.disableBlocking();
                    connectedDeviceProductIDs[connectedJoysticks] = hIDDeviceInfo.getProduct_id();
                    connectedDevicePaths[connectedJoysticks]= hIDDeviceInfo.getPath();
                    connectedJoysticks++; 
                    switch (hIDJoystickInfo.getUsage()) {
                        case 4:
                            startOfAxisDataIndex= 0;
                            halfByteButtonIndex = 4; 
                            wholeByteButtonIndex = 5; 
                            break;
                        case 5:
                            startOfAxisDataIndex= 2; 
                            halfByteButtonIndex = 1; 
                            wholeByteButtonIndex = 0; 
                            break;
                        default:
                            throw new AssertionError();
                    }
                    
                    break; 
                }
            }
        } catch (Exception e) {
            hIDJoystickInfo = null; 
            hIDJoystick = null; 
        }
        
        if (hIDJoystick == null){
            return false; 
        }else { 
            return true; 
        }
        
    }
 
开发者ID:wildstang111,项目名称:2013_drivebase_proto,代码行数:69,代码来源:WsHardwareJoystick.java


示例16: listAllDaplug

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * Return all Daplug or Plug-up device on computer
 * @return Vector<HIDDeviceInfo> list 
 * @author yassir
 */
public Vector<HIDDeviceInfo> listAllDaplug() {
	return this.listDevice(VENDOR_ID, PRODUCT_ID);
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:9,代码来源:HIDExec.java


示例17: ListAllHidDevice

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * List all HID Device on the computer
 * @return HIDDeviceInfo[] array of all HID Device
 * @author yassir
 */
public static HIDDeviceInfo[] ListAllHidDevice()
{
	return _this.hidexec.listDevice();
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:10,代码来源:DaplugDongleHID.java


示例18: ListAllSpecificHidDevice

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * List all devices with a specific vendor_id, and product_id
 * @param vid vendor_id
 * @param pid product_id
 * @return Vector<HIDDeviceInfo> List of all device with specific vid and pid
 * @author yassir
 */
public static Vector<HIDDeviceInfo> ListAllSpecificHidDevice(int vid, int pid)
{
	return _this.hidexec.listDevice(vid, pid);
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:12,代码来源:DaplugDongleHID.java


示例19: ListAllDaplug

import com.codeminders.hidapi.HIDDeviceInfo; //导入依赖的package包/类
/**
 * List all device on computer with Plugup vendor_id and product_id
 * @return a List all device
 * @author yassir
 */
public static Vector<HIDDeviceInfo> ListAllDaplug()
{
	return _this.hidexec.listAllDaplug();
}
 
开发者ID:Plug-up,项目名称:daplug-java,代码行数:10,代码来源:DaplugDongleHID.java



注:本文中的com.codeminders.hidapi.HIDDeviceInfo类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AttributeContext类代码示例发布时间:2022-05-23
下一篇:
Java Context类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap