![]() |
Forum Index : Microcontroller and PC projects : PicoMiteVGA: Quick PS2 hack for games developers
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
As an experiment I've implemented a Basic interrupt triggered by raw PS2 codes. PicoMiteVGA.zip ![]() This allows you to manage keydown and keyup events. Let me know if this is useful. See https://wiki.osdev.org/PS/2_Keyboard for the scan codes (Set 2). I haven't implemented print screen pressed , print screen released, pause pressed , pause released for obvious reasons |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5089 |
Thanks Peter, Will try this with my 2 player Circle game. See if I can let them play on the WASD cluster and the arrows cluster on a single keyboard.. Edited 2022-10-17 03:51 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Martin H.![]() Guru ![]() Joined: 04/06/2022 Location: GermanyPosts: 1233 |
Thank you Peter, after a Quick test works fine, gets Keys like Right Shift/ctrl/Alt Left Shift/ctrl/AltGr Repeat is still there (Cause of the Keyboard electronic) but stops sending as soon as the Key is released. @Harm no, only one key press is reported, so you dont get a "Mixed result" if more than one key is Pressed at once. Will test it further. Cheers Mart!n 'no comment |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Hi folks, This code demonstrates conversion from "scan-codes" to the "key-codes" reported by the CMM2 KEYDOWN() method ... approximately(*) Option Base 0 Option Default None Option Explicit On Dim map_00%(31) Dim map_e0%(31) Dim key_map%(31) read_data() On Ps2 on_ps2() Do Pause 500 print_keys_down() Loop End Sub read_data() Local i% For i% = 0 To 31 Read map_00%(i%) Next For i% = 0 To 31 Read map_e0%(i%) Next End Sub Sub on_ps2() Local ch%, down%, scan_code% = Mm.Info(PS2) Select Case scan_code% Case Is < &hE000 ch% = Peek(Var map_00%(), scan_code% And &hFF) : down% = 1 Case Is < &hF000 ch% = Peek(Var map_e0%(), scan_code% And &hFF) : down% = 1 Case Is < &hE0F000 ch% = Peek(Var map_00%(), scan_code% And &hFF) Case Else ch% = Peek(Var map_e0%(), scan_code% And &hFF) End Select Poke Var key_map%(), ch%, down% End Sub Sub print_keys_down() Local ch%, count% For ch% = 0 To 255 If Peek(Var key_map%(), ch%) Then If count% > 0 Then Print ", "; If ch% > 32 And ch% < 127 Then Print Chr$(ch%) " "; Else If ch% <> 0 Then Print "[" + Hex$(ch%) + "] "; EndIf Inc count% EndIf Next ch% If count% > 0 Then Print End Sub Data &h9C92919395009900, &h0060099496989A00, &h0031710000018B00, &h00327761737A0000 Data &h0033346564786300, &h0035727466762000, &h0036796768626E00, &h003837756A6D0000 Data &h0039306F696B2C00, &h002D703B6C2F2E00, &h00003D5B00270000, &h000023005D0A0100 Data &h0008000000005C00, &h0000000000000000, &h001B000000002E00, &h0000002A2D002B9B Data &h0000000097000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000008B00, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000008782008700, &h0000808300817F84, &h0000889D00890000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 Data &h0000000000000000, &h0000000000000000, &h0000000000000000, &h0000000000000000 @matherp Somewhat randomly an F4 key-up doesn't seem to call the PS2 interrupt, is this a BUG ? or do I have a duff keyboard, it seems to be working otherwise because releasing and pressing F4 generates key-down interrupts (I only have one PS/2 keyboard so can't try a different one.) Can we hope for anything more in the firmware, e.g. "scan-code" to "key-code" conversion or is this "our lot" ? * It only "approximately" does what the CMM2 does because it doesn't perform the *magic* that KEYDOWN() does for the [Shift] and [Ctrl] modifier keys, and infact currently won't report their state at all. Best wishes, Tom Edited 2022-11-11 10:01 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Hi Peter, Sorry to (continue to) be a bloody nuisance, but could you please fix PicoMite/Keyboard.c#587 ? Currrently: if(!(Code==0xe0 || Code==0xf0 || (Code==0x12 && KeyE0) || (Code==12 && KeyUpCode)) && Code){ Should be: if(!(Code==0xe0 || Code==0xf0 || (Code==0x12 && KeyE0) || (Code==0x12 && KeyUpCode)) && Code){ Note 12 => 0x12, I think that is why F4 isn't working properly. Actually in some ways what the PicoMite now does is better than what seems to be implemented in the CMM2. On the CMM2 is there anyway to determine if one of the modifier keys is down ? - I don't think KEYDOWN does it. Also could you enlighten me as to whether when it comes to different language (PS/2) keyboards, are the scan-codes tied to location of the key on the keyboard or to the character the key will generate, I'm assuming the former ? Best wishes, Tom Edited 2022-11-11 22:09 by thwill MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Will fix Yes it does RTM No Don't know which I why I'm not going to pursue conversion |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
Thanks Peter. Yes it does RTM What do you know, I am human after all, that's probably a relief ![]() No Ack, you haven't made it easy to provide a platform independent keydown API that covers both the CMM2 and the PicoMiteVGA. On spec can I ask for an MM.INFO$(OPTION KEYBOARD) on the PicoMite, c.f. MM.INFO$(OPTION USBKEYBOARD) on the CMM2 ? Don't know which I why I'm not going to pursue conversion I suspect they are tied to the key position, could I prevail on someone with a non-English keyboard to try the attached and see what happens in the haunted wing of the keyboard - my suspicion is it will report the colocated UK keys: scancode.zip Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |