Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Keypad Entry
#11
As I mentioned previous, it's an underlying GLUT issue.  Try and hold down CTRL and press ANY of the number keys....  You won't get a keydown or keyup value for any of them with _KEYHIT.  We're aware of it, an issue is in the repo concerning it, and when someone gets a chance, they'll work into seeing what we can do about it.  (It may require removing glut completely and swapping over to something like GLFW instead.  Who knows at this point yet, what the final fix might be?)

Option 1 is to use the windows commands directly to get their keycodes.

Code: (Select All)
$If WIN Then
    Declare Library 'function is already used by QB64 so "User32" is not required
        Function GetKeyState% (ByVal vkey As Long)
        Function GetAsyncKeyState% (ByVal vkey As Long)
    End Declare
$End If

Do
    Cls
    For i = 1 To 254
        If GetAsyncKeyState(i) And &H8000 Then Print "Keycode ="; i
    Next
    _Delay .25
    _Display
Loop


Option 2 is to make use of my KeyHit library which remaps these windows codes into the same values that we're used to seeing with _KEYHIT and _KEYDOWN.

Option 3 is to just not use those keys until someone can finally get a fix in for this longstanding issue.
Reply
#12
https://qb64phoenix.com/forum/showthread.php?tid=21 <-- Keyboard Library is your friend!
Reply
#13
I'm guessing the codes come from GLUT, which I know nothing about.

Steve mentioned his keyboard library.  I'm not sure where to find that.  Maybe he'll chime in again?  Steve chimed in as I was typing.  Thank you, sir!

Maybe after some sleep I'll look into using the Windows API to get Windows scancodes, but my brain is fried for the day.



Code: (Select All)
bed:
sleep (28800)
_BLINK
_BLINK
_BLINK
_BLINK
GOTO Wake_Up

Wake_Up:
    GET (Up, Eventually)
    DO
        Stuff
    LOOP
GOTO bed
Reply
#14
So, the only remaining solution to coding keypad-5 is the following:

Code: (Select All)
Rem Keypad-5 = 76
Rem Shift-Keypad-5 = 53
Rem Ctrl-Keypad-5 = 143
Do
  X = _KeyHit
  If X Then
      'Print "Keypress="; X
      If X = 27 Then End
      If X < 0 Then
        Select Case X
            Case -12
              Print "keypad-5"
            Case -17
              Print "ctrl-keypad-5"
        End Select
      End If
      If X >= 256 And X <= 65535 Then
        X = (X And &HFF00) / 256
        Print "Ascii2="; X
        Select Case X
            Case 76
              Print "keypad-5"
            Case 53
              Print "shift-keypad-5"
            Case 143
              Print "ctrl-keypad-5"
        End Select
      End If
  End If
Loop
End
Reply
#15
(01-09-2023, 04:17 AM)JRace Wrote: I'm guessing the codes come from GLUT, which I know nothing about.

Steve mentioned his keyboard library.  I'm not sure where to find that.  Maybe he'll chime in again?

Post before yours.  Wink

https://qb64phoenix.com/forum/showthread.php?tid=21
Reply
#16
(01-09-2023, 04:18 AM)eoredson Wrote: So, the only remaining solution to coding keypad-5 is the following:

Code: (Select All)
Rem Keypad-5 = 76
Rem Shift-Keypad-5 = 53
Rem Ctrl-Keypad-5 = 143
Do
  X = _KeyHit
  If X Then
      'Print "Keypress="; X
      If X = 27 Then End
      If X < 0 Then
        Select Case X
            Case -12
              Print "keypad-5"
            Case -17
              Print "ctrl-keypad-5"
        End Select
      End If
      If X >= 256 And X <= 65535 Then
        X = (X And &HFF00) / 256
        Print "Ascii2="; X
        Select Case X
            Case 76
              Print "keypad-5"
            Case 53
              Print "shift-keypad-5"
            Case 143
              Print "ctrl-keypad-5"
        End Select
      End If
  End If
Loop
End

I tend to go with:

Code: (Select All)
'$INCLUDE:'Keyboard Library.BI'


Do
    k = KeyHit
    If k <> 0 Then Print k
    _Limit 30
Loop

'$INCLUDE:'Keyboard Library.BM'
Reply
#17
That is a nice library..

Could it edited to return ascii 0-255 and extended ascii 0-255?

Thanks.
Reply
#18
(01-09-2023, 04:38 AM)eoredson Wrote: That is a nice library..

Could it edited to return ascii 0-255 and extended ascii 0-255?

Thanks.

Fully editable to return whatever you want it to.  Currently it's configured for US, german, italian, and european keyboards, if you just change the init call, but you can set it up to return whatever you'd like with it.
Reply




Users browsing this thread: 4 Guest(s)