Mouse RAW INPUT since PB 6.0 has different behavior

Just starting out? Need help? Post your questions and find answers here.
RolfT
New User
New User
Posts: 8
Joined: Thu May 24, 2012 7:25 am

Mouse RAW INPUT since PB 6.0 has different behavior

Post by RolfT »

Hello and thanks for any help! :-)

THIS PROGRAM works fine inclusive 5.71! :D
It does not work under 6.00 (it loops without ending) !


Repeat
ExamineMouse()
mausLeftG=MouseButton( #PB_MouseButton_Left)
do_something_like_drawing_on_a_SCREEN()
FlipBuffers()
Delay(10)
Until mausLeftG=0

Any help or changes in PB to make it compatible working in 6.00?
Thanks a lot
Greetings
Rolf
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by Mijikai »

Works fine here (tested on Windows 10 with PB 6.0 - x64 ASM & C and x86 C):

Code: Select all

EnableExplicit

Procedure.i Main()
  Protected exit.i
  Protected mb.i
  If InitSprite() And InitKeyboard() And InitMouse()
    If OpenWindow(0,0,0,320,200,#Null$,#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
      If OpenWindowedScreen(WindowID(0),0,0,WindowWidth(0),WindowHeight(0))
        SetFrameRate(60)
        Repeat
          Repeat
            Select WindowEvent()
              Case #PB_Event_CloseWindow
                exit = #True
              Case #PB_Event_None
                Break
            EndSelect
          ForEver
          ExamineKeyboard()
          ExamineMouse()
          mb =  MouseButton(#PB_MouseButton_Left)
          ClearScreen($0)
          If StartDrawing(ScreenOutput())
            Box(MouseX() - 4,MouseY() - 4,8,8,#Red)
            StopDrawing()
          EndIf
          FlipBuffers()
        Until exit Or KeyboardReleased(#PB_Key_Escape) Or mb
        CloseScreen()
      EndIf
      CloseWindow(0)  
    EndIf  
  EndIf
  ProcedureReturn #Null
EndProcedure

Main()

End
RolfT
New User
New User
Posts: 8
Joined: Thu May 24, 2012 7:25 am

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by RolfT »

Hi Mijikai!
Thank for your Answer!
Your Program is runng fine at my PC. :D
Maybe it is a Problem because I ONLY youse a SCREEN not a windowed Screen.
Maybe there is an Update sometimes which enables the old 5.73 MOUSE behavior at SCREEN :D

Greetings
Rofl
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by Mijikai »

I will wait for a runnable example :D
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by Fred »

You need an event loop (While WindowEvent() : Wend) .
RolfT
New User
New User
Posts: 8
Joined: Thu May 24, 2012 7:25 am

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by RolfT »

Fred wrote: Mon Dec 05, 2022 9:58 am You need an event loop (While WindowEvent() : Wend) .
Hi Fred! Thanks for your answer and this great basic I am using long long time :-).

In my program I NEVER used a WINDOWED Screen, so WindowEvent() does not work for me :-(

I use only a SCREEN without a Window...

Greetings Rolf
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by Fred »

I will check then, it should work out of the box !
Fred
Administrator
Administrator
Posts: 16617
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by Fred »

I tried to reproduce it, but without success. Can anybody else confirm ?

Code: Select all

If InitSprite() = 0 Or InitKeyboard() = 0
  MessageRequester("Error", "Sprite system can't be initialized", 0)
  End
EndIf

InitMouse()

If OpenScreen(800, 600, 32, "Sprite")

  ; Load our 16 bit sprite (which is a 24 bit picture in fact, as BMP doesn't support 16 bit format)
  ;
  LoadSprite(0, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp")
  CopySprite(0, 1, 0)
  
  Repeat
    
    ; Inverse the buffers (the back become the front (visible)... And we can do the rendering on the back)
    
    FlipBuffers()
    
    ClearScreen(RGB(0,0,0))
    
    ; Draw our sprite

    ClipSprite(0, 0, 0, x, x/8)
     
    DisplaySprite(0, x, 100)
    DisplaySprite(1, x, x)
    DisplaySprite(0, 600-x, x)
    
    x+1
    ExamineMouse()
    
    If MouseButton(#PB_MouseButton_Left)
      
      DisplaySprite(1, MouseX(), MouseY())
    EndIf
    
    
    ExamineKeyboard()
  Until KeyboardPushed(#PB_Key_Escape)
  
Else
  MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf
RolfT
New User
New User
Posts: 8
Joined: Thu May 24, 2012 7:25 am

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by RolfT »

Hello Fred!
Your example works fine! :D
My big program (16000 Lines) not under 6.0. :(

Maybe I have programmed something unclean :? that works under 5.71 but not under 6.0.
I will have a look insinde my code once more.
If I found a hint I will tell it here!

Thanks for your support so far!

A happy user for all the years!

Rolf
RolfT
New User
New User
Posts: 8
Joined: Thu May 24, 2012 7:25 am

Re: Mouse RAW INPUT since PB 6.0 has different behavior

Post by RolfT »

Hello to all the Helpers! Partely SOLVED for me!

Repeat
ExamineMouse()
mausLeftG=MouseButton( #PB_MouseButton_Left)
;----------------------
8) 8) FlipBuffers() ; ==> whithout FlipBuffers() here it does not work under PB 6.00. But it works under 5.71 8) 8)
;----------------------
Until mausLeftG=0

Under 5.71 it works without FlipBuffers() in this Loop!
Under 6.00 only with FlipBuffers()

Thanks for all your Help!

Greetings RolfT

(Here is a running but flickering demonstration.
if you remove the FlipBuffers() in the first Loop it freezes under 6.00)
=============================================================

If InitSprite() = 0 Or InitKeyboard() = 0
MessageRequester("Error", "Sprite system can't be initialized", 0)
End
EndIf

InitMouse()

If OpenScreen(800, 600, 32, "Sprite")

; Load our 16 bit sprite (which is a 24 bit picture in fact, as BMP doesn't support 16 bit format)
;
LoadSprite(0, #PB_Compiler_Home + "examples/sources/Data/PureBasic.bmp")
CopySprite(0, 1, 0)
Repeat
x+1
Repeat
ExamineMouse()
mausLeftG=MouseButton( #PB_MouseButton_Left)
;----------------------
FlipBuffers() ; ==> whithout FlipBuffers() here it does not work under PB 6.00. But it works under 5.71 :?:
;----------------------
Until mausLeftG=0
Repeat
ExamineMouse()
mausLeftG=MouseButton( #PB_MouseButton_Left)
DisplaySprite(0, x, 100)
DisplaySprite(1, x, x)
DisplaySprite(0, 600-x, x)
If mausLeftG<>0
DisplaySprite(1, MouseX(), MouseY())
Repeat
ExamineMouse()
mausLeftG=MouseButton( #PB_MouseButton_Left)
FlipBuffers()
Delay(10)
Until mausleftG=0

EndIf

FlipBuffers()
Delay(10)
Until mausLeftG=0

ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)

Else
MessageRequester("Error", "Can't open a 800*600 - 32 bit screen !", 0)
EndIf
Post Reply