Shop OBEX P1 Docs P2 Docs Learn Events
P2 Hosted USB Keyboard/Mouse - Page 8 — Parallax Forums

P2 Hosted USB Keyboard/Mouse

1234568»

Comments

  • RossHRossH Posts: 5,770
    edited 2026-05-30 08:16

    I'm looking for any version of the 1CogKbM driver that works with any version of a Spin2 compiler. Can anyone point me to a combination of driver and compiler that works together? I've tried every combination I can find, and by messing around with the code I can usually make it compile, and (usually) get the start-up banner to appear -so I know it is compiling, loading and executing. But none of my attempts seem to get any further. And Spin2 does my head in :(

    I'm using a P2 Eval board, which I know used to work with this driver, but I can't seem to find the right combination of driver version and Spin2 compiler any more.

    Any assistance would be appreciated.

    Ross.

  • RaymanRayman Posts: 16,445
    edited 2026-05-30 10:41

    USBNew is good. I mainly use it for game controllers.

    For keyboards and mice, still using a modification of the old version...

    There are variations on this that let you not use the enable pin and not use the LED pin...

    CON 'USB mouse pin settings --> Set USB keyboard basepin here!
      USB_BASE_PIN    =24'16'24'16'24'16              'led for USB activity
      USB_ENABLE_PIN  =USB_BASE_PIN+1  'Parallax adapter uses this to control USB power  (can be -1 to disable)
      USB_DM_PIN      =USB_BASE_PIN+2  'upper port on Parallax 2 port adapter
      USB_ERR_LED_PIN =USB_BASE_PIN+0 'Need to update USB driver so this can be ignored...
    
    var 'USB kbm vars
      long mx,my,MaxX,MaxY,buttons,scan1,scan2  'leave these together in this order
    
        'Start keyboard
        'Start up USB
        kbm.Start(USB_BASE_PIN, USB_ENABLE_PIN, USB_DM_PIN, USB_ERR_LED_PIN, @mx)
        'Wait for keypress
        repeat until scan1
    
  • maccamacca Posts: 1,058

    @RossH said:
    I'm looking for any version of the 1CogKbM driver that works with any version of a Spin2 compiler. Can anyone point me to a combination of driver and compiler that works together? I've tried every combination I can find, and by messing around with the code I can usually make it compile, and (usually) get the start-up banner to appear -so I know it is compiling, loading and executing. But none of my attempts seem to get any further. And Spin2 does my head in :(

    I'm using a P2 Eval board, which I know used to work with this driver, but I can't seem to find the right combination of driver version and Spin2 compiler any more.

    If it compiles and load but doesn't work maybe is some settings, like pin numbers, clock settings, etc. ?
    The original 1CogKbM driver doesn't support hubs.

    Anyway, the usb driver I have on my Github repository https://github.com/maccasoft/P2/blob/master/usb.spin2 is PASM-only so it is compiler-independent, it doesn't have a Spin interface, you need to compile and run with debug to see activity from connected devices.

    Other versions, like Ada's usbnew have a lot of preprocessor statements that are not compatible with either PNut or Spin Tools.

    Hope this helps.

  • RossHRossH Posts: 5,770

    @macca said:

    Anyway, the usb driver I have on my Github repository https://github.com/maccasoft/P2/blob/master/usb.spin2 is PASM-only so it is compiler-independent, it doesn't have a Spin interface, you need to compile and run with debug to see activity from connected devices.

    Aha! Bingo! Thanks very much!

    I already have an older version of this driver included as part of Catalina - but I discovered a few days ago that while my version works ok with hardwired keyboards, it no longer works with any of the the hardwired mice I have on hand.

    Your program confirmed that it is my mice that are the problem. The driver seems to support only a limited range of hardwired mice, and I had apparently replaced all my hardwired mice (which used to work) with ones that the 1CogKbM driver does not support - but I did not realize this until a few days ago.

    Both your driver and mine still work with my wireless mouse and keyboard, so at least I now know the problem is with the driver, and is not something I broke in my version (which was what I had feared!).

    Not sure how to fix the driver so it supports a wider variety of hardwired mice yet - but your "standalone" driver is sure to be a great help!

    Ross.

  • maccamacca Posts: 1,058

    @RossH said:
    Your program confirmed that it is my mice that are the problem. The driver seems to support only a limited range of hardwired mice, and I had apparently replaced all my hardwired mice (which used to work) with ones that the 1CogKbM driver does not support - but I did not realize this until a few days ago.

    Both your driver and mine still work with my wireless mouse and keyboard, so at least I now know the problem is with the driver, and is not something I broke in my version (which was what I had feared!).

    Not sure how to fix the driver so it supports a wider variety of hardwired mice yet - but your "standalone" driver is sure to be a great help!

    Take a look at usbnew linked above and follow the MOUSE_FULL_PROTOCOL defines, could be that you mice doesn't support the BOOT protocol.

Sign In or Register to comment.