Beyond getch()
Does anyone know of a "getch()" that returns the KEYCODE (not the ASCII of the character the key displays) like JAVA''s "e.getKeyCode" or in BASIC "is it scancode()?". Anyway I need it for implementing key controls from the arrow keys so if you could help that would be cool .
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I''m not sure, but aren''t the keycodes the same as the ascii codes, except for letters, where they are always the value of an uppercase. Someone correct me if I''m wrong...
Those who do not love don''t live.
[MSDN|Google|Bloodshed|My lousy page|email.me]
Those who do not love don''t live.
[MSDN|Google|Bloodshed|My lousy page|email.me]
They are definetely different. I wrote a simple C++ program to return the value of getch() and it was different to the values returned by my java test program for "e.getKeyCode()". Also in getch() all the arrow keys return the same value (someone correct ME if my program is corrupt, the JAVA one is definetely correct as I checked it with the keyCode example on www.java.sun.com). Also I've just started the project I need this info for and yet another question has arisen!
How do you get the following to work:
main.cpp:
classes.cpp:
members.cpp
include.h:
The problem is I can't find a way to let main.cpp, class.cpp and members.cpp communicate with each other. If I just include the members in "TheHeader....Write.h" I get about 30 errors. I need to know how to write "TheHeaderICantWorkOutHowToWrite.h".
Thanks
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
[edited by - ilthigore on August 17, 2002 1:44:26 PM]
How do you get the following to work:
main.cpp:
#include "include.h"main(){ exampleClass example(...); . . //Class members are called. . return 0;}
classes.cpp:
class exampleClass{public: exampleClass(int); exampleClass(exampleClass&); void member1(); void member2(); . . //The rest of the class. .};
members.cpp
exampleClass::exampleClass(int a){A=a;}exampleClass::exampleClass(exampleClass&c){A=c.A;)void exampleClass::member1(){ . .//member 1 .}void exampleClass::member2(){ . .//member2 .}....//other members
include.h:
#ifndef EXAMPLE_INCLUDE_H#define EXAMPLE_INCLUDE_H#include <iostream>using namespace std#include <stdlib.h>#include <conio.h>..//headers.#include "TheHeaderICantWorkOutHowToWrite.h"#endif
The problem is I can't find a way to let main.cpp, class.cpp and members.cpp communicate with each other. If I just include the members in "TheHeader....Write.h" I get about 30 errors. I need to know how to write "TheHeaderICantWorkOutHowToWrite.h".
Thanks
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
And the Dark Lord shall DESTROY Middle Earth
And Ilthigore will save you
[edited by - ilthigore on August 17, 2002 1:44:26 PM]
if you include windows.h you can use GetAsyncKeyState().. it returns if the specified key has been pressed.
i.e.
if(GetAsyncKeyState(VK_ESCAPE))
i.e.
if(GetAsyncKeyState(VK_ESCAPE))
I searched windows.h for the VK_* definitions and I can''t find them although VK_LEFT doesn''t work. If someone could print a list of definitions for:
That would be great. Also I notice the parameter type is int. Can you just use scan/key codes here to make life easier or not?
(note: If you answer the last question don''t bother with the definitions as I can use scancodes/keycodes fine)
Thanks for the help so far!
- Left
- Right
- Up
- Down
- Control
- Space
- Return/Enter
- Alt
- Shift
That would be great. Also I notice the parameter type is int. Can you just use scan/key codes here to make life easier or not?
(note: If you answer the last question don''t bother with the definitions as I can use scancodes/keycodes fine)
Thanks for the help so far!
And the Dark Lord shall DESTROY Middle Earth
But Ilthigore will save you
All virtual key code definitions are declared in winuser.h. And ASCII codes for letters and numbers are the same, if you dont believe me heres a snippet from winuser.h :
/* * VK_0 - VK_9 are the same as ASCII ''0'' - ''9'' (0x30 - 0x39) * 0x40 : unassigned * VK_A - VK_Z are the same as ASCII ''A'' - ''Z'' (0x41 - 0x5A) */
From MSDN: "When reading a function key or an arrow key, getch must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code."
Does that answer your question on the arrowkeys?
Does that answer your question on the arrowkeys?
quote:Original post by Ilthigore
They are definetely different. I wrote a simple C++ program to return the value of getch() and it was different to the values returned by my java test program for "e.getKeyCode()". Also in getch() all the arrow keys return the same value (someone correct ME if my program is corrupt, the JAVA one is definetely correct as I checked it with the keyCode example on www.java.sun.com). Also I''ve just started the project I need this info for and yet another question has arisen!
That''s because Java uses 16bit characters (UNICODE), C++ uses 6bit characters (ASCII).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement