paul@3 | 1 | /* |
paul@3 | 2 | * Common input event server functionality. |
paul@3 | 3 | * |
paul@31 | 4 | * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> |
paul@3 | 5 | * |
paul@3 | 6 | * This program is free software; you can redistribute it and/or |
paul@3 | 7 | * modify it under the terms of the GNU General Public License as |
paul@3 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@3 | 9 | * the License, or (at your option) any later version. |
paul@3 | 10 | * |
paul@3 | 11 | * This program is distributed in the hope that it will be useful, |
paul@3 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@3 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@3 | 14 | * GNU General Public License for more details. |
paul@3 | 15 | * |
paul@3 | 16 | * You should have received a copy of the GNU General Public License |
paul@3 | 17 | * along with this program; if not, write to the Free Software |
paul@3 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@3 | 19 | * Boston, MA 02110-1301, USA |
paul@3 | 20 | */ |
paul@3 | 21 | |
paul@3 | 22 | #pragma once |
paul@3 | 23 | |
paul@3 | 24 | #ifdef __cplusplus |
paul@3 | 25 | |
paul@153 | 26 | #include <l4/re/c/dataspace.h> |
paul@153 | 27 | #include <l4/re/env.h> |
paul@153 | 28 | #include <l4/re/event> |
paul@17 | 29 | |
paul@153 | 30 | #include "input_interface.h" |
paul@153 | 31 | |
paul@153 | 32 | |
paul@3 | 33 | |
paul@3 | 34 | /* Server object to provide input event source access. */ |
paul@3 | 35 | |
paul@153 | 36 | class Input_event_server : public Input |
paul@3 | 37 | { |
paul@3 | 38 | private: |
paul@153 | 39 | l4re_ds_t _mem; |
paul@153 | 40 | l4_cap_idx_t _irq; |
paul@3 | 41 | L4Re::Event_buffer _events; |
paul@3 | 42 | |
paul@3 | 43 | public: |
paul@3 | 44 | /* Initialise the server with a capability referencing the exported memory |
paul@3 | 45 | and an event buffer through which events will be communicated. */ |
paul@3 | 46 | |
paul@153 | 47 | explicit Input_event_server(l4re_ds_t mem, |
paul@3 | 48 | L4Re::Event_buffer events) |
paul@17 | 49 | : _mem(mem), _events(events) |
paul@3 | 50 | { |
paul@3 | 51 | } |
paul@3 | 52 | |
paul@153 | 53 | /* Input event interface operations. */ |
paul@153 | 54 | |
paul@153 | 55 | virtual long get_buffer(l4re_ds_t *mem); |
paul@153 | 56 | |
paul@153 | 57 | virtual long bind(unsigned int irqnum, l4_cap_idx_t irq); |
paul@3 | 58 | |
paul@3 | 59 | /* Event sending methods. */ |
paul@3 | 60 | |
paul@3 | 61 | void send_event(int type, int code, int value); |
paul@3 | 62 | }; |
paul@3 | 63 | |
paul@3 | 64 | #endif |