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

User avatar
IonutZ

27 Oct 2013, 21:14

You mean get a new teensy lol. What about DP DM for the actual keyboard being hooked up to the teensy?

User avatar
Soarer

27 Oct 2013, 22:12

Eh? The keyboard doesn't go in that hole!

User avatar
IonutZ

27 Oct 2013, 22:25

Of course not, I'm talking about which pinout on the teensy is for DP and which one is for DM...

PD0 = Data = DP
PD1 = Clock = DM

?

User avatar
Soarer

27 Oct 2013, 22:46

DP = D+
DM = D-

Those are only available on the USB socket (or those resistors).

User avatar
IonutZ

27 Oct 2013, 23:01

Yea but I want to use my USB 6kro keyboard to your converter to get NKRO... I understood this was possible.

User avatar
Soarer

27 Oct 2013, 23:30

As long as it supports NKRO over PS/2, sure. Then it connects to PD0 and PD1. To make the connection you could either...
a) use a passive USB-PS/2 adapter (the likes of which may have come with your keyboard) and a PS/2 socket wired to the Teensy,
b) remove the cable from your keyboard and wire the Teensy direct to the keyboard's controller, or
c) butcher the keyboard's cable and wire that to the Teensy.

In any of those cases, the keyboard attaches to PD0, PD1, +5V and GND, recognises that it's hooked up to a PS/2 port, and switches to that mode.

But I guess what you're asking is 'how is one of these passive thingies wired?'...

Image

I reckon D+ is Clock, and D- is Data (from Holtek datasheet).

User avatar
IonutZ

28 Oct 2013, 01:15

you were right! Made it work! Thanks Soarer.

User avatar
Muirium
µ

12 Nov 2013, 13:42

Blast! I figured it out. I was in the middle of writing this…
Okay, here's a weird one.

I recently picked up an SSK, and so I'd like to implement the integrated numberpad as suggested by its caps. (That's the usual square around the I key arrangement that I'm already used to from my PowerBook, which reuses 7,8,9 as the top row of a virtual pad.) As my function layer is already full of HHKB arrows and such, I made a new layer. And then I got cunning and tried to make a layer lock.

The SSK has a Num Lock key, so I tried to use it as the trigger. Those are ignored on the Mac (it reads the row above the Insert/Home/Page Up block as F13-15) so I wrote a macro which fires when Num Lock is pressed, and manipulates a virtual fn3 key. Actually, I wrote two macros: one to press the fn3 key (using the MAKE command) and another to release it (using BREAK), the difference being Shift. But to my surprise I found that the MAKE macro was ignored entirely and the BREAK one is enough to act as a toggle by itself!

Here's my code.

Code: Select all

layerblock
	fn1 		1
	fn2 		1		# One for each hand, where available
	fn1 fn2		2		# Press them both for a hard to reach second layer
	fn3			3		# Numlock layer lock virtual key
endblock

remapblock
layer 3
	# SSK Num Lock Layer
	j			pad_1
	k			pad_2
	l			pad_3
	u			pad_4
	i			pad_5
	o			pad_6
	7			pad_7
	8			pad_8
	9			pad_9
	m			pad_0
	period		pad_period
	minus		pad_minus
	equal		pad_plus
	semicolon	pad_asterix
	slash		pad_slash
endblock

macroblock
	# Don't know what's going on, but simply breaking fn3 is acting as a toggle!
	# Num Lock = Layer 3 lock
	# macro scroll_lock -shift
	# make fn3
	# endmacro
	
	# This one works, both ways!?
	# Num Lock = Layer 3 lock
	macro scroll_lock
	break fn3
	endmacro
endblock
But now all is revealed. The combo Shift + Num Lock is recognised natively by the Mac and engages that integrated numpad anyway. In fact, I modified my layer 3 on purpose just to test, and the alterations are ignored: this numpad mode is independent of my code. Oh well. I thought I was onto something there!

I still seek the illusive layer lock for my nonstandard stuff…

User avatar
Halvar

12 Nov 2013, 14:12

Muirium wrote: But now all is revealed. The combo Shift + Num Lock is recognised natively by the Mac and engages that integrated numpad anyway.
That's interesting -- definitely doesn't work in Windows. Are you sure that this shift-numpad mode isn't just a feature of the SSK controller? I can't test it myself because I don't use the original SSK controller in mine, but I coould imagine that the SSK controller has it own layering and sends scancodes of numpad keys when shift+num_lock was pressed (which in fact is shift+scroll_lock on the SSK).

Does it work with every keyboard on your Mac?

User avatar
Muirium
µ

12 Nov 2013, 14:24

Good question! I have my homemade 60% plugged in now (running Soarer's Controller beta) and I've been furtively trying to pull off the same trick with it, but no success so far. Perhaps there is an IBM dimension to this cunning logicus!

User avatar
Soarer

12 Nov 2013, 15:02

Yup, whatever the SSK does for its numpad, it does it itself. I don't think it depends on numlock state. For remapping etc., treat the SSK just like a full-sized keyboard, and live with not being able to change the shift+numlock behaviour.

Re. make/break FN3 in a macro - won't work. See the dataflow diagram ;)

User avatar
Muirium
µ

12 Nov 2013, 15:26

Soarer wrote:Re. make/break FN3 in a macro - won't work. See the dataflow diagram ;)
Yeah, I figured after this that whatever I was doing, I was doing it wrong!

hid_listen shows the SSK at its work. Num Lock is on the same key as Scroll Lock (usual for PC boards, right?) but accessed with a shift. On my Acer switch PS/2 keyboard, that key sends 0x47 (SCROLL_LOCK) whether shift it pressed or not. But on the SSK, 0x47 becomes 0x53 (NUM_LOCK) when shift is pressed too. Not only that, but 7,8,9 are converted to pad_7, pad_8, pad_9 and so on. IBM's doing, not mine. But needless to say I like it!

gonka

06 Dec 2013, 11:51

Hi, anyone managed to run Soarer's converter tools on linux 64 bits (scas, scwr... etc) ?
Not able to compile them either, any idea?
Thanks you

User avatar
Soarer

06 Dec 2013, 13:14

I don't have a 64-bit install to try things out on, but something like this might help:

Code: Select all

apt-get install ia32-libs-multiarch
Otherwise, the tools ought to be fairly to compile, especially scas and scdis which don't even use the HID library. What errors do you get?

gonka

06 Dec 2013, 15:07

Hei Soarer, installing ia32-libs-multiarch worked! Thanks

User avatar
urbancamo

18 Jan 2014, 00:31

Hi Soarer,

Have you tried the PS/2 variant of the DEC/HP LK series of keyboards at all? I have plugged an LK461-A2 into your converter and it works reasonably well, but not well enough to distinguish between all the keys. These keyboards have an OpenVMS layout, and I believe they work using scan code set 3.

When I set config to force set 3 it worked reasonably well, but I got stuck when I started looking at the higher keys such as F19,F20 and the PF1-PF4 keys. Also, there is a key unshifted is < and shifted is > - wasn't sure how that would work.

I'd be happy to lend you one to get it going with ;) Or I could dump out the hid_listen output for each key if that would help.

Regards, Mark

User avatar
Soarer

18 Jan 2014, 01:51

I haven't tried that one, not sure what codes they send for those keys (F19...). A bit of hid_listen output would help for sure! The <> key should end up as \| if you have UK layout set on your PC.

User avatar
urbancamo

20 Jan 2014, 14:44

OK, I'll make a table up with HID output. The LK450 which is the same layout but designed (more) to work with PCs works OK - I was successfully able to map everything well enough to work with Reflection terminal software. The ESCAPE key and PF1 key both send ESCAPE - I don't think there is any way round that however.

Thanks, Mark.

User avatar
PJE

30 Jan 2014, 01:58

Hi Soarer, apologies if this has been discussed on the thread. I'm on my tablet at the moment and it's a little slow scanning through the thread...

Question: Is it possible to use any other pins for the keyboard input, or are you using the I2C hardware within your code?

The reason I ask is that I'd love to look at incorporating your converter into a modified OneHand keyboard. I'd like to keep away from the I2C and Serial pins as I was planning on using them for displays and a Twiddler V1 converter. I'm also planning on using a Pro Micro board rather than the Teensy which reduces the available I/O.

Keep up the excellent work. You're documentation is on a totally different level to what I'm used to!

User avatar
Soarer

30 Jan 2014, 15:18

There's one big problem with that idea - I haven't released the source code yet, and no idea when I will!

User avatar
PJE

30 Jan 2014, 17:33

Soarer wrote:There's one big problem with that idea - I haven't released the source code yet, and no idea when I will!
I understand.

Theoretically, could your software be modified to work from any pin pair, or do you need specific functions associated with the I2C pins? I suppose I could look at the PS/2 keyboard timing.

I'm making a RS232 to USB converter for an old Handkey Twiddler V1 (which can also be used for serial Bar Code scanners), and thought about adding it to my OneHand design. At that point it would also make sense to add a PS/2 input capability as well, which would allow a PS/2 keyboard to be used to configure the chords on the OneKey using a simple press PS/2 key followed by OneKey chord... I could also pass the RS232, PS/2 and OneHand characters through the same Macro function block before sending it to USB.

I use I2C on my OneHand to connect an OLED display and also a second OneHand to make a split keyboard, so the I2C pins are not available for the PS/2 interface.

User avatar
Soarer

30 Jan 2014, 20:44

The data signal could use any pin, but for my code the clock signal needs to be on an pin capable of generating interrupts on both low-high and high-low edges. So that's one of PD0..3 or PE6, on an ATmega32U4.

User avatar
PJE

30 Jan 2014, 22:56

Soarer wrote:The data signal could use any pin, but for my code the clock signal needs to be on an pin capable of generating interrupts on both low-high and high-low edges. So that's one of PD0..3 or PE6, on an ATmega32U4.
Thanks for the response.

I may look at making my own much simpler PS/2 keyboard converter, my current design has a few pins including PE6 free. I'm using both the serial and i2c interfaces, but my design has a few pics available.

quantalume

17 Apr 2014, 19:27

I'm having trouble getting a macro working the way I want. What I want to do is remap the "Rule" key on a 122-key Model M terminal (the key in the middle of the cursor cluster) to HOME and make ALT-RULE send END.

Remapping "Rule" was no problem:

Code: Select all

remapblock
	LANG_4 HOME
endblock
But when I try to add a macro to make ALT-HOME send END:

Code: Select all

macroblock
  macro HOME ALT
    PUSH_META CLEAR_META ALL
    PRESS END
    POP_ALL_META
  endmacro
endblock
If I now type ALT-HOME, here is what hid_listen reports:

Code: Select all

r19 +E2 dE2
r6E +4A d4D u4D
rF0 r6E -4A
rF0 r19 -E2 uE2
This seems to have the desired effect, i.e., the cursor goes to the end of the line in a text editor. Do I understand the hid_listen output correctly in that the Teensy is sending the sequence dE2 d4D u4D uE2 to the computer? If this is the case, then the computer should be seeing ALT-END and not END. If I actually press ALT-END on the keyboard, I get the following hid_listen output:

Code: Select all

r19 +E2 dE2
r65 +4D d4D
rF0 r65 -4D u4D
rF0 r19 -E2 uE2
Which would seem to be sending the same sequence to the computer; however, in this case nothing happens, as expected. The cursor does not move to the end of the line because it does not have a translatable action for ALT-END. This would be nothing but an academic curiosity except that now I want to be able to use additional meta keys in combination with ALT-HOME. For example, if I hit SHIFT-ALT-HOME, I would expect the computer to see SHIFT-END. In this case, hid_listen reports the following:

Code: Select all

r12 +E1 dE1
r19 +E2 dE2
r6E +4A d4D u4D
rF0 r6E -4A
rF0 r19 -E2 uE2
rF0 r12 -E1 uE1
...and the cursor goes to the end of the line, but without selecting text, as if the shift wasn't pressed. Am I doing something wrong or am I not understanding hid_listen output correctly? Thanks for your help.
Last edited by quantalume on 17 Apr 2014, 23:19, edited 1 time in total.

quantalume

17 Apr 2014, 21:00

I was able to achieve the desired outcome by adding another macro:

Code: Select all

macroblock
  macro HOME SHIFT ALT
    PUSH_META CLEAR_META ALL
    SET_META SHIFT
    PRESS END
    POP_ALL_META
  endmacro
  macro HOME ALT
    PUSH_META CLEAR_META ALL
    PRESS END
    POP_ALL_META
  endmacro
endblock
I needed to provide a macro for the particular case of SHIFT-ALT-HOME. Apparently my interpretation of the hid_listen output is incorrect. It is not actually sending all codes preceded by u or d to the computer.

jorgej

27 May 2014, 11:56

IBM XT SPANISH LAYOUT

Soarer’s converter works great, but found some problems to adapt to (1986) Spanish layout

Retrete (from spanish MEDIAVIDA) hinted me to ask Soarer directly for a solution…

1) Got this wonderful XT keyboard with this unusual Spanish layout (that I’d love to use):
https://plus.google.com/u/0/photos/1054 ... 1264614145

Code: Select all

¡ ¿ # $ % / & * ( ) ? +
1 2 3 4 5 6 7 8 9 0 ' =

 Q W E R T Y U I O P : ^
 q w e r t y u i o p ; `

  A S D F G H J K L Ñ ¨ Ç
  a s d f g h j k l ñ ´ ç

> Z X C V B N M " ! _
< z x c v b n m , . -
2) Once I installed the Teensy 2.0 with the "Soarer_at2usb_v1.12_atmega32u4.hex" file, I got this outcome:

Code: Select all

! ” • $ % & / ( ) = ? ¿
1 2 3 4 5 6 7 8 9 0 ’ ¡

 Q W E R T Y U I O P ^ *
 q w e r t y u i o p ` +

  A S D F G H J K L Ñ ¨ ª
  A s d f g h j k l ñ ´ º

Ç Z X C V B N M ; : _
ç z x c v b n m , . -
3) By trial and error, from other .sc files, I’ve prepared the following SPANISH-XT.SC file, using also macro coding (it works, but I need some help to solve the remaining problems):

Code: Select all

### IBM XT KEYBOARD QWERTY SPANISH

force set1
ifkeyboard any
ifselect any

# 83-key mappings

# On the XT, the ~/` key is located next to '/", and the key next to lshift is \|
# Remap this to match modern ISO layout
remapblock
layer 0
BACK_QUOTE BACKSLASH
BACKSLASH EUROPE_2
F10 FN1 # need to map the FN key into the base layer (0)
endblock

# Match the SPANISH XT's unusual legends
macroblock

# PROBLEM
# How to get [¡] when pressing  Shift+1 ?

# Shift+2 = ¿
macro 2 shift -ctrl -alt
press EQUAL
endmacro

# Alt+Ctrl+2 = @
macro 2 -shift ctrl alt
push_meta set_meta
press 2
pop_meta
endmacro

# PROBLEM
# Shift+3 = #
macro 3 shift -ctrl -alt
press 3 #  What I get is [•] (but I can get [#] withAlt+Ctrl+3)
endmacro

# Shift+6 = /
macro 6 shift -ctrl -alt
press 7
endmacro

# Shift+7 = &
macro 7 shift -ctrl -alt
press 6
endmacro

# Shift+8 = *
macro 8 shift -ctrl -alt
press RIGHT_BRACE
endmacro

# Shift+9 = (
macro 9 shift -ctrl -alt
press 8
endmacro

# Shift+0 = )
macro 0 shift -ctrl -alt
press 9
endmacro

# PROBLEM
# The key to the left of BACKSPACE should give [=] and  [+], but I stil get [¡] y [¿]
# macro EQUAL -shift -ctrl -alt
# press EQUAL
# endmacro

# PROBLEM
# I can't get [;] in lower case (but I do get [:] in the upper)
macro LEFT_BRACE -shift -ctrl -alt
press COMMA
endmacro

# Shift+; = :
macro LEFT_BRACE shift -ctrl -alt
press PERIOD
endmacro

# Shift+, = ”
macro COMMA shift -ctrl -alt
press 2
endmacro

# ‘
macro RIGHT_BRACE -shift -ctrl -alt
press LEFT_BRACE
endmacro

# ^
macro RIGHT_BRACE shift -ctrl -alt
press LEFT_BRACE
endmacro

# [
macro QUOTE -shift ctrl alt
push_meta set_meta
press LEFT_BRACE
pop_meta
endmacro

# Shift+. = !
macro PERIOD shift -ctrl -alt
press 1
endmacro

# Alt+Ctrl < = \
macro EUROPE_2 -shift ctrl alt
push_meta set_meta
press BACK_QUOTE
pop_meta
endmacro

# PrtSc macro 
macro PAD_ASTERIX shift
press PRINTSCREEN
endmacro

endblock
4) The main problem is that HID codes for the sustitutions (a) does not separate lower characters in each key from the UPPER ones, and (b) they are based on the US layout.

Problems remaining:

How to get that Shift+1 gives [¡] (Spanish opening exclamation)
Idem Shift+3 to get #
How to get that the = + key gives that, and not [¡] y [¿]
How to get that the [;] key gives that, and not [,] (but its capital is giving me [:] correctly …)

Any idea for this? Someone worked out other layouts than the US? - Ah, and a big thank you to Soarer (and Retrete).
Last edited by jorgej on 27 May 2014, 13:28, edited 1 time in total.

User avatar
Muirium
µ

27 May 2014, 12:47

Have you set a Spanish keyboard layout on your computer? For characters like ¡ you need a software layout with them available, first.

jorgej

27 May 2014, 12:55

Yes Mu, my keyboard is working fine with an Spanish layout in Windows XP (for example, I got the Ñ and the question opening mark (¿).

At this point (using macro remapping) I'm stuck with the problem with HID codes (for the substitutions (a) does not separate normal characters from the CAPITALS, and (b) they are based on the US layout).

User avatar
Muirium
µ

27 May 2014, 13:51

Where is ¡ on your computer's software layout? (A diagram would be good.) Because the idea is to use macros to simulate the same combinations when Shifted legends need moved.

Also, I don't think you need these opening lines:

Code: Select all

force set1
ifkeyboard any
ifselect any
The ifs are for handling multiple keyboards (like I do with my boxed converter).

jorgej

27 May 2014, 14:11

First of all, thanks for your help, MU.

1) Ok to the ifs, I'll get rid of them

2) My ¡ is in the uppercase of the 1 . Here you have my keyboard as I see it now:

Code: Select all

¡ ¿ # $ % / & * ( ) ? +
1 2 3 4 5 6 7 8 9 0 ' =

 Q W E R T Y U I O P : ^
 q w e r t y u i o p ; `

  A S D F G H J K L Ñ ¨ Ç
  a s d f g h j k l ñ ´ ç

 > Z X C V B N M " ! _
 < z x c v b n m , . -
Last edited by jorgej on 27 May 2014, 14:36, edited 1 time in total.

Post Reply

Return to “Workshop”