SDL: can't initialize mouse

Trying to run an application using the SDL library on a development board I
have. I’ve made the application, but on running it I get the error can’t
initialize mouse.

Any idea why this is?

Also, could it be because I tried to link it with the library statically
(since I read somewhere that one cannot link statically with the free
version, only commercial versions)?

Thanks in advance

-Mike

2009/4/9 Mike Mike

Trying to run an application using the SDL library on a development board I
have. I’ve made the application, but on running it I get the error can’t
initialize mouse.

Any idea why this is?

Also, could it be because I tried to link it with the library statically
(since I read somewhere that one cannot link statically with the free
version, only commercial versions)?

Thanks in advance

-Mike


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Hello,

What mice do you have? Are they usb mice? How many mice are there? What OS
are you trying to run your application on? Is your computer a laptop? That’s
just a bunch of helpful information, that’ll help me solve the problem.

Best wishes–
– Szymon “Wilku” Wilczek
"The dreamer dies, but never dies the dream, Though Death shall call the
whirlwind to his aid, Enlist men’s passions, trick their hearts with hate,
Still shall the Vision live! Say nevermore, That dreams are fragile things?

Hi Szymon,

  • The mouse I have is a ps2 mouse.

  • I’m making use of 1 mouse 1 keyboard (both ps2)

  • The OS I’ making use of is Linux (a distro called snapgear linux, made
    to work on embedded systems)

  • The computer is not a laptop. It’s all running on a develpment board,
    with a processor on it named LEON3 (sparc architecture). The board has a VGA
    interface.

  • Trying to display (or render) an image via the VGA.

  • Made an application that does just that. But on an x86 system

  • The library and the application have all been cross-compiled to the
    processor architecture.

  • All I’m trying to do now is run the made application via the board to
    display the image via the vga.

  • What happens when I run it is that, It tries to initialise the mouse.

  • But an error comes up, saying can’t initialise mouse. And it says this
    error while the mouse (ps2) is connected.

What is now confusing me is that. When I try to statically link the code (on
x86) with all the required libraries (libSDL.a, libpthread (and atimes lm &
ldl)):

gcc -static source.c -I /dir/to/header_files -L /dir/to/libraries -lSDL -o
prog

The program got created successfully. But upon running the program (the last
time I did it). It kinda crashed. Making my screen resolution stuck to 800 x
600. Couldn’t even exit it (on Fedora i686 by the way). Had to log of and
log back in.

So doing the same, cross-compiling, I’m thinking is that a wrong move:
sparc-linux-gcc -static …etc

Could it be because I tried making the program statically?
Why would I get an error ‘SDL: can’t init mouse’?

Hope I explained it well.

Thanks in advance

-Mike

Just so you don’t get confused;

I get the ‘can’t init mouse’ error when I try to run the app on the embedded
system.

2009/4/11 Mike Mike

Just so you don’t get confused;

I get the ‘can’t init mouse’ error when I try to run the app on the embedded
system.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

The ‘can’t init mouse’ error is sent, when SDL can’t find any mice. It’s
strange, cause that would mean your xorg doesn’t see the mouse. It is
possible that the problem occures, because you are using a ps2 mouse. I
noticed that switching to the newest xorg made some problems, supposedly
there are some changes in the xorg API, that I used in SDL. If it is
possible, borrow an usb mouse and see if that mouse will be initialized.
That would be very helpful for me to dig into the bug.

Best wishes–
– Szymon “Wilku” Wilczek
"The dreamer dies, but never dies the dream, Though Death shall call the
whirlwind to his aid, Enlist men’s passions, trick their hearts with hate,
Still shall the Vision live! Say nevermore, That dreams are fragile things?

The ‘can’t init mouse’ error is sent, when SDL can’t find any mice. It’s
strange, cause that would mean your xorg doesn’t see the mouse.

Is Mike using X? Is he using framebuffer? He hasn’t made that clear.
(Though he mentioned his distro…)

It is
possible that the problem occures, because you are using a ps2 mouse. I
noticed that switching to the newest xorg made some problems, supposedly
there are some changes in the xorg API, that I used in SDL. If it is
possible, borrow an usb mouse and see if that mouse will be initialized.

He may not have a USB host controller.On Sat, Apr 11, 2009 at 11:16 AM, Szymon Wilczek wrote:


http://codebad.com/

Hi Guys,Yep, I’m not making use of any X system. I am unsure tho if there is
a frame buffer present. Although the board has on it a VGA interface (and as
it is included in the Datasheet; it has a 24-bit Video DAC
(ADV7125-50),which I figured would be able to output video). Because
at boot up, it
displays a picture (bmp).
I hope I’ve explained it a bit better. Sorry for the mis-understanding.

Thanks in advance

Yep, I’m not making use of any X system. I am unsure tho if there is a?frame
buffer?present.

Well, to be clear: the term “frame buffer” just means a buffer of
values representing each pixel in a frame. In the context of contrast
to X, however, I’m referring to the Linux kernel framebuffer module.
You can list all currently loaded modules with the lsmod command.
Try lsmod|grep fb to see if you have it loaded.

Although the board has on it a VGA interface (and as it is
included in the Datasheet; it has a?24-bit Video DAC (ADV7125-50), which I
figured would be able to output video). ?Because at boot up, it displays a
picture (bmp).

That sounds really cool. I’ve never been lucky enough to any embedded
Linux development for multimedia applications (or anything requiring a
screen or audio, to be more precise.) Of course, then again, if it’s
showing a picture at all, you must already have your video drivers
written, so you’ll just be doing straightforward Linux stuff when it
comes to the video display; you won’t have to play with any of the low
level stuff (unless something goes wrong;).

I hope I’ve explained it a bit better. Sorry for the mis-understanding.
Thanks in advance

Yes, thanks for explaining more thoroughly. Once you confirm that
you’re running the Linux kernel framebuffer module, find some
framebuffer module people (perhaps there are some on this list) to
help you test your mouse without depending on SDL. This will allow you
to narrow down the problem and – I suspect – rule out the
possibility that SDL is the source of the problem.

Good luck! (If you guys need to hire anyone, I am experience in this
field, and can travel…)On Sat, Apr 11, 2009 at 8:29 PM, Mike Mike wrote:


http://codebad.com/

?I hope I’ve explained it a bit better. Sorry for the mis-understanding.

Try a “cat /dev/input/mice” and moving the mouse. You should see
gibberish appearing when the mouse is moved. If that doesn’t work, try
it on /dev/psaux. If you don’t get anything on either of those, it’s
not starting out well. If you are, that means that SDL is having
trouble opening and reading from the mouse device? Running your
program under strace might provide some insight (try to match up the
steps the code goes through in that function I linked you to in an
earlier email).On Sat, Apr 11, 2009 at 8:29 PM, Mike Mike wrote:


http://pphaneuf.livejournal.com/

Ha! Donny, will definitely let you know when we’re is considering hiring.

@ *Pierre
Tried what you suggested

cat /dev/input/mice

but got error saying: **/dev/input/mice: No such device

why I don’t know.
I have connected a ps2 (wheel mouse) from microsoft. At startup I see it
recognise the mouse on the display. Naming the mouse wheel mouse (and it
does have a wheel).

Now, I’m lost. Any ideas?
**Will also check it under /dev/psaux (forgot)

And, what do you mean by ‘*Run your program under strace’?

*Thanks in advance

-Mike*

Ha! Donny, will definitely let you know when we’re is considering hiring.

:slight_smile:

cat /dev/input/mice
/dev/input/mice: No such device
why I don’t know.

That is a feature of the 2.6 kernel. Are you using 2.4 mike mike?

And, what do you mean by ‘Run your program under strace’?

strace is a program that can sit in between a client program and the
kernel, so that system API calls can be logged or manipulated. see man
1 strace.

Now, I’m lost. Any ideas?

You said you’re using Fedora? It looks like this is a known bug:

https://bugzilla.redhat.com/show_bug.cgi?id=472763

Please keep us appraised of your progress! We try to maintain interest
in bugs that affect SDL even if they are not necessarily caused by
SDL!On Wed, Apr 15, 2009 at 8:50 PM, Mike Mike wrote:


http://codebad.com/

Ah, Mike I should have read more carefully, there is a workaround:

The mouse device created by gpm is by default only readable for root.
Changing permissions so that all users can read the mouse device (see attached
patch) resolves the problem. I’ve successfully used this workaround/fix for a
couple of months, with no problems observed. However, I’m not sure if there’s
a good reason for these default permissions (in which case SDL has a bug, not
gpm).

To any SDL hacker who has a Fedora system around, have a look at this:

Hello,
device /dev/input/mice isn’t created by gpm but by udev. Also udev’s rule sets
access permission to that device, so changing its permission in gpm’s init
script isn’t good idea. Furthermore, this error message is displayed even when
gpm is stopped. So in my opinion this isn’t bug in gpm at all. (better
workaround, in case that you don’t need a mouse, is set environment variable
SDL_NOMOUSE=1)

I’m reassigning this to SDL, so the maintainer can make a comment.On Wed, Apr 15, 2009 at 9:42 PM, Donny Viszneki <@Donny_Viszneki> wrote:

https://bugzilla.redhat.com/show_bug.cgi?id=472763


http://codebad.com/

cat /dev/input/mice

but got error saying:? /dev/input/mice: No such device

why I don’t know.

That’s because your kernel doesn’t have the mousedev module loaded.
That’s for the new unified input model thingy, which I think is
supposed to pull events from both USB (sure) and PS/2 (less sure), but
isn’t strictly necessary for the latter, from what I remember.

I have connected a ps2 (wheel mouse) from microsoft. At startup I see it
recognise the mouse on the display. Naming the mouse wheel mouse (and it
does have a wheel).

That’s the psmouse driver, so I’m guessing /dev/psaux could work.

Now, I’m lost. Any ideas?
Will also check it under /dev/psaux (forgot)

That’d be critical. :slight_smile:

And, what do you mean by ‘Run your program under strace’?

It’s a program that allows you to trace all the system calls made by
your program, which can be very handy when trying to debug
interactions with the operating system.On Wed, Apr 15, 2009 at 8:50 PM, Mike Mike wrote:


http://pphaneuf.livejournal.com/

We forgot SDL_ThreadLock()!On Wed, Apr 15, 2009 at 10:03 PM, Pierre Phaneuf wrote:


http://codebad.com/

What?On Wed, Apr 15, 2009 at 10:09 PM, Donny Viszneki <donny.viszneki at gmail.com> wrote:

On Wed, Apr 15, 2009 at 10:03 PM, Pierre Phaneuf <@Pierre_Phaneuf> wrote:

We forgot SDL_ThreadLock()!


http://pphaneuf.livejournal.com/

Tried looking for dev/psaux, but it doesn’t exsist on the system. Except
/dev/input/mice…which still says no such device.
So how could I make SDL_NOMOUSE=1, which source code do I find it in?

Also, still playing around with the Strace program. Will let you know on
progress.**
Thanks in advance
**
-Mike

Ah , so to confirm. I change the variable SDL_NOMOUSE in SDL_init function?

Thanks in advance

Also, can I statically link a program to the SDL library?

You know, something like:

gcc -static test.c -I /usr/local/SDL -L /usr/local/lib -lSDL -lpthread -lm
-ldl -o app

Sorry for the multiple posts (if only I could delete)

Thanks in advance

-Mike

by the way, the lSDL (==libSDL.a) is a static library. I made them enabling
the static option. That’s why I had to include the pthread, math and dl
library individually. Because I noticed if I’m linking to a static libSDL as
opposed to libSDL.so, I had to include them all.

Hope I explained it properly.

Tried looking for dev/psaux,?but it doesn’t exsist on the system. Except
/dev/input/mice…which still says no such device.

Don’t let that stop you! Run “mknod /dev/psaux c 10 1”, it will create
the missing device node, which will allow you to try the “cat
/dev/psaux” command. This might have been your problem the whole time,
actually (the missing device node).

So?how could I make SDL_NOMOUSE=1, which source code do I find it in?

It’s an environment variable, so you do something like this:

$ export SDL_NOMOUSE=1
$ ./myprogramOn Fri, Apr 17, 2009 at 7:23 AM, Mike Mike wrote:


http://pphaneuf.livejournal.com/

Also, can I statically link a program to the SDL library?

You know, something like:

gcc -static test.c -I /usr/local/SDL -L /usr/local/lib -lSDL -lpthread -lm
-ldl -o app

Absolutely, modulo the licensing requirements of course.On Fri, Apr 17, 2009 at 7:56 AM, Mike Mike wrote:


http://pphaneuf.livejournal.com/