diff options
Diffstat (limited to 'libs/ui')
-rw-r--r-- | libs/ui/EventHub.cpp | 26 | ||||
-rw-r--r-- | libs/ui/InputReader.cpp | 25 | ||||
-rw-r--r-- | libs/ui/tests/InputReader_test.cpp | 4 |
3 files changed, 33 insertions, 22 deletions
diff --git a/libs/ui/EventHub.cpp b/libs/ui/EventHub.cpp index 01facbb..9c78a74 100644 --- a/libs/ui/EventHub.cpp +++ b/libs/ui/EventHub.cpp @@ -77,6 +77,9 @@ #define INDENT2 " " #define INDENT3 " " +//#define DEBUG_SHOW_DEVICES +//#define DEBUG_SHOW_KEYSDOWN + namespace android { static const char *WAKE_LOCK_ID = "KeyEvents"; @@ -92,9 +95,11 @@ 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, bool _bluetooth) +EventHub::device_t::device_t(int32_t _id, const char* _path, const char* name, uint32_t _bustype) : id(_id), path(_path), name(name), classes(0) - , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), fd(-1), bluetooth(_bluetooth), next(NULL) { + , keyBitmask(NULL), layoutMap(new KeyLayoutMap()), fd(-1), bustype(_bustype), next(NULL) { + bluetooth = (_bustype == BUS_BLUETOOTH); + usb = (_bustype == BUS_USB); } EventHub::device_t::~device_t() { @@ -137,11 +142,11 @@ String8 EventHub::getDeviceName(int32_t deviceId) const return device->name; } -bool EventHub::getDeviceBluetooth(int32_t deviceId) const +uint32_t EventHub::getDeviceBusType(int32_t deviceId) const { AutoMutex _l(mLock); device_t* device = getDeviceLocked(deviceId); - return device->bluetooth; + return device->bustype; } uint32_t EventHub::getDeviceClasses(int32_t deviceId) const @@ -217,16 +222,13 @@ int32_t EventHub::getKeyCodeStateLocked(device_t* device, int32_t keyCode) const uint8_t key_bitmask[sizeof_bit_array(KEY_MAX + 1)]; memset(key_bitmask, 0, sizeof(key_bitmask)); if (ioctl(device->fd, EVIOCGKEY(sizeof(key_bitmask)), key_bitmask) >= 0) { - #if 0 - for (size_t i=0; i<=KEY_MAX; i++) { - LOGI("(Scan code %d: down=%d)", i, test_bit(i, key_bitmask)); - } - #endif const size_t N = scanCodes.size(); for (size_t i=0; i<N && i<=KEY_MAX; i++) { int32_t sc = scanCodes.itemAt(i); - //LOGI("Code %d: down=%d", sc, test_bit(sc, key_bitmask)); if (sc >= 0 && sc <= KEY_MAX && test_bit(sc, key_bitmask)) { + #ifdef DEBUG_SHOW_KEYSDOWN + LOGI("Code %d: down=%d", sc, test_bit(sc, key_bitmask)); + #endif return AKEY_STATE_DOWN; } } @@ -662,7 +664,7 @@ int EventHub::openDevice(const char *deviceName) { mFDs = new_mFDs; mDevices = new_devices; -#if 0 +#ifdef DEBUG_SHOW_DEVICES LOGI("add device %d: %s\n", mFDCount, deviceName); LOGI(" bus: %04x\n" " vendor %04x\n" @@ -676,7 +678,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, BUS_BLUETOOTH == id.bustype); + device_t* device = new device_t(devid|mDevicesById[devid].seq, deviceName, name, id.bustype); if (device == NULL) { LOGE("out of memory"); return -1; diff --git a/libs/ui/InputReader.cpp b/libs/ui/InputReader.cpp index 4cd24859..7626b15 100644 --- a/libs/ui/InputReader.cpp +++ b/libs/ui/InputReader.cpp @@ -22,6 +22,9 @@ // Log debug messages about pointer assignment calculations. #define DEBUG_POINTER_ASSIGNMENT 0 +// Log mouse events +#define DEBUG_MOUSE_EVENTS 0 + #include <cutils/log.h> #include <ui/InputReader.h> @@ -331,8 +334,8 @@ InputDevice* InputReader::createDevice(int32_t deviceId, const String8& name, ui } if (keyboardSources != 0) { - device->addMapper(new KeyboardInputMapper(device, - associatedDisplayId, keyboardSources, keyboardType, mEventHub->getDeviceBluetooth(deviceId))); + device->addMapper(new KeyboardInputMapper(device, associatedDisplayId, keyboardSources, + keyboardType, mEventHub->getDeviceBusType(deviceId))); } // Trackball-like devices. @@ -873,10 +876,12 @@ int32_t SwitchInputMapper::getSwitchState(uint32_t sourceMask, int32_t switchCod // --- KeyboardInputMapper --- KeyboardInputMapper::KeyboardInputMapper(InputDevice* device, int32_t associatedDisplayId, - uint32_t sources, int32_t keyboardType, bool bluetooth) : + uint32_t sources, int32_t keyboardType, uint32_t bustype) : InputMapper(device), mAssociatedDisplayId(associatedDisplayId), mSources(sources), - mKeyboardType(keyboardType), mBluetooth(bluetooth) { + mKeyboardType(keyboardType), mBusType(bustype) { initializeLocked(); + mBluetooth = (mBusType == BUS_BLUETOOTH); + mUSB = (mBusType == BUS_USB); } KeyboardInputMapper::~KeyboardInputMapper() { @@ -965,7 +970,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 (!mBluetooth && mAssociatedDisplayId >= 0) { + if (!mBluetooth && !mUSB && mAssociatedDisplayId >= 0) { int32_t orientation; if (! getPolicy()->getDisplayInfo(mAssociatedDisplayId, NULL, NULL, & orientation)) { return; @@ -3514,10 +3519,14 @@ void MouseInputMapper::sync(nsecs_t when) { float x = fields & Accumulator::FIELD_REL_X ? mAccumulator.relX : 0.0f; float y = fields & Accumulator::FIELD_REL_Y ? mAccumulator.relY : 0.0f; - int32_t screenWidth; - int32_t screenHeight; - int32_t orientation; + static int32_t screenWidth; + static int32_t screenHeight; + static int32_t orientation; +#if DEBUG_MOUSE_EVENTS + LOGI("MouseInputMapper: x,y=%.1f,%.1f abs %dx%d, screen %dx%d", + x, y, mAccumulator.absX, mAccumulator.absY, screenWidth, screenHeight); +#endif mAccumulator.absX = (mAccumulator.absX + x) > screenWidth ? screenWidth -1 : ((mAccumulator.absX + x) < 0 ? 0 : mAccumulator.absX + x); mAccumulator.absY = (mAccumulator.absY + y) > screenHeight ? screenHeight -1 : ((mAccumulator.absY + y) < 0 ? 0 : mAccumulator.absY + y); pointerCoords.x = mAccumulator.absX; diff --git a/libs/ui/tests/InputReader_test.cpp b/libs/ui/tests/InputReader_test.cpp index aec7ba9..abfc157 100644 --- a/libs/ui/tests/InputReader_test.cpp +++ b/libs/ui/tests/InputReader_test.cpp @@ -486,8 +486,8 @@ private: return device ? device->name : String8("unknown"); } - virtual bool getDeviceBluetooth(int32_t deviceId) const { - return false; + virtual uint32_t getDeviceBusType(int32_t deviceId) const { + return 0; } virtual status_t getAbsoluteAxisInfo(int32_t deviceId, int axis, |