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


Java InputManager类代码示例

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


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

示例1: onCreate

import android.hardware.input.InputManager; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    if (DEBUG) Log.d(TAG, "onCreate");

    mUsbManager = (UsbManager) getBaseContext().getSystemService(Context.USB_SERVICE);
    mAudioManager = (AudioManager) getBaseContext().getSystemService(Context.AUDIO_SERVICE);
    mPowerManager = (PowerManager) getBaseContext().getSystemService(Context.POWER_SERVICE);
    mInputManager = (InputManager) getBaseContext().getSystemService(Context.INPUT_SERVICE);

    ConfigStorage.SerialPortIdentifier portIdentifier =
            ConfigStorage.readDefaultPort(getBaseContext());
    if (DEBUG) Log.d(TAG, "onCreate, portIdentifier: " + portIdentifier);
    if (portIdentifier != null) {
        UsbSerialPort port = findUsbSerialPort(portIdentifier);
        if (port == null) {
            Log.w(TAG, "Unable to find usb serial port,  make sure device is connected: "
                    + portIdentifier);
            return;
        }

        onUsbSerialPortChanged(port);
    }
}
 
开发者ID:OpilkiInside,项目名称:bimdroid,代码行数:26,代码来源:BmwIBusService.java

示例2: handleMessage

import android.hardware.input.InputManager; //导入依赖的package包/类
public void handleMessage(Message m) {
    switch (m.what) {
        case MSG_INJECT_KEY:
            final long eventTime = SystemClock.uptimeMillis();
            final InputManager inputManager = (InputManager)
                    XposedHelpers.callStaticMethod(InputManager.class, "getInstance");

            int flags = KeyEvent.FLAG_FROM_SYSTEM;
            XposedHelpers.callMethod(inputManager, "injectInputEvent",
                    new KeyEvent(eventTime - 50, eventTime - 50, KeyEvent.ACTION_DOWN, m.arg1, 0,
                            0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_UNKNOWN), 0);
            XposedHelpers.callMethod(inputManager, "injectInputEvent",
                    new KeyEvent(eventTime - 50, eventTime - 25, KeyEvent.ACTION_UP, m.arg1, 0,
                            0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags, InputDevice.SOURCE_UNKNOWN), 0);

            break;
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:PieController.java

示例3: injectKey

import android.hardware.input.InputManager; //导入依赖的package包/类
public static void injectKey(final int keyCode) {
    Handler handler = (Handler) XposedHelpers.getObjectField(mPhoneWindowManager, "mHandler");
    if (handler == null) return;

    handler.post(new Runnable() {
        @Override
        public void run() {
            try {
                final long eventTime = SystemClock.uptimeMillis();
                final InputManager inputManager = (InputManager)
                        mContext.getSystemService(Context.INPUT_SERVICE);
                int flags = KeyEvent.FLAG_FROM_SYSTEM;
                XposedHelpers.callMethod(inputManager, "injectInputEvent",
                        new KeyEvent(eventTime - 50, eventTime - 50, KeyEvent.ACTION_DOWN,
                                keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags,
                                InputDevice.SOURCE_UNKNOWN), 0);
                XposedHelpers.callMethod(inputManager, "injectInputEvent",
                        new KeyEvent(eventTime - 50, eventTime - 25, KeyEvent.ACTION_UP,
                                keyCode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD, 0, flags,
                                InputDevice.SOURCE_UNKNOWN), 0);
            } catch (Throwable t) {
                XposedBridge.log(t);
            }
        }
    });
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:27,代码来源:ModHwKeys.java

示例4: prepareAndStartGame

import android.hardware.input.InputManager; //导入依赖的package包/类
private void prepareAndStartGame() {
    GameView gameView = (GameView) getView().findViewById(R.id.gameView);
    mGameEngine = new GameEngine(getActivity(), gameView, 4);
    mGameEngine.setInputController(new CompositeInputController(getView(), getYassActivity()));
    mGameEngine.setSoundManager(getYassActivity().getSoundManager());
    new ParallaxBackground(mGameEngine, 20, R.drawable.seamless_space_0).addToGameEngine(mGameEngine, 0);
    new GameController(mGameEngine, GameFragment.this).addToGameEngine(mGameEngine, 2);
    new FPSCounter(mGameEngine).addToGameEngine(mGameEngine, 2);
    new ScoreGameObject(this, getView(), R.id.score_value).addToGameEngine(mGameEngine, 0);
    new LivesCounter(getView(), R.id.lives_value).addToGameEngine(mGameEngine, 0);
    mGameEngine.startGame();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        InputManager inputManager = (InputManager) getActivity().getSystemService(Context.INPUT_SERVICE);
        inputManager.registerInputDeviceListener(GameFragment.this, null);
    }
    gameView.postInvalidate();
}
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:18,代码来源:GameFragment.java

示例5: prepareAndStartGame

import android.hardware.input.InputManager; //导入依赖的package包/类
private void prepareAndStartGame() {
        GameView gameView = (GameView) getView().findViewById(R.id.gameView);
        mGameEngine = new GameEngine(getActivity(), gameView, 4);
        mGameEngine.setInputController(new CompositeInputController(getView(), getYassActivity()));
        mGameEngine.setSoundManager(getYassActivity().getSoundManager());
        new ParallaxBackground(mGameEngine, 20, R.drawable.seamless_space_0).addToGameEngine(mGameEngine, 0);
//                mGameEngine.addGameObject(new ParallaxBackground(mGameEngine, 30, R.drawable.parallax60), 0);
        new GameController(mGameEngine, GameFragment.this).addToGameEngine(mGameEngine, 2);
        new FPSCounter(mGameEngine).addToGameEngine(mGameEngine, 2);
        new ScoreGameObject(getView(), R.id.score_value).addToGameEngine(mGameEngine, 0);
        new LivesCounter(getView(), R.id.lives_value).addToGameEngine(mGameEngine, 0);
        mGameEngine.startGame();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            InputManager inputManager = (InputManager) getActivity().getSystemService(Context.INPUT_SERVICE);
            inputManager.registerInputDeviceListener(GameFragment.this, null);
        }
    }
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:18,代码来源:GameFragment.java

示例6: prepareAndStartGame

import android.hardware.input.InputManager; //导入依赖的package包/类
private void prepareAndStartGame() {
    GameView gameView = (GameView) getView().findViewById(R.id.gameView);
    mGameEngine = new GameEngine(getActivity(), gameView, 4);
    mGameEngine.setInputController(new CompositeInputController(getView(), getYassActivity()));
    mGameEngine.setSoundManager(getYassActivity().getSoundManager());
    new ParallaxBackground(mGameEngine, 20, R.drawable.seamless_space_0).addToGameEngine(mGameEngine, 0);
    new GameController(mGameEngine, GameFragment.this).addToGameEngine(mGameEngine, 2);
    new FPSCounter(mGameEngine).addToGameEngine(mGameEngine, 2);
    new ScoreGameObject(getView(), R.id.score_value).addToGameEngine(mGameEngine, 0);
    new LivesCounter(getView(), R.id.lives_value).addToGameEngine(mGameEngine, 0);
    mGameEngine.startGame();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        InputManager inputManager = (InputManager) getActivity().getSystemService(Context.INPUT_SERVICE);
        inputManager.registerInputDeviceListener(GameFragment.this, null);
    }
    gameView.postInvalidate();
}
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:18,代码来源:GameFragment.java

示例7: onViewCreated

import android.hardware.input.InputManager; //导入依赖的package包/类
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    view.findViewById(R.id.btn_play_pause).setOnClickListener(this);
    final ViewTreeObserver obs = view.getViewTreeObserver();
    obs.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
                obs.removeGlobalOnLayoutListener(this);
            }
            else {
                obs.removeOnGlobalLayoutListener(this);
            }
            mGameEngine = new GameEngine(getActivity());
            mGameEngine.setInputController(new CompositeInputController(getView(), getYassActivity()));
            mGameEngine.addGameObject(new Player(getView()));
            mGameEngine.startGame();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                InputManager inputManager = (InputManager) getActivity().getSystemService(Context.INPUT_SERVICE);
                inputManager.registerInputDeviceListener(GameFragment.this, null);
            }
        }
    });
}
 
开发者ID:PacktPublishing,项目名称:Android-Game-Programming,代码行数:26,代码来源:GameFragment.java

示例8: MotionEventSender

import android.hardware.input.InputManager; //导入依赖的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

示例9: prepareAndStartGame

import android.hardware.input.InputManager; //导入依赖的package包/类
private void prepareAndStartGame() {
        GameView gameView = (GameView) getView().findViewById(R.id.gameView);
        mGameEngine = new GameEngine(getActivity(), gameView, 4);
        mGameEngine.setSoundManager(getMainActivity().getSoundManager());
        new GameController(mGameEngine, GameFragment.this).addToGameEngine(mGameEngine, 2);
//        new FPSCounter(mGameEngine).addToGameEngine(mGameEngine, 2);
        new BackgroundImage(mGameEngine, R.drawable.background).addToGameEngine(mGameEngine, 0);
        mGameEngine.startGame();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            InputManager inputManager = (InputManager) getActivity().getSystemService(Context.INPUT_SERVICE);
            inputManager.registerInputDeviceListener(GameFragment.this, null);
        }
        gameView.postInvalidate();

        for (int i=0; i<DUMMY_OBJECT_POOL_SIZE; i++) {
            mDummyObjectPool.add(new DummyObject(mGameEngine));
        }

        getView().findViewById(R.id.gameView).setOnTouchListener(this);
    }
 
开发者ID:plattysoft,项目名称:BalloonsGame,代码行数:21,代码来源:GameFragment.java

示例10: onDestroy

import android.hardware.input.InputManager; //导入依赖的package包/类
@Override
public void onDestroy()
{
	this.webView.setOnGenericMotionListener(null);
	this.webView.setOnKeyListener(null);

	usedIndices = null;
	buttonsToJustProcessActionDown = null;
	eventArgument = null;
	gamepads = null;

	this.cordova.getActivity().runOnUiThread(new Runnable()
	{
		@Override
		public void run()
		{
			InputManager inputManager = (InputManager) cordova.getActivity()
					.getSystemService(Context.INPUT_SERVICE);
			inputManager.unregisterInputDeviceListener(CordovaPluginGamepad.this);
		}
	});
}
 
开发者ID:WinnipegAndroid,项目名称:cordova-android-tv,代码行数:23,代码来源:CordovaPluginGamepad.java

示例11: onCreate

import android.hardware.input.InputManager; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mInputManager = (InputManager)getSystemService(Context.INPUT_SERVICE);

    mInputDeviceStates = new SparseArray<InputDeviceState>();
    mSummaryAdapter = new SummaryAdapter(this, getResources());

    setContentView(R.layout.game_controller_input);

    mGame = (GameView) findViewById(R.id.game);

    mSummaryList = (ListView) findViewById(R.id.summary);
    mSummaryList.setAdapter(mSummaryAdapter);
    mSummaryList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mSummaryAdapter.onItemClick(position);
        }
    });
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:23,代码来源:GameControllerInput.java

示例12: GameView

import android.hardware.input.InputManager; //导入依赖的package包/类
public GameView(Context context) {
    super( context );

    setEGLContextClientVersion( 2 );
    this.setRenderer( this );
    this.requestFocus();

    mInstance = this;

    mLastUpdateTimeMillis = System.currentTimeMillis();

    mShip = new Ship();

    InputManager inputManager = (InputManager) context.getSystemService( Context.INPUT_SERVICE );
    inputManager.registerInputDeviceListener( this, null );
    mAsteroids = new ArrayList<Asteroid>();
    mBullets = new ArrayList<Bullet>();
    initLevel();
}
 
开发者ID:Lakkichand,项目名称:AndroidDemoProjects,代码行数:20,代码来源:GameView.java

示例13: EventInput

import android.hardware.input.InputManager; //导入依赖的package包/类
public EventInput() throws Exception {
    //Get the instance of InputManager class using reflection
    String methodName = "getInstance";
    Object[] objArr = new Object[0];
    im = (InputManager) InputManager.class.getDeclaredMethod(methodName, new Class[0])
            .invoke(null, objArr);

    //Make MotionEvent.obtain() method accessible
    methodName = "obtain";
    MotionEvent.class.getDeclaredMethod(methodName, new Class[0]).setAccessible(true);

    //Get the reference to injectInputEvent method
    methodName = "injectInputEvent";
    injectInputEventMethod = InputManager.class.getMethod(
            methodName, new Class[]{InputEvent.class, Integer.TYPE});
}
 
开发者ID:omerjerk,项目名称:RemoteDroid,代码行数:17,代码来源:EventInput.java

示例14: injectKey

import android.hardware.input.InputManager; //导入依赖的package包/类
protected void injectKey(int keycode) {
	InputManager inputManager = (InputManager) XposedHelpers
			.callStaticMethod(InputManager.class, "getInstance");
	long now = SystemClock.uptimeMillis();
	final KeyEvent downEvent = new KeyEvent(now, now, KeyEvent.ACTION_DOWN,
			keycode, 0, 0, KeyCharacterMap.VIRTUAL_KEYBOARD,
			0, KeyEvent.FLAG_FROM_SYSTEM, InputDevice.SOURCE_KEYBOARD);
	final KeyEvent upEvent = KeyEvent.changeAction(downEvent,
			KeyEvent.ACTION_UP);

	Integer INJECT_INPUT_EVENT_MODE_ASYNC = XposedHelpers
			.getStaticIntField(InputManager.class,
					"INJECT_INPUT_EVENT_MODE_ASYNC");

	XposedHelpers.callMethod(inputManager, "injectInputEvent", downEvent,
			INJECT_INPUT_EVENT_MODE_ASYNC);
	XposedHelpers.callMethod(inputManager, "injectInputEvent", upEvent,
			INJECT_INPUT_EVENT_MODE_ASYNC);

}
 
开发者ID:adipascu,项目名称:XposedMenuBeGone,代码行数:21,代码来源:Main.java

示例15: onDestroy

import android.hardware.input.InputManager; //导入依赖的package包/类
@Override
protected void onDestroy() {
    super.onDestroy();

    if (controllerHandler != null) {
        InputManager inputManager = (InputManager) getSystemService(Context.INPUT_SERVICE);
        inputManager.unregisterInputDeviceListener(controllerHandler);
    }

    wifiLock.release();

    if (connectedToUsbDriverService) {
        // Unbind from the discovery service
        unbindService(usbDriverServiceConnection);
    }

    // Destroy the capture provider
    inputCaptureProvider.destroy();
}
 
开发者ID:moonlight-stream,项目名称:moonlight-android,代码行数:20,代码来源:Game.java


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