ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / native_client_sdk / src / libraries / nacl_io / devfs / tty_node.h
blobf4a28505e6325b77cc0287f44940c4d554f079f4
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
6 #define LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_
8 #include <poll.h>
9 #include <pthread.h>
11 #include <deque>
13 #include <ppapi/c/pp_var.h>
15 #include "nacl_io/char_node.h"
16 #include "nacl_io/ioctl.h"
17 #include "nacl_io/ostermios.h"
19 namespace nacl_io {
21 class TtyNode : public CharNode {
22 public:
23 explicit TtyNode(Filesystem* filesystem);
25 virtual EventEmitter* GetEventEmitter();
27 virtual Error VIoctl(int request, va_list args);
29 virtual Error Read(const HandleAttr& attr,
30 void* buf,
31 size_t count,
32 int* out_bytes);
34 virtual Error Write(const HandleAttr& attr,
35 const void* buf,
36 size_t count,
37 int* out_bytes);
39 virtual Error Tcgetattr(struct termios* termios_p);
40 virtual Error Tcsetattr(int optional_actions,
41 const struct termios* termios_p);
43 virtual Error Isatty() { return 0; }
45 private:
46 ScopedEventEmitter emitter_;
48 Error ProcessInput(PP_Var var);
49 Error ProcessInput(const char* buffer, size_t num_bytes);
50 Error Echo(const char* string, int count);
51 void InitTermios();
53 std::deque<char> input_buffer_;
54 struct termios termios_;
56 /// Current height of terminal in rows. Set via ioctl(2).
57 int rows_;
58 /// Current width of terminal in columns. Set via ioctl(2).
59 int cols_;
61 // Output handler for TTY. This is set via ioctl(2).
62 struct tioc_nacl_output output_handler_;
63 // Lock to protect output_handler_. This lock gets aquired whenever
64 // output_handler_ is used or set.
65 sdk_util::SimpleLock output_lock_;
68 } // namespace nacl_io
70 #endif // LIBRARIES_NACL_IO_DEVFS_TTY_NODE_H_