Re: Keyboard scancodes

2010-04-24 Thread Patrick Lamaiziere
Le Fri, 23 Apr 2010 11:20:50 +0200,
Michael Cardell Widerkrantz m...@hack.org a écrit :

 I was recently given an original Happy Hacking Keyboard. As I
 sometimes work in the FreeBSD console, I wanted to have my usual
 console keymap adjusted to the new keyboard, but didn't know the
 scancode for the HHKB meta key (the diamond key). I couldn't find any
 program in base or ports that would show me the scancodes, so I ended
 up writing my own:
 
   http://hack.org/mc/hacks/kbdscan/

Thanks, that could be usefull when doing syscons keymap. Last time I
did it, I put some printf into the keyboard driver :(

Regards.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Keyboard scancodes

2010-04-23 Thread Michael Cardell Widerkrantz
I was recently given an original Happy Hacking Keyboard. As I sometimes
work in the FreeBSD console, I wanted to have my usual console keymap
adjusted to the new keyboard, but didn't know the scancode for the HHKB
meta key (the diamond key). I couldn't find any program in base or ports
that would show me the scancodes, so I ended up writing my own:

  http://hack.org/mc/hacks/kbdscan/

It's little more than a quick hack done while my baby daughter was
napping, but it works for my purposes. The program sets the FreeBSD
console keyboard in raw scancode mode and the terminal in raw mode
without echo. It then shows scancodes of keys pressed and released.

Five seconds of inactivity resets the keyboard and terminal to the
original modes and quits the program. Nota bene: If the process receives
any signals, it will currently leave the keyboard and console in the raw
mode.

When I was searching for information about this, I found a lot of
similar questions on freebsd-questions and in other fora about similar
problems, so I thought I should post about it. Please excuse me if this
is inappropriate.

Happy hacking,
MC.

-- 
http://hack.org/mc/
Use plain text e-mail, please. OpenPGP welcome, 0xE4C92FA5.
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to freebsd-hackers-unsubscr...@freebsd.org


Re: PC Keyboard Scancodes

2000-04-20 Thread Daniel O'Connor


On 19-Apr-00 Brian Fundakowski Feldman wrote:
  I've got a nice script and better version of scancodes.c to do this for
  me
  now, so here goes :)  These are the keys on the Logitech cordless
  keyboard,
  and they are undoubtedly the same for the rest of the Logitech iTouch
  keyboards.  Script or scancodes.c on request, of course :)  I hope this
  will help whosoever decides to take upon the task.

I don't suppose you could change 'ch' to be 'unsigned char' and print the
values as hex? I'm too lazy to convert them :)

I've altered atkbd.c to grok the new keys, I also added 'power' and 'halt'
to kbdcontrol/syscons - so now the power button works 8-)

I think for a lot of the other keys we'll need a userland daemon which
talks to syscons to handle stuff.

---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-20 Thread Daniel O'Connor


On 20-Apr-00 Brian Fundakowski Feldman wrote:
 Sure:

Gracias.

 With the new output format, I can tell that the released scancode is the
 pressed scancode + 128 (| 0x80).  Cool :)

Yes, the kbd driver handles this automatically.

 I've altered atkbd.c to grok the new keys, I also added 'power' and 'halt'
 to kbdcontrol/syscons - so now the power button works 8-)
 Heh, cool :)  This goes well with my small diffs to make the ATX power
 button a true 'panic', don't you think?

Damn straight :)

 Yeah, but along with stuff like this (usbd et al), we should have something
 in the kernel (thread?) to do most of it.  A unified event daemon would
 probably be half in the kernel and half out of it, and it would provide a
 pretty clean interface for this kind of thing (when it's not vaporware).

Hmm OK.. I was thinking about something like apmd (and usbd) which spends most
of its time blocked waiting for events, but a unified daemon would be nice :)

---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-18 Thread Brian Fundakowski Feldman

I've got a nice script and better version of scancodes.c to do this for me
now, so here goes :)  These are the keys on the Logitech cordless keyboard,
and they are undoubtedly the same for the rest of the Logitech iTouch
keyboards.  Script or scancodes.c on request, of course :)  I hope this
will help whosoever decides to take upon the task.

 KeyPressed Released
 ------ 
   Sleep-32, 95 -32, -33
Mute-32, 32 -32, -96
 Decrease Volume-32, 46 -32, -82
 Increase Volume-32, 48 -32, -80
Play-32, 34 -32, -94
Stop-32, 36 -32, -92
  Rewind-32, 16 -32, -112
Fast Forward-32, 25 -32, -103
Mail-32, 108-32, -20
  Search-32, 101-32, -27
Home-32, 50 -32, -78
 Run-32, 102-32, -26

--
 Brian Fundakowski Feldman   \  FreeBSD: The Power to Serve!  /
 [EMAIL PROTECTED]`--'



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-16 Thread Soren Schmidt

It seems Anatoly Vorobey wrote:
 
 Of course, with all those new keys on all those keyboards, we should
 perhaps think about whether to add all of them as new keycodes,
 and if so, in which order, etc. I've no idea if FreeBSD's concept
 of 'keycode' (i.e. key number independent of keyboard model) is
 synchronized with other BSD's, or Linux, etc.

I modelled them after SCO UNIX 3.2 way back when, I know that upto
some point I kept the keymaps compatible to SCO's, but I think that
got broken since

-Søren


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-16 Thread Warner Losh

In message [EMAIL PROTECTED] Soren Schmidt writes:
: I modelled them after SCO UNIX 3.2 way back when, I know that upto
: some point I kept the keymaps compatible to SCO's, but I think that
: got broken since

I don't think SCO does these new keys.  If I do anything in this area,
I'll check with the relevant people/systems before inventing
something.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-15 Thread Warner Losh

In message [EMAIL PROTECTED] Mike Pritchard writes:
: Here are the codes for the Compaq "Easy Access Internet Keyboard".
: They also have a newer version with even more buttons, but I don't
: have access to one, so I can't supply the codes for it.  If someone
: is going to do some work to get the Microsoft keyboard's extra keys
: to work, it shouldn't be hard to integrate these keys at the same time.

Thanks Mike.  If I move forward on this, I'll include these too.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-15 Thread Anatoly Vorobey

You, Warner Losh, were spotted writing this on Sat, Apr 15, 2000 at 12:01:05AM -0600:
 In message [EMAIL PROTECTED] Mike Pritchard writes:
 : Here are the codes for the Compaq "Easy Access Internet Keyboard".
 : They also have a newer version with even more buttons, but I don't
 : have access to one, so I can't supply the codes for it.  If someone
 : is going to do some work to get the Microsoft keyboard's extra keys
 : to work, it shouldn't be hard to integrate these keys at the same time.
 
 Thanks Mike.  If I move forward on this, I'll include these too.

To make FreeBSD grok them, go to sys/dev/kbd/atkbd.c (that's assuming
the keyboard is AT-style rather than USB), and modify atkbd_read_char():

--- atkbd.c Sat Apr 15 11:58:13 2000
+++ atkbd.c.new Sat Apr 15 12:09:28 2000
@@ -681,6 +681,15 @@
case 0x5d:  /* menu key */
keycode = 0x6b;
break;
+/* the following are super-duper extended MS keys */
+case 0x5f: /* Sleep key */
+keycode = 0x6d;
+break;
+case 0x65:/* Search key */
+keycode = 0x6e;
+case 0x66:/* Favourites key */
+keycode = 0x70;
+
default:/* ignore everything else */
goto next_code;
}

And so on for all the keys, using your scancodes in case
statements, and allocating new keycodes as you go along, starting
from the first available one now which is 0x6d.  Then
you just add new lines to keymap files, starting from 109=0x6d,
and it should work at once. We have 148 spare entries in keymap_t
at the moment, they should suffice for some time ;)

Of course, with all those new keys on all those keyboards, we should
perhaps think about whether to add all of them as new keycodes,
and if so, in which order, etc. I've no idea if FreeBSD's concept
of 'keycode' (i.e. key number independent of keyboard model) is
synchronized with other BSD's, or Linux, etc.

Have no idea what to do about X though. 

-- 
Anatoly Vorobey,
[EMAIL PROTECTED] http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



PC Keyboard Scancodes

2000-04-14 Thread Daniel O'Connor

Hi,
I put together a new PC and noticed the keyboard I bought has 3 extra keys
(Wakeup, Sleep, and Power). I wondered if they could be used by mapping
scancodes to the corresponding meanings, but I can't find the scan codes.

I made a keymap file which mapped the scan codes from 109 to 255 to
'debug' but pressing the keys don't trigger it :(

Does anyone know if/how I can use them? Suggestions thus far have been to
patch syscons to print all the scan codes it gets :)

---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Anatoly Vorobey

You, Daniel O'Connor, were spotted writing this on Fri, Apr 14, 2000 at 05:54:16PM 
+0930:
 Hi,
 I put together a new PC and noticed the keyboard I bought has 3 extra keys
 (Wakeup, Sleep, and Power). I wondered if they could be used by mapping
 scancodes to the corresponding meanings, but I can't find the scan codes.
 
 I made a keymap file which mapped the scan codes from 109 to 255 to
 'debug' but pressing the keys don't trigger it :(
 
 Does anyone know if/how I can use them? Suggestions thus far have been to
 patch syscons to print all the scan codes it gets :)

No need to patch. Put syscons into the K_RAW mode (open the device, and
use the KDSKBMODE ioctl - search for it in syscons source for details),
and syscons'll give you back the scancodes when you read it. This is
what X does, by the way.

One reason why your approach might not have been working is that
keymaps really translate from keycodes to charcodes, not from scancodes
to charcodes, and the keyboard driver might've been unsuccessful
in matching nonstandard scancodes to keycodes.

-- 
Anatoly Vorobey,
[EMAIL PROTECTED] http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton






To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Warner Losh

In message [EMAIL PROTECTED] "Daniel
O'Connor" writes:
: I put together a new PC and noticed the keyboard I bought has 3 extra keys
: (Wakeup, Sleep, and Power). I wondered if they could be used by mapping
: scancodes to the corresponding meanings, but I can't find the scan codes.

I also yesterday got one of those damn microsoft internet keyboards
and it has lots of extra keys that don't show up either.  Including
the Wakeup, Sleep and power.  My belief is that maybe you have to
explicitly enable the extra keys?

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Anatoly Vorobey

 I will see if I can try what Anatoly suggests.. :)

Use this simple prog to cough up the scancodes:

#include stdio.h
#include sys/kbio.h
#include sys/ioctl.h
#include fcntl.h
#include termios.h

void die(char *str) {
  perror(str);
  exit(0);
}

int main(void) {
  int err, mode;
  struct termios term_saved, term;
  int i;
  char ch;

  err = tcgetattr(0,term);
  if(err==-1) die("tcgetattr");
 
  term_saved = term;
  cfmakeraw(term);

  err = ioctl(0,KDGKBMODE, mode);
  if(err==-1) die("getkbdmode");
  else printf("current kb mode: %d\n", mode);

  err = ioctl(0,KDSKBMODE, K_RAW);
  if(err==-1) die("setkbmode");
  else printf("K_RAW mode set\n");

  printf("Press Esc to end.\n");

  err = tcsetattr(0,TCSANOW,term); /* set terminal to raw */
  if(err==-1) die("tcsetattr");

  for(i=0; i1000; i++) {
err=read(0,ch,1);
if(err!=1) break;
printf("%d ",ch); fflush(stdout);
if(ch==1) break; /* break on Escape */
  }

  err = tcsetattr(0,TCSANOW,term_saved);
  if(err==-1) die("tcsetattr");

  err = ioctl(0,KDSKBMODE,mode);
  if(err==-1) die("setkbmode");
  else printf("\nkb mode restored\n");

}


-- 
Anatoly Vorobey,
[EMAIL PROTECTED] http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Anatoly Vorobey

On Sat, Apr 15, 2000 at 01:43:40AM +0930, Daniel O'Connor [EMAIL PROTECTED]\
,Daniel O'Connor wrote: 
  
 On 14-Apr-00 Warner Losh wrote: 
  I also yesterday got one of those damn microsoft internet keyboards 
  and it has lots of extra keys that don't show up either.  Including 
  the Wakeup, Sleep and power.  My belief is that maybe you have to 
  explicitly enable the extra keys? 
  
 Could be :-/ 
  
 I couldn't find any info about the technical jiggery pokery of them on the \
web 
 though :( 
 
Also this may be of help: 
 
http://www.microsoft.com/hwdev/desinit/scancode.htm 
 
It doesn't seem to contain anything about enabling them though, seems 
like they should just emit the scancodes listed. 


-- 
Anatoly Vorobey,
[EMAIL PROTECTED] http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Warner Losh

In message [EMAIL PROTECTED] Anatoly Vorobey writes:
: Use this simple prog to cough up the scancodes:

OK.  Looks like the new microsoft keyboard that I have does indeed
just send the scan codes.  I have just a few keys:

Key DownUp

Back-32 106 -32 -22
Forward -32 105 -32 -23
Stop-32 104 -32 -24
Mail-32 108 -32 -20
Search  -32 101 -32 -27
Favorites   -32 102 -32 -26
Web/Home-32 50  -32 -78
My Computer -32 107 -32 -21
Calculator  -32 33  -32 -95
Sleep   -32 95  -32 -33

See a pattern :-)

-32 is 0xe0, which is also used to introduce the function keys like
Insert, Delete, etc.  So adding more shouldn't be too horrible.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Warner Losh

In message [EMAIL PROTECTED] Anatoly Vorobey writes:
: Also this may be of help: 
:  
: http://www.microsoft.com/hwdev/desinit/scancode.htm 
:  
: It doesn't seem to contain anything about enabling them though, seems 
: like they should just emit the scancodes listed. 

That's what I'm seeing here.

now, to find some time to "package" it into something the FreeBSD can
use.

And also to hack XFree86 into groking them.

Ah, but that would require that I have something like freetime.

Warner


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message



Re: PC Keyboard Scancodes

2000-04-14 Thread Daniel O'Connor


On 14-Apr-00 Warner Losh wrote:
 That's what I'm seeing here.
 now, to find some time to "package" it into something the FreeBSD can
 use.
 
 And also to hack XFree86 into groking them.
 
 Ah, but that would require that I have something like freetime.

Well, I can probably get FreeBSD to grok em... No idea about X though 8-)

---
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message