Game Dev Forum
September 08, 2010, 06:53:28 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Octane Engine is now open source on Google Code with examples, and is being updated to the multi-threaded version. See the forum for details.
 
   Home   Help Media Login Register  
Beginning Game Programming, Third Edition
Pages: [1]   Go Down
  Print  
Author Topic: Acquiring Keyboard and Mouse  (Read 56 times)
0 Members and 1 Guest are viewing this topic.
ConnieStarr
Newbie


Karma: 0
Offline Offline

Posts: 4


« on: July 21, 2010, 07:47:49 AM »

This is actually from the 2nd edition book--chapter 10 Paddle Game. I'm getting E_ACCESSDENIED when trying to acquire both the keyboard and the mouse. I've done some research and most posts with regard to this problem say that I'm trying to acquire in the foreground, and I'm in the background, so they put the acquire in a loop until it CAN be acquired. This is OK, except when you are debugging in VS the application will ALWAYS be in the background when you step over a line a code, right? So, won't the loop always fail if you are debugging and trying to figure out why it fails? This is exasperating. Any ideas or tips, please?
Logged
J. Harbour
Administrator
Expert Member
*****

Karma: 43
Offline Offline

Posts: 1767


WWW
« Reply #1 on: July 21, 2010, 10:44:45 AM »

Try changing the cooperative mode to DISCL_NONEXCLUSIVE for both:


result = dimouse->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);


result = dikeyboard->SetCooperativeLevel(hwnd, DISCL_NONEXCLUSIVE | DISCL_FOREGROUND);
Logged
ConnieStarr
Newbie


Karma: 0
Offline Offline

Posts: 4


« Reply #2 on: July 22, 2010, 05:48:43 AM »

I already have NONEXCLUSIVE for the keyboard, it only seems to work at all with BACKGROUND. I also tried it for the mouse, and I got the same error. Any other suggestions?
Thanks!
Logged
J. Harbour
Administrator
Expert Member
*****

Karma: 43
Offline Offline

Posts: 1767


WWW
« Reply #3 on: July 22, 2010, 12:37:46 PM »

That's a strange problem that I've never experienced before. Could it be a permissions problem on your PC? Do you have admin rights?
Logged
ConnieStarr
Newbie


Karma: 0
Offline Offline

Posts: 4


« Reply #4 on: July 29, 2010, 07:18:27 AM »

Yes, I am an administrator. Of course, it is a VISTA computer (grrrr).
Logged
J. Harbour
Administrator
Expert Member
*****

Karma: 43
Offline Offline

Posts: 1767


WWW
« Reply #5 on: July 29, 2010, 12:51:39 PM »

I've run into this problem myself before, but just using DISCL_NONEXCLUSIVE worked. Try replacing DISCL_FOREGROUND with DISCL_BACKGROUND.
Logged
ConnieStarr
Newbie


Karma: 0
Offline Offline

Posts: 4


« Reply #6 on: July 30, 2010, 09:02:06 AM »

I've  messed with this project so many times, I don't know what I've done and haven't done. I've got both NON-EXCLUSIVE and BACKGROUND on both keyboard and mouse, and at least the program and keyboard work. The mouse, not so much. If I move the mouse, it get a tiny spurt of the paddle, but it doesn't follow. I'm using a USB mouse on my laptop, so that is probably the reason--the laptop only has a mousepad, and that does the same thing. I've tried all combinations of unplugging the USB mouse and using only the  mousepad, and turning the mousepad off, but it doesn't work. In addition, when I press the left mouse button, it escapes (quits the program). I think maybe these DirectX commands were only for older mice?
Logged
J. Harbour
Administrator
Expert Member
*****

Karma: 43
Offline Offline

Posts: 1767


WWW
« Reply #7 on: July 30, 2010, 02:26:41 PM »

No, its not due to the mouse itself. do you play other games on that laptop?
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!