Loading include/ui/Input.h +9 −1 Original line number Diff line number Diff line Loading @@ -179,6 +179,14 @@ public: inline nsecs_t getEventTime() const { return mEventTime; } // Return true if this event may have a default action implementation. static bool hasDefaultAction(int32_t keyCode); bool hasDefaultAction() const; // Return true if this event represents a system key. static bool isSystemKey(int32_t keyCode); bool isSystemKey() const; void initialize( int32_t deviceId, int32_t nature, Loading include/ui/InputTransport.h +3 −1 Original line number Diff line number Diff line Loading @@ -339,12 +339,14 @@ public: explicit AInputQueue(const android::sp<android::InputChannel>& channel); /* Destroys the consumer and releases its input channel. */ ~AInputQueue(); virtual ~AInputQueue(); inline android::InputConsumer& getConsumer() { return mConsumer; } android::status_t consume(android::InputEvent** event); virtual void doDefaultKey(android::KeyEvent* keyEvent) = 0; private: android::InputConsumer mConsumer; android::PreallocatedInputEventFactory mInputEventFactory; Loading libs/ui/Input.cpp +64 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,70 @@ void InputEvent::initialize(int32_t deviceId, int32_t nature) { // class KeyEvent bool KeyEvent::hasDefaultAction(int32_t keyCode) { switch (keyCode) { case KEYCODE_HOME: case KEYCODE_BACK: case KEYCODE_CALL: case KEYCODE_ENDCALL: case KEYCODE_VOLUME_UP: case KEYCODE_VOLUME_DOWN: case KEYCODE_POWER: case KEYCODE_CAMERA: case KEYCODE_HEADSETHOOK: case KEYCODE_MENU: case KEYCODE_NOTIFICATION: case KEYCODE_FOCUS: case KEYCODE_SEARCH: case KEYCODE_MEDIA_PLAY_PAUSE: case KEYCODE_MEDIA_STOP: case KEYCODE_MEDIA_NEXT: case KEYCODE_MEDIA_PREVIOUS: case KEYCODE_MEDIA_REWIND: case KEYCODE_MEDIA_FAST_FORWARD: case KEYCODE_MUTE: return true; } return false; } bool KeyEvent::hasDefaultAction() const { return hasDefaultAction(getKeyCode()); } bool KeyEvent::isSystemKey(int32_t keyCode) { switch (keyCode) { case KEYCODE_MENU: case KEYCODE_SOFT_RIGHT: case KEYCODE_HOME: case KEYCODE_BACK: case KEYCODE_CALL: case KEYCODE_ENDCALL: case KEYCODE_VOLUME_UP: case KEYCODE_VOLUME_DOWN: case KEYCODE_MUTE: case KEYCODE_POWER: case KEYCODE_HEADSETHOOK: case KEYCODE_MEDIA_PLAY_PAUSE: case KEYCODE_MEDIA_STOP: case KEYCODE_MEDIA_NEXT: case KEYCODE_MEDIA_PREVIOUS: case KEYCODE_MEDIA_REWIND: case KEYCODE_MEDIA_FAST_FORWARD: case KEYCODE_CAMERA: case KEYCODE_FOCUS: case KEYCODE_SEARCH: return true; } return false; } bool KeyEvent::isSystemKey() const { return isSystemKey(getKeyCode()); } void KeyEvent::initialize( int32_t deviceId, int32_t nature, Loading Loading
include/ui/Input.h +9 −1 Original line number Diff line number Diff line Loading @@ -179,6 +179,14 @@ public: inline nsecs_t getEventTime() const { return mEventTime; } // Return true if this event may have a default action implementation. static bool hasDefaultAction(int32_t keyCode); bool hasDefaultAction() const; // Return true if this event represents a system key. static bool isSystemKey(int32_t keyCode); bool isSystemKey() const; void initialize( int32_t deviceId, int32_t nature, Loading
include/ui/InputTransport.h +3 −1 Original line number Diff line number Diff line Loading @@ -339,12 +339,14 @@ public: explicit AInputQueue(const android::sp<android::InputChannel>& channel); /* Destroys the consumer and releases its input channel. */ ~AInputQueue(); virtual ~AInputQueue(); inline android::InputConsumer& getConsumer() { return mConsumer; } android::status_t consume(android::InputEvent** event); virtual void doDefaultKey(android::KeyEvent* keyEvent) = 0; private: android::InputConsumer mConsumer; android::PreallocatedInputEventFactory mInputEventFactory; Loading
libs/ui/Input.cpp +64 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,70 @@ void InputEvent::initialize(int32_t deviceId, int32_t nature) { // class KeyEvent bool KeyEvent::hasDefaultAction(int32_t keyCode) { switch (keyCode) { case KEYCODE_HOME: case KEYCODE_BACK: case KEYCODE_CALL: case KEYCODE_ENDCALL: case KEYCODE_VOLUME_UP: case KEYCODE_VOLUME_DOWN: case KEYCODE_POWER: case KEYCODE_CAMERA: case KEYCODE_HEADSETHOOK: case KEYCODE_MENU: case KEYCODE_NOTIFICATION: case KEYCODE_FOCUS: case KEYCODE_SEARCH: case KEYCODE_MEDIA_PLAY_PAUSE: case KEYCODE_MEDIA_STOP: case KEYCODE_MEDIA_NEXT: case KEYCODE_MEDIA_PREVIOUS: case KEYCODE_MEDIA_REWIND: case KEYCODE_MEDIA_FAST_FORWARD: case KEYCODE_MUTE: return true; } return false; } bool KeyEvent::hasDefaultAction() const { return hasDefaultAction(getKeyCode()); } bool KeyEvent::isSystemKey(int32_t keyCode) { switch (keyCode) { case KEYCODE_MENU: case KEYCODE_SOFT_RIGHT: case KEYCODE_HOME: case KEYCODE_BACK: case KEYCODE_CALL: case KEYCODE_ENDCALL: case KEYCODE_VOLUME_UP: case KEYCODE_VOLUME_DOWN: case KEYCODE_MUTE: case KEYCODE_POWER: case KEYCODE_HEADSETHOOK: case KEYCODE_MEDIA_PLAY_PAUSE: case KEYCODE_MEDIA_STOP: case KEYCODE_MEDIA_NEXT: case KEYCODE_MEDIA_PREVIOUS: case KEYCODE_MEDIA_REWIND: case KEYCODE_MEDIA_FAST_FORWARD: case KEYCODE_CAMERA: case KEYCODE_FOCUS: case KEYCODE_SEARCH: return true; } return false; } bool KeyEvent::isSystemKey() const { return isSystemKey(getKeyCode()); } void KeyEvent::initialize( int32_t deviceId, int32_t nature, Loading