[all versions] certain keyboard inputs ignored

Just starting out? Need help? Post your questions and find answers here.
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

[all versions] certain keyboard inputs ignored

Post by heartbone »

Below is a minimum code loop that works to sense a user keypress and then flash the screen green for 2 seconds to complete the task:

Code: Select all

; ****** WINDOWED INTERFACE
InitSprite() : InitKeyboard()
OpenWindow(0,0,0,800,600,"SOFTWARE",#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0),0,0,800,600,#True,0,0)
; WAIT FOR USER TO PRESS A KEY BEFORE CONTINUING
Repeat
   Repeat
       X= WindowEvent() : If X = #PB_Event_CloseWindow : End : EndIf   
   Until X = 0
   Delay(20) : ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
ClearScreen($00FF00) : FlipBuffers() : Delay(2000) : End
The same minimum code snippet executing within the full screen environment does not work.
I can kill the PB session with Alt-F4, so it may not actually be a KeyboardPushed() problem, but that's my best guess.

Code: Select all

; ****** FULL SCREEN INTERFACE
InitSprite() : InitKeyboard()
OpenScreen(800,600,32,"SOFTWARE")
; WAIT FOR USER TO PRESS A KEY BEFORE CONTINUING
Repeat
   Delay(20) : ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
ClearScreen($00FF00) : FlipBuffers() : Delay(2000) : End 
Last edited by heartbone on Sun Jun 08, 2014 9:44 pm, edited 1 time in total.
Keep it BASIC.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: keyboard inputs ignored in fullscreen

Post by Danilo »

heartbone wrote:The same minimum code snippet executing within the full screen environment does not work.
I can kill the PB session with Alt-F4, so it may not actually be a KeyboardPushed() problem, but that's my best guess.

Code: Select all

; ****** FULL SCREEN INTERFACE
InitSprite() : InitKeyboard()
OpenScreen(800,600,32,"SOFTWARE")
; WAIT FOR USER TO PRESS A KEY BEFORE CONTINUING
Repeat
   Delay(20) : ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
ClearScreen($00FF00) : FlipBuffers() : Delay(2000) : End 
What happens when you add "ClearScreen($000000) : FlipBuffers()" inside your loop?
Maybe fullscreen event handling is done in FlipBuffers(), as the event handling is the only big difference
I see between the two codes, and you usually call FlipBuffers() in fullscreen loops.
User avatar
idle
Always Here
Always Here
Posts: 5837
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [all versions] keyboard inputs ignored in fullscreen

Post by idle »

The keyboard works if you use flipbuffers()
ububtu 12.04 x64
Windows 11, Manjaro, Raspberry Pi OS
Image
User avatar
heartbone
Addict
Addict
Posts: 1058
Joined: Fri Apr 12, 2013 1:55 pm
Location: just outside of Ferguson

Re: [all versions] keyboard inputs ignored in fullscreen

Post by heartbone »

Danilo wrote:What happens when you add "ClearScreen($000000) : FlipBuffers()" inside your loop?
Maybe fullscreen event handling is done in FlipBuffers(), as the event handling is the only big difference
I see between the two codes, and you usually call FlipBuffers() in fullscreen loops.
Interesting thinking there Danilo, and I see that Idle has confirmed your speculation.
idle wrote:The keyboard works if you use flipbuffers()
ububtu 12.04 x64
Yes indeed all that I needed to do was add the mystery GRAPHICS command FlipBuffers() to seemingly get the keyboard to work!!! (Are you serious???)

Code: Select all

; ****** FULL SCREEN INTERFACE
InitSprite() : InitKeyboard()
OpenScreen(800,600,32,"SOFTWARE")
; WAIT FOR USER TO PRESS A KEY BEFORE CONTINUING
Repeat
   FlipBuffers()
   Delay(20) : ExamineKeyboard()
Until KeyboardPushed(#PB_Key_All)
ClearScreen($00FF00) : FlipBuffers() : Delay(2000) : End 
OK......... thanks. :shock:

Now before closing this crazy thread. let's take a look at the next part of this situation...

Code: Select all

InitSprite() : InitKeyboard()
OpenWindow(0,0,0,640,480,"SOFTWARE",#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget) 
OpenWindowedScreen(WindowID(0),0,0,640,480,#True,0,0)
ESCAPE= 0 : UPDATE= 0
Repeat
   Delay(20)  
   Repeat 
      X= WindowEvent() : If X = #PB_Event_CloseWindow : End : EndIf   
   Until X = 0 
   ExamineKeyboard() 
   If KeyboardPushed(#PB_Key_Escape) : ESCAPE+ 1
   ElseIf KeyboardPushed(#PB_Key_Capital) 
      KEY$= "CAPITAL" 
   ElseIf KeyboardPushed(#PB_Key_LeftShift) 
      KEY$= "LEFT SHIFT" 
   ElseIf KeyboardPushed(#PB_Key_LeftControl)
      KEY$= "LEFT CONTROL" 
   ElseIf KeyboardPushed(#PB_Key_Tab) 
      KEY$= "TAB"
   ElseIf KeyboardPushed(#PB_Key_All) 
      KEY$= "something else"
   Else 
      KEY$= "no keypress"
   EndIf
   UPDATE+ 1 : If Not(UPDATE % 50) : Debug KEY$ : EndIf
Until ESCAPE : End
This snippet works as I expect in Windows both 32 and 64 bits.
It almost works in UBUNTU but it fails for me in 32 bits the same way that it fails on my 64 bit system.
Even though I see the caps lock indicator light toggling, as far as the program can tell it is as if the caps lock or tab keys can never, ever be pressed.
Is it just a bad UBUNTU keyboard configuration on my systems?
Keep it BASIC.
User avatar
idle
Always Here
Always Here
Posts: 5837
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: [all versions] keyboard inputs ignored in fullscreen

Post by idle »

I can't run that in the debugger, it spits the dummy with windowscreen.

All I got was Left Shift & Left Control, no Caps or Tab are reported

I think the Screen libs are long overdue a needed sanity check on linux.

Code: Select all

InitSprite() : InitKeyboard()
KeyboardMode(#PB_Keyboard_International  | #PB_Keyboard_AllowSystemKeys)
OpenWindow(0,0,0,640,480,"SOFTWARE",#PB_Window_ScreenCentered|#PB_Window_MinimizeGadget) 
OpenWindowedScreen(WindowID(0),0,0,640,480,#True,0,0)
OpenConsole() 

ESCAPE= 0 : UPDATE= 0
Repeat
   Delay(20)  
   Repeat 
      X= WindowEvent() : If X = #PB_Event_CloseWindow : End : EndIf   
   Until X = 0 
   ExamineKeyboard() 
   If KeyboardPushed(#PB_Key_Escape) : ESCAPE+ 1
   ElseIf KeyboardPushed(#PB_Key_Capital) 
      KEY$= "CAPITAL" 
   ElseIf KeyboardPushed(#PB_Key_LeftShift) 
      KEY$= "LEFT SHIFT" 
   ElseIf KeyboardPushed(#PB_Key_LeftControl)
      KEY$= "LEFT CONTROL" 
   ElseIf KeyboardPushed(#PB_Key_Tab) 
      KEY$= "TAB"
   ElseIf KeyboardPushed(#PB_Key_All) 
      KEY$= KeyboardInkey()
   EndIf
   If KEY$   
      PrintN( KEY$)
      KEY$="" 
   EndIf
   ClearScreen(0)
   FlipBuffers()
   
Until ESCAPE : End
Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply