| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/events/ozone/evdev/key_event_converter_ozone.h" | 5 #include "ui/events/ozone/evdev/key_event_converter_evdev.h" |
| 6 | 6 |
| 7 #include <linux/input.h> | 7 #include <linux/input.h> |
| 8 | 8 |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| 11 | 11 |
| 12 namespace { | 12 namespace { |
| 13 | 13 |
| 14 ui::KeyboardCode KeyboardCodeFromButton(unsigned int code) { | 14 ui::KeyboardCode KeyboardCodeFromButton(unsigned int code) { |
| 15 static const ui::KeyboardCode kLinuxBaseKeyMap[] = { | 15 static const ui::KeyboardCode kLinuxBaseKeyMap[] = { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 LOG(ERROR) << "Unknown key code: " << code; | 149 LOG(ERROR) << "Unknown key code: " << code; |
| 150 return ui::VKEY_UNKNOWN; | 150 return ui::VKEY_UNKNOWN; |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace | 153 } // namespace |
| 154 | 154 |
| 155 namespace ui { | 155 namespace ui { |
| 156 | 156 |
| 157 // TODO(rjkroege): Stop leaking file descriptor. | 157 // TODO(rjkroege): Stop leaking file descriptor. |
| 158 KeyEventConverterOzone::KeyEventConverterOzone() {} | 158 KeyEventConverterEvdev::KeyEventConverterEvdev() {} |
| 159 KeyEventConverterOzone::~KeyEventConverterOzone() {} | 159 KeyEventConverterEvdev::~KeyEventConverterEvdev() {} |
| 160 | 160 |
| 161 void KeyEventConverterOzone::OnFileCanReadWithoutBlocking(int fd) { | 161 void KeyEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) { |
| 162 input_event inputs[4]; | 162 input_event inputs[4]; |
| 163 ssize_t read_size = read(fd, inputs, sizeof(inputs)); | 163 ssize_t read_size = read(fd, inputs, sizeof(inputs)); |
| 164 if (read_size <= 0) | 164 if (read_size <= 0) |
| 165 return; | 165 return; |
| 166 | 166 |
| 167 CHECK_EQ(read_size % sizeof(*inputs), 0u); | 167 CHECK_EQ(read_size % sizeof(*inputs), 0u); |
| 168 for (unsigned i = 0; i < read_size / sizeof(*inputs); ++i) { | 168 for (unsigned i = 0; i < read_size / sizeof(*inputs); ++i) { |
| 169 const input_event& input = inputs[i]; | 169 const input_event& input = inputs[i]; |
| 170 if (input.type == EV_KEY) { | 170 if (input.type == EV_KEY) { |
| 171 scoped_ptr<KeyEvent> key( | 171 scoped_ptr<KeyEvent> key( |
| 172 new KeyEvent(input.value == 0 ? ET_KEY_RELEASED : ET_KEY_PRESSED, | 172 new KeyEvent(input.value == 0 ? ET_KEY_RELEASED : ET_KEY_PRESSED, |
| 173 KeyboardCodeFromButton(input.code), | 173 KeyboardCodeFromButton(input.code), |
| 174 0, | 174 0, |
| 175 true)); | 175 true)); |
| 176 DispatchEvent(key.PassAs<ui::Event>()); | 176 DispatchEvent(key.PassAs<ui::Event>()); |
| 177 } else if (input.type == EV_SYN) { | 177 } else if (input.type == EV_SYN) { |
| 178 // TODO(sadrul): Handle this case appropriately. | 178 // TODO(sadrul): Handle this case appropriately. |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 void KeyEventConverterOzone::OnFileCanWriteWithoutBlocking(int fd) { | 183 void KeyEventConverterEvdev::OnFileCanWriteWithoutBlocking(int fd) { |
| 184 NOTREACHED(); | 184 NOTREACHED(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 } // namespace ui | 187 } // namespace ui |
| OLD | NEW |