Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Anonymous
unregistriert
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
int KeyArray[] = {DIK_A, DIK_B, DIK_C, DIK_D, DIK_E, DIK_F, DIK_G, DIK_H, DIK_I, DIK_J, DIK_K, DIK_L, DIK_M, DIK_N, DIK_O, DIK_P, DIK_Q, DIK_R, DIK_S, DIK_T, DIK_U, DIK_V, DIK_W, DIK_X, DIK_Y, DIK_Z, 10000}; // hier muss man noch ergänzen char CharArray[] = {'a', 'b', 'c', 'd', 'e',............., 'z'}; BOOL bBigLetters = FALSE; if((Keys[DIK_LSHIFT] & 0x80) || ((Keys[DIK_RSHIFT] & 0x80))) bBigLetters = TRUE; int i = 0; char BStabe; while(KeyArray[i] != 10000) { if(Keys[KeyArray[i]] & 0x80) { if (bBigLetters) { strcat ( txt, CharArray[i]); } else { BStabe = (char)((int)CharArray[i]-32); strcat ( txt, &BStabe); } } } |
Anonymous
unregistriert
Zitat von »"cbee"«
Mich würde auch mal interessieren, was die Funktion KeyDown macht!
Ich könnte mir vorstellen, dass der Fehler durch das zweimalige Aufrufen der Funktion KeyDown zustande kommt.
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
//Taste gedrückt? int KeyDown( bool number_value ) { BYTE aKey[256]; HRESULT hr; //Daten abfragen hr = g_pKeyboard->GetDeviceState( sizeof( aKey ), &aKey ); for ( int a = 0; a < 256; a++ ) { if ( aKey[ a ] & 0x80 ) { if ( number_value == true ) { return a; } else if ( number_value == false ) { return static_cast <BYTE> ( a ); } }; }; return NULL; }; |
Anonymous
unregistriert
Zitat von »"Fabster"«
Na da haste doch den Fehler...
Du fragst 2x mal die States ab und brichst bei der ersten gedrückten Taste ab
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
char szKey[256]; // Abfragen der States GetKeyStateArray(&szKey); // Print Big letters if(szKey[DIK_LSHIFT] & 0x80 || szKey[DIK_RSHIFT] & 0x80) { ToBigLetters(szKey); } PrintLetters(szKey); |
Quellcode |
|
1 2 3 4 5 |
void KeyDown( BYTE aKey[256] ) { //Daten abfragen g_pKeyboard->GetDeviceState( sizeof( aKey ), &aKey ); }; |
Quellcode |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
bool lettersize = false; BYTE szKey[256]; if ( active == true ) { KeyDown( szKey ); if ( szKey[DIK_LSHIFT] & 0x80 || szKey[DIK_RSHIFT] & 0x80 ) { lettersize = true; }; for( int a; a < 256; a++ ) { if ( szKey[a] & 0x80 ) { strcat ( txt, diArray [ szKey[a] ] ); }; }; }; |
Anonymous
unregistriert
Zitat von »"Fabster"«
for( int a= 0; a < 256; a++ )
Quellcode |
|
1 2 3 4 5 |
*p_aKey[256] ) { //Daten abfragen g_pKeyboard->GetDeviceState( sizeof( p_aKey ), &p_aKey ); }; |
Quellcode |
|
1 |
KeyDown( &szKey ); |
Werbeanzeige