Key Up
Colin Ferris (399) 1818 posts |
Is there a way of getting the Wimp to return a Key Up event? |
Colin Ferris (399) 1818 posts |
Ref above:- Using the Down key -as a morse key – is there a way of getting the Wimp to return a Key Up event? |
Rick Murray (539) 13850 posts |
Why not just sit on INKEY until the key reports as not pressed? |
Ronald May (387) 407 posts |
Is there a way of getting the Wimp to return a Key Up event? I happened to be browsing the PRM’s this morning, and 1-158 (162 in !PDF) says Events 11 a key has been pressed or released. |
Vince M Hudd (116) 534 posts |
Yes, as I posted on csa.programmer on the 14th:
I should have added that never having needed to do that in a multitasking program, I don’t know if there are any restrictions or problems that might apply – but I would guess that as long as you have the input focus when the key is pressed, there should be no problems. (Edit: As long as the call to OS_Byte is done on each return from Wimp_Poll?) |
Rick Murray (539) 13850 posts |
There shouldn’t be a problem, as it is you that got notified of the keypress. The only thing to bear in mind is why you want to detect the key being released – so that if you lose input focus with the key still held down (unlikely, I know, but worth considering all the same!), you can either continue watching that key or you can treat losing input focus as a key release. You will need to either call Wimp_Poll or Wimp_PollIdle (with a fairly short timeout), and NOT mask out NULL events. Then when you get a NULL event, check and see if the key is still pressed. |
Colin Ferris (399) 1818 posts |
Thanks for the ideas. loop Also being able to poll the Serial Port – for a Morse Key wired in. |
Colin Ferris (399) 1818 posts |
Found a interesting Module ‘Call’ by Steve Drain which seems to send fixed pulses in the form of ‘Wimp messages’ to a Wimp task. Is there away of peeking the output of the SoundSystem? |
Steve Drain (222) 1620 posts |
I should point out that Call uses OS_CallAfter and OS_CallEvery. Justin Fletcher rapped me over the knuckles for doing this, saying that anyone writing a Wimp program should be able to use Wimp_PollIdle to implement this without adding to the operating system load. I agree that this is so, but the use of Call is simpler if you have not worked out your scheduling code yet. ;-) |
Colin Ferris (399) 1818 posts |
I was wondering in a module – if the up key event could be trapped and checked and to see if the down key was released – and another unused key number inserted into the stream. (are there any spare key numbers – that are not used?) So the Wimp could be made to react to a down key/up event. (Is there a low level key number to the key with a windows flag on it -third key in from the left bottom row – just before the Left Alt?) (Left Alt /Tab seems to be grabbed by Windows – and overrides the Emulator) |
Fred Graute (114) 645 posts |
You can sit on KeyV and monitor the key pressed and key released reason codes.
Unused key numbers are unlikely to be passed to the Wimp as is. You’d probably have to provide a replacement keyboard handler. A better way is for your Wimp task to use a pollword. When the module sees a key up it stores the key number in the pollword. Your Wimp task will then get a Pollword-nonzero event, it can then use the key number to act appropriately. An alternative would be to put a small Wimp task in the module. Have that watch a pollword and when nonzero send a Key Pressed event to your Wimp task with word at +24 set to 0 – character code (to indicate that it’s a key up). Of course things aren’t that simple, in both cases the module would need to know which tasks are interested in key up events and for which keys. |