mouse grab - alex25 - 11-14-2008
quite a few times now i've had vdrift crash and then the mouse was just stuck and i couldn't use it any more (this is on linux). i assume vdrift grabbed the mouse and when it crashed it never released it. this is really annoying as i had to re-start the x-server to get the mouse working again.
on a completely different note, it would be nice if the screen shot functionality were to work again.
--alex--
- thelusiv - 11-14-2008
This was driving me crazy too and I bugged Joe about it, so he added this to the config file:
Code: [ control ]...
mousegrab = false
...
PS: omg I'm back! Sadly VDrift post-refactor is not working very well on 64-bit systems, so I won't be doing much. I'm still pretty busy with other stuff too. But I do exist!
- alex25 - 11-14-2008
thelusiv Wrote:This was driving me crazy too and I bugged Joe about it, so he added this to the config file:
Code: [ control ]...
mousegrab = false
...
thanks, that kind of works but what i would like is for vdrift to grab the mouse when running (so i don't end up with the mouse outside the vdrift window) but when it crashes with an exception to actually release the grab (i've been looking at the code but i can't figure out where it grabs the mouse in the first place).
btw, i am also running on a 64-bit machine and the refactor branch seems to work okay (i don't have a 32-bit machine any more so i can't tell what the differences are).
--alex--
- joevenzon - 11-16-2008
alex25 Wrote:what i would like is for vdrift to grab the mouse when running (so i don't end up with the mouse outside the vdrift window) but when it crashes with an exception to actually release the grab
That'd be great, but I haven't been able to figure it out so far. Let me know if you're able to get it working.
alex25 Wrote:i've been looking at the code but i can't figure out where it grabs the mouse in the first place
It happens in EVENTSYSTEM_SDL::SetMouseCursorVisibility().
Re: mouse grab - joevenzon - 11-16-2008
alex25 Wrote:it would be nice if the screen shot functionality were to work again.
I've got it in the issue tracker thing here:
http://code.google.com/p/vdrift/issues/detail?id=91
I think there's a way to star the item so you'll get an e-mail when there's progress. I'll see if I can get it fixed pretty soon.
- alex25 - 11-16-2008
joevenzon Wrote:alex25 Wrote:what i would like is for vdrift to grab the mouse when running (so i don't end up with the mouse outside the vdrift window) but when it crashes with an exception to actually release the grab
That'd be great, but I haven't been able to figure it out so far. Let me know if you're able to get it working.
this is a quick and dirty hack, but it works for me. basically i am adding a signal handler so when abort is called vdrift releases the mouse first before crashing:
Code: --- game.cpp (revision 2219)
+++ game.cpp (working copy)
@@ -32,6 +32,15 @@
#include <algorithm>
using std::sort;
+#include <signal>
+
+void release_mouse(int a)
+{
+// eventsystem.SetMouseCursorVisibility(true);
+ std::cout << "should be releasing mouse" << endl;
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
///start the game with the given arguments
void GAME::Start(list <string> & args)
{
@@ -41,6 +50,10 @@
}
info_output << "Starting VDrift: " << VERSION << ", " << REVISION << end
l;
+// release the mouse when we abort
+ struct sigaction act;
+ act.sa_handler = release_mouse;
+ sigaction(SIGABRT,&act, NULL);
InitializeCoreSubsystems();
there must be a better way of doing this, this is just a proof of concept.
actually this code should go in main if implemented in this form.
--alex--
- alex25 - 11-16-2008
alex25 Wrote:actually this code should go in main if implemented in this form.
something like this:
Code: --- main.cpp (revision 2219)
+++ main.cpp (working copy)
@@ -1,5 +1,7 @@
#include "game.h"
+#include <fenv>
+
#include <list>
using std::list;
@@ -12,9 +14,26 @@
#include "logging.h"
#include "pathmanager.h"
+#include <signal>
+void release_mouse(int a)
+{
+// eventsystem.SetMouseCursorVisibility(true);
+ std::cout << "should be releasing the mouse" << endl;
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
+
int main (int argc, char * argv[])
{
+// catch fpe exceptions.
+// feenableexcept(FE_INVALID|FE_DIVBYZERO|FE_OVERFLOW);
+// feenableexcept(FE_ALL_EXCEPT);
+// release the mouse when we abort
+ struct sigaction act;
+ act.sa_handler = release_mouse;
+ sigaction(SIGABRT,&act, NULL);
+
list <string> args(argv, argv + argc);
//find the path of the log file
ignore the part about fpe exceptions, i guess (and the debug statement).
--alex--
- joevenzon - 11-16-2008
Cool! I take it this is linux only? I wonder if it'll work on OSX.
By the way, screenshots should be working again in R2220.
- alex25 - 11-16-2008
joevenzon Wrote:Cool! I take it this is linux only? I wonder if it'll work on OSX.
signal handlers should work on bsd as well but i guess somebody needs to check it out.
--alex--
- joevenzon - 11-16-2008
Okay, this code is in R2222. I had to add .h to the includes for them to be picked up on my system.
|