Using the Mouse in Linux Windowed/Fullscreen Game

Linux specific forum
The_Pharao
User
User
Posts: 57
Joined: Sun Jan 04, 2004 2:11 pm

Using the Mouse in Linux Windowed/Fullscreen Game

Post 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...
Christian
Enthusiast
Enthusiast
Posts: 154
Joined: Mon Dec 08, 2003 7:50 pm
Location: Germany

Post 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
Fred
Administrator
Administrator
Posts: 16664
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I have missed the mouse library on linux ?! I will check..
Christian
Enthusiast
Enthusiast
Posts: 154
Joined: Mon Dec 08, 2003 7:50 pm
Location: Germany

Post 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
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

the mouse code above works here! :D
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
Christian
Enthusiast
Enthusiast
Posts: 154
Joined: Mon Dec 08, 2003 7:50 pm
Location: Germany

Post by Christian »

Fine! :)

Works the normal mouse library of PB on your system?

best regards,
Christian
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

Christian wrote:Works the normal mouse library of PB on your system?
which sample should I run to determine that? --jb
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
The_Pharao
User
User
Posts: 57
Joined: Sun Jan 04, 2004 2:11 pm

Post 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:
Christian
Enthusiast
Enthusiast
Posts: 154
Joined: Mon Dec 08, 2003 7:50 pm
Location: Germany

Post 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
Post Reply