Welcome, Guest. Please login or register.

Author Topic: Simulate key press, help need.  (Read 7379 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« on: May 29, 2006, 04:25:34 PM »
I guess you could patch the Keyboard interrupt.  A lot of non-multitasking games probably still use this, as it's the best fool-proof way to get keyboard input.  But of course that is only triggered when a key is actually pressed.  Any other interrupt, e.g. vertical blank, is liable to be turned off or replaced.

It also means writing to the CIA Serial Data Register ($BFEC01) directly, not sure how well that would work, if at all.
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #1 on: May 29, 2006, 06:47:43 PM »
@Piru

You can write to the SDR, and it will stay as written until the next keypress.  (I just tried it.)  So doing that before exiting the interrupt should spoof a keypress.

However, how does one invoke the interrupt?  Of course we can set the Intreq bit, but where do we set it from?  If we set it from the keyboard interrupt server, the computer will never execute anything other than that interrupt!
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #2 on: May 29, 2006, 08:16:15 PM »
Simply writing to SDR won't generate a keypress, of course.  You'd need to trigger the interrupt as well.  Which may well overwrite the SDR anyway doing what it does... but if you're writing to it FROM the interrupt, all should be ok.  Maybe...

Thing is though, joystick movements don't generate any interrupts, so there would be no way to make them generate the interrupt without changing the code of the non-multitasking program.  We could set a vertical blank interrupt to do it, but the game would probably turn it off to set its own.
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #3 on: May 29, 2006, 08:38:31 PM »
Quote

motorollin wrote:
If joystick movements don't generate an interrupt, then how do you check for them?

--
moto

You just read directly out of some registers, any time you need to know the state of the joystick.  Usually once a frame.
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #4 on: May 29, 2006, 08:58:20 PM »
@motorollin
I don't know how WHDLoad does it, but as mentioned earlier, it's a specific hack for each specific game, not a catch-all solution.  Someone must have spent some time figuring it out for each of the games it works on.

There is already code that polls the keyboard registers, that's what the keyboard interrupt does.  This code is called when someone presses or releases a key.  That's what I'm talking about doing, patching this interrupt (which is part of the OS, not the game) with extra code.  But there is nowhere to put code that checks the joystick, other than in that interrupt, or other than actually rewriting the game itself.  But if you put it in that interrupt, of course it will only look at the joystick when someone presses a key on the keyboard!
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #5 on: May 29, 2006, 09:13:48 PM »
@motorollin
I thought about this... it's do-able, but some task... especially if you sometimes need to configure it to use different keys.

It's just a shame 4 player games don't already work with the 4-player adapter, then we wouldn't even need to solve this problem!
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #6 on: May 29, 2006, 09:55:20 PM »
@motorollin
I don't think you can send signals right back to the keyboard itself.  I suspect it only gets back as far as the CIA chip.  To add that sort of functionality, you're going to have to start soldering things direct to your motherboard... not a nice concept.

But if you're wiring a couple extra joystick ports on it, of course you could also wire in a special "program" switch.  When that switch is on, if you press a joystick control and a key simultaneously it would assign it.
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show all replies
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #7 on: May 29, 2006, 10:10:30 PM »
Quote

motorollin wrote:
Maybe the device could connect to the parallel port and receive its mappings that way.


This is getting very silly now...
[A1200/060, 32Mb fast RAM, 1.2Gb HDD, 19\\" Acer TFT Monitor]
I never write anything that won\\\'t run on a stock A1200.  That\\\'s the Jigsaw Lounge Guarantee.