On Sat, 30 Mar 2002, James Susinno wrote: > as i understand, the file keymap.h is generated by > dumpkeys | loadkeys -m > keymap.h > from /usr/src/linux/drivers/char/defkeymap.map > > so i made a copy ./nostromo.map, which i would like to edit. > changed the Makefile line to: > dumpkeys | loadkeys nostromo.map -m > keymap.h > > so the nostromo uses keys 48-56 as key down events, corresponding roughly > to characters (set within braces) {bnm,./* }. > > i tried to edit those in my nostromo.map file, then regenerate keymap.h > (and the keymap.his smaller than the one generated from defkeymap). > > the changes dont seem to take effect.i issued 'make clean' and deleted > the old keymap.h, and still the same bnm,. etc. chars come through. > > is there something obvious im missing? I don't know. Did you try to remove the keymap.h generation commands from Makefile? -- Matan Ziv-Av. matan@svgalib.org On Sat, 30 Mar 2002, James Susinno wrote: > heres the keymap.h target from the makefile (modded): > > keymap.h: > # dumpkeys | loadkeys -m > keymap.h > dumpkeys | loadkeys nostromo.map -m > keymap.h > > it seems right; and it generates a new keymap.h with an array that looks > like this: (i deleted most of the entry lines from nostromo.map, which > came from > cp /usr/src/linux/drivers/char/defkaymap.map nostromo.map > ) > > u_short plain_map[NR_KEYS] = { > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xfb61, 0xfb62, 0xfb63, 0xfb64, 0xfb65, 0xfb66, 0xfb67, 0xfb68, > 0xfb69, 0xfb6a, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, 0xf200, > }; > > it seems like changes have taken effect by examining keymap.h: it is > different from the other one(generated from the linux map). > > after issuing make again(with the new keymap.h), usb2keygives the same > characters as it did with the old keymap.h. > > also i do not see response from the directional pad or the throttle wheel > using usb2key - > but i can see response from them when using evtest. Are you checking in X, or on VC? There is a difference in behavior, since X gets the raw keys, while the VC gets cooked keys (going thru all the tables). -- Matan Ziv-Av. matan@svgalib.org On Tue, 2 Apr 2002, James Susinno wrote: > > so im beginning to grok the usb2key source that you gave me... > > im writing a function to handle nostromo key events. > i can have it send regular keypresses no problem...i have a one-key > macro in place for the 'make' command. > > i would really loveto have arrow keys as well... > ive tried sending'\033', '[', '[', 'A' in sequence and i think i get a > page up or something... I think this should work. Maybe you need to translate that button to button 103, just before all the other translations, between the two lines in the main loop: ch=ev.code; if(ch<128) { This way it will be handled like a normal up arrow key in both cooked and raw mode. Anyway, up is "Esc[A". "Esc[[A" is F1 - see dumpkeys. > ive tried the numbers i get from showkey( {103,108,105,106} for{up down > left right} )but there seemed to be no effect calling send() on these values. > ive tried subbing the values showkey gives for {abcd} == {30,48,46,32}. > no dice. I think you are mixing the two modes - they keycodes (30,48,...) should be sent in raw mode (X11) and characters ('\033', '[', ...) should be sent in cooked mode (text console). Are you mixing them up. > id also love to have a 'cut' shortcut on a button... to send the control-W > signal would be fine for an emacs user like me. > > how do i simulate this signal? > ive tried sending 29 then 17 (got that from showkey) for control key > press, but the behavior is it sticks down the control key. I assume this is in X11 - because you need to later send a 128|17= 'W' release event. and then a 128|29= Control release event. Otherwise, as you noted, X11 think the keys are still pressed. > in addition, id like to be able to check the state of the directional pad. > evtest recognizes the dpadas: > Event: time 1017786527.019959, type 3 (Absolute), code 1 (Y), value 128 Are those sent to the same device? If so, see that there is only one read (in the main loop). The event type is checked to see that it is an EV_KEY. You can check also if it is an EV_ABS, and act accordingly. -- Matan Ziv-Av. matan@svgalib.org > i wrote an opengl display program which currently runs as its own > executable, calling read(the nostromo device) from the display loop. > since the read is a blocking call, the display only refreshes when an > event comes through the device. > id like to split the display interface off into a separate app, refreshing > on input events from the nostromo as well as mouse/keyboard/window > manager(which glut handles for me now). > i guess there are 2 approaches(at least) > - signals/sockets > - threads There are two more, which are probably better for you: Reading the event device non-blocking. Using select with a timeout. > and when i send keypress events as macros to the terminal, should i worry > about sending the corresponding release events?for mdifiers yes, but is > it necessary for regular keys? I am not sure I understand the question, but remember there are two modes cooked mode where you send character values (97 for a, etc.), in which there are no release events. And raw mode where you send key values (1 for esc, etc.), and key releases are necessary since it's the app's responsibility to track keys state. > i would like to modify/rewrite/retweak this driver for a gravis aftershock > gamepad, with 2 analogsticks. id like to be able to use the analog > sticks as a mouse device in X11. > would this involve setting up a .xinitrc file, or would i have to pass the > gamepadevents through a framework like usb2key to translate them into > mouse events (is so-how)? > the events are coming through fine with evtest on /dev/input/event2 . This requires a long answer: First you need to understand how usb input works: there is low level driver (probably hid, but might be joystick specific) that gets input from the usb controller and sends it to input mid-layer. (stuff like "keyboard release key l", "joystick button 5 pressed", "mouse moved -16 horizontal"). The input mid-layer has translators, which get those keys and present them to application: evdev - presents all events as they are used in usb2key. mousedev - presents mouse events, in a imps/2 format. This is how X uses usb mouse. If you have one, you'll note that it is defined as imps/2 in X. keybdev - presents keyboard events as if they are a true (AT or PS/2) keyboard. So your options are (one of) - * Hack the hid (or joystick driver) to pass to the mid-layer mouse events for the pad, instead of joystick events, so mousedev will think it is a mouse. * Hack mousedev to treat specific joystick events as if they are mouse events. * Write a new translator, similar to mousedev, that takes joystick events and presents them as a mouse. Note that all those are in kernel space. If you want to do it in user space, you should look at what gpm does, with -R option. -- Matan Ziv-Av. matan@svgalib.org On Mon, 22 Apr 2002, James Susinno wrote: > so i need to be root to run the nostromo driver. > i cant find source for gpm, and for the time being i dont mind running > this proggie and the joystick daemon in bg as root.although userspace > would be much nicer. > > also need to be root to run evtest... > > [jim@pikkon jim]$ ./evtest /dev/input/event1 > evtest: Permission denied This is a simple matter of permissions (I expect). Try chmod a+rw /dev/input/event1 , and evtext will probably run as user. > is there no way to do all this(access devices, send keystrokes/mouse > events) in user space without > much rewriting and restructuring of code? Similarly, usb2key delivers it's keystrokes to /dev/tty?. The user running the program needs to have rw access to those device nodes. > > > > i think i like option 3:Write a new translator that takes joystick events > and presents them as a mouse. > i like the idea of a separate executable running as daemon in the bg... This is not a daemon, but a kernel driver. > how would i go about setting this daemon's priority(btw)? Since this daemon does nothing cpu bound, but always sleeps on IO, priority is meaningless in this case. > i took a look at this file: > /usr/src/linux-2.4.13/drivers/usb/usbmouse.c > i guess what im looking for is the mouse event equivalent of the send() > function from usb2key... The file you should look at (if writing a new translator) is mousedev.c (in drivers/input). Not usbmouse.c. usbmouse should not be used anyway. hid.c replaces it. -- Matan Ziv-Av. matan@svgalib.org On Mon, 22 Apr 2002, James Susinno wrote: > alright, now im sorry for bothering you again, but im on a much lower > level of kernel knowledge... > > [sh/c]ould i... > - manually edit /usr/src/linux-2.4.13/drivers/input/mousedev.c and > recompile kernel Yes. > - copy that file to gamepaddev.c, then recompilekernel(how would i get > the new device in there?insmod?) You also need to edit config files and/or makefiles. > - stick the mouse device reading functions into a main(){while(1){}} loop > of its own like usb2key mousedev sends it's output to /dev/input/mice, which X (or gpm, or svgalib) reads directly. It does not go thru usb2key. > the last option i like because adding printf's makes debugging easy. > with this kernel code,where would the printfs print? You use printk, instead of printf, with some priority, and it goes to dmesg, and whereever your syslog sends it from there (probably some file in /var/log). -- Matan Ziv-Av. matan@svgalib.org On Mon, 6 May 2002, James Susinno wrote: > > > Similarly, usb2key delivers it's keystrokes to /dev/tty?. The user > > running the program needs to have rw access to those device nodes. > > i did a chmod a+rw on /dev/input/event1 > but you still have to be root to run the nostromo driver. > this call: > > if(ioctl(tty,TIOCSTI,&value)){ > fails every time, and sets errno to 1. > from /usr/src/linux-2.4.13/include/asm-i386/errno.h > #define EPERM 1 /* Operation not permitted */ The kernel might have some check for super user privileges. In that case, there is no solution other than changing the kernel. > ------------ > > also, how do i send the correct keycodes(raw mode, in X) for page up/down > and home/end? > ive tried: > // 104, 128|104, 0, 0, 0, 0, // page up key > 1, 26, 6, 42, 41, 128|42, 0, 0, 0, 0, // page up Esc[5~ > > neither seem to work. I don't know. > ------------ > on another note, for the hacked mousedev-gamepad driver: > > > mousedev sends it's output to /dev/input/mice, which X (or gpm, or > > svgalib) reads directly. It does not go thru usb2key. > > so the first thing to do would be get the following code into the mousedev > to read the gamepad events: > i = read(indev, &ev, sizeof(struct input_event)); mousedev is kernel code. It does not work exactly like that. The code start executing in the function: static int __init mousedev_init(void) which first calls input_register_handler(&mousedev_handler); Which register "handlers", which is a function that the input layer calls for some events (connect, disconnect and event). The important one is event which is called for any input event (key press, key release, mouse motions, etc.) This converts input event to PS/2 (using _packet) mouse code which is sent to user code in (_read). The _connect function is the one that decides if the device is one that mousedev should handle. -- Matan Ziv-Av. matan@svgalib.org On Thu, 23 May 2002, James Susinno wrote: > > ok in order to make the module mousedev... > i tried issuing: > cd /usr/src/linux-2.4.13 > make modules > make modules_install did you configure mousedev to be compiled as a module? (does the .config have a line: CONFIG_INPUT_MOUSEDEV=m) > but the mousedev.o module was not remade.do i have to recompile the > entire kernel, > like this: > make dep && make clean && make modules && make modules_install && make && > make bzImage > ? > > and also, how come i dont see mousedev in > [root@pikkon /root]# lsmod > Module Size Used by > NVdriver 722960 14 (autoclean) > evdev 4080 1 > usbmouse 1744 0 (unused) > hid 12496 0 (unused) > usb-ohci 18128 0 (unused) > usbcore 49440 1 [usbmouse hid usb-ohci] Why do you use usbmouse module? It is not recomended. hid is prefereable. Did you read the kernel howto? -- Matan Ziv-Av. matan@svgalib.org On Thu, 23 May 2002, James Susinno wrote: > > [root@pikkon jim]# lsmod > Module Size Used by > NVdriver 722960 14 > mousedev 4192 1 > hid 12512 0 (unused) > input 3264 0 [mousedev hid] > usb-ohci 18128 0 (unused) > usbcore 49440 1 [hid usb-ohci] > [root@pikkon jim]# > > > ive inserted some printk's to track the code flow, one in _connect and one > in _event. > > i can see the printouts in dmesg and /var/log/messages: > they happen when the usb mouse is moved, and also on startup(theres 2 > connect printouts). > but not when the gamepad buttons/stick are moved... > > do i need to register another callback, for events on /dev/input/event2? > in other words, when an event happens on the gamepad, how will the mouse > driver know about it? Did you edit mousedev? I think that in the connect function the driver decides which devices interest it and which does not. Did you make sure that it 'takes interest' in your device? -- Matan Ziv-Av. matan@svgalib.org On Fri, 24 May 2002, James Susinno wrote: > for (i=0;i<100;i++) thank you! > > the mousedev-gravis driver works! > > now im trying to get the same driver running on my dell inspiron 8200 > laptop. > i copied the file over to the laptop. > > the laptop runs a 2.4.7-10 kernel (from the redhat 7.2 install), which did > not come with source. > i downloaded and compiled the 2.4.7 source, but the new compiled kernel > did not boot properly.... > these kernels(source build) also didnt work: > - 2.4.17 > - 2.4.18 > so i booted back into the stock 2.4.7-10 kernel and tried to insmod > mousedev. > > i got a bunch of errors: unresolved symbol. > > im guessing that the stock kernel does not have mousedev configured as a > module... Not necessarily. It might be a modversion issue. Look at http://kernelnewbies.org > so i gotta get a source build of the kernel to work on my laptop. > is the best way to go about this to just change config options and keep > remaking until it works? > is there a smarter way? The smart way is to understand the options, and select the correct ones for your computer. The distribution that installed your kernel 2.4.7-10, should have a source package for it, which includes the .config file used. -- Matan Ziv-Av. matan@svgalib.org On Tue, 30 Jul 2002, James Susinno wrote: > hi, i used your program usb2key to create a device driver for a usb > device(thanks again btw!).However, i have found that it uses many cpu > cycles resulting in a frame rate decrease for gaming/realtime 3d > applications. You probably did something wrong, since there is no reason for it to use a noticeable amount of CPU time. The program should be sleeping except for when it gets an event from the device, which should be less than 100 times a second. > would it be possible to use akernel module to interpret the input events > from a usb device(belkin nostromo)?i would think that a module would > incur less overhead than a userland app. > > which module should i hack? > - drivers/input/keybdev.c > - drivers/usb/usbkbd.c > - some other one? I think you should look at keybdev.c (or mousedev.c) in the drivers/input subdirectory. -- Matan Ziv-Av. matan@svgalib.org James Susinno wrote: > hi, my names jim and ive just been getting into kernel device driver > development. > > some of my stuff is available at http://jimbomania.com > > i would like to ask you some questions regarding drivers im working on, > would you mind sharing some information with me? > > im currently hacking mousedev.c and i have the gravis pad working under > linux-2.4.13 on an athlon1.4. im trying to get the same driver running on > a dell inspiron running redhat 7.2's kernel 2.4.7-10, but i cant get a > source kernel to compile, and i get a lot of unresolvable symbol > input_register_minor_Re986ad09... errors. > > my approach is to just try lots of different kernel config files, but i > havent found one yet... is my approach a sensible one? should i try an > older or newer kernel(generally)? Hi, Your kenrel on that "dell" system is using "symbol versionning". Turn that off. It's a nuisance. Roger. -- ** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 ** *-- BitWizard writes Linux device drivers for any device you may have! --* * There are old pilots, and there are bold pilots. * There are also old, bald pilots.