Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest are viewing this topic.

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #14 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 Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Simulate key press, help need.
« Reply #15 on: May 29, 2006, 08:10:56 PM »
Hm hm, I was fairly sure writing SDR would not work, since I tried to play with this years ago. Ohwell.

Quote
However, how does one invoke the interrupt? Of course we can set the Intreq bit, but where do we set it from?

From the part generating the false events, naturally (joystick movement are turned into key presses and releases).
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #16 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 motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Simulate key press, help need.
« Reply #17 on: May 29, 2006, 08:26:21 PM »
If joystick movements don't generate an interrupt, then how do you check for them?

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #18 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 motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Simulate key press, help need.
« Reply #19 on: May 29, 2006, 08:51:17 PM »
So WHDLoad must already be doing this with the keyboard, right? That's how it detects the quit key. Couldn't code be added to poll the keyboard registers, and remap to keyboard events? Which joysticks are checked and which keys the map to could be specified in the tooltypes of the game.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #20 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 motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Simulate key press, help need.
« Reply #21 on: May 29, 2006, 09:04:48 PM »
I suppose you would have to insert code in to the game to make it check the joystick every frame, and then generate a keyboard interrupt. But as you said, that means re-writing the game.

I less elegant but easier solution may be to use hardware. Maybe something which connects to the keyboard interface but has joystick inputs. The hardware would translate the joystick input in to keyboard events. A passthrough would ensure you can still connect your keyboard.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #22 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 balrogsoftTopic starter

  • Full Member
  • ***
  • Join Date: Jan 2006
  • Posts: 186
    • Show only replies by balrogsoft
    • http://www.amigaskoolnet
Re: Simulate key press, help need.
« Reply #23 on: May 29, 2006, 09:36:55 PM »
Some hours offline and i found 2 pages on this topic, thanks to all, i will try to use input device and send system friendly events, i found a device example on blitz basic 2, blitz2 have commands to access AmigaOS devices, but i will take a look on my Amiga Hardware books and read about keyboard interrupts. Thanks to all, very interesting reading.
Balrog Software · http://www.amigaskool.net
Mac Mini G4 1,5ghz · MorphOS 2.7 · Ati Radeon 9200 64Mb · 1 Gb RAM · 80 GB HD
Efika · MorphOS 2.7 · Ati Radeon 9250 128Mb · 120 Gb WD HD
Amiga 1200T · OS 3.9 · Voodoo3 · Blizzard 603e/240mhz 060/50mhz · 98 Mb RAM · 40 GB HD
Amiga 600 · OS 3.1 · ACA 630/25mhz 32 Mb RAM · 4Gb CF
 

Offline motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Simulate key press, help need.
« Reply #24 on: May 29, 2006, 09:49:47 PM »
@Tricky
Of course, you would need some way of changing the mappings for different games. Maybe the interface would wait for an unusual key combination (maybe all of the F keys simultaneously), at which point it would enter a programming mode. You would then press the keys on the keyboard (in a set order) which you want to map to up/down/left/right/fire.

You could even have software which has presets for different games, so you just select the game you want from a list, and the software simulates pressing all of the F keys to put the interface in to programming mode, then simulates pressing the correct keys for that game. The application should be controllable by the command line so it can be included in a script when launching the game.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #25 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 motorollin

  • Hero Member
  • *****
  • Join Date: Nov 2005
  • Posts: 8669
    • Show only replies by motorollin
Re: Simulate key press, help need.
« Reply #26 on: May 29, 2006, 10:05:24 PM »
Quote
Tricky wrote:
@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.

Good point... simulating a keypress wouldn't be the same as pressing the key (which could be detected by the device).

Quote
Tricky wrote:
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.

That would work, but you couldn't automate it through software. Maybe the device could connect to the parallel port and receive its mappings that way.

--
moto
Code: [Select]
10  IT\'S THE FINAL COUNTDOWN
20  FOR C = 1 TO 2
30     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NAAAA
40     DA-NA-NAAAA-NAAAA DA-NA-NA-NA-NA-NA-NAAAAA
50  NEXT C
60  NA-NA-NAAAA
70  NA-NA NA-NA-NA-NA-NAAAA NAAA-NAAAAAAAAAAA
80  GOTO 10
 

Offline Tricky

  • Full Member
  • ***
  • Join Date: Aug 2005
  • Posts: 127
    • Show only replies by Tricky
    • http://www.jigsawlounge.co.uk/kungfu/
Re: Simulate key press, help need.
« Reply #27 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.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Simulate key press, help need.
« Reply #28 on: May 29, 2006, 10:32:29 PM »
Quote
I less elegant but easier solution may be to use hardware.

hardware solution

/me runs ;-)
 

Offline balrogsoftTopic starter

  • Full Member
  • ***
  • Join Date: Jan 2006
  • Posts: 186
    • Show only replies by balrogsoft
    • http://www.amigaskoolnet
Re: Simulate key press, help need.
« Reply #29 from previous page: May 30, 2006, 08:52:48 AM »
A few questions more, as i understand the main problem to use keyboard interrupt is that joystick don't generate a interrupt, when i send an event to keyboard using input.device, it will call keyboard interrupt? And if we put something on the keyboard to have a key continously pressed? then the interrupt will be called, then you can overwrite the interrupt and read joystick, and put the key that we want to simulate. I don't know if it will work... I saw also a note on Amiga hardware reference saying that you can't use $BFEC01 address, that is the serial input connected to keyboard, it says that hardware is using continously.
Balrog Software · http://www.amigaskool.net
Mac Mini G4 1,5ghz · MorphOS 2.7 · Ati Radeon 9200 64Mb · 1 Gb RAM · 80 GB HD
Efika · MorphOS 2.7 · Ati Radeon 9250 128Mb · 120 Gb WD HD
Amiga 1200T · OS 3.9 · Voodoo3 · Blizzard 603e/240mhz 060/50mhz · 98 Mb RAM · 40 GB HD
Amiga 600 · OS 3.1 · ACA 630/25mhz 32 Mb RAM · 4Gb CF