I am converting a game from the 1997 source and updating it to HD. It's all going well except for one niggling element. When I launch the game, the mouse does not have focus on the app. (it shows a blue circle spinning around). When I hit CTRL ALT DEL (to bring up the task manager menu) and then hit ESC. The mouse is now focused on the game and all it well! It's been a while since I've programmed windows but this seems bizarre. If anyone has any ideas on how to get my game to get mouse focus out of the gate I would much appreciate it! :)
Thanks
Related
I tried to set up a VM running on centos7, my host run on windows 10. After I add the guest additions, my mouse still doesn't work properly : if you look at the image (https://imgur.com/a/zKeMRvT), the mouse work properly below the red line, and won't work on the rest of the screen. I found nothing related to that problem on Internet, so I'd be glad if you had any idea or advice.
You have to press the [CTRL] key on the right hand side of the keyboard.
Then the mouse gets release back to you.
I'm working on a Qt class project. We're supposed to develop an application like Microsoft Paint. Now I don't know how to enlarge a selected part of an image. Actually I don't even know how to "select" an area. You know, just like that on the desktop of Windows, you press the left button of the mouse and than move it, a dashed-line rectangle will show up. I hope to move or zoom in/out this particular area.
Any help will be appreciated, thanks!
It could be done by using mouse events. Here's example that might be useful to you:https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html
I am trying to record my in-game mouse movement so I can play it back. The game is Call of Duty 4, although that isn't relevant to this question. What is relevant is that most First Person Shooter games re-center the mouse cursor when you move it, so that you never hit any borders. I can't find anything about this online after searching for a while. I am currently using a mouse hook (WH_MOUSE) in order to keep track of the mouse movements (WM_MOUSEMOVE). When I list these messages, I can see that the cursor is pulled back to screenResolutionX / 2, screenResolutionY / 2 (the center of the screen).
My first attempt at figuring this out was to ignore the messages if they are equal to the center of the screen, so that when I play back these mouse movements, the re-centering is ignored. I assumed this would solve the problem, but now when I play back the mouse movements the mouse goes too far (way off from what I recorded). When I do the same recording/playing back in the main menu of the game (where the cursor isn't re-centered), the playback is incredibly accurate. My question is: what can I do to record mouse movements in the game accurately, given that the game re-centers my cursor?
Thanks in advance.
Edit: let me clarify what I'm asking. I want to only record actual user mouse input, not the game re-centering the mouse cursor.
In order to intercept those mouse messages you'd have to make a filter driver or a hook. Here's a nice article (with code) on the subject:
http://www.oblita.com/interception.html
That article is based on this Windows API: SetWindowsHookEx and shold be a good starting point for you.
Have you considered Low Level Mouse Hook? It intercepts mouse messages earlier than just mouse hook.
I am working on a Qt application which resembles hex editor for Mac.
(picture from Google)
It has a very large portion of data to scroll vertically(upward and downward) because it shows all large files data in hex format.
In my application, I'd like to add two finger smooth scrolling in both direction: up and down like that in Macbook Air two finger scrolling.
It work properly with mouse wheel but not with trackpad two finger move scrolling.
If someone has a solution, please help me out. Thanks in advance.
The scroller allows for gestures like click and drag to do kinetic scrolling.
http://qt-project.org/doc/qt-5/qscroller.html#details
Note on this page:
QScroller::TouchGesture 0
The gesture recognizer will only trigger on touch events. Specifically it will react on single touch points when using a touch screen and dual touch points when using a touchpad.
So then the example they give would turn into this for you:
QWidget *w = ...;
QScroller::grabGesture(w, QScroller::TouchGesture);
There is more on doing new things with touch screens and touch pads by handling the QTouchEvent:
http://qt-project.org/doc/qt-5/qtouchevent.html#details
Hope that helps.
I am trying to send mouse events to a (I think SDL/OpenGL) game that doesn't support a gamepad. I know I could just use one of the many Gamepad to Keyboard/Mouse applications available, but I thought it would be fun to write my own. The following code works fine except when the game is running:
// point is a CGPoint that is set earlier on...
CGEventRef event = CGEventCreateMouseEvent(NULL,kCGEventMouseMoved , point, 0);
CGEventSetType(event, kCGEventMouseMoved);// apparently there is a apple bug that requires this...
CGEventPost(kCGHIDEventTap, event);
CFRelease(event);
With this, I can move the cursor on my desktop, and even in the games menu's, however the only time the game gets it while in the actual game is when I move my physical mouse. Sending keyboard events works fine in the game, so I don't know what the problem is
I found out what the problem was, I had to use:
CGEventSetIntegerValueField(event, kCGMouseEventDeltaX, dX);
CGEventSetIntegerValueField(event, kCGMouseEventDeltaY, dY);
to set the relative coordinates of the mouse move. I think this is because the game was warping the mouse to the center of the game window, and my application wasn't getting the mouse move events from that.