GideonZ / 1541ultimate

Official GIT archive of 1541 ultimate II sources
GNU General Public License v3.0
174 stars 45 forks source link

Features: USB HID: Mouse + Gamepad Controller + Bluetooth adapter #171

Open HVR88 opened 4 years ago

HVR88 commented 4 years ago

Couldn't find any mention of these subjects here in the issues tracked, closed or open.

Support current/standard USB mice on U64's USB port(s).

Support USB HID game controller on U64's USB port(s).

Support USB Bluetooth adapter on U64's USB port(s) - with HID mouse and game controller support (able to be extended by third parties in the future for non-HID or proprietary schemes)

GideonZ commented 4 years ago

Support current/standard USB mice on U64's USB port(s).

Not yet supported. I will need to understand how the mice work in order to emulate them. Will only work on U64, not on U2/U2+.

Support USB HID game controller on U64's USB port(s).

Not yet supported. Will be supported as soon as I have a decent HID driver. Will only work on U64, not on U2/U2+.

Support USB Bluetooth adapter on U64's USB port(s) - with HID mouse and game controller support (able to be extended by third parties in the future for non-HID or proprietary schemes)

Will never be supported. USB Bluetooth drivers are incredibly complex.

HVR88 commented 4 years ago

Sounds great!

Sorry, I should have been more clear, HID Bluetooth adapter - which doesn't require a bluetooth driver/stack - just to confirm it works once HID keyboard, mouse and controllers are supported. The adapter should look to the software as any of the other HID devices (or composite of two or more).

markusC64 commented 4 years ago

I have just found the following information on how mice work on C64:

Proportional mode

The proportional mode requires a special driver program in machine language to develop its full performance. The mouse works as follows:

Every movement is registered within the mouse. The current position is transmitted modulo 64 every 512 microseconds to the SID registers POTX (for the x-position) and POTY (for the y-position) without the need for any software.
Register assignment:

    Bit position   7  6   5   4   3   2   1  0
    POT register X P5 P4 P3 P2 P1 P0 N 

    with:

X ....... not used bit P5-P0... Mouse position modulo 64 N ....... special (noise) bit

The left mouse button is connected like a joystick fire button.
The right mouse button is connected to the contact for the upward direction of the joystick.
p2mate commented 4 years ago

https://github.com/svofski/mouse1351 is a ps/2 to 1351 adapter with source code (running on atmega8). I think this explains quite well how the 1351 works. The trick is to be able to manipulate the paddle inputs. I have no idea how to do that though :)

GideonZ commented 4 years ago

That would be very easy. I'll just have a mouse-emulation register and multiplex it with the paddle input logic?

p2mate commented 4 years ago

Well paddle registers + whatever is needed to make the buttons work. But the buttons are just joystick inputs.

GideonZ commented 4 years ago

So I am not limited to interfacing with the SID analog input. :) I do, however, need to stick to the 512-cycle timing. I could have a look at the Atmega8 code; but that would be then mainly for the HID side. I prefer to use the HID specification.

p2mate commented 4 years ago

The reason I posted the link the the Atmega8 code is to help understanding how the 1351 works. I didn't mean to suggest the U64 implementation should be the same as long as the implementation interacts with software written for the 1351. Coming to think of it, what would software would be used with this 1351 emulation? GEOS?

p2mate commented 4 years ago

And yes, using USB HID for the mouse input is a good idea. PS/2 mice are kind of obsolete by now :) and dongles to use them on USB are cheap, if you would want to use one.

Zibri commented 1 year ago

How about connecting one or two playstation 2 gamepad to the u2+ and use it on the c64? I think the cartridge could do that? Why did you say only on u64 and not u2+??

GideonZ commented 1 year ago

How about connecting one or two playstation 2 gamepad to the u2+ and use it on the c64? I think the cartridge could do that? Why did you say only on u64 and not u2+??

Because the U2+ cannot disable the CIA maybe? I thought that would be quite obvious.