Author Topic: Programmable Keyboard Input  (Read 4571 times)

0 Members and 1 Guest are viewing this topic.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Programmable Keyboard Input
« Reply #30 on: January 16, 2020, 04:19:56 pm »
I'm glad to post this add to Steve's work!

CP_850 for IT keyboard
and
CP_1252 for Western Europe countries (it works also for IT keyboard)

Code: QB64: [Select]
  1. SUB Init_KeyCodes (Language AS STRING)
  2.     RESTORE default_keyboard_data
  3.     FOR i = 1 TO 254
  4.         READ Keys(i).Index, Keys(i).ASCII, Keys(i).Ctrl, Keys(i).Shift, Keys(i).Alt, Keys(i).AltGr, Keys(i).Repeat
  5.         Keys(i).LastHit = 0: Keys(i).Down = 0
  6.     NEXT
  7.  
  8.     default_keyboard_data:
  9.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  10.     DATA 1,900001,0,0,0,0,0.2: 'Left Mouse Button
  11.     DATA 2,900002,0,0,0,0,0.2: 'Right Mouse Button
  12.     DATA 3,900003,0,0,0,0,0.2: 'VK_Cancel
  13.     DATA 4,900004,0,0,0,0,0.2: 'Middle Mouse Button
  14.     DATA 5,900005,0,0,0,0,0.2: 'Mouse Button 4
  15.     DATA 6,900006,0,0,0,0,0.2: 'Mouse Button 5
  16.     DATA 7,900007,0,0,0,0,0.2: 'Undefined
  17.     DATA 8,8,0,0,0,0,0.2: 'Backspace
  18.     DATA 9,9,0,0,0,0,0.2: 'Tab
  19.     DATA 10,900010,0,0,0,0,0.2: 'Reserved
  20.     DATA 11,900011,0,0,0,0,0.2: 'Reserved
  21.     DATA 12,19456,0,0,0,0,0.2: 'Clear
  22.     DATA 13,13,0,0,0,0,0.2: 'Enter
  23.     DATA 14,900014,0,0,0,0,0.2: 'Undefined
  24.     DATA 15,900015,0,0,0,0,0.2: 'Undefined
  25.     DATA 16,100016,0,0,0,0,-1: 'Shift (Notice I set it to simple toddle and report UP/DOWN results for us)
  26.     DATA 17,100017,0,0,0,0,-1: 'Ctrl   (Same)
  27.     DATA 18,100018,0,0,0,0,-1: 'Alt     (Same)
  28.     DATA 19,100019,0,0,0,0,0.2: 'Pause
  29.     DATA 20,100301,0,0,0,0,-1: 'Caps Lock
  30.     DATA 21,900021,0,0,0,0,0.2: 'VK_Hangul
  31.     DATA 22,900022,0,0,0,0,0.2: 'Undefined
  32.     DATA 23,900023,0,0,0,0,0.2: 'VK_Junja
  33.     DATA 24,900024,0,0,0,0,0.2: 'VK_Final
  34.     DATA 25,900025,0,0,0,0,0.2: 'VK_Hanga//VK_Kanji
  35.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  36.     DATA 26,900026,0,0,0,0,0.2: 'Undefined
  37.     DATA 27,27,0,0,0,0,0.2: 'ESC
  38.     DATA 28,900028,0,0,0,0,0.2: 'VK_Convert
  39.     DATA 29,900029,0,0,0,0,0.2: 'VK_NonConvert
  40.     DATA 30,900030,0,0,0,0,0.2: 'VK_Accept
  41.     DATA 31,900031,0,0,0,0,0.2: 'VK_ModeChange
  42.     DATA 32,32,0,0,0,0,0.2: 'VK_Space
  43.     DATA 33,18688,0,0,0,0,0.2: 'Page Up
  44.     DATA 34,20736,0,0,0,0,0.2: 'Page Down
  45.     DATA 35,20224,0,0,0,0,0.2: 'End
  46.     DATA 36,18176,0,0,0,0,0.2: 'Home
  47.     DATA 37,19200,0,0,0,0,0.2: 'Left Arrow
  48.     DATA 38,18432,0,0,0,0,0.2: 'Up Arrow
  49.     DATA 39,19712,0,0,0,0,0.2: 'Right Arrow
  50.     DATA 40,20480,0,0,0,0,0.2: 'Down Arrow
  51.     DATA 41,900041,0,0,0,0,-1: 'VK_SELECT
  52.     DATA 42,900042,0,0,0,0,-1: 'CK_PRINT
  53.     DATA 43,900043,0,0,0,0,-1: 'VK_EXECUTE
  54.     DATA 44,900044,0,0,0,0,-1: 'VK_SNAPSHOT
  55.     DATA 45,20992,0,0,0,0,0.2: 'INS
  56.     DATA 46,21248,0,0,0,0,0.2: 'DEL
  57.     DATA 47,900047,0,0,0,0,0.2: 'VK_HELP
  58.     DATA 48,48,0,41,0,0,0.2: '0
  59.     DATA 49,49,0,33,0,0,0.2: '1
  60.     DATA 50,50,0,64,0,0,0.2: '2
  61.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  62.     DATA 51,51,0,35,0,0,0.2: '3
  63.     DATA 52,52,0,36,0,0,0.2: '4
  64.     DATA 53,53,0,37,0,0,0.2: '5
  65.     DATA 54,54,0,94,0,0,0.2: '6
  66.     DATA 55,55,0,38,0,0,0.2: '7
  67.     DATA 56,56,0,42,0,0,0.2: '8
  68.     DATA 57,57,0,40,0,0,0.2: '9
  69.     DATA 58,900058,0,0,0,0,0.2: 'Undefined
  70.     DATA 59,900059,0,0,0,0,0.2: 'Undefined
  71.     DATA 60,900060,0,0,0,0,0.2: 'Undefined
  72.     DATA 61,900061,0,0,0,0,0.2: 'Undefined
  73.     DATA 62,900062,0,0,0,0,0.2: 'Undefined
  74.     DATA 63,900063,0,0,0,0,0.2: 'Undefined
  75.     DATA 64,900064,0,0,0,0,0.2: 'Undefined
  76.     DATA 65,65,0,97,0,0,0.2: 'a
  77.     DATA 66,66,0,98,0,0,0.2: 'b
  78.     DATA 67,67,0,99,0,0,0.2: 'c
  79.     DATA 68,68,0,100,0,0,0.2: 'd
  80.     DATA 69,69,0,101,0,0,0.2: 'e
  81.     DATA 70,70,0,102,0,0,0.2: 'f
  82.     DATA 71,71,0,103,0,0,0.2: 'g
  83.     DATA 72,72,0,104,0,0,0.2: 'h
  84.     DATA 73,73,0,105,0,0,0.2: 'i
  85.     DATA 74,74,0,106,0,0,0.2: 'j
  86.     DATA 75,75,0,107,0,0,0.2: 'k
  87.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  88.     DATA 76,76,0,108,0,0,0.2: 'l
  89.     DATA 77,77,0,109,0,0,0.2: 'm
  90.     DATA 78,78,0,110,0,0,0.2: 'n
  91.     DATA 79,79,0,111,0,0,0.2: 'o
  92.     DATA 80,80,0,112,0,0,0.2: 'p
  93.     DATA 81,81,0,113,0,0,0.2: 'q
  94.     DATA 82,82,0,114,0,0,0.2: 'r
  95.     DATA 83,83,0,115,0,0,0.2: 's
  96.     DATA 84,84,0,116,0,0,0.2: 't
  97.     DATA 85,85,0,117,0,0,0.2: 'u
  98.     DATA 86,86,0,118,0,0,0.2: 'v
  99.     DATA 87,87,0,119,0,0,0.2: 'w
  100.     DATA 88,88,0,120,0,0,0.2: 'x
  101.     DATA 89,89,0,121,0,0,0.2: 'y
  102.     DATA 90,90,0,122,0,0,0.2: 'z
  103.     DATA 91,100311,0,0,0,0,-1: 'Left WIN
  104.     DATA 92,100312,0,0,0,0,-1: 'Right WIN
  105.     DATA 93,100319,0,0,0,0,-1: 'Applications (Menu)
  106.     DATA 94,900094,0,0,0,0,0.2: 'Reserved
  107.     DATA 95,900095,0,0,0,0,0.2: 'VK_SLEEP
  108.     DATA 96,48,0,0,0,0,0.2: 'Numpad 0
  109.     DATA 97,49,0,0,0,0,0.2: 'Numpad 1
  110.     DATA 98,50,0,0,0,0,0.2: 'Numpad 2
  111.     DATA 99,51,0,0,0,0,0.2: 'Numpad 3
  112.     DATA 100,52,0,0,0,0,0.2: 'Numpad 4
  113.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  114.     DATA 101,53,0,0,0,0,0.2: 'Numpad 5
  115.     DATA 102,54,0,0,0,0,0.2: 'Numpad 6
  116.     DATA 103,55,0,0,0,0,0.2: 'Numpad 7
  117.     DATA 104,56,0,0,0,0,0.2: 'Numpad 8
  118.     DATA 105,57,0,0,0,0,0.2: 'Numpad 9
  119.     DATA 106,42,0,0,0,0,0.2: 'Numpad *
  120.     DATA 107,43,0,0,0,0,0.2: 'Numpad +
  121.     DATA 108,900108,0,0,0,0,0.2: 'VK_SEPARATOR
  122.     DATA 109,51,0,0,0,0,0.2: 'Numpad -
  123.     DATA 110,52,0,0,0,0,0.2: 'Numpad .
  124.     DATA 111,53,0,0,0,0,0.2: 'Numpad /
  125.     DATA 112,15104,0,0,0,0,0.2: 'F1
  126.     DATA 113,15360,0,0,0,0,0.2: 'F2
  127.     DATA 114,15616,0,0,0,0,0.2: 'F3
  128.     DATA 115,15872,0,0,0,0,0.2: 'F4
  129.     DATA 116,16128,0,0,0,0,0.2: 'F5            /
  130.     DATA 117,16384,0,0,0,0,0.2: 'F6
  131.     DATA 118,16640,0,0,0,0,0.2: 'F7
  132.     DATA 119,16896,0,0,0,0,0.2: 'F8
  133.     DATA 120,17152,0,0,0,0,0.2: 'F9
  134.     DATA 121,17408,0,0,0,0,0.2: 'F10
  135.     DATA 122,34048,0,0,0,0,0.2: 'F11
  136.     DATA 123,34304,0,0,0,0,0.2: 'F12
  137.     DATA 124,900124,0,0,0,0,0.2: 'F13
  138.     DATA 125,900125,0,0,0,0,0.2: 'F14
  139.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  140.     DATA 126,900126,0,0,0,0,0.2: 'F15
  141.     DATA 127,900127,0,0,0,0,0.2: 'F16
  142.     DATA 128,900128,0,0,0,0,0.2: 'F17
  143.     DATA 129,900129,0,0,0,0,0.2: 'F18
  144.     DATA 130,900130,0,0,0,0,0.2: 'F19
  145.     DATA 131,900131,0,0,0,0,0.2: 'F20
  146.     DATA 132,900132,0,0,0,0,0.2: 'F21
  147.     DATA 133,900133,0,0,0,0,0.2: 'F22
  148.     DATA 134,900134,0,0,0,0,0.2: 'F23
  149.     DATA 135,900135,0,0,0,0,0.2: 'F24
  150.     DATA 136,900136,0,0,0,0,0.2: 'Unassigned
  151.     DATA 137,900137,0,0,0,0,0.2: 'Unassigned
  152.     DATA 138,900138,0,0,0,0,0.2: 'Unassigned
  153.     DATA 139,900139,0,0,0,0,0.2: 'Unassigned
  154.     DATA 140,900140,0,0,0,0,0.2: 'Unassigned
  155.     DATA 141,900141,0,0,0,0,0.2: 'Unassigned
  156.     DATA 142,900142,0,0,0,0,0.2: 'Unassigned
  157.     DATA 143,900143,0,0,0,0,0.2: 'Unassigned
  158.     DATA 144,100300,0,0,0,0,-1: 'NUM LOCK
  159.     DATA 145,100302,0,0,0,0,-1: 'SCROLL LOCK
  160.     DATA 146,900146,0,0,0,0,0.2: 'OEM SPECIFIC
  161.     DATA 147,900147,0,0,0,0,0.2: 'OEM SPECIFIC
  162.     DATA 148,900148,0,0,0,0,0.2: 'OEM SPECIFIC
  163.     DATA 149,900149,0,0,0,0,0.2: 'OEM SPECIFIC
  164.     DATA 150,900150,0,0,0,0,0.2: 'OEM SPECIFIC
  165.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  166.     DATA 151,900151,0,0,0,0,0.2: 'Unassigned
  167.     DATA 152,900152,0,0,0,0,0.2: 'Unassigned
  168.     DATA 153,900153,0,0,0,0,0.2: 'Unassigned
  169.     DATA 154,900154,0,0,0,0,0.2: 'Unassigned
  170.     DATA 155,900155,0,0,0,0,0.2: 'Unassigned
  171.     DATA 156,900156,0,0,0,0,0.2: 'Unassigned
  172.     DATA 157,900157,0,0,0,0,0.2: 'Unassigned
  173.     DATA 158,900158,0,0,0,0,0.2: 'Unassigned
  174.     DATA 159,900159,0,0,0,0,0.2: 'Unassigned
  175.     DATA 160,100304,0,0,0,0,-1: 'Left Shift
  176.     DATA 161,100303,0,0,0,0,-1: 'Right Shift
  177.     DATA 162,100306,0,0,0,0,-1: 'Left Control
  178.     DATA 163,100305,0,0,0,0,-1: 'Right Control
  179.     DATA 164,100308,0,0,0,0,-1: 'Left Alt
  180.     DATA 165,100309,0,0,0,0,-1: 'Right Alt
  181.     DATA 166,900166,0,0,0,0,0.2: 'Browser back
  182.     DATA 167,900167,0,0,0,0,0.2: 'Browser forward
  183.     DATA 168,900168,0,0,0,0,0.2: 'Browser refresh
  184.     DATA 169,900169,0,0,0,0,0.2: 'Browser stop
  185.     DATA 170,900170,0,0,0,0,0.2: 'Browser search
  186.     DATA 171,900171,0,0,0,0,0.2: 'Browser favorites
  187.     DATA 172,900172,0,0,0,0,0.2: 'Browser home
  188.     DATA 173,900173,0,0,0,0,0.2: 'Mute
  189.     DATA 174,900174,0,0,0,0,0.2: 'Vol Down
  190.     DATA 175,900175,0,0,0,0,0.2: 'Vol Up
  191.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  192.     DATA 176,900176,0,0,0,0,0.2: 'Media Next
  193.     DATA 177,900177,0,0,0,0,0.2: 'Media prev
  194.     DATA 178,900178,0,0,0,0,0.2: 'Media stop
  195.     DATA 179,900179,0,0,0,0,0.2: 'Media Play/Pause
  196.     DATA 180,900180,0,0,0,0,0.2: 'Launch mail
  197.     DATA 181,900181,0,0,0,0,0.2: 'Launch media select
  198.     DATA 182,900182,0,0,0,0,0.2: 'Launch app1
  199.     DATA 183,900183,0,0,0,0,0.2: 'Launch app2
  200.     DATA 184,900184,0,0,0,0,0.2: 'Reserved
  201.     DATA 185,900185,0,0,0,0,0.2: 'Reserved
  202.     DATA 186,59,0,58,0,0,0.2: ';:
  203.     DATA 187,61,0,43,0,0,0.2: '=+
  204.     DATA 188,44,0,60,0,0,0.2: ',<
  205.     DATA 189,45,0,95,0,0,0.2: '-_
  206.     DATA 190,46,0,62,0,0,0.2: '.>
  207.     DATA 191,47,0,63,0,0,0.2: '/?
  208.     DATA 192,96,0,126,0,0,0.2: '`~
  209.     DATA 193,900193,0,0,0,0,0.2: 'Reserved
  210.     DATA 194,900194,0,0,0,0,0.2: 'Reserved
  211.     DATA 195,900195,0,0,0,0,0.2: 'Reserved
  212.     DATA 196,900196,0,0,0,0,0.2: 'Reserved
  213.     DATA 197,900197,0,0,0,0,0.2: 'Reserved
  214.     DATA 198,900198,0,0,0,0,0.2: 'Reserved
  215.     DATA 199,900199,0,0,0,0,0.2: 'Reserved
  216.     DATA 200,900200,0,0,0,0,0.2: 'Reserved
  217.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  218.     DATA 201,900201,0,0,0,0,0.2: 'Reserved
  219.     DATA 202,900202,0,0,0,0,0.2: 'Reserved
  220.     DATA 203,900203,0,0,0,0,0.2: 'Reserved
  221.     DATA 204,900204,0,0,0,0,0.2: 'Reserved
  222.     DATA 205,900205,0,0,0,0,0.2: 'Reserved
  223.     DATA 206,900206,0,0,0,0,0.2: 'Reserved
  224.     DATA 207,900207,0,0,0,0,0.2: 'Reserved
  225.     DATA 208,900208,0,0,0,0,0.2: 'Reserved
  226.     DATA 209,900209,0,0,0,0,0.2: 'Reserved
  227.     DATA 210,900210,0,0,0,0,0.2: 'Reserved
  228.     DATA 211,900211,0,0,0,0,0.2: 'Reserved
  229.     DATA 212,900212,0,0,0,0,0.2: 'Reserved
  230.     DATA 213,900213,0,0,0,0,0.2: 'Reserved
  231.     DATA 214,900214,0,0,0,0,0.2: 'Reserved
  232.     DATA 215,900215,0,0,0,0,0.2: 'Reserved
  233.     DATA 216,900216,0,0,0,0,0.2: 'Unassigned
  234.     DATA 217,900217,0,0,0,0,0.2: 'Unassigned
  235.     DATA 218,900218,0,0,0,0,0.2: 'Unassigned
  236.     DATA 219,91,0,123,0,0,0.2: '[{
  237.     DATA 220,92,0,124,0,0,0.2: '\|
  238.     DATA 221,93,0,125,0,0,0.2: ']}
  239.     DATA 222,39,0,34,0,0,0.2: ''"
  240.     DATA 223,900223,0,0,0,0,0.2: 'OEM SPECIFIC
  241.     DATA 224,900224,0,0,0,0,0.2: 'Reserved
  242.     DATA 225,900225,0,0,0,0,0.2: 'OEM SPECIFIC d
  243.     DATA 226,900226,0,0,0,0,0.2: 'Either the Angle Bracket key,or Backslash on RT 102-key keyboard
  244.     DATA 227,900227,0,0,0,0,0.2: 'OEM SPECIFIC
  245.     DATA 228,900228,0,0,0,0,0.2: 'OEM SPECIFIC
  246.     DATA 229,900229,0,0,0,0,0.2: 'IME PROCESS key (whatever that is)
  247.     DATA 230,900230,0,0,0,0,0.2: 'OEM SPECIFIC
  248.     DATA 231,900231,0,0,0,0,0.2: 'Used to pass UNICODE characters (however that works)
  249.     DATA 232,900232,0,0,0,0,0.2: 'Unassigned
  250.     DATA 233,900233,0,0,0,0,0.2: 'OEM SPECIFIC
  251.     DATA 234,900234,0,0,0,0,0.2: 'OEM SPECIFIC
  252.     DATA 235,900235,0,0,0,0,0.2: 'OEM SPECIFIC
  253.     DATA 236,900236,0,0,0,0,0.2: 'OEM SPECIFIC
  254.     DATA 237,900237,0,0,0,0,0.2: 'OEM SPECIFIC
  255.     DATA 238,900238,0,0,0,0,0.2: 'OEM SPECIFIC
  256.     DATA 239,900239,0,0,0,0,0.2: 'OEM SPECIFIC
  257.     DATA 240,900240,0,0,0,0,0.2: 'OEM SPECIFIC
  258.     DATA 241,900241,0,0,0,0,0.2: 'OEM SPECIFIC
  259.     DATA 242,900242,0,0,0,0,0.2: 'OEM SPECIFIC
  260.     DATA 243,900243,0,0,0,0,0.2: 'OEM SPECIFIC
  261.     DATA 244,900244,0,0,0,0,0.2: 'OEM SPECIFIC
  262.     DATA 245,900245,0,0,0,0,0.2: 'OEM SPECIFIC
  263.     DATA 246,900246,0,0,0,0,0.2: 'VK_ATTN
  264.     DATA 247,900247,0,0,0,0,0.2: 'VK_ATTN
  265.     DATA 248,900248,0,0,0,0,0.2: 'VK_ATTN
  266.     DATA 249,900249,0,0,0,0,0.2: 'VK_ATTN
  267.     DATA 250,900250,0,0,0,0,0.2: 'VK_ATTN
  268.     DATA 251,900251,0,0,0,0,0.2: 'VK_ATTN
  269.     DATA 252,900252,0,0,0,0,0.2: 'Reserved
  270.     DATA 253,900253,0,0,0,0,0.2: 'VK_PA1
  271.     DATA 254,900253,0,0,0,0,0.2: 'VK_OEM_CLEAR
  272.     DATA 0,0,0,0,0,0,0.2: 'END OF DATA
  273.     AltGr(0) = 165
  274.     AltGr(1) = 0
  275.  
  276.     SELECT CASE Language
  277.         CASE "DE"
  278.             RESTORE Microsoft_windows_cp1250
  279.             FOR i = 128 TO 255
  280.                 READ unicode
  281.                 _MAPUNICODE unicode TO ASCIIcode
  282.             NEXT
  283.             Microsoft_windows_cp1250:
  284.             DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,352,8249,346,356,381,377
  285.             DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,353,8250,347,357,382,378
  286.             DATA 160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379
  287.             DATA 176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380
  288.             DATA 340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270
  289.             DATA 272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223
  290.             DATA 341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271
  291.             DATA 273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729
  292.             'Remap_KeyCode (Which, ASCII, Ctrl , Shift, Alt, AltGr, Repeat AS _FLOAT)
  293.             Remap_KeyCode 226, 60, 0, 62, 124, 92, 0.2 '<>|
  294.             Remap_KeyCode 219, 225, 0, 63, 0, 0, 0.2 '-
  295.             Remap_KeyCode 48, 48, 0, 61, 0, 125, 0.2 '0
  296.             Remap_KeyCode 192, 148, 0, 153, 0, 0, 0.2
  297.             Remap_KeyCode 222, 132, 0, 142, 0, 0, 0.2
  298.             Remap_KeyCode 50, 50, 0, 34, 0, 253, 0.2: '2 .. I don't see a superscript 3 for AltGr codes for the 3 key.
  299.             Remap_KeyCode 51, 51, 0, 35, 0, 0, 0.2: '3 ..I don't see the squiggle for this in the ASCII code.  It needs to be changed, but I dunno with what.
  300.             Remap_KeyCode 54, 54, 0, 38, 0, 0, 0.2: '6
  301.             Remap_KeyCode 55, 55, 0, 47, 0, 123, 0.2: '7
  302.             Remap_KeyCode 56, 56, 0, 40, 0, 91, 0.2: '8
  303.             Remap_KeyCode 57, 57, 0, 41, 0, 93, 0.2: '9
  304.             Remap_KeyCode 186, 129, 0, 154, 0, 0, 0.2: ';:
  305.             Remap_KeyCode 187, 43, 0, 42, 0, 126, 0.2: '=+
  306.             Remap_KeyCode 191, 35, 0, 249, 0, 0, 0.2: '/?
  307.             Remap_KeyCode 81, 81, 0, 113, 0, 64, 0.2: 'q
  308.             Remap_KeyCode 69, 69, 0, 101, 0, 238, 0.2: 'e
  309.             Remap_KeyCode 77, 77, 0, 109, 0, 0, 0.2: 'm -- again, I failed to find the goofy u which AltGr produces in the 256 ASCII set
  310.  
  311.         CASE "WE"
  312.             RESTORE Microsoft_windows_cp1252
  313.             FOR i = 128 TO 255
  314.                 READ unicode
  315.                 _MAPUNICODE unicode TO ASCIIcode
  316.             NEXT
  317.  
  318.             Microsoft_windows_cp1252:
  319.             DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0
  320.             DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376
  321.             DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  322.             DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  323.             DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  324.             DATA 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
  325.             DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  326.             DATA 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  327.  
  328.  
  329.             'remap_KeyCode (Which, ASCII, Ctrl , Shift, Alt, AltGr, Repeat AS _FLOAT)
  330.             Remap_KeyCode 188, 44, 0, 59, 0, 0, 0.2: ',;
  331.             Remap_KeyCode 190, 46, 0, 58, 0, 0, 0.2: '.:
  332.             Remap_KeyCode 50, 50, 0, 34, 0, 0, 0.2: '2 "
  333.             Remap_KeyCode 51, 51, 0, 156, 0, 0, 0.2: '3 œ
  334.             Remap_KeyCode 191, 151, 0, 21, 0, 0, 0.2: '£ 
  335.             Remap_KeyCode 222, 133, 0, 248, 0, 35, 0.2: '… ø#
  336.             Remap_KeyCode 192, 149, 0, 128, 0, 64, 0.2: '• € @
  337.             Remap_KeyCode 186, 138, 0, 130, 0, 91, 0.2 'Š ‚ [
  338.             Remap_KeyCode 187, 43, 0, 42, 0, 93, 0.2 ' + * ]
  339.             Remap_KeyCode 54, 54, 0, 38, 0, 0, 0.2 '6 &
  340.             Remap_KeyCode 55, 55, 0, 47, 0, 0, 0.2 '7 /
  341.             Remap_KeyCode 56, 56, 0, 40, 0, 0, 0.2 '8(
  342.             Remap_KeyCode 57, 57, 0, 41, 0, 0, 0.2 '9 )
  343.             Remap_KeyCode 48, 48, 0, 61, 0, 0, 0.2 '0 =
  344.             Remap_KeyCode 219, 39, 0, 63, 0, 0, 0.2 ' ' ?
  345.             Remap_KeyCode 221, 141, 0, 94, 0, 0, 0.2 ' ^
  346.             Remap_KeyCode 226, 60, 0, 62, 0, 0, 0.2 '< >
  347.  
  348.         CASE "IT"
  349.  
  350.             RESTORE ASCII_cp850
  351.             FOR i = 128 TO 255
  352.                 READ unicode
  353.                 _MAPUNICODE unicode TO ASCIIcode
  354.             NEXT
  355.  
  356.             ASCII_cp850:
  357.             DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  358.             DATA 201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,402
  359.             DATA 225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187
  360.             DATA 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
  361.             DATA 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
  362.             DATA 240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600
  363.             DATA 211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180
  364.             DATA 173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
  365.  
  366.             'remap_KeyCode (Which, ASCII, Ctrl , Shift, Alt, AltGr, Repeat AS _FLOAT)
  367.             Remap_KeyCode 188, 44, 0, 59, 0, 0, 0.2: ',;
  368.             Remap_KeyCode 190, 46, 0, 58, 0, 0, 0.2: '.:
  369.             Remap_KeyCode 50, 50, 0, 34, 0, 0, 0.2: '2 "
  370.             Remap_KeyCode 51, 51, 0, 156, 0, 0, 0.2: '3 œ
  371.             Remap_KeyCode 191, 151, 0, 21, 0, 0, 0.2: '£ 
  372.             Remap_KeyCode 222, 133, 0, 248, 0, 35, 0.2: '… ø#
  373.             Remap_KeyCode 192, 149, 0, 128, 0, 64, 0.2: '• € @
  374.             Remap_KeyCode 186, 138, 0, 130, 0, 91, 0.2 'Š ‚ [
  375.             Remap_KeyCode 187, 43, 0, 42, 0, 93, 0.2 ' + * ]
  376.             Remap_KeyCode 54, 54, 0, 38, 0, 0, 0.2 '6 &
  377.             Remap_KeyCode 55, 55, 0, 47, 0, 0, 0.2 '7 /
  378.             Remap_KeyCode 56, 56, 0, 40, 0, 0, 0.2 '8(
  379.             Remap_KeyCode 57, 57, 0, 41, 0, 0, 0.2 '9 )
  380.             Remap_KeyCode 48, 48, 0, 61, 0, 0, 0.2 '0 =
  381.             Remap_KeyCode 219, 39, 0, 63, 0, 0, 0.2 ' ' ?
  382.             Remap_KeyCode 221, 141, 0, 94, 0, 0, 0.2 ' ^
  383.             Remap_KeyCode 226, 60, 0, 62, 0, 0, 0.2 '< >
  384.     END SELECT
  385.  

Please substitutes this SUB in the original posted by Steve and try if your keyboard layout works fine.
On my notebook using  original keyboard and USB keyboard  it is ok!
Programming isn't difficult, only it's  consuming time and coffee

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: Programmable Keyboard Input
« Reply #31 on: June 06, 2020, 02:42:28 am »
The GetKeystate function extract messages from the queue, but may be that processing the message queue is a better solution, including the traslating. See here:

https://docs.microsoft.com/en-us/windows/win32/inputdev/using-keyboard-input

Quote
MSG msg;
BOOL bRet;

while (( bRet = GetMessage(&msg, (HWND) NULL, 0, 0)) != 0)
{
    if (bRet == -1);
    {
        // handle the error and possibly exit
    }
    else
    {
        if (TranslateAccelerator(hwndMain, haccl, &msg) == 0)
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    }
}