Click here to Skip to main content
15,909,835 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Window Title. Pin
<k>Andreas Hoheisel24-Aug-01 10:18
<k>Andreas Hoheisel24-Aug-01 10:18 
Generalcstring heap error Pin
Amit Jain23-Aug-01 11:28
Amit Jain23-Aug-01 11:28 
GeneralRe: cstring heap error Pin
Chris Losinger23-Aug-01 11:33
professionalChris Losinger23-Aug-01 11:33 
GeneralRe: cstring heap error Pin
Amit Jain23-Aug-01 13:58
Amit Jain23-Aug-01 13:58 
GeneralRe: cstring heap error Pin
Bret Faller23-Aug-01 14:37
Bret Faller23-Aug-01 14:37 
GeneralRe: cstring heap error Pin
Amit Jain23-Aug-01 14:41
Amit Jain23-Aug-01 14:41 
GeneralRe: cstring heap error Pin
Amit Jain23-Aug-01 16:36
Amit Jain23-Aug-01 16:36 
QuestionDirect input 8? Pin
23-Aug-01 10:32
suss23-Aug-01 10:32 
I'm trying to use Direct Input 8 to navigate my SpaceShip. But I cant get DirectInput 8 to work. I read the whole Tutorial about Keyboard inputs that comes with the DirectX8 Docs, Heres the Code!

To Int the DirectInput Object i did:
-----------------------------------------------------
//Put this in WinMain()
hr = DirectInput8Create(hInst, DIRECTINPUT_VERSION,
IID_IDirectInput8, (void**)&g_lpDI, NULL);
if FAILED(hr)
{
// DirectInput not available; take appropriate action
}

LPDIRECTINPUTDEVICE8 g_lpDIDevice;
hr = g_lpDI->CreateDevice(GUID_SysKeyboard, &g_lpDIDevice, NULL);
if FAILED(hr) {
DI_Term();
return FALSE;
}

hr = g_lpDIDevice->SetDataFormat(&c_dfDIKeyboard);

if FAILED(hr) {
DI_Term();
return FALSE;
}

// Set the cooperative level
hr = g_lpDIDevice->SetCooperativeLevel(hWnd,
DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);

if FAILED(hr) {
DI_Term();
return FALSE;

if (g_lpDIDevice) g_lpDIDevice->Acquire();


}

no Compile Error!

A function to check if the key is pressed.
----------------------------------------
void WINAPI ProcessKBInput()
{
#define KEYDOWN(name, key) (name[key] & 0x80)

char buffer[256];
HRESULT hr;
PlayerX++;

hr = g_lpDIDevice->GetDeviceState(sizeof(buffer),(LPVOID)&buffer);
if FAILED(hr)
{
// If it failed, the device has probably been lost.
// Check for (hr == DIERR_INPUTLOST)
// and attempt to reacquire it here.
return;
}

// Turn the spaceship right or left
if (KEYDOWN(buffer, DIK_RIGHT))
{
PlayerX++;
}
}
No Compile error Smile | :)

But I need some way to execute the function, and in the Documents that MicroSoft released, there was no example Frown | :(

I tried to put ProcessKBInput();
in my ProcessNextFrame(); function.

no compile error, but my program crashes every time i ran it. Frown | :( No error message just turns black for a few seconds and then back to windows!

Hope any one get an ideer what my problem is.

Thanks

PS: Am not a super programmer so dont taunt me if its a easy thing to fix, okay? Roll eyes | :rolleyes:
AnswerRe: Direct input 8? Pin
Christian Graus23-Aug-01 12:28
protectorChristian Graus23-Aug-01 12:28 
GeneralRe: Direct input 8? Pin
24-Aug-01 0:23
suss24-Aug-01 0:23 
GeneralBYREF from VB to VC DLL HELP! Pin
23-Aug-01 7:45
suss23-Aug-01 7:45 
GeneralCDialog problem on Windows 2000 Pin
Craig Miller23-Aug-01 7:37
Craig Miller23-Aug-01 7:37 
GeneralRe: CDialog problem on Windows 2000 Pin
CodeGuy23-Aug-01 10:52
CodeGuy23-Aug-01 10:52 
GeneralRe: CDialog problem on Windows 2000 Pin
Craig Miller23-Aug-01 12:44
Craig Miller23-Aug-01 12:44 
GeneralCDialogBar buttons. Pin
John Uhlenbrock23-Aug-01 7:22
John Uhlenbrock23-Aug-01 7:22 
GeneralRe: CDialogBar buttons. Pin
Tomasz Sowinski23-Aug-01 7:24
Tomasz Sowinski23-Aug-01 7:24 
GeneralPATH AND REGION : HELP Pin
23-Aug-01 7:21
suss23-Aug-01 7:21 
GeneralRe: PATH AND REGION : HELP Pin
23-Aug-01 7:43
suss23-Aug-01 7:43 
GeneralRe: PATH AND REGION : HELP Pin
Christian Graus23-Aug-01 12:34
protectorChristian Graus23-Aug-01 12:34 
GeneralTracking the mouse Pin
Bret Faller23-Aug-01 7:12
Bret Faller23-Aug-01 7:12 
GeneralRe: Tracking the mouse Pin
CodeGuy23-Aug-01 11:00
CodeGuy23-Aug-01 11:00 
GeneralRe: Tracking the mouse Pin
Bret Faller23-Aug-01 11:25
Bret Faller23-Aug-01 11:25 
GeneralRe: Tracking the mouse Pin
CodeGuy23-Aug-01 11:31
CodeGuy23-Aug-01 11:31 
GeneralRe: Tracking the mouse Pin
Bret Faller23-Aug-01 11:33
Bret Faller23-Aug-01 11:33 
GeneralRe: Tracking the mouse Pin
Bret Faller23-Aug-01 11:46
Bret Faller23-Aug-01 11:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.