Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #1782

Re: Detecting Keyboard types...

From Martin Wuerthner <spamtrap@mw-software.com>
Newsgroups comp.sys.acorn.programmer
Subject Re: Detecting Keyboard types...
Date 2012-06-06 18:33 +0200
Organization MW Software
Message-ID <0ddca99b52.martin@bach.planiverse.com> (permalink)
References <c0136566-badf-433d-a1bd-8465bbad6446@w24g2000vby.googlegroups.com>

Show all headers | View raw


In message <c0136566-badf-433d-a1bd-8465bbad6446@w24g2000vby.googlegro 
ups.com>
          Gazza <usenet@garethlock.com> wrote:

> This is another issue with my keyboard handler library (eventually to
> become the keyboard handler for the port of UMoria I'm writing). I'm
> finding that the mappings for the old Archimedes etc keyboards are
> different to those of the more modern PC type keyboards. At the
> moment, I'm using a long-winded look-up table, which still isn't
> catching all differences.

> I guess I'm asking whether there is either a better way of doing it
> than this, (OS call etc.) or is there an easy way to detect the
> keyboard type on the fly and macro in the appropriate differences.

It really looks like you are trying to reinvent the wheel here. The OS 
(or more accurately, the keyboard driver) knows about keyboard 
layouts, and even more so, it also knows about locale settings, which 
you have not addressed yet. If you decided to bypass all that and scan 
physical keys, you would also have to deal with the fact that the key 
labelled "Q" on a UK keyboard produces the letter "A" on a machine 
with the keyboard driver set to French, and the key labelled "Y" 
produces the letter "Z" on my machine with the keyboard driver set to 
German.

If your game says that Ctrl+Z does something, then users expect to be 
able to enter Ctrl+Z in the usual way as everywhere else. That means, 
that on my machine I hold down Ctrl and press the key to the right of 
"T" and the keyboard driver maps that to Ctrl+Z correctly.

So, you had better forget about basing your input method on scanning 
physical keys. Simply process the character codes you get from the 
standard RISC OS input stream, which gives you a specific character 
code for Ctrl+Z, and there is no need for you to worry which physical 
keys were pressed in order to generate it. The OS deals with all that. 
If you want to detect the difference between Ctrl+Z and Ctrl+Shift+Z, 
which both result in the same character code, you just need to scan 
the state of the Shift key, which has the same internal key number 
everywhere (with the usual caveat about potential timing differences 
between the user pressing the keys and your program receiving the 
input character).

-- 
Martin
---------------------------------------------------------------------
Martin Wuerthner         MW Software      http://www.mw-software.com/
        RISC OS Software for Design, Printing and Publishing
---------------------------------------------------------------------

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Detecting Keyboard types... Gazza <usenet@garethlock.com> - 2012-06-06 07:34 -0700
  Re: Detecting Keyboard types... Martin Wuerthner <spamtrap@mw-software.com> - 2012-06-06 18:33 +0200
    Re: Detecting Keyboard types... Gazza <usenet@garethlock.com> - 2012-06-06 11:07 -0700
      Re: Detecting Keyboard types... jgharston <jgh@arcade.demon.co.uk> - 2012-06-06 17:38 -0700
        Re: Detecting Keyboard types... Gazza <usenet@garethlock.com> - 2012-06-07 01:29 -0700
          Re: Detecting Keyboard types... Gazza <usenet@garethlock.com> - 2012-06-08 09:04 -0700
  Re: Detecting Keyboard types... Gazza <usenet@garethlock.com> - 2012-06-06 09:39 -0700

csiph-web