Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turings input.keydown
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
omni




PostPosted: Thu Jun 10, 2004 7:58 pm   Post subject: Turings input.keydown

Alright, I've gotten used to Turing's syntax a lot. It seems to me that in C++ in order to use functions, you have to include libraries. Maybe I'm blind, but I can't find the parameters needed for other functions.

Anyways

Currently, the only command I know that can receive input is cin .
But that command waits, is there a command that will recieve input, but also continue on with the loop. EX; Turings Input.KeyDown.
Sponsor
Sponsor
Sponsor
sponsor
McKenzie




PostPosted: Thu Jun 10, 2004 8:22 pm   Post subject: (No subject)

Assuming you are developing in a Windows environment you keep track of the status of all of the keys yourself (array of bool). Windows will generate a message for both keydown and keyup and tell you which key. In the DOS environment it is similar but you have to use some assembly to get it to work (well at least with the last DOS compiler I used)
omni




PostPosted: Thu Jun 10, 2004 8:50 pm   Post subject: (No subject)

ok, I understood part of what you said, I want to run in a Windows environment. So:

char key[256] // or was it 255 keys?

for (x=0,x =255,x++)
key[x]= ????

Is there an ord( function in C++?
Catalyst




PostPosted: Thu Jun 10, 2004 9:36 pm   Post subject: (No subject)

this would be ur message handler

code:

LRESULT CALLBACK WndProc (HWND hWnd, UINT message,WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_KEYDOWN:       
        keys[wParam] = true;                                   
        return 0;   
       
    case WM_KEYUP:       
        keys[wParam] = false;                                   
        return 0;                         
    default:
        return DefWindowProc (hWnd, message, wParam, lParam);
    }
wtd




PostPosted: Fri Jun 11, 2004 12:47 am   Post subject: (No subject)

There's no need for things like "ord" in C++. Characters are integers. Just really small integers. Feel free to cats from char to int.

code:
char ch = 'A';
int i = static_cast<int>(ch);
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: