problem with keyboard layout

Post bugreports for the Windows version here
case
Enthusiast
Enthusiast
Posts: 141
Joined: Thu Aug 07, 2003 11:09 am

problem with keyboard layout

Post by case »

my keyboard is a french keyboard to see the bug i guess that you might have the correct keyboard layout (fr) mapped , i don't know if the problem happens with other foreign languages keyboard.

my pure basic version : pb 4.51 (x86), windows 7 64bit

a key of the keyboard is not correctly tested, this key is the key 'M' on qwerty keyboards and the "," key on french keyboards
to be sure this is a bug i'm using a loop to test the keys so all keys might be scanned.

run the code bellow the first part test the keyboard in qwerty mode, all keys works and flash the window background red

the second part use the international keyboard layout , all keys are responding and flash the window blue except the "M" (or "," key in french)

the third part use the same layout but scan the entire kevyboard using #pb_key_all and flash the screen magenta, the key is working

the fourthpart, use the international keyboard layout and enable system keys all keys including the "M" key (or "," key in french) flash the window green

it seems that the key is not polled in the second case .

Code: Select all

InitKeyboard()
main=OpenWindow(#PB_Any,0,0,640,200,"test",#PB_Window_ScreenCentered)
InitSprite()
OpenWindowedScreen(WindowID(main),0,0,640,200,0,0,0)
KeyboardMode(#PB_Keyboard_Qwerty)
Repeat
  ExamineKeyboard()
  ClearScreen(0)   
  For a=1 To 256
    If KeyboardPushed(a)
      ClearScreen($0000ff)
    EndIf 
  Next
  StartDrawing(ScreenOutput())
  DrawText(0,0,"qwerty keyboard")
  DrawText(0,16,"press the key next to N")
  DrawText(0,32,"press escape to change keyboard mode")
  StopDrawing()
  FlipBuffers()
  WaitWindowEvent(0)
Until KeyboardPushed(#PB_Key_Escape)
Repeat
  ExamineKeyboard()
Until KeyboardReleased(#PB_Key_Escape)
KeyboardMode(#PB_Keyboard_International)
Repeat
  ExamineKeyboard()
  ClearScreen(0)  
  For a=1 To 256
    If KeyboardPushed(a)
      ClearScreen($ff0000)
    EndIf  
  Next
  StartDrawing(ScreenOutput())
  DrawText(0,0,"international keyboard")
  DrawText(0,16,"press the key next to N")
  DrawText(0,32,"the key is not tested this is not a special key in my country layout (FR)")
  DrawText(0,48,"press escape to change keyboard mode")
  StopDrawing()  
  FlipBuffers()
  WaitWindowEvent(0)
Until KeyboardPushed(#PB_Key_Escape)
Repeat
  ExamineKeyboard()
Until KeyboardReleased(#PB_Key_Escape)
Repeat
  ExamineKeyboard()
  ClearScreen(0)  
  ;For a=1 To 256
    If KeyboardPushed(#PB_Key_All)
      ClearScreen($ff00ff)
    EndIf  
  ;Next
  StartDrawing(ScreenOutput())
  DrawText(0,0,"international keyboard")
  DrawText(0,16,"press the key next to N")
  DrawText(0,32,"the key works when using #pb_all to chek the keydown")
  DrawText(0,48,"press escape to change keyboard mode")
  StopDrawing()  
  FlipBuffers()
  WaitWindowEvent(0)
Until KeyboardPushed(#PB_Key_Escape)
KeyboardMode(#PB_Keyboard_International|#PB_Keyboard_AllowSystemKeys)
Repeat
  ExamineKeyboard()
  ClearScreen(0)  
  For a=1 To 256
    If KeyboardPushed(a)
      ClearScreen($00ff00)
    EndIf  
  Next
  StartDrawing(ScreenOutput())
  DrawText(0,0,"#PB_Keyboard_International|#PB_Keyboard_AllowSystemKeys")
    DrawText(0,16,"press the key next to N")
  DrawText(0,32,"the key is tested but special keys are activated so may cause bugs")
  DrawText(0,48,"press escape to change keyboard mode")  
  StopDrawing()  
  FlipBuffers()
  WaitWindowEvent(0)
Until KeyboardPushed(#PB_Key_Escape)

jem
New User
New User
Posts: 3
Joined: Mon Sep 26, 2011 9:38 am

Re: problem with keyboard layout

Post by jem »

Up for this Bug.

I have some informations du give.
This probleme exist with 4.51 and 4.60 RC1 version

With the KeyboardMode(#PB_Keyboard_International) entry.

The Keyboard key "?" a the right of the "N" on a AZERTY keyboard fire No Scancode.
But the Key "M" Fire 2 ScanCode 39 and 50.

When with comment Line ;KeyboardMode(#PB_Keyboard_International) , so we use the default Keyboard Layout ( QWERTY - US ) all seems to be good.

It's very problematic for French Keyboard Programming. We can't assign "," and "?" characteres to any command

Code: Select all

;- *** ENUMERATION ***


;- *** VARIABLES AND CONSTANTS ***
#MAIN_GAMEWINDOW_WIDTH=1024
#MAIN_GAMEWINDOW_HEIGHT=768

;- *** PROCEDURES ***
Procedure GetKeyboard()
  ExamineKeyboard()
  
  If KeyboardReleased(#PB_Key_Escape)
    End
  EndIf
  
EndProcedure


Procedure GetKeyboardScanCode()
  Protected i.l
  
  For i=0 To 255
    ExamineKeyboard()
    If KeyboardPushed(i)
      Debug i
    EndIf
    
  Next
  
EndProcedure

;- *** INIT PROCEDURE ***

InitSprite()
InitKeyboard()
InitMouse()

OpenWindow(0,0,0,#MAIN_GAMEWINDOW_WIDTH,#MAIN_GAMEWINDOW_HEIGHT,"test Keyboard",#PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
OpenWindowedScreen(WindowID(0),0,0,#MAIN_GAMEWINDOW_WIDTH,#MAIN_GAMEWINDOW_HEIGHT,1,0,0)

KeyboardMode(#PB_Keyboard_International)

;-  *** MAIN LOOP ***
Repeat
  Select WindowEvent()
    Case #PB_Event_CloseWindow
      End
  EndSelect
  
  GetKeyboardScanCode()
  
  FlipBuffers()
  ClearScreen($000000)

  GetKeyboard()
  
ForEver

I hope this can be help to solve the probleme
buddymatkona
Enthusiast
Enthusiast
Posts: 252
Joined: Mon Aug 16, 2010 4:29 am

Re: problem with keyboard layout

Post by buddymatkona »

Note: Code above does not display the Scan Code of the last Character...just the PB KeyID value for a KeyPress
which does not take into account such things as CAPSLOCK_DOWN.

About the French keyboard problem, if you want a quick, temporary solution to try, remap the problem keys to keys you do not need.
There are tools you can download to remap keyboard Scan Codes or if you use Windows, just change the registry.
Run Regedit and navigate to:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
Click on Edit->New->Binary Value and name it "Scancode Map" without the quotes.

_____Name___________Type______________________ DATA

Code: Select all

ScanCode Map     REG_BINARY   00,00,00,00,00,00,00,00,02,00,00,00,33,00,46,00,00,00,00,00
_____Example ___________ DATA ___________________ Fields

Code: Select all

00,00,00,00,00,00,00,00,02,00,00,00,33,00,46,00,00,00,00,00                        ; Comma Remapped to ScrollLock 
00,00,00,00,00,00,00,00,02,00,00,00,32,00,44,00,00,00,00,00                        ; Press F10 and software will see m
00,00,00,00,00,00,00,00,02,00,00,00,4D,00,5D,00,00,00,00,00                        ; SHIFT_F10 becomes M

00,00,00,00,00,00,00,00,04,00,00,00,33,00,46,00,32,00,44,00,4D,00,5D,00,00,00,00,00; All three changes at once
_____________________________|_____________| One_________| Two________| Three
_____________________________|
_____________________________Number of changes+1 in a single DATA field

This would be for all Users and of course applications using their own key mapping might overwrite so it gets complicated. :)
case
Enthusiast
Enthusiast
Posts: 141
Joined: Thu Aug 07, 2003 11:09 am

Re: problem with keyboard layout

Post by case »

still not fixed in curent 4.61 beta 1 build .
User avatar
Fig
Enthusiast
Enthusiast
Posts: 351
Joined: Thu Apr 30, 2009 5:23 pm
Location: Côtes d'Azur, France

Re: problem with keyboard layout

Post by Fig »

jem wrote: The Keyboard key "?" a the right of the "N" on a AZERTY keyboard fire No Scancode.
But the Key "M" Fire 2 ScanCode 39 and 50.
I just hit this bug. On French keyboard (can't tell on qwerty).
Purebasic is 5.45LTS my program is stuck, i can't have my own gui.
Please Fred... :|
There are 2 methods to program bugless.
But only the third works fine.

Win10, Pb x64 5.71 LTS
Post Reply