29 January 2016, 00:45 | #1 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Virtual mouse
This is a side project for JOTD's CD32Load utility.
What I've got currently working at the moment is, if you have a joystick plugged into the mouse port, you can move the cursor around (tested in emulator, not on real hardware just yet). This is achieved by simply writing to JOYTEST ($DFF036), which sets the top six bits of both bytes for both JOY0DAT and JOY1DAT. Since the bottom two bits are ignored, it doesn't necessarily interfere with joystick control. But there are a number of caveats, I figured the requests below were impossible but I thought I should ask: - You can move the cursor on gamepad two but I haven't worked out a way to set the left/right mouse button states. Is there a way this could be done? - Since the bottom two bits can't be set, precision is limited (minimum move of four pixels?). Are there alternatives to JOYTEST that could be used? |
29 January 2016, 06:05 | #2 |
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
If I am not mistaken, you are trying to poke the hardware registers live in order to fool the currently running program (OS, or else) that what is connected in the mouse port is really a mouse even though it is actually a digital joystick. Is this correct?
This would be why you are resetting the mouse counters to 0, because joystick data generally causes them to behave completely randomly. But I still do not understand what you mean by "move the cursor on gamepad two". Also, setting the left/right mouse button states forcefully implies to set these two lines (6 and 9 respectively) as output and that is definitely not something you want to be doing while a joystick or mouse is plugged in the port. I am not too sure what you are trying to do but I would think that you would be better off intercepting the data at a higher level. |
29 January 2016, 06:32 | #3 | |||||
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Quote:
Quote:
Quote:
Quote:
Quote:
If it helps illustrate what I'm up to, here's the main portion of my code so far (I'm extremely new to ASM, so apologies if my coding is terrible!) Code:
JOY0DAT EQU $DFF00A JOY1DAT EQU $DFF00C JOYTEST EQU $dff036 MOVEAMOUNT EQU $4 ;Bottom two bits of each byte aren't recognised by JOYTEST, hence you can't make smaller moves than 4 pixels vm_testright ;Get the current mouse data move.w JOY0DAT,D1 move.w D1,D2 lsr #8,D2 BTST #JPB_BTN_RIGHT,D0 beq vm_testleft add.b #MOVEAMOUNT,D1 vm_testleft BTST #JPB_BTN_LEFT,D0 beq vm_testup sub.b #MOVEAMOUNT,D1 vm_testup BTST #JPB_BTN_UP,D0 beq vm_testdown sub.b #MOVEAMOUNT,D2 vm_testdown BTST #JPB_BTN_DOWN,D0 beq vm_done add.b #MOVEAMOUNT,D2 vm_done lsl #8,D2 move.b D1,D2 move.w D2,JOYTEST |
|||||
29 January 2016, 08:09 | #4 | ||||
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
Quote:
Quote:
Not using output mode is the most common reason for 2nd button not working with some pads (those that don't have internal pullup resistor) Quote:
Output mode should always read back same value (if nothing is connected) that was written unless someone else modifies either bit (data or direction) Quote:
|
||||
29 January 2016, 08:31 | #5 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Thanks for the clarification
What bits do I write to which registers? Bit 10 on the POTGO for rmb and Bit 6 on the CIAADDRA to set to output mode? |
29 January 2016, 13:54 | #6 | ||
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
Quote:
Quote:
I did indeed notice that the HRM mentioned that setting output mode would trigger pull-up or pull-down depending on the set bit value which is logical but I understood that this meant the joystick was responsible for using +5V to provide pull-up for the input lines when input mode. I guess this was not how the Atari joystick protocol worked though so they could not expect existing joysticks to do that. Still, it is weird to call this output mode when the Amiga is the one reading the lines. Naming it "Driven" mode would have been less confusing for my inner kitten. |
||
29 January 2016, 14:04 | #7 |
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
|
29 January 2016, 14:06 | #8 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Ok, I'm embarrassed - I think I've worked it out for left mouse button (below) but I can't work it out for right mouse button. This is what I'm trying, please let me know where I've messed up
Init code: BSET #6, CIAADDRA BSET #11-8, POTGO Simulate left mouse down: BCLR #6, CIAAPRA Simulate left mouse not down: BSET #6, CIAAPRA Simulate right mouse down: BCLR #10-8, POTGO Simulate right mouse not down: BSET #10-8, POTGO |
29 January 2016, 14:12 | #9 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
|
29 January 2016, 14:33 | #10 |
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
I am sure there a few which do but mine certainly will.
The POTGO bits 11 and 9 must be set to 1 to set pins 9 and 5 (bits 10 and 8) as output. Cf http://amigadev.elowar.com/read/ADCD.../node018B.html. So, set bits 11 and 9 to 1, then set 10 and 8 to the value desired for the buttons. Edit: Aside from your original BSET 11-8, this seems to be what you are doing though. Strange. Last edited by ReadOnlyCat; 29 January 2016 at 14:42. |
29 January 2016, 14:41 | #11 | |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Quote:
|
|
29 January 2016, 15:30 | #12 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,534
|
I hope POTGO is memory address, not a custom register for obvious reasons..
|
29 January 2016, 18:43 | #13 |
This cat is no more
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,302
|
Obvious for Toni
you cannot BSET POTGO since it implies read & write. Read POTGOR, mask and write to POTGO. |
29 January 2016, 19:03 | #14 |
Code Kitten
Join Date: Aug 2015
Location: Montreal/Canadia
Age: 52
Posts: 1,178
|
Good catch, could explain it indeed.
My brain automatically assumed that the BSET was a logical simplification and not an actual instruction. |
29 January 2016, 20:18 | #15 |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Whoops!
Unfortunately there's still a roadblock that I don't think I can work around. The game itself (using Lemmings to test with) sets the POTGO back to it's own value every frame, so it looks like it's not going to work thanks anyway guys |
29 January 2016, 22:05 | #16 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,789
|
earok your onto something
|
18 March 2016, 20:11 | #17 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 472
|
@earok
I don't really understand what this is all about. Do you try to move the mousepointer with a game pad in port 0 or move the mousepointer with a mouse in port 1 or all at the same time?? Anyway good luck! :-) |
18 March 2016, 20:19 | #18 |
Registered User
Join Date: May 2001
Location: ?
Posts: 19,646
|
|
18 March 2016, 20:48 | #19 |
Registered User
Join Date: Oct 2014
Location: Europe
Posts: 472
|
|
18 March 2016, 21:13 | #20 | |
Registered User
Join Date: Dec 2013
Location: Auckland
Posts: 3,543
|
Quote:
I later found out what I did is basically the same approach as what the CD32 ROM does to enable gamepad support on Lemmings CDTV! |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
MOUSE ADAPTER MADNESS! Less than half price PS/2 mouse adapters! | Mounty | MarketPlace | 6 | 01 September 2015 21:47 |
Mouse mat to lower optical mouse sensitivity? | Bamiga2002 | support.Hardware | 7 | 22 March 2013 07:35 |
Magic mouse/virtual mouse driver issues | mark_k | support.WinUAE | 2 | 04 December 2012 20:43 |
AMIGA MOUSE == Any 9 PIN Serial Mouse ????? | megajetman | support.Hardware | 15 | 26 April 2012 13:51 |
A4000, mouse clicks, no mouse move, no keyboard | OverDose | support.Hardware | 4 | 16 March 2011 13:25 |
|
|