diff options
author | dbehr <dominikbehr@yahoo.com> | 2011-10-07 01:45:05 -0700 |
---|---|---|
committer | dbehr <dominikbehr@yahoo.com> | 2011-10-07 01:45:05 -0700 |
commit | f4b4cf5b60960ad76e5d240bcc080121d724ce84 (patch) | |
tree | 7e5e1ba0c66ab2425e77311e066caaba6fc2aefd | |
parent | 5dd3bd4857804fd7ab9d1891c7051740e099ce53 (diff) | |
download | frameworks_base-f4b4cf5b60960ad76e5d240bcc080121d724ce84.zip frameworks_base-f4b4cf5b60960ad76e5d240bcc080121d724ce84.tar.gz frameworks_base-f4b4cf5b60960ad76e5d240bcc080121d724ce84.tar.bz2 |
do not rotate keyboard dpad events for bluetooth keyboards (since they are not attached to the device and do not rotate when device is rotated)
-rw-r--r-- | include/ui/EventHub.h | 11 | ||||
-rw-r--r-- | include/ui/InputReader.h | 3 | ||||
-rw-r--r-- | libs/ui/EventHub.cpp | 13 | ||||
-rw-r--r-- | libs/ui/InputReader.cpp | 8 | ||||
-rw-r--r-- | libs/ui/tests/InputReader_test.cpp | 4 |
5 files changed, 28 insertions, 11 deletions
diff --git a/include/ui/EventHub.h b/include/ui/EventHub.h index 404be25..6211e9d 100644 --- a/include/ui/EventHub.h +++ b/include/ui/EventHub.h @@ -158,6 +158,8 @@ public: virtual String8 getDeviceName(int32_t deviceId) const = 0; + virtual bool getDeviceBluetooth(int32_t deviceId) const = 0; + virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, RawAbsoluteAxisInfo* outAxisInfo) const = 0; @@ -201,9 +203,11 @@ public: status_t errorCheck() const; virtual uint32_t getDeviceClasses(int32_t deviceId) const; - + virtual String8 getDeviceName(int32_t deviceId) const; - + + virtual bool getDeviceBluetooth(int32_t deviceId) const; + virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, RawAbsoluteAxisInfo* outAxisInfo) const; @@ -245,9 +249,10 @@ private: KeyLayoutMap* layoutMap; String8 keylayoutFilename; int fd; + bool bluetooth; device_t* next; - device_t(int32_t _id, const char* _path, const char* name); + device_t(int32_t _id, const char* _path, const char* name, bool _bluetooth); ~device_t(); }; diff --git a/include/ui/InputReader.h b/include/ui/InputReader.h index 8d9ad5c..bc8508b 100644 --- a/include/ui/InputReader.h +++ b/include/ui/InputReader.h @@ -405,7 +405,7 @@ private: class KeyboardInputMapper : public InputMapper { public: KeyboardInputMapper(InputDevice* device, int32_t associatedDisplayId, uint32_t sources, - int32_t keyboardType); + int32_t keyboardType, bool bluetooth = false); virtual ~KeyboardInputMapper(); virtual uint32_t getSources(); @@ -432,6 +432,7 @@ private: int32_t mAssociatedDisplayId; uint32_t mSources; int32_t mKeyboardType; + bool mBluetooth; struct LockedState { Vector<KeyDown> keyDowns; // keys that are down diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp index 5f920a7..01facbb 100644 --- a/libs/ui/EventHub.cpp +++ b/libs/ui/EventHub.cpp @@ -92,9 +92,9 @@ static inline const char* toString(bool value) { return value ? "true" : "false"; } -EventHub::device_t::device_t(int32_t _id, const char* _path, const char* name) +EventHub::device_t::device_t(int32_t _id, const char* _path, const char* name, bool _bluetooth) : id(_id), path(_path), name(name), classes(0) - , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), fd(-1), next(NULL) { + , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), fd(-1), bluetooth(_bluetooth), next(NULL) { } EventHub::device_t::~device_t() { @@ -137,6 +137,13 @@ String8 EventHub::getDeviceName(int32_t deviceId) const return device->name; } +bool EventHub::getDeviceBluetooth(int32_t deviceId) const +{ + AutoMutex _l(mLock); + device_t* device = getDeviceLocked(deviceId); + return device->bluetooth; +} + uint32_t EventHub::getDeviceClasses(int32_t deviceId) const { AutoMutex _l(mLock); @@ -669,7 +676,7 @@ int EventHub::openDevice(const char *deviceName) { version >> 16, (version >> 8) & 0xff, version & 0xff); #endif - device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName, name); + device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName, name, BUS_BLUETOOTH == id.bustype); if (device == NULL) { LOGE("out of memory"); return -1; diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp index b6879dd..23fb533 100644 --- a/libs/ui/InputReader.cpp +++ b/libs/ui/InputReader.cpp @@ -332,7 +332,7 @@ InputDevice* InputReader::createDevice(int32_t deviceId, const String8& name, ui if (keyboardSources != 0) { device->addMapper(new KeyboardInputMapper(device, - associatedDisplayId, keyboardSources, keyboardType)); + associatedDisplayId, keyboardSources, keyboardType, mEventHub->getDeviceBluetooth(deviceId))); } // Trackball-like devices. @@ -870,9 +870,9 @@ int32_t SwitchInputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCod // --- KeyboardInputMapper --- KeyboardInputMapper::KeyboardInputMapper(InputDevice* device, int32_t associatedDisplayId, - uint32_t sources, int32_t keyboardType) : + uint32_t sources, int32_t keyboardType, bool bluetooth) : InputMapper(device), mAssociatedDisplayId(associatedDisplayId), mSources(sources), - mKeyboardType(keyboardType) { + mKeyboardType(keyboardType), mBluetooth(bluetooth) { initializeLocked(); } @@ -962,7 +962,7 @@ void KeyboardInputMapper::processKey(nsecs_t when, bool down, int32_t keyCode, if (down) { // Rotate key codes according to orientation if needed. // Note: getDisplayInfo is non-reentrant so we can continue holding the lock. - if (mAssociatedDisplayId >= 0) { + if (!mBluetooth && mAssociatedDisplayId >= 0) { int32_t orientation; if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) { return; diff --git a/libs/ui/tests/InputReader_test.cpp b/libs/ui/tests/InputReader_test.cpp index 09d1680..aec7ba9 100644 --- a/libs/ui/tests/InputReader_test.cpp +++ b/libs/ui/tests/InputReader_test.cpp @@ -486,6 +486,10 @@ private: return device ? device->name : String8("unknown"); } + virtual bool getDeviceBluetooth(int32_t deviceId) const { + return false; + } + virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, RawAbsoluteAxisInfo* outAxisInfo) const { Device* device = getDevice(deviceId); |