All pastes #26866 Raw Edit

Mine

public c v1 · immutable
#26866 ·published 2005-10-27 22:31 UTC
rendered paste body
/* * PC Engines WRAP(.1C/.1D/.1E/.2B/.2B) Keyboard LED Emulation * Copyright (c) 2005 Shane Spencer <shane@bogomip.com> *//* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */#include <linux/kernel.h>#include <linux/slab.h>#include <linux/input.h>#include <linux/module.h>#include <linux/init.h>#include <asm/io.h>#include <linux/scx200_gpio.h>#define NAME "wrapled"#define DRIVER_DESC "PC Engines WRAP(.1C/.1D/.1E/.2B/.2B) Keyboard LED Emulation"MODULE_AUTHOR("Shane Spencer <shane@bogomip.com>");MODULE_DESCRIPTION(DRIVER_DESC);MODULE_LICENSE("GPL");static struct input_dev dev;static int open;static unsigned char wrap_keycode[256] ={     0,  0,  0,  0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,     50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44,  2,  3,     4,  5,  6,  7,  8,  9, 10, 11, 28,  1, 14, 15, 57, 12, 13, 26,     27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,     65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,     105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,     72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,     191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,     115,114,  0,  0,  0,121,  0, 89, 93,124, 92, 94, 95,  0,  0,  0,     122,123, 90, 91, 85,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,     29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,     150,158,159,128,136,177,178,176,142,152,173,140};static int wrapled_open(struct input_dev *dev){   open++;   return 0;}static void wrapled_close(struct input_dev *dev){   open--;}/* * Event callback from the input module (the magic). */static int wrapled_event(struct input_dev *dev, unsigned int type, unsigned int code, int value){   switch (type) {    case EV_LED:      scx200_gpio_set(2, !test_bit(LED_NUML,   dev->led));      scx200_gpio_set(3, !test_bit(LED_CAPSL,   dev->led));      scx200_gpio_set(18, !test_bit(LED_SCROLLL,   dev->led));      return 0;   }   return -1;}static int __init wrapled_init(void){   int i;   if (!scx200_gpio_present())     {        printk(KERN_ERR NAME ": no SCx200 gpio pins available\n");        return -ENODEV;     }   dev.evbit[0] = BIT(EV_KEY) | BIT(EV_LED);   dev.ledbit[0] = BIT(LED_CAPSL) | BIT(LED_NUML) | BIT(LED_SCROLLL);   init_input_dev(&dev);   for (i = 0; i < 255; i++)     set_bit(wrap_keycode[i], dev.keybit);   clear_bit(0, dev.keybit);   dev.private = NULL;   dev.open = wrapled_open;   dev.close = wrapled_close;   dev.event = wrapled_event;   dev.name = "WRAPLED";   dev.id.bustype = BUS_HOST;   dev.id.vendor = 0x0001;   dev.id.product = 0x0001;   dev.id.version = 0x0100;   input_register_device(&dev);   printk(KERN_INFO "input: keyboard: %s initialized\n", dev.name);   return 0;}static void __exit wrapled_exit(void){   input_unregister_device(&dev);   printk(KERN_INFO "input: keyboard: %s deinitialized\n", dev.name);}module_init(wrapled_init);module_exit(wrapled_exit);