Redirect/reprogram a keypress?

Anything QL Software or Programming Related.
Post Reply
robsoft
ROM Dongle
Posts: 42
Joined: Wed Jun 15, 2016 5:14 pm

Redirect/reprogram a keypress?

Post by robsoft »

Here's the first of 2 questions tonight (sorry) - I suspect they will both be shot down instantly but if you don't ask, you never know... :-)

My physical QL has a replacement keyboard membrane, but for one reason or another the operation of Ctrl+left cursor together is very hit and miss. You have to really hold Ctrl down for it to register. I could (and at some point, probably will) open it up and look to see if the membrane could be fractionally repositioned etc, but right now opening it up and messing with the membrane feels like asking for trouble...!

So deleting characters is a bit of a pain. Is it theoretically possible to install some kind of machine-code subroutine that would intercept when 'caps lock' was pressed and reinterpret that as pressing 'delete'? I was boggled when I first got a real QL a few weeks ago and realised it had no dedicated delete key, and I think it's kind of niggled me ever since. I think, even if I could get my Ctrl+left arrow combination working well, it would still be nice to run a patch that could remap a key to do 'delete' duty :-)

Anyone ever tried anything like this - is it remotely a starter? I know nothing about the innards yet, although I've started accumulating documentation ready for a play....


RWAP
RWAP Master
Posts: 2834
Joined: Sun Nov 28, 2010 4:51 pm
Location: Stone, United Kingdom
Contact:

Re: Redirect/reprogram a keypress?

Post by RWAP »

It is probably a physical issue - most likely the screw on the backing plate nearest those keys is not tight enough (or you have managed to get a small kink in the keyboard membrane - ie not positioned it flat over the locating pegs).

It could also be the rubber bubble mat which sits under the keys which may have a hole or similar in the mat (I do have lots of these spare!)

The other option could even be something like crumbs under the keys!

You need to identify whether the keys work ok on their own (remember you could use the left cursor and then CTRL right to delete the character to the right). If they work on their own but not together, then I am stuck!


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Redirect/reprogram a keypress?

Post by tofro »

We're not shooting anyone for asking a question (I'd rather think of tar and feathers :) )

What you want is partially possible, although not with the CAPS LOCK key - That key is like the other modifiers not generating a real key press, but is rather evaluated by the IPC and not sent to the QL.

With other keys that really generate a symbol, you could download or write a program that POKEs the symbol for DELETE into the keyboard buffer. Unfortunately, there's no other easy one to choose from, so I'd rather bite it and fix the key mechanically.

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
robsoft
ROM Dongle
Posts: 42
Joined: Wed Jun 15, 2016 5:14 pm

Re: Redirect/reprogram a keypress?

Post by robsoft »

Yeah, you're probably both right. I just hate the thought of opening it up again!


User avatar
dilwyn
Mr QL
Posts: 2753
Joined: Wed Dec 01, 2010 10:39 pm

Re: Redirect/reprogram a keypress?

Post by dilwyn »

robsoft wrote: My physical QL has a replacement keyboard membrane, but for one reason or another the operation of Ctrl+left cursor together is very hit and miss. You have to really hold Ctrl down for it to register.
First thing - isolate if it's the CTRL key or LEFT arrow key at fault, probably easiest way is to use a KEYROW loop to check for keypresses (KEYROW can detect CTRL, INKEY$ can't). I can't test this as I don't have a QL set up at th emoment and KEYROW on QPC2 doesn't detect CTRL (it does detect SHIFT and ALT)

Code: Select all

100 REPeat loop
110 PRINT KEYROW(7)
120 END REPeat loop
And to check the left arrow key:

Code: Select all

100 REPeat loop
110 PRINT KEYROW(1)
120 END REPeat loop
Both should print a value of 2 when the key is pressed.

Now, as to reprogramming a key combination, use the ALTKEY command if you have Toolkit 2 active on your system. For example, if you find that the CTRL key is not working, you could reprogram some little used keys to become equivalent to CTLR LEFT, e.g. this will make ALT F5 behave like CTRL LEFT

ALTKEY CHR$(248),CHR$(194)

Not all keys (e.g. CAPS LOCK, TAB, Cursor arrow keys) can be reprogrammed like this, and of course ALT F5 is a lot less convenient than CTRL LEFT.

For single keypresses you could reprogram F1 to F5 but these are commonly used in programs like Quill.


robsoft
ROM Dongle
Posts: 42
Joined: Wed Jun 15, 2016 5:14 pm

Re: Redirect/reprogram a keypress?

Post by robsoft »

Thanks Dilwyn, that's great, I appreciate your time keying all that in :-)
dilwyn wrote: For single keypresses you could reprogram F1 to F5 but these are commonly used in programs like Quill.
As a matter of interest, how would I program a function key? I thought there might be an obvious SuperBASIC way of doing that, but either it's so obvious I'm over complicating it, or my Google skills have let me down today.


User avatar
dilwyn
Mr QL
Posts: 2753
Joined: Wed Dec 01, 2010 10:39 pm

Re: Redirect/reprogram a keypress?

Post by dilwyn »

robsoft wrote:Thanks Dilwyn, that's great, I appreciate your time keying all that in :-)
dilwyn wrote: For single keypresses you could reprogram F1 to F5 but these are commonly used in programs like Quill.
As a matter of interest, how would I program a function key? I thought there might be an obvious SuperBASIC way of doing that, but either it's so obvious I'm over complicating it, or my Google skills have let me down today.
Strictly speaking you don't (at least not in the same way as you would with a BBC micro, for example). You can use an ALTKEY definition to provide text which is replaced for the function key press, by using key codes 232,236, 240, 244, 248 for F1 to F5 respectively (add 2 to each code for SHIFT F1 etc to get up to 5 extra ones). For this to work, you press ALT F1 insteadof F1 (this is why I say they are not programmable as such).

ALTKEY CHR$(232),"Hello"
That would just create text Hello when you press ALT F1. You can put in all sorts of keycodes too, for example a newline with CHR$(10):

ALTKEY CHR$(236),"Hello"&CHR$(10)&"There"
Alt-F1 now prints

Hello
There

You could generate your address for wordprocessing on ALT SHIFT F1 (SHIFT F1 is like F6 in a keyboard which has more than 5 function keys, as on a PC emulator) using something like this:

ALTKEY CHR$(234),"Robsoft"&CHR$(10)&"The Street"&CHR$(10)&"Anytown"

so that you could insert your address in a Quill document by just pressing ALT SHIFT F1.

I vaguely remember a machine code routine from Sinclair back in the very early days which I think allowed direct programming of function keys, I couldn't find it just then, but if I do I'll post it here for you later. The advantage of that is a that function keys become a single key press, the disadvantage being you lose the normal use of function keys (e.g. F1 for Help in Quill).


Ralf R.

Re: Redirect/reprogram a keypress?

Post by Ralf R. »

dilwyn wrote:I vaguely remember a machine code routine from Sinclair back in the very early days which I think allowed direct programming of function keys, I couldn't find it just then, but if I do I'll post it here for you later. The advantage of that is a that function keys become a single key press, the disadvantage being you lose the normal use of function keys (e.g. F1 for Help in Quill).
If this is Sinclair based (so a bit old), I think it would work like TK2 Altkey, say a polling task rather than a job. That would of course overwrite any job that polls the queue. I am sure it was written by TT ;)

Nevertheless, it would be interesting to see, as interesting as the SPK was ;) .


User avatar
dilwyn
Mr QL
Posts: 2753
Joined: Wed Dec 01, 2010 10:39 pm

Re: Redirect/reprogram a keypress?

Post by dilwyn »

Ralf R. wrote:
dilwyn wrote:I vaguely remember a machine code routine from Sinclair back in the very early days which I think allowed direct programming of function keys, I couldn't find it just then, but if I do I'll post it here for you later. The advantage of that is a that function keys become a single key press, the disadvantage being you lose the normal use of function keys (e.g. F1 for Help in Quill).
If this is Sinclair based (so a bit old), I think it would work like TK2 Altkey, say a polling task rather than a job. That would of course overwrite any job that polls the queue. I am sure it was written by TT ;)

Nevertheless, it would be interesting to see, as interesting as the SPK was ;) .
My mistake,it was a Sinclair routine for user defined graphics (redefining fonts), not user defined keys - the routine is at http://www.dilwyn.me.uk/fonts/udg.zip.


User avatar
mk79
QL Wafer Drive
Posts: 1349
Joined: Sun Feb 02, 2014 10:54 am
Location: Esslingen/Germany
Contact:

Re: Redirect/reprogram a keypress?

Post by mk79 »

robsoft wrote:So deleting characters is a bit of a pain. Is it theoretically possible to install some kind of machine-code subroutine that would intercept when 'caps lock' was pressed and reinterpret that as pressing 'delete'?
Actually that is probably not that difficult, at least for CapsLock. You can register a routine that is called on CapsLock by writing its address to sys_csub. The routine would have to post the delete character to the current keyboard queue and maybe reset the capslock status in case it's already toggled, I'm not sure.

Marcel


Post Reply