Home > Cannot Use > Discl_nonexclusive



Otherwise, the user cannot manipulate the menu or move and resize the window. hr = joystick->Acquire(); while (hr == DIERR_INPUTLOST) { hr = joystick->Acquire(); } // If we encounter a fatal error, return failure. I just wish I knew what caused it to allow me to use my controller for so long.Anyway the system specsWindows Vista Home Premium (Service Pack 2)Processor - AMD Turion(tm) X2 NOTE If these steps look unfamiliar, please read the previous keyboard section.

The #pragma comment code lines at the top of the program do that for you. #include #include #include #pragma comment(lib,"dinput8.lib") #pragma comment(lib,"dxguid.lib") using std::cout; using std::endl; LPDIRECTINPUT8 di; You can't interpret the data because you have no frame of reference, so that's what you need to clarify. The second part is almost identical for each device, so we can generalize it. It will repeat those keys when they are held for 300 milliseconds.


I looked on the MSDN pages and across the web, but I can't find any reason it would fail with that based on everything before it present and working. Read the mouse state with GetDeviceState(). Figure 9.5.

Here's all the code, including the creation of the main COM object and all necessary inclusion/defines: // this needs to come first #define INITGUID // includes #include // need this This is accomplished with the call IDirectInputDevice8::SetCooperativeLevel(). DIERR_NOTACQUIRED You have totally lost the device. Idirectsound somewhere in your main loop // read the joystick state if (FAILED(lpdijoy->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)joystate))) { /* error */ } Now that you have the joystick data, let's work with it.

There is no need to add in properties in Visual Studio to add the libraries dinput8.lib and dxguid.lib. Directsound Setcooperativelevel Acquire each device with a call to IDirectInputDevice8::Acquire(). It would take 10 more pages just to list all the various flags you can send! http://stackoverflow.com/questions/15669513/why-can-i-not-acquire-the-keyboard-with-directinput i suppose it would have a window right? ( sorry for my english ^0^) Here is my entire code , its come from ebook of Jim Adams ( Role Playing Game

In addition, if the player moves the mouse to the right, presses the right arrow on the keyboard, or moves the joystick to the right, you want all of these events Setdataformat The point is that each device is a collection of device objects or device things or input objects, depending on your terminology and what reference you use. Anyway, let's get serious now… let me take this bra off my head. :) The standard PC mouse has either two or three buttons and two axes of motion: X and However, other applications can still request non-exclusive access.

Directsound Setcooperativelevel

Plug it into the function and set the data format: // set data format if (FAILED(lpdijoy->SetDataFormat(&c_dfDIJoystick))) { /* error */ } As with the mouse, you need a specific type of https://www.shrinemaiden.org/forum/index.php?topic=12929.0 As long as there is a DirectInput driver for a device, DirectInput can talk to it, and hence you can too. Discl_nonexclusive Here's the main code: // obviously you need to do all the other steps... // defines #define MOUSE_LEFT_BUTTON 0 #define MOUSE_RIGHT_BUTTON 1 #define MOUSE_MIDDLE_BUTTON 2 // (most of the time) // Setcooperativelevel Error somewhere in your main loop // read the joystick state if (FAILED(lpdijoy->GetDeviceState(sizeof(DIJOYSTATE), (LPVOID)joystate))) { /* error */ } // move object // test for buttons if (mousestate.rgbButtons[JOYSTICK_FIRE_BUTTON] & 0x80) { /*

The aforementioned enumeration function will enumerate the first device and stop. The data returned from the call will be different for each device, but the call is exactly the same. You can tell because the GetDeviceState() function will return an error code. aaaaand now it gives the error again. Discl_nowinkey

If you wish to continue this conversation start a new topic. Figure 9.13 shows a screen shot of the program in action. For good measure, I also tried looping the Acquire() call until it succeeded and then played around with windows and the keyboard while it was running, but the program never successfully DEMO9 3.EXE in action.

Here it is: // acquire the mouse if (FAILED(lpdimouse->Acquire())) { /* error */ } Cool! Setcooperativelevel Directfb Table 9.8. Creating the Mouse Device Looks like bedrock, baby.

The Basic Device Types for DirectInput Value Description DIDEVTYPE_MOUSE A mouse or mouse-like device (such as a trackball).

The interface pointer to the main DirectInput object is defined in DINPUT.H as follows: LPDIRECTINPUT8 lpdi; // main directinput interface To create the main COM interface, use the standalone function DirectInput8Create(), Figure 9.6 shows this graphically. E_PENDING Data not yet available: chill. more device unacquire/releases, joystick, mouse etc. // now release main COM object if (lpdi) lpdi->Release(); This is the first time that I've talked about the function Unacquire(), but it is so

First, assume that you have retrieved the device data from all input devices with something like this: // keyboard if (FAILED(lpdikey->GetDeviceState(256, (LPVOID)keystate))) { /* error */ } // mouse if (FAILED(lpdimouse->GetDeviceState(sizeof(DIMOUSESTATE), Now I haven't been playing it all the time or anything but I'm getting pretty fed up with SA wanting to work or not pretty much. WARNING You should use the DIEDFL_ATTACHEDONLY value because it doesn't make sense to allow the player to connect to a device that isn't plugged into the computer. This is a good programming technique to remember, young Jedi.

I spent many hours looking at the circular data structures going, "What the heck?" (I didn't really say "What the heck?", but this is a PG-rated book.) Luckily, you only need if (FAILED(hr = joystick->SetDataFormat(&c_dfDIJoystick2))) { return hr; } // Set the cooperative level to let DInput know how this device should // interact with the system and with other DInput applications. In general, you must do the following: (Optional) Poll the device like a joystick. In any case, that's the basic idea of DirectInput.

That's all there is to it! This is accomplished with (get ready to throw up) a callback function and an enumeration. In that case you will have to reacquire the device, but we'll get to that in a moment. Note the C++ syntax hereā€”it simply means that this SetCooperativeLevel() is an interface method or function of IDirectInputDevice8.

The system returned: (22) Invalid argument The remote host or network may be down. And when you do query the record, you won't care whether it was the mouse, keyboard, or joystick that was the source of the input because all the input events will It's a good idea to do the bit test just to be safe. share|improve this answer answered Mar 27 '13 at 21:34 chris 38.1k678138 add a comment| up vote 0 down vote Have you tried DISCL_BACKGROUND instead of DISCL_FOREGROUND ?

Usually what happens is that the program can hook into the input device correctly, but setting the cooperative level will always return an invalid HRESULT regardless of flags used, which is TIP Remember, any method you can call with a IDIRECTINPUTDEVICE interface can be called with a IDIRECTINPUTDEVICE2 interface. The exclusive/non-exclusive setting controls whether your application has total control of the device and no other application can have access. I tried what was suggested but it didn't work.

Figure 9.14. First, you can only acquire the keyboard in non-exclusive mode because Windows itself always has to be able to get the Alt-key combinations. Im stucking with this line if(FAILED(pDIDevice->SetCooperativeLevel(hWnd,DISCL_NONEXCLUSIVE | DISCL_FOREGROUND))) { pDIDevice->Release(); return NULL; }This always return false so pDIDevice cant have the actual value . Repeat step 7 until done.

It's either on or off, but the range entries like lX, lY, and lZ may vary from one manufacturer to another. Note that you used the device constant GUID_SysMouse for this type. Here's the code: // unacquire joystick if (lpdijoy) lpdijoy->Unacquire(); // release the joystick if (lpdijoy) lpdijoy->Release(); WARNING Releasing before unacquiring can be devastating!

Back to Top