Results 1 to 15 of 15

Thread: Time now for a stupid question.

  1. #1

    Thread Starter
    Lively Member Zero's Avatar
    Join Date
    Feb 2000
    Posts
    101

    Time now for a stupid question.

    I've been trying to write a SNES pad driver in Visual Basic. As you are probably aware, Visual Basic is slow. Yes, my driver program works, but if there is anything using any remote amount of processing power (like, I don't know, the game I'm trying to use it in?) the thing slows down to the point where control is impossible.

    Now, my program wouldn't be too bad if it just had to watch the parallel port (where my hotwired SNES pad is) for input - But you have to manually poll the stupid thing several times a second (a real SNES does 60, one poll for each frame drawn on the screen). This is great, except my polling gets slowed down considerably by whatever other programs are running.

    Winding around to my question: I'm thinking about rewriting my program in C++. This will be the first useful program I've ever written in C. Thus, can this be done in C? Will I have to do something fancy with threads and whatnot to get the polling speed I need? I'm not going to go for the full 60 hz. polling. Maybe 30 would be nice. Does anyone have any comments? Suggestions? Polite notifications that this idea is impossible and cannot be done, C or no C?

    ~Zero the Inestimable

  2. #2
    Zaei
    Guest
    Well, considering that C/C++ is oh, 50+ times as fast as VB, of course it is possible.

    Z.

  3. #3
    Megatron
    Guest
    About 2 years ago, I did some experiments and C++ proved to be several hunderd times faster

  4. #4
    Zaei
    Guest
    Well, that fits in the range of "50+" =P.

    Z.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Threads would be a good idea. Your primary thread (the one running main or WinMain) spawns off a worker thread that runs at 30Hz (use a multimedia timer) and calls a callback function when that happens.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  6. #6

    Thread Starter
    Lively Member Zero's Avatar
    Join Date
    Feb 2000
    Posts
    101

    Stupid question, round two:

    Alright then. Now, does anyone know off the top of their heads a good way to simulate key presses (real key presses, not that pansy VB SendKeys kind of thing) in C++?

    ~Zero the Inestimable

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    keybd_event
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  8. #8
    Megatron
    Guest
    What do you consider "real" keypressing. SendKeys is "real" keypressing.

    The equivilent in C++ could be sending the WM_KEYDOWN message, the keybd_event() function (as kedaman mentioned), and the SetKeyboardState() function.

  9. #9
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    keybd_event is closest related The thing about Sendkeys is that it's hard to send specific keycodes, it's more ascii-related and you can't control states either. Shortly, it sucks.

    with keybd_event you can set the up/down and Lock/unlock state on any key specifically. SetKeyboardState does this for all keys simulateously, so unless you really need to do a reset or something you need to use it in conjunction with GetKeyboardState, so not usefull for most cases. WM_KEYDOWN's and WM_KEYUP's need target window handle explicitely. Usefull if you need to send keys to a specific window without switching focus.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  10. #10
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    This sounds intresting, using the snes pad, i have one lol, but it sounds freakishly fun what ur doing, u have turned ur snes pad plug into one that works on a pc right ?

  11. #11
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Ok, but then for the application (sos if there is one in the zip, ent opened it yet). ???

  12. #12

    Thread Starter
    Lively Member Zero's Avatar
    Join Date
    Feb 2000
    Posts
    101

    ...

    I haven't finished the app yet, y'see. The Zip just has a word document with some diagrams and stuff that tell you how to convert the controller.

    You can the SNES controller in ZSNES and a few other emulators without a driver app, though.

    ~Zero the Inestimable

  13. #13
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    ok, my bro is going to do it with his snes pad, he also has a turbo pad, any work on that perhaps ???? have u done ???

    Im getting the bits this Thursday and then im gonna work on it we already have emulators going
    Last edited by PsyVision; Aug 6th, 2001 at 12:49 PM.

  14. #14

    Thread Starter
    Lively Member Zero's Avatar
    Join Date
    Feb 2000
    Posts
    101

    ...

    It will work with any SNES controller. Even that bazooka thing, even though nothing supports it...

    I have used normal, arcade style, and turbo controllers with no problems.

    ~Zero the Inestimable

  15. #15
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    Yeah, we have the bazooka light gun, the arcade style pad, the orignal pad and the competition pro pad And three games for the bazooka thing (plus ofcourse other ones )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width