I have following problem when I control camera through EDSDK: if camera fails to shoot after EdsSendCommand, for example if autofocus fails, then it will return "device is busy" error for any subsequent commands. Is there any way to bring camera back to working state except for physically turning it off and on again?
Try to send the camera button code to release busy event
My camera init
Private WithEvents MainCamera As EOSDigital.API.Camera
Cancel Busy
MainCamera.SendCommand(CameraCommand.PressShutterButton, 3)
MainCamera.SendCommand(CameraCommand.PressShutterButton, 0)
Related
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.
Here is a part of SDL2 code
SDL main function
int main(int argc,char *argv[])
{
...
...
bool quit=false;
SDL_Event e;
while(!quit) ///First while (say)
{
while(SDL_PollEvent(&e)) ///Second while (say)
{
if(e.type==SDL_QUIT)
{
quit=true;
}
handleEvent(e) ;///Function for executing certain event
}
...
SDL_RenderPresent((SDL_Renderer)renderer);
}
}
My question is,what does this SDL_PollEvent() actually do ,and suppose an event occur does the execution goes out of the second while() and call the SDL_RenderPresent() or it waits for all the events to take poll and then SDL_RenderPresent() is called , i am totally confused ?
The above is a very common single thread event loop:
Basically the application is constantly inside the outer while loop. To get the smoothest user experience we try to keep this loop under 17ms (for a 60 frames a sec rate)
Every 'frame' starts by responding to all the events that are waiting in the queue (the inner while):
while(SDL_PollEvent(&e)) ///Second while (say)
{
if(e.type==SDL_QUIT)
{
quit=true;
}
handleEvent(e) ;///Function for executing certain event
}
Events are notifications from the operating system that something happened. It might be that the window is closing SDL_QUIT or that the mouse was moved.
You must respond to these events for the application to be responsive. Usually the response is to change the state of the application.
For example we might see a left-mouse is down event we might find what is "under" the mouse button and indicate that it is now selected. This is normally just finding the object and calling a function that will change its state. All that changes is the boolean value that indicates the object is now selected.
Maybe moving the mouse needs to change the point of view of the next frame so we will update the vector that stores the direction we are looking at. So we update the vector in memory.
You may have long stretches where the event queue is empty and the application does not have any events to handle. And there might be flurries of activity (for instance the user moving the mouse) where you will get lots of events to respond to.
SDL_PollEvent will not "wait" for events. If there is an event in the queue you will get the information. If there is no event it will return false.
Handling events should be done quickly (remember we have to be finished in 17ms) don't worry it is quite a lot of time on a PC.
Once you are done with all the events and out of the inner loop you are ready to move on to updating the world and rendering.
At this point you will normally do stuff like AI. Calling physics engine. For instance you might iterate over the objects and change their position based on their velocity.
The next step is to actually do the drawing.
SDL_RenderClear(renderer);
...
SDL_RenderPresent((SDL_Renderer)renderer);
The first call will clear the screen. You then go and based on the state of different objects do the rendering. For instance maybe because we changed the object state to selected we will now draw a glowing border around it.
Your final call is for SDL_RenderPresent(renderer) to present the new screen to the user
If you are using Vsync (quite common) then this final call will hide a small wait time to synch the screen update with the graphics card capabilities. This will produce a smoother graphics. Assuming a 60Hz refresh rate (60 frames per second) and assuming you are running under 16.6 ms in your frame rendering logic the app will wait the remaining time.
Now the application is ready to go back to the start of the loop and check if there are any events in SDL_PollEvent. Since the entire loop typically only takes a few milliseconds the application will always feel responsive.
I have a scene that is modified when mouse left button is clicked.
My problem is: this modified scene was supposed to appear with a sound, but the scene waits the sounds to finish before it renders itself.
I'm using this function:
do {
alGetSourcei(source, AL_SOURCE_STATE, &state);
} while (state == AL_PLAYING);
Of course, this function tells the program to wait. But what alternative could I use? if I remove this function, the sound isnt played
I even tried to create a function sound(), that is called after glutPostRedisplay but it still waits the sound complete to render
I think your problem, that the sounds stop, is somewhere else. alGetSourcei is not required to keep the sound playing.
Anyway you can't do that in a while loop because it will block the update of the windows messages and OpenGL and will prevent the scene from redrawing.
To play it you just need to call alSourcePlay, after this you could check each frame if the source is still playing ( if you need to do this for some reason ).
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.
i want to pause my game i used the following code but its not pausing when we return from any interrupt its shows the main menu screen.its starting from 1st again.
It is expected that if user gives any sort of interrupt during action phase of the game then after returning back from the interrupt game should pause at the exact location where interrupt occurred displaying pause screen with required options.
CCDirector.sharedDirector().pause();
I got this issue solved. The problem is with the screen orientation change. The game is in landscape mode, when the device sleeps the screen orientation automatically changes to portrait mode. This results in restarting the activity.
Adding android:configChanges="keyboard|keyboardHidden|orientation" to the activity in the manifest solves the issue.