How can I check if a key is down asynchronously? Like, instead of getchar(), which stops program execution and requires you to hit enter to input the variable.
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X
R- tv+ b++ DI+(+++) D- G e* h!"
Decode my geekcode!
Geekcode.com
Visit our web site:
Asylum Entertainment
Asynchronous Keys
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t XR- tv+ b++ DI+(+++) D- G e* h!"Decode my geekcode!Geekcode.com
Visit our web site:Asylum Entertainment
Visit our web site:Asylum Entertainment
#define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
That is the exact code for if a key is up or down... Don''t thank me, thank "The man," Andre LaMothe.
------------------------------
The Shining Knight
BlueScream Software
http://www15.brinkster.com/bluescream
#define KEYUP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)
That is the exact code for if a key is up or down... Don''t thank me, thank "The man," Andre LaMothe.
------------------------------
The Shining Knight
BlueScream Software
http://www15.brinkster.com/bluescream
I tried that and I don''t think it worked. This is a console app, I know that works for non-console apps, but I don''t think it was working when I tried it in my Win32 console app. Any other suggestions?
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X
R- tv+ b++ DI+(+++) D- G e* h!"
Decode my geekcode!
Geekcode.com
Visit our web site:
Asylum Entertainment
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X
R- tv+ b++ DI+(+++) D- G e* h!"
Decode my geekcode!
Geekcode.com
Visit our web site:
Asylum Entertainment
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t XR- tv+ b++ DI+(+++) D- G e* h!"Decode my geekcode!Geekcode.com
Visit our web site:Asylum Entertainment
Visit our web site:Asylum Entertainment
I figured it out, but in case someone else wanted the answer, here it is. You use kbhit() to determine if a key has been hit. Then you use getch() to get the char and act on it.
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X
R- tv+ b++ DI+(+++) D- G e* h!"
Decode my geekcode!
Geekcode.com
Visit our web site:
Asylum Entertainment
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t X
R- tv+ b++ DI+(+++) D- G e* h!"
Decode my geekcode!
Geekcode.com
Visit our web site:
Asylum Entertainment
My Geekcode: "GCS d s: a14 C++$ P+(++) L+ E-- W+++$ K- w++(+++) O---- M-- Y-- PGP- t XR- tv+ b++ DI+(+++) D- G e* h!"Decode my geekcode!Geekcode.com
Visit our web site:Asylum Entertainment
Visit our web site:Asylum Entertainment
...or you can write your own keyboard handler that will substitute the default in your program, when you press some key processor is interuppted on some irq, then processor multiplies this irq number with 8 and use that new number in special table(IDT), basically you write appropriate function then you substitute original(first save it), with your own,...you can substitute with some special function that will operate with IDT(check your compiler manual or sth)..i think this works just for console app, in true win32 app you cant do that(use DirectInput or GetAsyn...or WM keyboard functions), when you exit your program you then give back the original function that you have saved in the beginning...
have fun
have fun
^cyer: You''re talking about DOS programs. I think ziplux is talking about a Win32 Console App, which is a true Win32 App, only it runs in a DOS-like console window.
cu,
Prefect
---
Sanity is the trademark of a weak mind.
cu,
Prefect
---
Sanity is the trademark of a weak mind.
Widelands - laid back, free software strategy
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement