git.y1.nz

fbui

Framebuffer-based graphical environment
download: https://git.y1.nz/archives/fbui.tar.gz
README | Files | Log | Refs

drivers/input/fbui-input.c

      1 /*
      2  * FBUI input event snagging
      3  * Code for relaying input events to FBUI.
      4  *
      5  * Modification for FBUI by Zachary Smith, copyright (C) 2004.
      6  * Based on evbug, which is copyright (c) 1999-2001 Vojtech Pavlik
      7  *
      8  * This program is free software; you can redistribute it and/or modify
      9  * it under the terms of the GNU General Public License as published by
     10  * the Free Software Foundation; either version 2 of the License, or
     11  * (at your option) any later version.
     12  *
     13  * This program is distributed in the hope that it will be useful,
     14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16  * GNU General Public License for more details.
     17  *
     18  * You should have received a copy of the GNU General Public License
     19  * along with this program; if not, write to the Free Software
     20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
     21  *
     22  * Should you need to contact me, the author, you can do so either by
     23  * e-mail - mail your message to <fbui@comcast.net>.
     24  */
     25 
     26 #include <linux/slab.h>
     27 #include <linux/module.h>
     28 #include <linux/input.h>
     29 #include <linux/init.h>
     30 #include <linux/device.h>
     31 #include <linux/input.h>
     32 #include <linux/spinlock.h>
     33 
     34 
     35 
     36 MODULE_AUTHOR("Zachary Smith <fbui@comcast.net>");
     37 MODULE_DESCRIPTION("Input-driver-event besnagger module");
     38 MODULE_LICENSE("GPL");
     39 
     40 
     41 #ifdef CONFIG_INPUT_FBUI
     42 
     43 static char fbui_input_name[] = "fbui_input";
     44 
     45 static spinlock_t mylock = SPIN_LOCK_UNLOCKED;
     46 
     47 static FBUIInputEventHandler *handler = NULL;
     48 static u32 handlerparam = 0;
     49 
     50 
     51 void fbui_input_register_handler (FBUIInputEventHandler *h, u32 param)
     52 {
     53 	if (h) {
     54 		handler = h;
     55 		handlerparam = param;
     56 	}
     57 }
     58 
     59 static void fbui_input_event(struct input_handle *handle, unsigned int type, unsigned int code, int value)
     60 {
     61 	unsigned long flags;
     62 
     63 	// printk(KERN_INFO "fbui_input.c: Event. Dev: %s, Type: %d, Code: %d, Value: %d\n", handle->dev->phys, type, code, value);
     64 
     65 	if (!handler)
     66 		return;
     67 
     68 	spin_lock_irqsave(&mylock, flags);
     69 
     70 	struct input_event e;
     71 	e.type = type;
     72 	e.code = code;
     73 	e.value= value;
     74 	do_gettimeofday(&e.time);
     75 	(handler) (handlerparam, &e);
     76 
     77 	spin_unlock_irqrestore(&mylock, flags);
     78 }
     79 
     80 static struct input_handle *fbui_input_connect(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id)
     81 {
     82 	struct input_handle *handle;
     83 
     84 	if (!(handle = kmalloc(sizeof(struct input_handle), GFP_KERNEL)))
     85 		return NULL;
     86 	memset(handle, 0, sizeof(struct input_handle));
     87 
     88 	handle->dev = dev;
     89 	handle->handler = handler;
     90 	handle->name = fbui_input_name;
     91 
     92 	input_open_device(handle);
     93 
     94 	return handle;
     95 }
     96 
     97 static void fbui_input_disconnect(struct input_handle *handle)
     98 {
     99 	input_close_device(handle);
    100 	kfree(handle);
    101 }
    102 
    103 static struct input_device_id fbui_input_ids[] = {
    104 	{ .driver_info = 1 },	/* Matches all devices */
    105 	{ },			/* Terminating zero entry */
    106 };
    107 
    108 MODULE_DEVICE_TABLE(input, fbui_input_ids);
    109 
    110 static struct input_handler fbui_input_handler = {
    111 	.event =	fbui_input_event,
    112 	.connect =	fbui_input_connect,
    113 	.disconnect =	fbui_input_disconnect,
    114 	.name =		"fbui_input",
    115 	.id_table =	fbui_input_ids,
    116 };
    117 
    118 int __init fbui_input_init(void)
    119 {
    120 	handler = NULL;
    121 
    122 	printk(KERN_INFO "FBUI input module: initializing\n");
    123 
    124 	input_register_handler(&fbui_input_handler);
    125 	return 0;
    126 }
    127 
    128 void __exit fbui_input_exit(void)
    129 {
    130 	handler = NULL;
    131 
    132 	input_unregister_handler(&fbui_input_handler);
    133 }
    134 
    135 EXPORT_SYMBOL(fbui_input_register_handler);
    136 
    137 module_init(fbui_input_init);
    138 module_exit(fbui_input_exit);
    139 
    140 #endif

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.