XT/AT/PS2/Terminal to USB Converter with NKRO

User avatar
Soarer

30 Jun 2013, 22:42

Sure, can have multiple connectors, and just use one at a time.

The PC/XT is the same pinout as the PC/AT. So alternatively you could build with a PS/2 socket, and use an AT-to-PS/2 adapter (which are fairly easy to find).

You can make a config that works for different keyboards by using the ifset and ifkeyboard commands to choose whether certain bits of config are activated. So for example you could have a layer for function keys mapped to the number row, that's only active when an XT or AT (84-key) keyboard is plugged in, with this code...

Code: Select all

ifset set1 set2
# config for layer or whatever here
ifset any
One note: you should disconnect the USB when changing keyboard. The connection order should always be: keyboard to converter, THEN converter to computer.

User avatar
Muirium
µ

01 Jul 2013, 12:21

Thanks gentlemen, that's exactly what I wanted to hear!

I am indeed considering a larger box for status LEDs and a bit of weight so the XT's massive coiled cable doesn't send it flying every which way. Might as well port it out! And a dynamic config is just the kind of crafty solution I was hoping for. Brilliant!

I've already annoyed the entire house with my Model F typing, and I must get around to pluging it in.

User avatar
Muirium
µ

02 Jul 2013, 15:02

JBert wrote:Ooh, the one and only PC keyboard. Typing on the very same at this moment.

A converter can have both input ports, just connect them according to the schemes and don't use them both at the same time.

However, I can't recall whether the PC and AT pinout of the DIN plug were the same, so be careful if you ever plug an AT keyboard into the DIN port.
Sweet keyboard you got there! I'm pleased to join the club.

Just got my Teensies in the mail. (One for this and one for an all metal 60% custom keyboard's controller; hopefully I won't fry either of them.) Fortunately, I see in Soarer's docs that XT and Din AT use the same pinout — Clock, Ground, Data and 5V/VCC are all on the same pins in both — so that should be safe. (Right?) I don't have any AT keyboards to plug in anyway, but back when XT was being replaced by AT, plenty of people did and I imagine that the AT's designers were keen that neither keyboard nor motherboard were fried when someone plugged the two together.

Ooh: light flash fast … press button … light flash slow. Teensy is alive. On to the good stuff.

User avatar
Muirium
µ

02 Jul 2013, 21:44

There we go: it works! First time, too. Big thanks Soarer!

Now I've got to customise this layout…

User avatar
Muirium
µ

02 Jul 2013, 23:18

Sweet Bejesus! That's some NKRO over USB you've got there Soarer!

Seeing as this monumental keyboard doesn't have dedicated arrow keys either, I'm thinking of trying one of the tricks set aside for my custom 60% build. Any idea if and how I can do this?
Arrow Combo Specials

a+e => up arrow
a+s => left arrow
a+d => down arrow
a+f => right arrow

;+i => up arrow
;+j => left arrow
;+k => down arrow
;+l => right arrow
Home row centred arrow layers, one on each side, activated by the corresponding little finger. A sneaky trick too far, I wonder? The only other keys I'd want to mix with them held down are the usual suspect modifiers.

JBert

02 Jul 2013, 23:38

I use the right Alt as an Fn key and never looked back (well, except the fact that I no longer had an AltGr, which I hacked around using RAlt + Space + character). This key can be pressed with the side of your right hand, making an alternative "always on the homerow" combo compared to the HHKB.

I attached my Soarer Config, so you can see what hacks I added. It does include colemak_select1.sc and colemak.sc.

Sidenote: Deskthority doesn't like attaching bare SC files...
Attachments
jbert-modelfxtconfig.zip
(1013 Bytes) Downloaded 254 times

User avatar
Muirium
µ

02 Jul 2013, 23:52

Great stuff JBert. I intend to use * (just right of right shift and straight under return) as function, like an HHKB. I'll map Alt to Command (the Mac version of the Windows key, and used for most shortcuts) and Caps Lock to Option (Alt), and see how it goes. I've fiddled around in the OS to do that in software the first hour or two I've had it working and I seem to be fine with it.

But right Alt? Mine doesn't have that!

Image

Caps Lock or different keyboards!

JBert

03 Jul 2013, 00:04

Hmmm, for some reason my XT has two Alt keycaps. Maybe the "Caps Lock" key got lost and replaced by the previous owner.

I meant Caps lock though, because that one is just beneath my right hand's palm.

User avatar
Muirium
µ

03 Jul 2013, 00:17

Cool. I thought you might just have been kidding about Caps Lock: a key so dangerous and vile I have it disabled on my other keyboards. The Model F, however, has Control in its rightful place so I can relax!

Your Caps cap likely got replaced by an earlier owner, [brag mode engage] as this one's been barely used over all the years [and relax]. Here's a fancy industrial with the exact same caps:

Image

But honestly, our classic white ones are better!

The single key I can't see showing up on my computer is Scroll Lock. This could be because scroll lock plain doesn't exist on the Mac. All the better reason for me to map it to something useful. Function layer lock?

User avatar
Soarer

03 Jul 2013, 04:13

Muirium wrote:Sweet Bejesus! That's some NKRO over USB you've got there Soarer!
:D
Muirium wrote:Home row centred arrow layers, one on each side, activated by the corresponding little finger. A sneaky trick too far, I wonder? The only other keys I'd want to mix with them held down are the usual suspect modifiers.
Yeah, too far. Well... you can make those Fn keys if you want, but then that's all they'll be! I'm not a fan of having keys only register after a time or when released... certainly not a fan of coding such things, since it seems it would be very hard to get it 'just right'.

User avatar
Muirium
µ

03 Jul 2013, 11:10

Fair enough. Thought it might be a problem, because, as you say, there's a sweet spot you have got to hit where it feels just right. I will explore other avenues of cunning.

User avatar
Muirium
µ

04 Jul 2013, 21:02

Just downloaded (and recompiled for my old G5) PJRC's hid_listen to figure out my keyboard ID so my 83 key Model F specific layout hacks don't mess up other keyboards:
Keyboard ID: 0000
Code Set: 1
Mode: PC/XT
Awesome!

User avatar
Soarer

04 Jul 2013, 21:27

Heh, we could've told you that :p PC/XT protocol is one-way, so we can't ask it for its ID ;)

hid_listen will come in handy regardless :)

'ifset' is usually good enough for testing the keyboard type, with 'ifkeyboard' being intended for distinuishing between the various terminal keyboards that use set3 (122-key, unsaver, 102-key) by setting their jumpers / DIP switches etc.

User avatar
Muirium
µ

04 Jul 2013, 21:54

Here's my current config. Spot the copy / paste code style…

Code: Select all

# define that FN1 accesses layer 1
layerblock
	FN1 1
	# FN2 2
endblock

# Primary Function Layer: HHKB + ESDF Arrows
# the layer itself is just some remaps tagged with the layer number
remapblock
layer 1
	LEFT_BRACE UP
	SEMICOLON LEFT
	SLASH DOWN
	QUOTE RIGHT
	L PAGE_UP
	PERIOD PAGE_DOWN
	K HOME
	COMMA END
	H PAD_ASTERIX
	J PAD_SLASH
	N PAD_PLUS
	M PAD_MINUS
	E UP
	S LEFT
	D DOWN
	F RIGHT
	R PAGE_UP
	V PAGE_DOWN
	A HOME
	G END
	PAD_1 PAD_1
	PAD_2 PAD_2
	PAD_3 PAD_3
	PAD_4 PAD_4
	PAD_5 PAD_5
	PAD_6 PAD_6
	PAD_7 PAD_7
	PAD_8 PAD_8
	PAD_9 PAD_9
	PAD_PLUS PAD_PLUS
endblock

# Second layer: XT numpad?

# base layer remaps time!
# need to map the FN key into the base layer (0)
remapblock
layer 0
	PAD_ASTERIX FN1
	PAD_PLUS PAD_ENTER
	LALT LGUI
	CAPS_LOCK RALT
	SCROLL_LOCK SYSTEM_POWER
	# BACK_QUOTE HASH!
	PAD_1 END
	PAD_2 DOWN
	PAD_3 PAGE_DOWN
	PAD_4 LEFT
	PAD_5 UNASSIGNED
	PAD_6 RIGHT
	PAD_7 HOME
	PAD_8 UP
	PAD_9 PAGE_UP
	F1 MEDIA_VOLUME_DOWN
	F2 MEDIA_VOLUME_UP
	F3 MEDIA_MUTE
	F4 MEDIA_PLAY_PAUSE
	F5 MEDIA_PREV_TRACK
	F6 MEDIA_NEXT_TRACK
	F7 F9
	F8 F10
	F9 F11
	F10 F12
endblock
Getting errors while trying to make Alt into Command (GUI) and Caps Lock into Option (ALT). Tried specifying single keys instead, e.g. RALT but no dice. Fixed it.

I've hijacked the numpad for dedicated arrow keys, the numbers proper hidden in layer 1 behind the all important function key: asterisk! Which happens to live just right of right shift, just where it is on the HHKB.

Is there any particular reason to define layer 0 after layer 1, I wonder? Probably just giving myself more work to do this way!

Also interested in remapping Shift + 2 to " instead of @, and a few other miscellaneous shift combos. Is that better done in the converter or with a different keyboard layout set in the OS?

A persistently annoying mismatch is the # ~ key just above right shift. Hash is not ordinarily a bare key, but on this keyboard it is. You hit shift + hash to get tilde, according to the legends. But so far not the logic!

User avatar
Soarer

04 Jul 2013, 22:47

Yeah, remapping only does single keys, the un-handed ones are for macro commands and triggers. So...

Code: Select all

LALT LGUI    # from LALT not ALT
CAPS_LOCK RALT    # should work...?!
Then use macros for multi-key stuff...

Code: Select all

macroblock

macro 2 shift -ctrl -alt -gui
press QUOTE
endmacro

macro BACK_QUOTE -all
push_meta set_meta lshift
press 3
pop_meta
endmacro

endblock
Note that if you remap some other key to BACK_QUOTE, you'll have two of them, and either will trigger the macro! So in that case also remap BACK_QUOTE to something unused (LANG_n are good), and then trigger the macro on that.

It shouldn't matter what order the layers are defined.

User avatar
Muirium
µ

04 Jul 2013, 22:59

Cool, thanks Soarer. This is pretty powerful stuff!

One last idea on my mind: is it possible to make a "layer lock" just by editing the current config? I mean something like how Scroll Lock works. The fact there's persistent state involved makes me doubt it, but I could devise a use or two!

User avatar
Soarer

04 Jul 2013, 23:15

Might be able to add a layer lock in the next version. Until then, the closest thing is SELECT_n, and ifselect, but that probably means duplicating chunks of config ('include' can be used to ease that pain, but it still makes the binary config bigger).

User avatar
Muirium
µ

04 Jul 2013, 23:39

Just knowing that it's possible gives me the incentive to look!

User avatar
Muirium
µ

07 Jul 2013, 03:20

No layer lock yet, but I've designed a fairly good layout, for my purposes, which looks like this:
IBM PC XT Model F.png
IBM PC XT Model F.png (310.76 KiB) Viewed 10872 times
It took a while, but I realised the XT has plenty of room for modifier keys if you think outside the box a bit. Its bottom row has 8 keys including the (huh-yuge) spacebar, which is the same number as my 60% design. So I transplanted a bunch of ideas. First of all: if it's on row 1, it's a mod! Function keys are overrated anyways.

Power key at top right is pretty handy. HHKB style function layer key and arrow bindings are neat too. And several macros are in effect to achieve a close match to the Model F's own keys in the default layer. Num Lock is where I'd put the layer lock key, if I had figured out such things yet. So for now it's reserved.

Code now includes comments:

Code: Select all

# define that FN1 accesses layer 1
layerblock
	FN1 		1
	# FN2 2
endblock

# Base layer remaps time
# need to map the FN key into the base layer (0)
remapblock
# Just for the PC/XT keyboard
ifset set1
layer 0
	PAD_ASTERIX FN1					# The all important function key
	LCTRL		FN1					# And the second one: currently the same
	PAD_PLUS 	PAD_ENTER			# Puts an enter at the far right edge
	LALT 		LGUI				# Command!
	CAPS_LOCK 	RGUI				# And again
	PAD_0 		RALT				# Option spills over onto the numpad
	PAD_PERIOD	RCTRL				# Control does too
	F9 			LCTRL				# Mirror image for left and function keys
	F10			LALT				# Completing the 6 mod set
	SCROLL_LOCK SYSTEM_POWER		# Closest I got to Eject, works nicely
	PAD_1 		END					# Hijack the numpad for cursor controls
	PAD_2 		DOWN
	PAD_3 		PAGE_DOWN
	PAD_4 		LEFT
	PAD_5 		UNASSIGNED
	PAD_6 		RIGHT
	PAD_7 		HOME
	PAD_8 		UP
	PAD_9 		PAGE_UP
	F1 			MEDIA_VOLUME_DOWN	# Hijack the f-keys for media controls
	F2 			MEDIA_VOLUME_UP
	F3 			MEDIA_MUTE
	F4 			MEDIA_PLAY_PAUSE
	F5 			F9					# Including the full set for Exposé
	F6 			F10
	F7 			F11
	F8 			F12
endblock


# Primary Function Layer: HHKB + ESDF Arrows
# the layer itself is just some remaps tagged with the layer number
remapblock
# Just for the PC/XT keyboard
ifset set1
layer 1
# 	HHKB Arrows
	LEFT_BRACE 	UP
	SEMICOLON 	LEFT
	SLASH 		DOWN
	QUOTE 		RIGHT
	L 			PAGE_UP
	PERIOD 		PAGE_DOWN
	K 			HOME
	COMMA 		END
	H 			PAD_ASTERIX
	J 			PAD_SLASH
	N			PAD_PLUS
	M			PAD_MINUS
	
# 	ESDF Arrows	
	E			UP
	S			LEFT
	D			DOWN
	F			RIGHT
	R			PAGE_UP
	V			PAGE_DOWN
	A			HOME
	G			END
	
# 	Restore the Numpad	
	PAD_1		PAD_1
	PAD_2		PAD_2
	PAD_3		PAD_3
	PAD_4		PAD_4
	PAD_5		PAD_5
	PAD_6		PAD_6
	PAD_7		PAD_7
	PAD_8		PAD_8
	PAD_9		PAD_9
	PAD_PLUS	PAD_PLUS
	PAD_PERIOD	PAD_PERIOD
	PAD_0		PAD_0
	
# 	Restore the Function Keys	
	F1			F1
	F2			F2
	F3			F3
	F4			F4
	F5			F5
	F6			F6
	F7			F7
	F8			F8
	F9			F9
	F10			F10
	
# 	Media keys across the number row	
	1			F14					# Decrease Display Brightness 
	2			F15					# Increase Display Brightness
	3			F10					# Exposé: All App Windows
	4			F12					# Dashboard
	5			F11					# Exposé: Show Desktop
	6			F9					# Exposé: All Windows in All Apps
	7			MEDIA_PREV_TRACK	# iTunes / media playback controls
	8			MEDIA_PLAY_PAUSE
	9			MEDIA_NEXT_TRACK
	0			MEDIA_MUTE			# Volume controls
	MINUS		MEDIA_VOLUME_DOWN
	EQUAL		MEDIA_VOLUME_UP
	BACKSPACE	DELETE				# Delete for Backspace
	LCTRL		CAPS_LOCK			# Capslock lives, out of harm's way
	ENTER		PAD_ENTER			# Enter for Return
	ESC			EUROPE_2			# This § symbol
	BACK_QUOTE	EUROPE_2			# In both places I might look for it
endblock


# Let the going get weird
# Match the PC/XT's unusual legends
# Just for the PC/XT keyboard
ifset set1
macroblock

# Shift 2 = "
macro 2 shift -ctrl -alt -gui
press QUOTE
endmacro

# Shift ' = @
macro QUOTE shift -ctrl -alt -gui
push_meta set_meta lshift
press 2
pop_meta
endmacro

# Shift Option + # = ±
# Corresponding with § remap, this time with shift
macro BACK_QUOTE shift alt -gui -ctrl
push_meta set_meta rshift
press EUROPE_2
pop_meta
endmacro

# ` = #
macro BACK_QUOTE -all
push_meta set_meta ralt
press 3
pop_meta
endmacro

# Command + Escape = Command + Section break (for app window cycling)
macro ESC gui -ctrl -alt
push_meta set_meta lgui
press EUROPE_2
pop_meta
endmacro

endblock
Here's a zip of my Soarer's Converter config file and my OmniGraffle file for the layout chart above for anyone looking for either as a template.
MuXT.zip
(130.03 KiB) Downloaded 238 times
So chuffed to be using this awesome old keyboard. Thanks again Soarer!

User avatar
Soarer

07 Jul 2013, 15:27

Very nice!

The last macro, since a gui key is already pressed, does it need the set_meta etc? Perhaps just...

Code: Select all

# Command + Escape = Command + Section break (for app window cycling)
macro ESC gui -ctrl -alt
press EUROPE_2
endmacro
Minor point... with two keys remapped to FN1 it won't work as expected if you press both of them, then release one, then press another key - you'll get the base layer rather than layer 1. Using two FN codes avoids that...

Code: Select all

# define that FN1 and FN2 both access layer 1
layerblock
   FN1  1
   FN2  1
   FN1 FN2  1
endblock
In fact, the same thing affects any duplicated codes, like the two sets of cursors you've mapped, but there's no way round that (and it's an even more minor issue when it's on final keys rather than modifiers or fn keys). Technically I could add code to track such things, but it doesn't seem worth the code, or the memory it would use up :ugeek:

User avatar
Muirium
µ

07 Jul 2013, 15:39

Good catch, Soarer. I added the second function key (the XT's single Control) late on in my tinkering. I'd already mapped Fn + Control to Caps Lock, which still works regardless! You can tell I've not quite mastered this stuff yet.

Once I've added a physical PS/2 port to my converter, the next step will be to put all of this into a separate file and include it with a single ifset set1 command so my XT's wackiness doesn't drive every other keyboard nuts and I can work on a clean set for them.

Here's a feature request, if you're interested: the Teensy has a lot more pins than the four that conversion requires, plus the usual optional status LEDs. I'd quite like layer indicators! One LED for layer 1, a second for layer 2 and so on. Would that be much overhead to keep track of?

The place they'd really come in handy is in a custom controller, one LED behind each corresponding number key! But that's another project…

User avatar
Soarer

07 Jul 2013, 16:04

The idea is that the config gives low-level pieces that can be put together... so even I don't know all of what might be possible with different combinations of settings!

People posting their configs is great - it gives me as chance to nit-pick, and see where extra comments might be useful in the docs. How to do a nice beginner level explanation of macros still eludes me, but I'll have to tackle that when I add even more stuff to macros or it will just be too much to take in in one go!

User avatar
Muirium
µ

07 Jul 2013, 16:11

Something I found useful was bouncing my config back out again with scrd and scdis. That's how I figured out the logical scope of ifset.

I'm too used to {curly brackets}!

User avatar
bhtooefr

07 Jul 2013, 16:14

This is what I've got in my converter, although it needs further tweaking for OS X:

Code: Select all

force set3 
ifkeyboard any
ifselect any
remapblock
layer 0
	EXTRA_BACKSLASH BACKSLASH
	EUROPE_1 BACKSLASH
	EXTRA_F1 MEDIA_VOLUME_UP
	EXTRA_F2 ESC
	EXTRA_F3 MEDIA_VOLUME_DOWN
	EXTRA_F4 PRINTSCREEN
	EXTRA_F5 MEDIA_MUTE
	EXTRA_F6 SCROLL_LOCK
	EXTRA_F7 MEDIA_PLAY_PAUSE
	EXTRA_F8 PAUSE
	EXTRA_F9 APP
	EXTRA_F10 LGUI
	ESC NUM_LOCK
	NUM_LOCK PAD_SLASH
	SCROLL_LOCK PAD_ASTERIX
	EXTRA_SYSRQ PAD_MINUS
	PAD_ASTERIX PAD_PLUS
	PAD_MINUS PAD_PLUS
	PAD_PLUS PAD_ENTER
	LANG_4 DOWN
endblock
I forced set3 because, well, it's permanently installed inside my 122 F. And, I actually mapped things planning to convert it to ANSI, and never did so.

User avatar
Soarer

07 Jul 2013, 16:26

Muirium wrote:Something I found useful was bouncing my config back out again with scrd and scdis. That's how I figured out the logical scope of ifset.

I'm too used to {curly brackets}!
Haha, logical scope... there isn't a lot of that! It's an assembler of config 'blocks', not a compiler, so some of the commands just set flags that are written out as part of each block. The if commands are like that, and don't get reset after the block is written. The layer command can be written before the block rather than inside (which might help if using select and include to simulate layer lock...), but it is reset to 0 when the next remapblock is written out.

User avatar
Muirium
µ

07 Jul 2013, 17:23

I know a little C, a little Objective-C, and how to swear in AppleScript. This straight to a chip stuff of yours is advanced technology to me!

Extra_f keys? I hadn't thought of trying those. Thanks Bhtooefr!

Edit: ah, indeed. I'm imagining things. It's too hot today…
Last edited by Muirium on 07 Jul 2013, 17:28, edited 2 times in total.

User avatar
bhtooefr

07 Jul 2013, 17:25

Those keys won't be present on a set 1 board, that's for 122-key terminals.

The EXTRA_Fn keys are equivalent to the Fn keys on an XT (set 1) or AT (set 2).

User avatar
Halvar

07 Jul 2013, 22:57

bhtooefr wrote:This is what I've got in my converter, although it needs further tweaking for OS X:
...
What key is EXTRA_BACKSLASH? I think I don't have that on my board. Is that just the ANSI backslash above the return key?

My config file for my M122 (ISO) is in Soarer's zip file, but I think it won't help you much at this point any more, because it's ooptimized for Windows.

User avatar
bhtooefr

07 Jul 2013, 23:02

My config is also optimized for Windows, and I did it a while back (when 0.997 was current). Well, I tweaked it to hardcode set 3 the other day, when I finally cracked the board open (because 0.997 can't go into the bootloader without pressing the button) and updated it...

In any case, according to the help files...
Soarer wrote:

Code: Select all

EXTRA_BACKSLASH	0xB5	AT-F extra pad top of enter
So, yep, it's the ANSI backslash.

User avatar
Soarer

07 Jul 2013, 23:11

Halvar wrote:What key is EXTRA_BACKSLASH? I think I don't have that on my board. Is that just the ANSI backslash above the return key?
That's for the AT-F key in that position, since it uses an odd code for that one (and the one under the left side of its bigass enter, which is EXTRA_EUROPE_2).

For the 122-key, EUROPE_1 and BACKSLASH should cover both of those since it uses more standard codes.

Hmm.... EXTRA_EUROPE_2 should really be EXTRA_EUROPE_1... bugger!

Post Reply

Return to “Workshop”