diff options
-rw-r--r-- | skey.c | 27 |
1 files changed, 26 insertions, 1 deletions
@@ -5,6 +5,7 @@ #include <linux/kthread.h> #include <linux/delay.h> #include <linux/sched.h> +#include "keymap.h" /* * defines whether to access the gpios so other parts of the kernel module can * be tested on systems w/o the prerequisite GPIOs @@ -22,11 +23,16 @@ static __initdata unsigned int row_pins[3] = {3, 6, 5}; static __initdata char * clabels[10] = {"C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7", "C8", "C9",}; static __initdata char * rlabels[3] = {"R0", "R1", "R2"}; /* - * variables for setting up the thread + * task struct for setting up the thread */ static struct task_struct *update_task; /* + * input.h input device + */ +struct input_dev * skey_dev; + +/* *This function is called every timer-period to actually read the keyboard */ int skey_update_thread (void *data) { @@ -121,6 +127,23 @@ static int __init skey_init (void) { } else { printk(KERN_ALERT "skey: currently in test mode with gpio use disabled\n"); } + /* + * sets up input.h device + */ + skey_dev = input_allocate_device(); + if (!skey_dev) { + printk(KERN_ALERT "skey: unable to allocate input device\n"); + return -ENOMEM; + } + // declares the event code and typesthe device emmits + set_bit(EV_KEY, skey_dev->evbit); + set_bit(EV_REL, skey_dev->evbit); + set_bit(KEY_A, skey_dev.keybit); + // registers the device + if (input_register_device(skey_dev)) { + input_free_device(skey_dev); + return -EINVAL; + } //sets up update thread printk("skey: setting up update thread...\n"); update_task = kthread_run(skey_update_thread, NULL, "skey_update_thread"); @@ -150,6 +173,8 @@ static void __exit skey_exit (void) { } //deletes the thread kthread_stop(update_task); + //frees input device + input_free_device(skey_dev); printk(KERN_INFO "skey: module exited\n"); return; } |