Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Any possible ideas/plans for a keyboard handler in FB?
#1
Dearest all of you fine QB45/QB71/FB community:

Konnichiwa!!! (That means “Hello” in Japanese.) Big Grin !

Kicking this off, I can remember right up front that there were keyboard handlers for QBasic/QuickBASIC that were so extremely useful for game programming and stuff, mainly due to the fact that when you press/hold a key, your character(s) just simply moved and kept going and going and going rather instead of that syndrome of “step, stop, and go” on the characters, which can grow very mundane and tiresome to at least some people, you know?

The three (3) examples in QB based on what I am talking about in this are:
_______________________________________________
  • • Multikey
    Authors: Joe Huber and Milo Sedlacek

    • Z-Keyboard Handler
    Authors: Greg McAusland and Christopher Neill of Exposed Dreams

    • QBMKEY
    Author: Toshi Horie
_______________________________________________

And, the QB-created games that I simply know of that had their keyboard handlers successfully implemented were Mono Space, Wetspot II, and the continually-developing Frantic Journey to name just a few. Wink=b

So, with all of that in mind now, do any of you people have a fresh idea or more for building some sort of keyboard handler like that in FreeBasic? All plans and suggestions pertaining to this topic are *most* welcome!! And, any lib at all presented in FB that has a built-in keyboard handler is also allowed in this topic, too! ^_^ !

Well, I thank you all so very much for your wonderful time and consideration. Talk to you soon. :king:



WITH SUCH BRIGHT SUCCESS TO YOU,

[Image: AAPname.gif]
Adigun Azikiwe Polack
One of the Founders of “Aura Flow”
Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger”
Webmaster of the “AAP Official Projects Squad”
url=http://dhost.hopto.org/aapproj/][Image: file.php?id=194][/url]
Your *official* home of the FreeBasic GFX Demo Central, now holding over 150 FB graphics demos so far!!! Big Grin !
Reply
#2
FB can use popular libraries that already exist for windows and such. GetKeyState has been added to the Windows API routiens that come with FB, but I'm not sure if it has been released yet. SDL is also a popular library that contains keyboard routiens.
Reply
#3
it's not too hard to use sdl's commands, and i'm not sure, but since qbgfx4fb uses sdl, wouldn't you be able to use sdl's routines as well? Why not just use sdl's getkeystate command? Just use sdlkeyb.bi as a reference.
Jumping Jahoolipers!
Reply
#4
Quote:and i'm not sure, but since qbgfx4fb uses sdl, wouldn't you be able to use sdl's routines as well?
Yep.
Reply
#5
To Barok:

So far, I am gonna agree with Sterling here, man. Smile=b And you know something, while I haven’t as of yet experienced FB programming for myself (though I would *really* love to do so someday, ESPECIALLY with Sterling’s own lib already out and an FB version of Rellib waiting in the wings here! Wink ), I have just looked at the file “sdlkeyb.bi” recently at the time that I am writing this message here. Just for reference reasons, here now is some code that I discovered from that file in one of the original FB builds showing the actual constants of the keyboard scan-codes:

Code:
    const SDLK_UNKNOWN        = 0
    const SDLK_FIRST        = 0
    const SDLK_BACKSPACE        = 8
    const SDLK_TAB        = 9
    const SDLK_CLEAR        = 12
    const SDLK_RETURN        = 13
    const SDLK_PAUSE        = 19
    const SDLK_ESCAPE        = 27
    const SDLK_SPACE        = 32
    const SDLK_EXCLAIM        = 33
    const SDLK_QUOTEDBL        = 34
    const SDLK_HASH        = 35
    const SDLK_DOLLAR        = 36
    const SDLK_AMPERSAND        = 38
    const SDLK_QUOTE        = 39
    const SDLK_LEFTPAREN        = 40
    const SDLK_RIGHTPAREN        = 41
    const SDLK_ASTERISK        = 42
    const SDLK_PLUS        = 43
    const SDLK_COMMA        = 44
    const SDLK_MINUS        = 45
    const SDLK_PERIOD        = 46
    const SDLK_SLASH        = 47
    const SDLK_0            = 48
    const SDLK_1            = 49
    const SDLK_2            = 50
    const SDLK_3            = 51
    const SDLK_4            = 52
    const SDLK_5            = 53
    const SDLK_6            = 54
    const SDLK_7            = 55
    const SDLK_8            = 56
    const SDLK_9            = 57
    const SDLK_COLON        = 58
    const SDLK_SEMICOLON        = 59
    const SDLK_LESS        = 60
    const SDLK_EQUALS        = 61
    const SDLK_GREATER        = 62
    const SDLK_QUESTION        = 63
    const SDLK_AT            = 64
    const SDLK_LEFTBRACKET    = 91
    const SDLK_BACKSLASH        = 92
    const SDLK_RIGHTBRACKET    = 93
    const SDLK_CARET        = 94
    const SDLK_UNDERSCORE        = 95
    const SDLK_BACKQUOTE        = 96
    const SDLK_a            = 97
    const SDLK_b            = 98
    const SDLK_c            = 99
    const SDLK_d            = 100
    const SDLK_e            = 101
    const SDLK_f            = 102
    const SDLK_g            = 103
    const SDLK_h            = 104
    const SDLK_i            = 105
    const SDLK_j            = 106
    const SDLK_k            = 107
    const SDLK_l            = 108
    const SDLK_m            = 109
    const SDLK_n            = 110
    const SDLK_o            = 111
    const SDLK_p            = 112
    const SDLK_q            = 113
    const SDLK_r            = 114
    const SDLK_s            = 115
    const SDLK_t            = 116
    const SDLK_u            = 117
    const SDLK_v            = 118
    const SDLK_w            = 119
    const SDLK_x            = 120
    const SDLK_y            = 121
    const SDLK_z            = 122
    const SDLK_DELETE        = 127
    const SDLK_WORLD_0        = 160
    const SDLK_WORLD_1        = 161
    const SDLK_WORLD_2        = 162
    const SDLK_WORLD_3        = 163
    const SDLK_WORLD_4        = 164
    const SDLK_WORLD_5        = 165
    const SDLK_WORLD_6        = 166
    const SDLK_WORLD_7        = 167
    const SDLK_WORLD_8        = 168
    const SDLK_WORLD_9        = 169
    const SDLK_WORLD_10        = 170
    const SDLK_WORLD_11        = 171
    const SDLK_WORLD_12        = 172
    const SDLK_WORLD_13        = 173
    const SDLK_WORLD_14        = 174
    const SDLK_WORLD_15        = 175
    const SDLK_WORLD_16        = 176
    const SDLK_WORLD_17        = 177
    const SDLK_WORLD_18        = 178
    const SDLK_WORLD_19        = 179
    const SDLK_WORLD_20        = 180
    const SDLK_WORLD_21        = 181
    const SDLK_WORLD_22        = 182
    const SDLK_WORLD_23        = 183
    const SDLK_WORLD_24        = 184
    const SDLK_WORLD_25        = 185
    const SDLK_WORLD_26        = 186
    const SDLK_WORLD_27        = 187
    const SDLK_WORLD_28        = 188
    const SDLK_WORLD_29        = 189
    const SDLK_WORLD_30        = 190
    const SDLK_WORLD_31        = 191
    const SDLK_WORLD_32        = 192
    const SDLK_WORLD_33        = 193
    const SDLK_WORLD_34        = 194
    const SDLK_WORLD_35        = 195
    const SDLK_WORLD_36        = 196
    const SDLK_WORLD_37        = 197
    const SDLK_WORLD_38        = 198
    const SDLK_WORLD_39        = 199
    const SDLK_WORLD_40        = 200
    const SDLK_WORLD_41        = 201
    const SDLK_WORLD_42        = 202
    const SDLK_WORLD_43        = 203
    const SDLK_WORLD_44        = 204
    const SDLK_WORLD_45        = 205
    const SDLK_WORLD_46        = 206
    const SDLK_WORLD_47        = 207
    const SDLK_WORLD_48        = 208
    const SDLK_WORLD_49        = 209
    const SDLK_WORLD_50        = 210
    const SDLK_WORLD_51        = 211
    const SDLK_WORLD_52        = 212
    const SDLK_WORLD_53        = 213
    const SDLK_WORLD_54        = 214
    const SDLK_WORLD_55        = 215
    const SDLK_WORLD_56        = 216
    const SDLK_WORLD_57        = 217
    const SDLK_WORLD_58        = 218
    const SDLK_WORLD_59        = 219
    const SDLK_WORLD_60        = 220
    const SDLK_WORLD_61        = 221
    const SDLK_WORLD_62        = 222
    const SDLK_WORLD_63        = 223
    const SDLK_WORLD_64        = 224
    const SDLK_WORLD_65        = 225
    const SDLK_WORLD_66        = 226
    const SDLK_WORLD_67        = 227
    const SDLK_WORLD_68        = 228
    const SDLK_WORLD_69        = 229
    const SDLK_WORLD_70        = 230
    const SDLK_WORLD_71        = 231
    const SDLK_WORLD_72        = 232
    const SDLK_WORLD_73        = 233
    const SDLK_WORLD_74        = 234
    const SDLK_WORLD_75        = 235
    const SDLK_WORLD_76        = 236
    const SDLK_WORLD_77        = 237
    const SDLK_WORLD_78        = 238
    const SDLK_WORLD_79        = 239
    const SDLK_WORLD_80        = 240
    const SDLK_WORLD_81        = 241
    const SDLK_WORLD_82        = 242
    const SDLK_WORLD_83        = 243
    const SDLK_WORLD_84        = 244
    const SDLK_WORLD_85        = 245
    const SDLK_WORLD_86        = 246
    const SDLK_WORLD_87        = 247
    const SDLK_WORLD_88        = 248
    const SDLK_WORLD_89        = 249
    const SDLK_WORLD_90        = 250
    const SDLK_WORLD_91        = 251
    const SDLK_WORLD_92        = 252
    const SDLK_WORLD_93        = 253
    const SDLK_WORLD_94        = 254
    const SDLK_WORLD_95        = 255        
    const SDLK_KP0        = 256
    const SDLK_KP1        = 257
    const SDLK_KP2        = 258
    const SDLK_KP3        = 259
    const SDLK_KP4        = 260
    const SDLK_KP5        = 261
    const SDLK_KP6        = 262
    const SDLK_KP7        = 263
    const SDLK_KP8        = 264
    const SDLK_KP9        = 265
    const SDLK_KP_PERIOD        = 266
    const SDLK_KP_DIVIDE        = 267
    const SDLK_KP_MULTIPLY    = 268
    const SDLK_KP_MINUS        = 269
    const SDLK_KP_PLUS        = 270
    const SDLK_KP_ENTER        = 271
    const SDLK_KP_EQUALS        = 272
    const SDLK_UP            = 273
    const SDLK_DOWN        = 274
    const SDLK_RIGHT        = 275
    const SDLK_LEFT        = 276
    const SDLK_INSERT        = 277
    const SDLK_HOME        = 278
    const SDLK_END        = 279
    const SDLK_PAGEUP        = 280
    const SDLK_PAGEDOWN        = 281
    const SDLK_F1            = 282
    const SDLK_F2            = 283
    const SDLK_F3            = 284
    const SDLK_F4            = 285
    const SDLK_F5            = 286
    const SDLK_F6            = 287
    const SDLK_F7            = 288
    const SDLK_F8            = 289
    const SDLK_F9            = 290
    const SDLK_F10        = 291
    const SDLK_F11        = 292
    const SDLK_F12        = 293
    const SDLK_F13        = 294
    const SDLK_F14        = 295
    const SDLK_F15        = 296
    const SDLK_NUMLOCK        = 300
    const SDLK_CAPSLOCK        = 301
    const SDLK_SCROLLOCK        = 302
    const SDLK_RSHIFT        = 303
    const SDLK_LSHIFT        = 304
    const SDLK_RCTRL        = 305
    const SDLK_LCTRL        = 306
    const SDLK_RALT        = 307
    const SDLK_LALT        = 308
    const SDLK_RMETA        = 309
    const SDLK_LMETA        = 310
    const SDLK_LSUPER        = 311        
    const SDLK_RSUPER        = 312        
    const SDLK_MODE        = 313        
    const SDLK_COMPOSE        = 314        
    const SDLK_HELP        = 315
    const SDLK_PRINT        = 316
    const SDLK_SYSREQ        = 317
    const SDLK_BREAK        = 318
    const SDLK_MENU        = 319
    const SDLK_POWER        = 320
    const SDLK_EURO        = 321
    const SDLK_UNDO        = 322
    const SDLK_LAST   = 323


    const KMOD_NONE  = &H0000,
    const KMOD_LSHIFT= &H0001,
    const KMOD_RSHIFT= &H0002,
    const KMOD_LCTRL = &H0040,
    const KMOD_RCTRL = &H0080,
    const KMOD_LALT  = &H0100,
    const KMOD_RALT  = &H0200,
    const KMOD_LMETA = &H0400,
    const KMOD_RMETA = &H0800,
    const KMOD_NUM   = &H1000,
    const KMOD_CAPS  = &H2000,
    const KMOD_MODE  = &H4000,
    const KMOD_RESERVED = &H8000
    const KMOD_CTRL = KMOD_LCTRL or KMOD_RCTRL
    const KMOD_SHIFT = KMOD_LSHIFT or KMOD_RSHIFT
    const KMOD_ALT = KMOD_LALT or KMOD_RALT
    const KMOD_META = KMOD_LMETA or KMOD_RMETA
    
    const SDL_ALL_HOTKEYS = &HFFFFFFFF
    const SDL_DEFAULT_REPEAT_DELAY = 500
    const SDL_DEFAULT_REPEAT_INTERVAL = 30

WHOA, talk about quite a mouthful there, that code! :o ! But seriously though, it is at least pretty fascinating to look at as an idea for an *awesome* custom keyboard handler if I do say so myself, Barok! Cool

(And to the rest of you people, you might want to take a closer look at that same code here as an inspiration piece in this topic, even for those of you especially willing to try FB out for the first time yourselves! ;*) )



And to Sterling and Jofers:

If you both and/or anyone else have already tested the built-in keyboard routines in the file “sdlkeyb.bi” on FB, could some of you please show us the stats of how well its handler has fared, just to give some ideas on making sure it is at the caliber of the three QB keyboard handler routines that I gave you the names of from the top of this thread? It would be much appreciated, and thanks so much!! Big Grin



I will be seeing you all later, Barok, Sterling, Jofers, and I like your ideas on this very much. Wink !



[Image: AAPname.gif]
- Adigun Azikiwe Polack
One of the Founders of “Aura Flow”
Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger”
Webmaster of the “AAP Official Projects Squad”
url=http://dhost.hopto.org/aapproj/][Image: file.php?id=194][/url]
Your *official* home of the FreeBasic GFX Demo Central, now holding over 150 FB graphics demos so far!!! Big Grin !
Reply
#6
Quote:FB can use popular libraries that already exist for windows and such. GetKeyState has been added to the Windows API routiens that come with FB, but I'm not sure if it has been released yet. SDL is also a popular library that contains keyboard routiens.
I released a version of user32.bi that included GetKeyState as well as all the constants it uses. The original user32.bi comes with GetAsyncKeyState, which operates slightly differently. I'm about half done with the final conversion of user32.bi, I should be able to release it in a few days and hopefully v1ctor can make it an official part of the FB project.
I'd knock on wood, but my desk is particle board.
Reply
#7
To Adosorken:

Very good. Wink Look, as soon as you do release your latest conversion of “user32.bi”, I would like some clear stats on it (based on what the latter part of my previous post is talking about on seeing how well its keyboard handler does), okay now? Thanks so much! Big Grin

You know what, I wanna wish both you and v3cz0r excellently well on making it one of the best quality keyboard handlers there ever is in FB just like Multikey successfully did for QB! Cool=b



[Image: AAPname.gif]
- Adigun Azikiwe Polack
One of the Founders of “Aura Flow”
Continuing Developer of “Frantic Journey”
Current Developer of “Star Angelic Slugger”
Webmaster of the “AAP Official Projects Squad”
url=http://dhost.hopto.org/aapproj/][Image: file.php?id=194][/url]
Your *official* home of the FreeBasic GFX Demo Central, now holding over 150 FB graphics demos so far!!! Big Grin !
Reply
#8
Uhh...GetKeyState and GetAsyncKeyState are native win32 API calls, aka they're already built into Windows. And for the record, the final conversion of user32.bi should be done in a couple of days. I've found a few API calls to which there's no documentation or examples, neither in winuser.h, the msdn, or anything on google. I'd say it's safe to assume that these few functions aren't really needed for user applications and are probably only used within the OS itself. But I don't know that for sure either.
I'd knock on wood, but my desk is particle board.
Reply
#9
AAP: SDL_GetKeyState is like multikey

Code:
dim k as ubyte ptr

k = SDL_GetKeyState(0)

if Peek(K + SDLK_UP) then
   'Do up
end if
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)