michael@0: /* michael@0: * Copyright (C) 2010 The Android Open Source Project michael@0: * michael@0: * Licensed under the Apache License, Version 2.0 (the "License"); michael@0: * you may not use this file except in compliance with the License. michael@0: * You may obtain a copy of the License at michael@0: * michael@0: * http://www.apache.org/licenses/LICENSE-2.0 michael@0: * michael@0: * Unless required by applicable law or agreed to in writing, software michael@0: * distributed under the License is distributed on an "AS IS" BASIS, michael@0: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. michael@0: * See the License for the specific language governing permissions and michael@0: * limitations under the License. michael@0: */ michael@0: michael@0: #ifndef _UI_INPUT_MANAGER_H michael@0: #define _UI_INPUT_MANAGER_H michael@0: michael@0: /** michael@0: * Native input manager. michael@0: */ michael@0: michael@0: #include "EventHub.h" michael@0: #include "InputReader.h" michael@0: #include "InputDispatcher.h" michael@0: michael@0: #include "Input.h" michael@0: #include "InputTransport.h" michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: michael@0: namespace android { michael@0: michael@0: /* michael@0: * The input manager is the core of the system event processing. michael@0: * michael@0: * The input manager uses two threads. michael@0: * michael@0: * 1. The InputReaderThread (called "InputReader") reads and preprocesses raw input events, michael@0: * applies policy, and posts messages to a queue managed by the DispatcherThread. michael@0: * 2. The InputDispatcherThread (called "InputDispatcher") thread waits for new events on the michael@0: * queue and asynchronously dispatches them to applications. michael@0: * michael@0: * By design, the InputReaderThread class and InputDispatcherThread class do not share any michael@0: * internal state. Moreover, all communication is done one way from the InputReaderThread michael@0: * into the InputDispatcherThread and never the reverse. Both classes may interact with the michael@0: * InputDispatchPolicy, however. michael@0: * michael@0: * The InputManager class never makes any calls into Java itself. Instead, the michael@0: * InputDispatchPolicy is responsible for performing all external interactions with the michael@0: * system, including calling DVM services. michael@0: */ michael@0: class InputManagerInterface : public virtual RefBase { michael@0: protected: michael@0: InputManagerInterface() { } michael@0: virtual ~InputManagerInterface() { } michael@0: michael@0: public: michael@0: /* Starts the input manager threads. */ michael@0: virtual status_t start() = 0; michael@0: michael@0: /* Stops the input manager threads and waits for them to exit. */ michael@0: virtual status_t stop() = 0; michael@0: michael@0: /* Gets the input reader. */ michael@0: virtual sp getReader() = 0; michael@0: michael@0: /* Gets the input dispatcher. */ michael@0: virtual sp getDispatcher() = 0; michael@0: }; michael@0: michael@0: class InputManager : public InputManagerInterface { michael@0: protected: michael@0: virtual ~InputManager(); michael@0: michael@0: public: michael@0: InputManager( michael@0: const sp& eventHub, michael@0: const sp& readerPolicy, michael@0: const sp& dispatcherPolicy); michael@0: michael@0: // (used for testing purposes) michael@0: InputManager( michael@0: const sp& reader, michael@0: const sp& dispatcher); michael@0: michael@0: virtual status_t start(); michael@0: virtual status_t stop(); michael@0: michael@0: virtual sp getReader(); michael@0: virtual sp getDispatcher(); michael@0: michael@0: private: michael@0: sp mReader; michael@0: sp mReaderThread; michael@0: michael@0: sp mDispatcher; michael@0: sp mDispatcherThread; michael@0: michael@0: void initialize(); michael@0: }; michael@0: michael@0: } // namespace android michael@0: michael@0: #endif // _UI_INPUT_MANAGER_H