Index: ui/events/ozone/evdev/touch_event_converter_evdev.cc |
diff --git a/ui/events/ozone/evdev/touch_event_converter_evdev.cc b/ui/events/ozone/evdev/touch_event_converter_evdev.cc |
index 55d3b59898d6880d6439a90e9308f6798a3bc026..deb8389112e1692319d58953400afb0626572a5f 100644 |
--- a/ui/events/ozone/evdev/touch_event_converter_evdev.cc |
+++ b/ui/events/ozone/evdev/touch_event_converter_evdev.cc |
@@ -78,11 +78,20 @@ int32_t AbsCodeToMtCode(int32_t code) { |
} |
} |
-ui::EventPointerType GetPointerTypeFromEvent( |
+ui::PointerDetails GetEventPointerDetails( |
const ui::InProgressTouchEvdev& event) { |
- return (event.tool_code == BTN_TOOL_PEN) |
- ? ui::EventPointerType::POINTER_TYPE_PEN |
- : ui::EventPointerType::POINTER_TYPE_TOUCH; |
+ ui::EventPointerType type; |
+ switch (event.tool_code) { |
+ case BTN_TOOL_PEN: |
+ type = ui::EventPointerType::POINTER_TYPE_PEN; |
+ break; |
+ default: |
+ type = ui::EventPointerType::POINTER_TYPE_TOUCH; |
+ } |
+ return ui::PointerDetails(type, event.radius_x, event.radius_y, |
+ event.pressure, |
+ /* tilt_x */ 0.0f, |
+ /* tilt_y */ 0.0f); |
} |
const int kTrackingIdForUnusedSlot = -1; |
@@ -317,8 +326,20 @@ void TouchEventConverterEvdev::ProcessKey(const input_event& input) { |
switch (input.code) { |
case BTN_TOUCH: |
case BTN_LEFT: |
+ ProcessButton(BTN_LEFT, input); |
+ break; |
+ case BTN_STYLUS: |
+ ProcessButton(BTN_RIGHT, input); |
+ break; |
+ case BTN_STYLUS2: |
+ ProcessButton(BTN_MIDDLE, input); |
break; |
case BTN_TOOL_PEN: |
+ // Do not change tool types while touching to prevent inconsistencies |
+ // from switching between Mouse and TouchEvents. |
+ if (events_[current_slot_].was_touching) |
spang
2016/08/16 21:36:21
Does this actually happen?
denniskempin
2016/08/17 21:47:17
I think a kernel driver shouldn't be allowed to do
|
+ break; |
+ |
if (input.value > 0) { |
events_[current_slot_].tool_code = input.code; |
} else { |
@@ -330,6 +351,21 @@ void TouchEventConverterEvdev::ProcessKey(const input_event& input) { |
} |
} |
+void TouchEventConverterEvdev::ProcessButton(unsigned int button, |
+ const input_event& input) { |
+ const InProgressTouchEvdev& event = events_[current_slot_]; |
+ |
+ // Don't handle buttons for touch slots |
+ if (event.tool_code == 0) |
+ return; |
+ |
+ bool down = input.value; |
+ dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams( |
+ input_device_.id, EF_DIRECT_INPUT, gfx::PointF(event.x, event.y), button, |
spang
2016/08/16 21:36:21
There's no guarantee the X/Y position is updated b
denniskempin
2016/08/17 21:47:17
Done.
|
+ down, false /* allow_remap */, GetEventPointerDetails(event), |
+ TimeTicksFromInputEvent(input))); |
+} |
+ |
void TouchEventConverterEvdev::ProcessAbs(const input_event& input) { |
switch (input.code) { |
case ABS_MT_TOUCH_MAJOR: |
@@ -400,16 +436,21 @@ EventType TouchEventConverterEvdev::GetEventTypeForTouch( |
return touch.was_touching ? ET_TOUCH_RELEASED : ET_UNKNOWN; |
} |
-void TouchEventConverterEvdev::ReportEvent(const InProgressTouchEvdev& event, |
- EventType event_type, |
- base::TimeTicks timestamp) { |
- PointerDetails details(GetPointerTypeFromEvent(event), event.radius_x, |
- event.radius_y, event.pressure, |
- /* tilt_x */ 0.0f, |
- /* tilt_y */ 0.0f); |
- dispatcher_->DispatchTouchEvent( |
- TouchEventParams(input_device_.id, event.slot, event_type, |
- gfx::PointF(event.x, event.y), details, timestamp)); |
+void TouchEventConverterEvdev::ReportTouchEvent( |
+ const InProgressTouchEvdev& event, |
+ EventType event_type, |
+ base::TimeTicks timestamp) { |
+ dispatcher_->DispatchTouchEvent(TouchEventParams( |
+ input_device_.id, event.slot, event_type, gfx::PointF(event.x, event.y), |
+ GetEventPointerDetails(event), timestamp)); |
+} |
+ |
+void TouchEventConverterEvdev::ReportStylusEvent( |
+ const InProgressTouchEvdev& event, |
+ base::TimeTicks timestamp) { |
+ dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams( |
+ input_device_.id, EF_DIRECT_INPUT, gfx::PointF(event.x, event.y), |
+ GetEventPointerDetails(event), timestamp)); |
} |
void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { |
@@ -426,12 +467,16 @@ void TouchEventConverterEvdev::ReportEvents(base::TimeTicks timestamp) { |
if (!event->altered) |
continue; |
- EventType event_type = GetEventTypeForTouch(*event); |
- if (event_type == ET_UNKNOWN || event_type == ET_TOUCH_CANCELLED) |
- event->cancelled = true; |
+ if (event->tool_code > 0) { |
+ ReportStylusEvent(*event, timestamp); |
+ } else { |
+ EventType event_type = GetEventTypeForTouch(*event); |
+ if (event_type == ET_UNKNOWN || event_type == ET_TOUCH_CANCELLED) |
+ event->cancelled = true; |
- if (event_type != ET_UNKNOWN) |
- ReportEvent(*event, event_type, timestamp); |
+ if (event_type != ET_UNKNOWN) |
+ ReportTouchEvent(*event, event_type, timestamp); |
+ } |
event->was_touching = event->touching; |
event->altered = false; |