当前位置: 首页>>代码示例>>Java>>正文


Java InputDevice.getDeviceIds方法代码示例

本文整理汇总了Java中android.view.InputDevice.getDeviceIds方法的典型用法代码示例。如果您正苦于以下问题:Java InputDevice.getDeviceIds方法的具体用法?Java InputDevice.getDeviceIds怎么用?Java InputDevice.getDeviceIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.InputDevice的用法示例。


在下文中一共展示了InputDevice.getDeviceIds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: hasConnectedController

import android.view.InputDevice; //导入方法依赖的package包/类
/**
 * Function that returns if any controller is paired/plugged/turned on
 */
private boolean hasConnectedController(){

    /*Get a list of valid input ids and iterate through them*/
    for (int deviceId : InputDevice.getDeviceIds()) {

        InputDevice currentDevice = InputDevice.getDevice(deviceId);

        /*Device ID of the controller*/
        String controllerName = currentDevice.getName().toLowerCase(Locale.ENGLISH);

        /*Check to see if a known controller is connected*/
        if (controllerName.contains("controller") ||
                controllerName.contains("conteroller") ||
                controllerName.contains("contoroller") ||
                controllerName.contains("pad") ||
                controllerName.contains("joystick") ||
                controllerName.contains("nintendo")) {
            //|| (this.hidDevicesOK && controllerName.equals("hid_device"))){
            return true;
        }
    }
    return false;
}
 
开发者ID:frpnit,项目名称:HeyaLauncher,代码行数:27,代码来源:StartUpControllerObserver.java

示例2: MotionEventSender

import android.view.InputDevice; //导入方法依赖的package包/类
public MotionEventSender() {
    try {
        Method imInstanceMethod = InputManager.class.getDeclaredMethod("getInstance");
        imInstanceMethod.setAccessible(true);
        inputManager = (InputManager) imInstanceMethod.invoke(null);

        injectInputEventMethod = InputManager.class.getDeclaredMethod("injectInputEvent",
                                                                      android.view.InputEvent.class,
                                                                      int.class);

        int[] deviceIds = InputDevice.getDeviceIds();
        for (int inputDeviceId : deviceIds) {
            InputDevice inputDevice = InputDevice.getDevice(inputDeviceId);
            int deviceSources = inputDevice.getSources();
            if ((deviceSources & InputDevice.SOURCE_TOUCHSCREEN) == InputDevice.SOURCE_TOUCHSCREEN) {
                DEVICE_ID = inputDeviceId;
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        exitFailure();
    }

}
 
开发者ID:MusalaSoft,项目名称:atmosphere-uiautomator-bridge,代码行数:26,代码来源:MotionEventSender.java

示例3: getGameControllerIds

import android.view.InputDevice; //导入方法依赖的package包/类
private List<Integer> getGameControllerIds() {
	List<Integer> gameControllerDeviceIds = new ArrayList<>();

	int[] deviceIds = InputDevice.getDeviceIds();
	for (int deviceId : deviceIds) {
		InputDevice dev = InputDevice.getDevice(deviceId);
		int sources = dev.getSources();

		if (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD)
				|| ((sources & InputDevice.SOURCE_JOYSTICK)
				== InputDevice.SOURCE_JOYSTICK)) {

			if (!gameControllerDeviceIds.contains(deviceId)) {
				gameControllerDeviceIds.add(deviceId);
			}
		}
	}

	return gameControllerDeviceIds;
}
 
开发者ID:TheFakeMontyOnTheRun,项目名称:knightsofalentejo,代码行数:21,代码来源:GameActivity.java

示例4: scanForGamepads

import android.view.InputDevice; //导入方法依赖的package包/类
private static void scanForGamepads() {
    int[] deviceIds = InputDevice.getDeviceIds();
    if (deviceIds == null) {
        return;
    }
    for (int i=0; i < deviceIds.length; i++) {
        InputDevice device = InputDevice.getDevice(deviceIds[i]);
        if (device == null) {
            continue;
        }
        if ((device.getSources() & InputDevice.SOURCE_GAMEPAD) != InputDevice.SOURCE_GAMEPAD) {
            continue;
        }
        addGamepad(device);
    }
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:17,代码来源:AndroidGamepadManager.java

示例5: areSonyXperiaGamepadKeysSwapped

import android.view.InputDevice; //导入方法依赖的package包/类
private static boolean areSonyXperiaGamepadKeysSwapped() {
    // The cross and circle buttons on Sony Xperia phones are swapped
    // in different regions
    // http://developer.sonymobile.com/2011/02/13/xperia-play-game-keys/
    final char DEFAULT_O_BUTTON_LABEL = 0x25CB;

    boolean swapped = false;
    int[] deviceIds = InputDevice.getDeviceIds();

    for (int i= 0; deviceIds != null && i < deviceIds.length; i++) {
        KeyCharacterMap keyCharacterMap = KeyCharacterMap.load(deviceIds[i]);
        if (keyCharacterMap != null && DEFAULT_O_BUTTON_LABEL ==
            keyCharacterMap.getDisplayLabel(KeyEvent.KEYCODE_DPAD_CENTER)) {
            swapped = true;
            break;
        }
    }
    return swapped;
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:20,代码来源:GamepadUtils.java

示例6: gatherControllers

import android.view.InputDevice; //导入方法依赖的package包/类
private void gatherControllers(boolean sendEvent) {
	// gather all joysticks and gamepads, remove any disconnected ones
	IntMap<AndroidController> removedControllers = new IntMap<AndroidController>();
	removedControllers.putAll(controllerMap);
	
	for(int deviceId: InputDevice.getDeviceIds()) {
		InputDevice device = InputDevice.getDevice(deviceId);
		AndroidController controller = controllerMap.get(deviceId);
		if(controller != null) {
			removedControllers.remove(deviceId);
		} else {
			addController(deviceId, sendEvent);
		}
	}
	
	for(Entry<AndroidController> entry: removedControllers.entries()) {
		removeController(entry.key);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:AndroidControllers.java

示例7: lookupTouchpadHardwareResolution

import android.view.InputDevice; //导入方法依赖的package包/类
/** Looks up the hardware resolution of the Glass touchpad. */
private void lookupTouchpadHardwareResolution() {
    int[] deviceIds = InputDevice.getDeviceIds();
    for (int deviceId : deviceIds) {
        InputDevice device = InputDevice.getDevice(deviceId);
        if ((device.getSources() & InputDevice.SOURCE_TOUCHPAD) != 0) {
            logVerbose("Touchpad motion range: x-axis [%d, %d] y-axis [%d, %d]",
                    device.getMotionRange(MotionEvent.AXIS_X).getMin(),
                    device.getMotionRange(MotionEvent.AXIS_X).getMax(),
                    device.getMotionRange(MotionEvent.AXIS_Y).getMin(),
                    device.getMotionRange(MotionEvent.AXIS_Y).getMax());

            mTouchpadHardwareWidth = device.getMotionRange(MotionEvent.AXIS_X).getRange();
            mTouchpadHardwareHeight = device.getMotionRange(MotionEvent.AXIS_Y).getRange();
            // Stop after we've seen the first touchpad device, because there might be multiple
            // devices in this list if the user is currently screencasting with MyGlass. The
            // first one will always be the hardware touchpad.
            break;
        }
    }
}
 
开发者ID:googleglass,项目名称:gdk-apidemo-sample,代码行数:22,代码来源:TouchpadView.java

示例8: isRecognizedInputDevice

import android.view.InputDevice; //导入方法依赖的package包/类
private static boolean isRecognizedInputDevice(UsbDevice device) {
    // On KitKat and later, we can determine if this VID and PID combo
    // matches an existing input device and defer to the built-in controller
    // support in that case. Prior to KitKat, we'll always return true to be safe.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        for (int id : InputDevice.getDeviceIds()) {
            InputDevice inputDev = InputDevice.getDevice(id);
            if (inputDev == null) {
                // Device was removed while looping
                continue;
            }

            if (inputDev.getVendorId() == device.getVendorId() &&
                    inputDev.getProductId() == device.getProductId()) {
                return true;
            }
        }

        return false;
    }
    else {
        return true;
    }
}
 
开发者ID:moonlight-stream,项目名称:moonlight-android,代码行数:25,代码来源:UsbDriverService.java

示例9: getTouchDeviceName

import android.view.InputDevice; //导入方法依赖的package包/类
@Nullable
public static String getTouchDeviceName() {
    for (int id : InputDevice.getDeviceIds()) {
        InputDevice device = InputDevice.getDevice(id);
        if (supportSource(device, InputDevice.SOURCE_TOUCHSCREEN) || supportSource(device, InputDevice.SOURCE_TOUCHPAD)) {
            return device.getName();
        }
    }
    return null;
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:11,代码来源:InputDevices.java

示例10: inputGetInputDeviceIds

import android.view.InputDevice; //导入方法依赖的package包/类
/**
 * This method is called by SDL using JNI.
 * @return an array which may be empty but is never null.
 */
public static int[] inputGetInputDeviceIds(int sources) {
    int[] ids = InputDevice.getDeviceIds();
    int[] filtered = new int[ids.length];
    int used = 0;
    for (int i = 0; i < ids.length; ++i) {
        InputDevice device = InputDevice.getDevice(ids[i]);
        if ((device != null) && ((device.getSources() & sources) != 0)) {
            filtered[used++] = device.getId();
        }
    }
    return Arrays.copyOf(filtered, used);
}
 
开发者ID:jomof,项目名称:cdep-android-studio-freetype-sample,代码行数:17,代码来源:SDLActivity.java

示例11: getInputDeviceIds

import android.view.InputDevice; //导入方法依赖的package包/类
@Override
public int[] getInputDeviceIds() {
    // add any hitherto unknown devices to our
    // collection of watched input devices
    int[] activeDevices = InputDevice.getDeviceIds();
    long time = SystemClock.elapsedRealtime();
    for ( int id : activeDevices ) {
        long[] lastContact = mDevices.get(id);
        if ( null == lastContact ) {
            // we have a new device
            mDevices.put(id, new long[] { time });
        }
    }
    return activeDevices;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:16,代码来源:InputManagerV9.java

示例12: getDetailedItems

import android.view.InputDevice; //导入方法依赖的package包/类
public List<ItemDetails> getDetailedItems() {
    List<ItemDetails> detailedItems = new ArrayList<>();
    int[] ids = InputDevice.getDeviceIds();
    for (int id : ids) {
        InputDevice device = InputDevice.getDevice(id);
        detailedItems.add(new ItemDetails(device.getName(), device.toString()));
    }

    return detailedItems;
}
 
开发者ID:iamtrk,项目名称:Device-Explorer,代码行数:11,代码来源:Content.java

示例13: getContents

import android.view.InputDevice; //导入方法依赖的package包/类
public String getContents() {
    StringBuilder sb = new StringBuilder();
    Formatter f = new Formatter(sb, Locale.US);
    int[] ids = InputDevice.getDeviceIds();
    f.format("Device count: %d\n", ids.length);
    for (int i = 0; i < ids.length; i++) {
        int id = ids[i];
        InputDevice device = InputDevice.getDevice(id);
        f.format("#%d: id = 0x%x\n%s\n", i, id, device);
    }
    return sb.toString();
}
 
开发者ID:iamtrk,项目名称:Device-Explorer,代码行数:13,代码来源:Content.java

示例14: isGameControllerConnected

import android.view.InputDevice; //导入方法依赖的package包/类
public boolean isGameControllerConnected() {
    int[] deviceIds = InputDevice.getDeviceIds();
    for (int deviceId : deviceIds) {
        InputDevice dev = InputDevice.getDevice(deviceId);
        int sources = dev.getSources();
        if (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) ||
            ((sources & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:13,代码来源:MainMenuFragment.java

示例15: getHardwareDevices

import android.view.InputDevice; //导入方法依赖的package包/类
public ArrayList<String> getHardwareDevices() {
	ArrayList<String> devices  = new ArrayList<String>();
	for(int deviceId : InputDevice.getDeviceIds()) {
		devices.add(InputDevice.getDevice(deviceId).getName());
	}
	
	return devices;
}
 
开发者ID:FAIMS,项目名称:faims-android,代码行数:9,代码来源:BeanShellLinker.java


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