Aug 112010
 

Ten years ago? Bloomin’ heck! Still as this still seems to get frequent hits, I suppose quick update is in order – I no longer use the Unicomp “naked” but go through a Soarer converter which is an easier way of mapping the keys and allows macros to be added.

Thanks to these guys (the thread eventually gets to the meaty details), I have changed my Unicomp 122-key keyboard (UB40T56) from a funky “be friendly to Windows IBM Terminal emulators” mode into something a little more interesting. Specifically each key should be sending a unique keycode – which if you select the right model from Unicomp, you’ll get.

This can be done by opening up the keyboard and removing the jumper from JP3 (just below a small chip and close to the scroll LED). In addition, it is strongly suggested that you set the kernel parameter “atkbd.softraw=0” which can be done with Ubuntu 10.04 with the following :-

  1. Edit /etc/default/grub and change the variable GRUB_CMDLINE_LINUX_DEFAULT to include “atkbd.softraw=0” at the end of what is already there.
  2. Finish editing and run grub-update and finally reboot.

Without this, showkey -s only shows the scancodes of keys that the kernel knows about – not what scancodes are sent by the keyboard! It is possible to show the unknown scancodes by enabling the i8042 module debug mode, but atkbd.softraw does the same thing more effectively.

This is currently a work in progress, and will need further checking before it can be taken as gospel, but …

Group Key Make Break Keycode
Function Keys
F13 5b db
F14 5c dc 95
F15 5d dd 183
F16 63 e3
F17 64 e4
F18 65 e5
F19 66 e6
F20 67 e7
F21 68 e8
F22 69 e9
F23 6a ea
F24 6b eb
(next row) F1 3b bb 59
F2 3c bc 60
F3 3d bd 61
F4 3e be 62
F5 3f bf 63
F6 40 c0 64
F7 41 c1 65
F8 42 c2 66
F9 43 c3 67
F10 44 c4 68
F11 57 d7 87
F12 58 d8 88
Left Keypad (Top left is “Esc”)
Esc 7e fe 121
Cent 76 f6 85
Print Screen 72 f2
Pause e1 1d 45 e1 9d c5 119
Print 74 f4
Help 6d ed
Record e0 2a e0 37 e0 b7 e0 aa 99
Play 6f ef
GUI (Windows) 75 f5
Menu 6c ec
Editing Pad (between QWERTY and Number Pad)
Backtab 5a da
Insert e0 49 e0 c9 104
PageUp e0 51 e0 d1 109
(next row) Blue Return e0 4f e0 cf 107
Delete e0 52 e0 d2 110
Page Down e0 53 e0 d3 111
(next row) Up Arrow e0 48 e0 c8 103
(next row) Left Arrow e0 4b e0 cb 105
Home e0 47 e0 c7 102
Right Arrow e0 4d e0 cd 106
(next row) Down Arrow e0 50 e0 d0 108
Number Pad
(top row) End 01 81 1
Scroll Lock 46 c6 70
(shifted Scroll Lock) Number Lock 45 c5 69
/ 37 b7 55
* e0 c5 e0 b5 98
(next row) KP-7 47 c7 71
KP-8 48 c8 72
KP-9 49 c9 73
4e ce 78
(next row) KP-4 41 cb 75
KP-5 4c cc 76
KP-6 4d cd 77
+ 4a ca 74
(next row) KP-1 4f cf 79
KP-2 50 d0 80
KP-3 51 d1 81
Enter e0 1c e0 9c 96
(next row) KP-0 52 d2 82
KP-. 53 d3 83
  • Group. To break things up a little, I’ve grouped the keys into the 5 separate parts of the keyboard – the function keys, the keypad to the left, the qwerty pad, the editing pad, and the number pad (“keypad”). The details of the qwerty pad will be the last as the other groups are more interesting (‘qwerty’ keys just work).
  • Key. This is the label on the key on my keyboard. This may be different on different variants so in all cases I have started with the top left, worked left and down (the “qwerty” row before the “asdf” row).
  • Make. This is the scancode produced when the key is pressed.
  • Break. This is the scancode produced when the key is released.
  • Keycode. The configured keycode produced on the Linux console. The red cells are values that are wrong, but in addition many are missing because they are not produced on a keypress. I say wrong because the keycode gives a result that does not match the key legend – in some cases dangerously wrong such as PageDown generating Delete. One thing to be aware of is that you must use “showkey -k” at the console to get the same numbers I have – X seems to add 8 to each keycode.

Three interesting oddities here … F14 and F15 have somehow been graced with keycodes by default; their scan codes must coincide with keys defined on more popular keyboards. And of course Num Lock and Scroll Lock sharing the same key is a little … odd. And lastly the Record key is effectively sending two keystrokes in one.

Fixing The Wrong Keys

The first place to start is to map the keys that return a keycode that represents a key other than that written on the keycap – such as the key marked “End” which thinks it is an “Esc” key. I have left out two of the wrong keys from this group as they fit better into the next section.

The wrong keys can be fixed with the following commands :-

setkeycodes 7e         1    # Esc
setkeycodes e049      82    # Insert
setkeycodes e051     105    # PageUp
setkeycodes e052     111    # Delete
setkeycodes e053     109    # PageDown
setkeycodes 01       107    # End
setkeycodes 37        98    # KP-/
setkeycodes e035      55    # KP-*
setkeycodes 4e        74    # KP--
setkeycodes 4a        78    # KP-+

I have left out a couple of the wrong keys from this section as they do not return dangerously incorrect values, and they fit more logically into the next section (being Record and Blue Return).

Dealing With The Extra Keys

Now onto dealing with the extra keys. The tricky bit here was coming up with new keycodes for these keys that did not conflict with existing keycodes, and were reasonable. This is effectively impossible, as xmodmap -pk appears to show no significant range of unused keycodes although some of the used keycodes are for things like “Shop” buttons!

So I picked a range with a larger number of useless key symbols and some unused ones :-

setkeycodes 5b       222    # F13
setkeycodes 5c       223    # F14
setkeycodes 5d       224    # F15
setkeycodes 63       225    # F16
setkeycodes 64       237    # F17
setkeycodes 65       238    # F18
setkeycodes 66       228    # F19
setkeycodes 67       229    # F20
setkeycodes 68       230    # F21
setkeycodes 69       231    # F22
setkeycodes 6a       232    # F23
setkeycodes 6b       233    # F24
setkeycodes 72        99    # Record (after keyswap)
setkeycodes 74       209    # Print
setkeycodes 6d       138    # Help
setkeycodes 6f       239    # Play
setkeycodes 75       234    # Windows (GUI)
setkeycodes 6c       240    # Menu
setkeycodes 5a       235    # Backtab
setkeycodes e04f     236    # BlueReturn

Once this has run, we can look at fixing the X mappings … which is why F17 and F18 are out of sequence in the above! One key has to be (at least until someone comes up with a better solution!) sorted out with a keycap swap. Take the keycap from the Record key and swap it for the one marked “Print Screen”. This is because the scancode for Record is effectively two scancodes in one and attempting to remap it will result in strange things happening.

Sorting Out X11

Once you have a set of keycodes that don’t do funny things under X (for instance F17 and F18 when in sequence produce not a keystroke under X11 but some other event), you can move onto configuring the X keyboard. The following attempts to map as close to the keycaps as possible without going to extremes :-

xmodmap -e "keycode 230 = F13"
xmodmap -e "keycode 231 = F14"
xmodmap -e "keycode 232 = F15"
xmodmap -e "keycode 233 = F16"
xmodmap -e "keycode 245 = F17"
xmodmap -e "keycode 246 = F18"
xmodmap -e "keycode 236 = F19"
xmodmap -e "keycode 237 = F20"
xmodmap -e "keycode 238 = F21"
xmodmap -e "keycode 239 = F22"
xmodmap -e "keycode 240 = F23"
xmodmap -e "keycode 241 = F24"
xmodmap -e "keycode 217 = Print"
xmodmap -e "keycode 9 = Escape 3270_Attn"
xmodmap -e "keycode  93 = cent bar"
xmodmap -e "keycode 175 = 3270_Record"
xmodmap -e "keycode 175 ="
xmodmap -e "keycode 247 = 3270_Play"
xmodmap -e "keycode 242 = Super_L"
xmodmap -e "keycode 248 = Multi_key"
xmodmap -e "keycode 243 = 3270_BackTab"
xmodmap -e "keycode 118 = Insert 3270_Duplicate"
xmodmap -e "keycode 112 = Prior 3270_Jump"
xmodmap -e "keycode 117 = Next 3270_Rule"

This results in a keyboard that more or less matches the key caps. For some of the blue symbols, you press the key in combination with shift.

The number pad could do with a little more attention in the realm of X-mapping, and there are a few blue symbols on the main qwerty pad that might be usefully mapped, but this is sufficient for my purposes.

Jul 242010
 

This is not so much a review, as a collection of random thoughts that occur to me as I get used to my iPhone4. As such, you may well see it change over the month ahead as I get used to it.

Firstly, the shiny glass back cover means I cannot just put the new iPhone on the arm of my chair. The old iPhone (a 3G) sits quite happily there, but the new one is far too keen to slide off. Worth bearing in mind if you’re used to a “sticky” iPhone – wouldn’t want you to have an accident with a brand new phone!

Next is the special coating the glass gets to prevent fingerprints. Nice try, but they can still appear. Of course today my fingers are especially sweaty and greasy so although some prints are showing up, the screen is a good deal better than older iPhones would have been.

Finally (for now), and this one is hardly Apple’s faulty, but there are some applications out there that lose data when you go through a backup old phone and restore to new phone. This is definitely a bug in those applications, and I’m sure they know who they are, because better written applications didn’t lose a bit of data. Apple itself does in fact lose passwords, but I would guess this is a security measure to ensure that stored passwords can’t be “hacked” by restoring a stolen phone backup onto another phone.

The new iPhone does not give an initial impression of being significantly smaller than the old iPhone – even though for the first weekend I was shuffling between old and new phones. But it does seem a lot smaller as soon as you start carrying it around – it feels quite a bit smaller in the pocket.

The known problems with the aerial are obviously a serious issue for those effected, but I suspect the number of sufferers is smaller than the impression given online. After all complaints are louder than the sounds of satisfaction. Certainly I have not seen the issue myself.

Jul 242010
 

When the iPhone was first introduced, it was available on “unlimited” data plans although in reality “unlimited” meant “as much as we think is reasonable” with no indication of how much was reasonable. The first iPhone was also not capable of being “tethered” to a computer so the computer could use the phone as an Internet router – which was kind of odd as all other smart phones allowed that.

And then the iPhone acquired the tethering ability and the carriers insisted that customers pay extra for tethering. Which was sort of odd as no other smart phone required that. But it was sort of understandable as the iPhone had an “unlimited” data plan, and the ease of use had encouraged customers to make use of that “unlimited” data plan to the extent that many mobile networks suffered from a lack of bandwidth. The extra cost of tethering was a means of rationing how much bandwidth an iPhone customer could use.

But now with the iPhone4, all those “unlimited” data plans have mysteriously disappeared to be replaced with plans that limit you to 500Mb-1Gb per month. And yes you still have to pay extra for tethering. Why ?

Now that the data plan is no longer unlimited, why is there an extra charge for tethering ? Surely we are now in a situation where it does not matter what you use the data bandwidth for, but merely how much and whether you exceed the default limit. Those who want to exceed that limit pay more; those who want to tether only in an emergency don’t need to pay extra for something they do not need every day.

And yes I am one of those who would only use tethering in what to me are unusual circumstances – I don’t travel frequently and when I do travel, I have no great urge to ensure that I’m online. But just occasionally it may be useful – say if I’m contacted by work, as a laptop is far better to run an ssh client than an iPhone.

Jul 082010
 

I have just spent the weekend doing all sorts of stuff that you won’t be interested in because it’s really boring (moving the main desktop machine, etc.) with News 24 on in the background. About every 4 hours I’ve been treated to Chip or Chop or whatever it is, proclaiming that home computing in the good old days was far better than it is today.

What a load of rancid rhinoceros dung! There is of course an element of truth to it, but in reality home computing back in the 1980s was a continual struggle with limited resources – we often had less than 32Kbytes of memory to play with. Yes that is 32Kbytes not 32Mbytes! The first computer that I was employed to work with had 4,000 times as much memory as the first computer I used; and 2,000 times as much as the one I spent a lot of time writing software for. Of course the machine I am writing this with has no less than 4,000,000 times as much memory as my first machine!

When we look back in time to early home computing, we tend to use nostalgia tinted glasses. In addition to the limits on memory, early home computers had a number of other drawbacks :-

  • Graphics were ridiculously bad. If you were lucky you had two colours at 640×256 resolution. If you were unlucky, graphics were made up of special “blobby” text characters that could produce “graphics” of a resolution of something like 80×50!
  • The screen was typically a discarded old colour TV … big and fuzzy. Even if you were lucky enough to have a colour monitor, it would usually refresh at a rate guaranteed to produce eyeball frenzy.
  • Sound quality was a little below par. You could get computer music – see the Commodore’s SID files – but the likelihood of  anything approaching the quality of 128Kbps MP3s just wasn’t going to happen.
  • Storage was extremely small in capacity and very slow. If you were lucky you had access to floppy disk drives with around 80Kbytes to 320Kbytes (there were floppy drives with 1Mbytes of storage available but they were not common), and these were slow.

Not that there is anything wrong with nostalgia of course – I run a few software machine emulators to play around with the computers of my childhood. And in one particular sense those old 1980s home computers did have one advantage over modern computers that modern machines do not have.

They were very easy to get trivial results out of.

Fire up a Commodore PET, and less than a second after switching on, it would type “READY?” at you. And it does mean that … it is ready for you to type the commands needed to load a program from tape or disk, or for you to start writing a program. No loading of an operating system; no complex IDE to learn. Just you, the computer and the keyboard.

Despite the primitiveness of the interface, the immediacy of the results is very attractive to new hackers of child age. For instance, a simple program can produce interesting results for a child :-

10 for i = 1 to 1000
20 for j = 1 to 20
30 print tab(j); "Name"
40 next j
50 for j = 20 to 1 step -1
60 print tab(j); "Name"
70 next j
80 next i

Such a simple program produces a snake of your name down the screen; with a few modifications a child can produce more interesting graphics. And many home computers of the time came with far more extensive manuals that would teach BASIC programming.

Whilst BASIC is perhaps an unfortunate language for language purists and probably does teach a few bad habits, it does have one big advantage over more “proper” languages. It is easy to produce simple programs to produce simple results. Of course there is nothing preventing us from creating a better BASIC than the original with enhanced features, but the key is not programming purity, but ease of use and the ability to produce interesting results easily even if that means losing flexibility.

Jun 262010
 

I have yet to play with (or indeed spend much time reading about) iOS4 so it is possible that I am totally wrong with this one and this missing feature is actually supplied by the latest iPhone operating system. But if not … what about plugin input methods ?

That is allow other people to write extensions to the on-screen iPhone keyboard. Whilst Apple have undoubtedly come up with the best possible method for inputing text on a touch-screen, there are always a few who would like to try other ways such as :-

You could even allow users to craft their own on screen keyboards to allow easy access to extra symbols such as emoticons – which for some strange reason are available on certain far eastern keyboards but not on English ones ?!?