summaryrefslogtreecommitdiffstats
path: root/ui/events/ozone/evdev/keyboard_util_evdev.cc
blob: 66071de62d4254fdc46b07735dc732e03d4aebf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/events/ozone/evdev/keyboard_util_evdev.h"

#include <linux/input.h>

#include "ui/events/keycodes/dom4/keycode_converter.h"

namespace ui {

namespace {

const int kXkbKeycodeOffset = 8;

}  // namespace

int NativeCodeToEvdevCode(int native_code) {
  if (native_code == KeycodeConverter::InvalidNativeKeycode())
    return KEY_RESERVED;

  return native_code - kXkbKeycodeOffset;
}

int EvdevCodeToNativeCode(int evdev_code) {
  if (evdev_code == KEY_RESERVED)
    return KeycodeConverter::InvalidNativeKeycode();

  return evdev_code + kXkbKeycodeOffset;
}

}  // namespace ui