Page 1 of 1

problem with keyboard layout

Posted: Sat Mar 26, 2011 7:55 pm
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)


Re: problem with keyboard layout

Posted: Mon Sep 26, 2011 9:46 am
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

Re: problem with keyboard layout

Posted: Tue Sep 27, 2011 8:04 pm
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. :)

Re: problem with keyboard layout

Posted: Fri Mar 16, 2012 8:55 pm
by case
still not fixed in curent 4.61 beta 1 build .

Re: problem with keyboard layout

Posted: Sat Aug 19, 2017 6:35 pm
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... :|