Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 09:57 10 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : hid2cdc - USB keyboard and mouse for picomite VGA

     Page 1 of 6    
Author Message
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2292
Posted: 12:56am 29 Dec 2023
Copy link to clipboard 
Print this post

after raising the idea of using a host-configured pico as an interface between a picomite VGA and USB keyboard+mouse, NoOne (the author of ps2x2pico) has created a new github project to achieve this:
https://github.com/No0ne/hid2cdc
and created a test .uf2 file here for us to try out:
https://github.com/No0ne/hid2cdc/raw/main/hid2cdc.uf2

unfortunately he has proceeded just a tad faster than i expected, so i don't really have a picomite VGA set up to test it with  

is anyone able to give the above a try? the parts should be plugged together thus:


keyboard input will be routed to the picomite's USB port as if from an attached PC, so no configuration of the picomite beyond enabling VGA should be required. i don't know if the mouse works yet (i doubt it). this is all just a proof of concept at the moment.

eventually it may also work with a CMM2, as an alternative way to connect USB mouse and keyboard.


cheers,
rob   :-)
Edited 2023-12-29 10:59 by robert.rozee
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 07:47am 29 Dec 2023
Copy link to clipboard 
Print this post

G’day Rob, All,

I only just gave a friend of mine my PicoVGA unit as he is recovering from serious illness and wanted to get into programming again.

I will try to scrounge up the time to build a PicoVGA and USB converter up to test the idea.

My issue is I think all my USB hubs are like this one




I am assuming that if I plug the lead into a USB plugpack (wall wart) then use a USB-A to micro-USB to the PicoVGA then simply plug a USB-kb (and mouse??) into the other ports that should work?

Regards

Mick



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2292
Posted: 09:20am 29 Dec 2023
Copy link to clipboard 
Print this post

the upstream port (on the flying lead) of the hub needs to connect, via an adapter, to the pico that is running usb2cdc.uf2. that pico also needs to have a 5-volt power supply feeding into VBUS (pin 40). this 5-volts is what powers the upstream pico, the hub, and all downstream devices attached to the hub.

into the downstream ports of the hub, you need to plug in:
1. a VGA picomite
2. a USB keyboard
3. a USB mouse (optional)

the VGA picomite needs to have a VGA monitor attached to see what is going on. if all is working, when a key is pressed on the USB keyboard, something should be displayed by the VGA picomite on the VGA screen... what exactly, i am not sure!


the upstream pico is effectively acting like a PC host would, the software of which:
A. reads keyboard scancodes from any attached USB keyboard, then,
B. converts those scancodes into ASCII characters (and VT escape sequences for function keys), and,
C. sends the resulting ASCII characters and VT escape sequences to any attached USB CDC serial device.

ultimately, i foresee the usb2cdc.uf2 also translating mouse movement codes received from any attached USB mouse into VT200 mouse escape sequences. this will allow a CMM2 (or PICO, with peter's consent) to have mouse functionality within the editor to the extent already supported when a terminal emulator is used.


cheers,
rob   :-)
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 09:26am 29 Dec 2023
Copy link to clipboard 
Print this post

Thanks for clearing that up Rob,

It makes sense now you think about it.  I might have to ‘bodge’ a cable as I am not sure if I have an adapter for that, if I do it’s some where in the Jurassic layer of my ‘mess pile’

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8600
Posted: 11:47am 29 Dec 2023
Copy link to clipboard 
Print this post

Based on a quick look I can't see how this (CDC) would support multiple different language keyboards which compromises its usefulness. The PS2 version might but I don't know if there is a guaranteed mapping between PS2 codes and USB scan codes
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2292
Posted: 12:29pm 29 Dec 2023
Copy link to clipboard 
Print this post

the picomote and CMM2 only 'understand' 7-bit ASCII characters, so there is no real need to accommodate anything outside of that set of 127:
a..z
A..Z
0..9
plus the usual 30 or so punctuation characters that make up the remaining slots in the ASCII table.

the major layout difference i can think of is QWERTY vs AZERTY vs QWERTZ, and i am guessing there may be a further three or four others. the difference between the above three can be resolved by asking the user to press the 'Q' key then the 'Y' key. as i recall the linux mint installer in fact offers this sort of keyboard detection as an option, with less than half a dozen keypresses needed to decide.

i'm picking function key scancodes are common across all country variants, and that the same holds for cursor keys. and we may see the odd case where shift and control keys are moved around. but to be honest, these days most of the world can be catered for with just the standard US layout.


cheers,
rob   :-)
Edited 2023-12-29 22:32 by robert.rozee
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5750
Posted: 12:53pm 29 Dec 2023
Copy link to clipboard 
Print this post

  Quote  ... these days most of the world can be catered for with just the standard US layout.


Don't let the Baltics & cyrillic countries hear you say that. They get a bit touchy about their alphabets. ;)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 01:37am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi Rob, All,

Well I have built it up and it is 75% working.

All letters and Numbers work
Esc works
Shift works
Enter (both) work
numpad works inc *-+/ but numlock does nothing
All shift Special chrs work (ie #$%^& etc)

The following keys do not seem to work

All function keys (so I cant write a test program using the kb)
CTRL
NumLock
Arrow keys dont work

I am not sure of Delete insert Home end etc

Excellent so far

I have option US keyboard and key arrangement looks good.

Regards,

Mick (the Big one)



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 02:27am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi Rob, All,

Probably as you expected, I tried Option keyboard UK instead of US and the key mapping remained the same (fixed at US layout).

A suggestion, possibly, for `No-one' is maybe use some link options on the HID2CDC GPIO pins to dictate regional mapping of the keyboard.

My brain is already kicking over with this new feature. (ie hiding a wireless dongle inside a piece of equipment).

Is it possible that this HID2CDC might ultimately support USB sticks (Hard drives even), although I suspect not as there surely is a lot of overhead for formats etc.

I will test a wireless USB keyboard and see what happens.

If you want to knock a piece of code to test what is transmitted from various keys and/or a mouse please send it to me and I will 'put it to the sword'.

Regards,

Mick



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2292
Posted: 03:48am 30 Dec 2023
Copy link to clipboard 
Print this post

excellent work mick! i have reported your success back to NoOne here:
https://github.com/No0ne/hid2cdc/issues/1

the HID2CDC pico is only lightly loaded, so it could possibly talk to other peripherals. HID devices also covers joysticks and webcams, but bear in mind that the link back to the picomite is 'dressed' as (albeit very fast) serial. this limits options a tad.

an interesting idea would be if the HID2CDC could export to the picomite some limited access to unused GPIO pins, or even provide a DVI video output running on the second core that was accessible as a VT character terminal screen. this would open up the possibility of pairing the HID2CDC with a non-VGA picomite while still having (character) video output.

mick: do you by chance have a github account?


cheers,
rob   :-)
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 03:53am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi Rob, All,

No i don't have a github account.

To be blunt, I have always been confused with github and unless a link stands out for some reason, or someone points it out to me, it takes me ages to find the `simple file or download' I want.

Not being a good programmer I don't understand the libraries and all the convolutions that code creation takes.

Why do you ask?

Regards,

Mick




.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1805
Posted: 03:57am 30 Dec 2023
Copy link to clipboard 
Print this post

  Quote  The following keys do not seem to work
All function keys (so I cant write a test program using the kb)

The F-keys are just shortcuts. Type EDIT, SAVE, RUN etc.
Don't know about Cut, Copy, Paste within the editor.

Edit P15 "Full Screen Editor"
  Quote  You can also use control keys instead of the function keys listed above. These control keystrokes are:
LEFT Ctrl-S RIGHT Ctrl-D UP Ctrl-E DOWN Ctrl-X
HOME Ctrl-U END Ctrl-K PageUp Ctrl-P PageDn Ctrl-L
DEL Ctrl-] INSERT Ctrl-N F1 Ctrl-Q F2 Ctrl-W
F3 Ctrl-R ShiftF3 Ctrl-G F4 Ctrl-T F5 Ctrl-Y

So most won't work.
Edited 2023-12-30 14:08 by phil99
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2292
Posted: 04:06am 30 Dec 2023
Copy link to clipboard 
Print this post

  bigmik said  No i don't have a github account.
Why do you ask?


just so you could provide feedback directly on the github thread:
https://github.com/No0ne/hid2cdc/issues/1

but no worries... don't know if NoOne is reading this thread, but i will continue posting progress reports back to github.

i agree, github can be quite difficult to navigate, i've always barely 'muddled my way through' with it!

cheers,
rob   :-)
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 04:10am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi Rob, All,

I wrote a small test program to test which keys are working (yes uses a GOTO.. Don't shout at me     )

mik:
a$=Inkey$:If a$="" Then GoTo mik
Print Asc(a$)
GoTo mik

I see `almost' every key that doesn't seem to work sends a 0 code. Of course the inkey$ is only getting the first character of what is sent. I think function keys etc send multiple characters for the key.

I am not sure how to read every character that is sent each time a key is pressed.

I have to disconnect the PicoVGA and plug it into my PC to write code as I cant even exit a running program as Ctrl doesnt work. so it is a case of unplug from HID2CDC, plug into PC, write code, unplug from PC and replug to HID2CDC and try.. ad infinitum.

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 04:14am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi Phill, All,

I can type EDIT to start the editor but typing SAVE etc. doesn't exit the editor, it adds the word SAVE into my code, and of course no CTRL keys work as the CTRL key seemingly doesn't respond.

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 1805
Posted: 04:17am 30 Dec 2023
Copy link to clipboard 
Print this post

  Quote  ON PS2 target
This triggers an interrupt whenever the PicoMite sees a message from the PS2
interface.
Use MM.info(PS2) to report the raw message received. This allows the
programmer to trap both keypress and release.
See https://wiki.osdev.org/PS/2_Keyboard for the scan codes (Set 2).
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 04:34am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi Phil, All,

But this setup isn't using the PS2 interface, it is effectively using the standard USB console connection into the PicoVGA.
This is a HID2CDC not the similar PS2x2Pico.

Doing a print mm.info(ps2) returns an error, as below but this could be my version (5.0704) but as above it isn't using the PS2 interface so I doubt it would work anyway.

? mm.info(ps2)
Error : Syntax

Regards,

Mick




.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 04:48am 30 Dec 2023
Copy link to clipboard 
Print this post

Hi All,

BTW,

The hub I am using is a very nice $3.55AU (~$2US) 1 into 4 unit.

>>> USB HUB <<<

And I also found these Micro to Type A Female adapters at 4 for $2.28AU (about $1.50US)

>>> USB Adapters <<<

I haven't tried the adapters as I made my own cable but they all look pretty decent and cheap.

Regards,

Mick
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3022
Posted: 02:51pm 30 Dec 2023
Copy link to clipboard 
Print this post

  bigmik said  I see `almost' every key that doesn't seem to work sends a 0 code. Of course the inkey$ is only getting the first character of what is sent. I think function keys etc send multiple characters for the key.


I'm not sure I understand enough to know if this will help, but here is code I used to replace INKEY$ with _INKEYCH$ to decode special keys.

Function _inkeyCh$()
 local ky$
 if loc(#1)>0 then
   ky$=input$(1,#1) ' get a character
 else
   ky$=inkey$
 endif
 if asc(ky$)=27 then ' escape sequence
   pause 20 ' await additional characters
   ky$=input$(1,#1): ky$=input$(1,#1): ky$=ucase$(ky$)
   If ky$="A" Then: ky$=chr$(128) ' up arrow
   ElseIf ky$="B" Then: ky$=chr$(129) ' down arrow
   ElseIf ky$="D" Then: ky$=chr$(130) ' left arrow
   ElseIf ky$="E" Then: ky$=chr$(131) ' right arrow
   ElseIf ky$="1" Then: ky$=chr$(134) ' home
   ElseIf ky$="4" Then: ky$=chr$(135) ' end
   ElseIf ky$="5" Then: ky$=chr$(136) ' pgup
   ElseIf ky$="6" Then: ky$=chr$(137) ' pgdn
   ' Function keys are ???
   EndIf
 endif
 _inkeyCh$=ky$
end function

This code was intended to read either keyboard input or input from serial (from the serial buffer). I didn't need the function keys, so didn't translate them. I forget where I got the "chr$(129)", etc. I believe I figured out the "B,D,E,1,4,5,6" by using inkey$ in a loop to display the values which were sent.

Tom may have similar (and perhaps more extensive) code somewhere.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
bigmik

Guru

Joined: 20/06/2011
Location: Australia
Posts: 2870
Posted: 12:36am 31 Dec 2023
Copy link to clipboard 
Print this post

Hi Lizby, All,

Sorry, I am showing how stupid I am. I really am a Tyro when it comes to programming with SUBS and Functions.

I get this error when I run this code, I realise that I have an A$ variable I haven't done anything with as I don't, yet, understand what the function is supposed to do or indeed how to use/call it.

RUN
[9] Function _inkeyCh$()
Error : Type specification is invalid: $
>


mik:
_inkeych$     ' I thought this would run the function
Print Asc(a$) ' ignore as superflous at this stage
GoTo mik


Function _inkeyCh$()
local ky$
if loc(#1)>0 then
  ky$=input$(1,#1) ' get a character
else
  ky$=inkey$
endif
if asc(ky$)=27 then ' escape sequence
  pause 20 ' await additional characters
  ky$=input$(1,#1): ky$=input$(1,#1): ky$=ucase$(ky$)
  If ky$="A" Then: ky$=chr$(128) ' up arrow
  ElseIf ky$="B" Then: ky$=chr$(129) ' down arrow
  ElseIf ky$="D" Then: ky$=chr$(130) ' left arrow
  ElseIf ky$="E" Then: ky$=chr$(131) ' right arrow
  ElseIf ky$="1" Then: ky$=chr$(134) ' home
  ElseIf ky$="4" Then: ky$=chr$(135) ' end
  ElseIf ky$="5" Then: ky$=chr$(136) ' pgup
  ElseIf ky$="6" Then: ky$=chr$(137) ' pgdn
  ' Function keys are ???
  EndIf
endif
_inkeyCh$=ky$
end function


Kind Regards,

Mick



.
Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<<
 
     Page 1 of 6    
Print this page
© JAQ Software 2024