Author Topic: A GetKey that doesn't wait?  (Read 9561 times)

0 Members and 1 Guest are viewing this topic.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
A GetKey that doesn't wait?
« on: November 01, 2010, 11:43:36 pm »
Is there such a thing? I know there are things like GetCSC and direct port input, but I'm wondering if GetKey has a non-waiting equivalent that also uses the A/keyExtend output format.

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #1 on: November 01, 2010, 11:49:00 pm »
No.  I'm not sure how you would want such a routine to work, but no, it does not exist.  If you have stuff to do in the background while GetKey is running, you can use a cursor hook, GetKey hook, or silent link hook, as appropriate.

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #2 on: November 01, 2010, 11:57:23 pm »
Dang, I have no idea how to use hooks... Anyone know of a good guide explaining how hooks work? Or anyone want to post a whirlwind tour of hooks?

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #3 on: November 02, 2010, 12:40:54 am »
It's... a bit complicated.  Maybe it would help if you could explain what exactly you're trying to do.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #4 on: November 02, 2010, 01:01:32 am »
Isn't there a BCALL somewhere that does exactly that? ???

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #5 on: November 02, 2010, 01:05:38 am »
Uh... no.  Not what he was asking.  There's GetCSC, which he mentioned, and GetK (BASIC's getKey), which he didn't.  Both of those routines return raw scancodes; they don't handle the shift keys, contrast control, APD, 2nd+Off, TIKB, or silent link.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #6 on: November 02, 2010, 01:17:08 am »
ahhh gotcha, i only dabble in Asm so i wasn't 100% sure ^^ thanks for the clarification!

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #7 on: November 02, 2010, 10:24:10 am »
It's... a bit complicated.  Maybe it would help if you could explain what exactly you're trying to do.

I just want to make a program that can work while waiting for key inputs and accepts key inputs in the A/keyExtend format.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: A GetKey that doesn't wait?
« Reply #8 on: November 02, 2010, 11:38:17 am »
Dang, I have no idea how to use hooks... Anyone know of a good guide explaining how hooks work? Or anyone want to post a whirlwind tour of hooks?

thepenguin77 gave me a quick guide earlier: http://ourl.ca/7566/131643




Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #9 on: November 02, 2010, 10:21:03 pm »
I just want to make a program that can work while waiting for key inputs and accepts key inputs in the A/keyExtend format.

You said that already.  The question is why.  For example, "I'm writing a game in which the user needs to type the answers to trivia questions in l33tspeak, while simultaneously using the arrow keys to dodge attacks from a giant lava monster."  Or "I'm writing a text editor where all the O's are actually eyes, that follow the cursor around the screen and blink at random intervals."

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #10 on: November 02, 2010, 10:32:17 pm »
More like the second. The background processes won't be very intensive, maybe static/slightly dynamic grayscale displaying at most.
« Last Edit: November 02, 2010, 10:34:31 pm by Runer112 »

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #11 on: November 02, 2010, 10:32:31 pm »
Both of those need to be made right now

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #12 on: November 02, 2010, 10:53:43 pm »
For grayscale, you might be able to make it work with a GetKey hook, but for accurate timing I'd think you'd want to use an IM 2 handler.  To make grayscale look good, you generally want to have consistent timing regardless of whatever else is going on in your program, and regardless of whether the user is pressing keys.  I didn't think of mentioning IM 2 handlers before, but that might be the way to go.

On the other hand, a GetKey hook requires less memory to set up.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: A GetKey that doesn't wait?
« Reply #13 on: November 02, 2010, 11:08:46 pm »
If I remember correctly, if you press the ON key during _getKey a flag is set which causes exactly what you want. If you set this flag manually, it might just work.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Runer112

  • Moderator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: A GetKey that doesn't wait?
« Reply #14 on: November 02, 2010, 11:11:58 pm »
Yeah, I might not bother with hooks or anything and just set up the program to run in an interrupt with a GetKeyRetOff running outside the interrupt.