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...
Using the Mouse in Linux Windowed/Fullscreen Game
-
- User
- Posts: 57
- Joined: Sun Jan 04, 2004 2:11 pm
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:
best regards,
Christian
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
Christian
-
- User
- Posts: 57
- Joined: Sun Jan 04, 2004 2:11 pm