Page 1 of 1
Using the Mouse in Linux Windowed/Fullscreen Game
Posted: Sun Jan 04, 2004 2:16 pm
by The_Pharao
How can I poll the mouse in a Linux Fullscreen or Windowed game?
InitMouse() gives an error, also the documentation says the mouse commands only work for Windows...
Posted: Mon Jan 05, 2004 12:59 pm
by Christian
Hi!
I've already posted it in the German forum, but perhaps somebody else here needs this, too. So if somebody have the same problem and can't use the Mousefunctions on his Linux distribution, than take a look to your /purebasic/examples/sources/sdl.pb file. You also can mix up the PB-Code with the SDL one. So here is an example for this:
Code: Select all
If SDL_Init_(#SDL_INIT_VIDEO | #SDL_INIT_AUDIO) >= 0 And InitSprite() <> 0 And OpenScreen(800, 600, 24, "Mousemovement under Linux") <> 0
CreateSprite(0, 5, 5)
StartDrawing(SpriteOutput(0))
Box(0, 0, 5, 5, RGB(255,255,255))
Stopdrawing()
Repeat
While SDL_PollEvent_(@Event.SDL_Event)
Select Event\Type
Case #SDL_QUIT ; Close button of the window has been pressed
quit = 1
; Case #SDL_KEYDOWN
; PrintN("Key: "+Str(Event\key\keysym\sym))
Case #SDL_MOUSEMOTION
PrintN("X:"+Str(Event\motion\x)+"; Y:"+Str(Event\motion\y))
EndSelect
Wend
DisplaySprite(0,Event\motion\x, Event\motion\y)
StartDrawing(ScreenOutput())
FrontColor(255,255,255)
Locate(Event\motion\x+5, Event\motion\y+5)
DrawText(Str(Event\motion\x)+"; "+Str(Event\motion\y))
StopDrawing()
FlipBuffers() : ClearScreen(0,0,0)
Until Event\key\keysym\sym = #SDLK_ESCAPE Or quit = 1
Else
MessageRequester("Error", "Couldn't initialize SDL or was unable to open a 800*600 24-bit screen!", 0)
End
Endif
best regards,
Christian
Posted: Mon Jan 05, 2004 6:13 pm
by Fred
I have missed the mouse library on linux ?! I will check..
Posted: Tue Jan 06, 2004 12:22 pm
by Christian
No you havn't missed it, Fred! On my system it works fine, but The_Pharao couldn't used it. But we don't know why.
best regards,
Christian
Posted: Tue Jan 06, 2004 4:32 pm
by TronDoc
the mouse code above works here!

Posted: Tue Jan 06, 2004 5:15 pm
by Christian
Fine!
Works the normal mouse library of PB on your system?
best regards,
Christian
Posted: Wed Jan 07, 2004 3:31 am
by TronDoc
Christian wrote:Works the normal mouse library of PB on your system?
which sample should I run to determine that? --jb
Posted: Wed Jan 07, 2004 7:38 am
by The_Pharao
i already posted it in the german forum: i tried it again with a clean linux installation, but then something with the graphic driver went wrong and well.... i'll try again in six months, perhaps i'll have better luck then :roll:
Posted: Wed Jan 07, 2004 7:41 pm
by Christian
@TronDoc:
See helpfile!
@The_Pharao:
Take a look in the Suse Support, perhaps you'll find something to solve your problem. Good luck for the next try with Linux.
regards,
christian