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