CPCWiki forum

General Category => Emulators => Topic started by: Devilmarkus on 22:36, 07 December 09

Title: Virtual keyboard idea for emulators
Post by: Devilmarkus on 22:36, 07 December 09
Hi together,
as I thought, it could be useful to have a virtual keyboard in an emulator.
The reason:
- Some games have a cheat mode (key combination like press A,B,C,D,E together)

An emulator cannot handle this because the PC keyboard mostly returns a beep.

Another reason:
- No emu can handle CRTL, SHIFT & ESC combination on a Windows PC (Your Taskmanager will popup)
This is not really needed but would also be nice...

So I decided to code a virtual keyboard today which can be used to enter keystrokes into emulation.
- Single keys: Each key will be released after click
- Multi-choose: All keys are held until you release them (click a 2nd time or click "Release all keys")

Screens:
The first screen shows the virtual keyboard

The second shows CTRL, SHIFT & ESC pressed (emulator resets)
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 23:01, 07 December 09
Example video:
To enable the cheat mode in "Beyond the ice palace" you must hold down caps-lock, and also enter the word ELITE
When the cheat has been activated, you will hear a sound.
http://cpc-live.com/beyond_cheat/
Title: Re: Virtual keyboard idea for emulators
Post by: Gryzor on 11:05, 08 December 09
I had thought about this in the past - what you say about the PC keyboards locking up with 3 keys or more is very true and screws things up... But I'd have thought it was too much trouble to implement it. Well done :)
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 14:52, 08 December 09
You can also pre-select keys now for a sequence.
These keys are all pressed together if needed.
(http://cpc-live.com/preselect.gif)
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 00:15, 11 December 09
I made the keyboard "more nostalgic" ;)
I scanned parts of my 6128 and included them into the keyboard GUI....
The result is here:
(http://cpc-live.com/cpc_keyboard.png)

I am just adding some other features, trying to find some bugs and will release it on 24.12.2009! ;)
Title: Re: Virtual keyboard idea for emulators
Post by: Octoate on 14:16, 11 December 09
Cool 8)!
Title: Re: Virtual keyboard idea for emulators
Post by: Gryzor on 15:53, 11 December 09
Wow! I don't know what it does to the size overhead, but it certainly looks lovely!
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 22:27, 12 December 09
I like big screens :D

Anyway...
Some news:

You all surely remember the "CPC-Keyboard-Clash" (press 3 keys and get 4 as output)
I am now also emulating this in the virtual keyboard.

(http://cpc-live.com/keyboard/keyboardclash.gif)

To understand this:
Kevin Thacker made a table once for all CPC Keys, their lines and bits. (Keyboard Matrix)
I modified this table a bit to make it more understandable.
http://cpc-live.com/keyboard

The clash is build like this:
When you press 3 keys, which would build a rectangle in this table, the 4th key in this rectangle, which is missing, is pressed!
Example: the keys 2,0 and 9: when you press them together, you will also get the 1 pressed.
http://cpc-live.com/keyboard/2091.html
all these 4 keys build a rectangle here.

There are for example games, which use a cheat like "press ED209" but the game awaits ED2091 to accept the cheat code.
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 17:30, 13 December 09
BTW.: The java source for this is quite simple:
jemu.system.cpc.Keyboard.java:


  protected int[]       KeyboardData = new int[16];

/*----------------------------------------------------------------*/

  public Keyboard() {
    super("CPC Keyboard",8,10);
    for (int i = 0; i < bytes.length; i++){
      KeyboardData[i] = 0xff;
      bytes[i] = 0xff;
    }
    setKeyMappings();
    reset();
  }

/*-------------------------------------------------------------------*/

  protected void keyChanged(int col, int row, int oldValue, int newValue) {
      if (DEBUG)
          System.out.println("BIT:" + col + " LINE:" + row + "oldValue="+oldValue+" newValue="+newValue);
      if (oldValue == 0) {
          if (newValue != 0)
              KeyboardData[row] &= (0x01 << col) ^ 0xff;
      }
      else if (newValue == 0)
          KeyboardData[row] |= (0x01 << col);
      GenerateKeyboardClash();
  }
  protected void GenerateKeyboardClash() {
      /* bytes is the final result after ghosts */
      System.arraycopy(KeyboardData, 0, bytes, 0, 16);
      for (int i=0; i<9; i++){
          int Line1 = KeyboardData[i];
          if (Line1 != 0x0ff){
              /* key(s) pressed in this row */
              for (int j=0; j<9; j++){
                  if (i!=j){
                      int Line2 = KeyboardData[j];
                      if (Line2!=0x0ff){
                          if ((Line1 | Line2)!=0x0ff){
                              /* common key(s) pressed in these two lines */
                              Line1 = Line1 & ((Line1 ^ Line2) ^ 0x0ff);
                          }
                      }
                  }
              }
              bytes[i] = Line1;
          }
      }
  }


I am using Kev's code here. Converted from C to JAVA...
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 21:42, 16 December 09
I am not sure if I can release on dec, 24th.

At the moment I am completely writing a new GUI for JavaCPC's settings!
It will be MUCH clearer and more comfortable than the old "Options" and thousand of menu entries...

But it's a long way to get it working.
Progress is about 80%...

Who wants to see the new GUI, please follow this URL:
http://cpc-live.com/new_options/

You can choose between 4 different styles here.

I hope the new Settings & Options will be much clearer and easier to understand than the old ones.

Cheers,
Markus

EDIT: Also new: the JavaCPC Desktop - A small, integrated desktop, where you can find the most important applications:
(http://cpc-live.com/new_options/desktop.png)
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 01:27, 21 December 09
Something funny in the coders-world:
http://cpc-live.com/java_wtf.png

:o :o :o :o :o :o :o :o :o :o :o :o :o
Title: Re: Virtual keyboard idea for emulators
Post by: robcfg on 12:08, 21 December 09
That was funny!  ;D

Coding and application errors can be hilarious...

BTW, Very nice your idea of the virtual keyboard, instead of guessing the keymaps, you simply press the keys.

Keep up the good work!
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 09:55, 22 December 09
I am really not sure if I can release it in time... Sorry guys.
But for all of you who don't want to wait, here's a URL to a actual screenshot:
http://cpc-live.com/new_desktop.png

::) 8)
Title: Re: Virtual keyboard idea for emulators
Post by: Gryzor on 15:52, 22 December 09
Well, mate, it's not like anyone is rushing you or putting the blade to your throat :D It'll be ready when it's ready!
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 15:55, 22 December 09
The biggest problem is:
You will be able to choose between desktop or normal view.
So I must modify a lot of things and add code for booth versions.

I will also have to clean up the "much too large" JavaCPC menu bar!!!!
Title: Re: Virtual keyboard idea for emulators
Post by: Gryzor on 15:57, 22 December 09
Yes, I think the choice between the two modes is a must, especially for low-res systems. Is the menu really that big? I didn't think so...
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 17:42, 23 December 09
BTW.: For those of you who want to see the new display-filter:
(http://cpc-live.com/op.png)

The screen is still flickering. I put booth screens with photoshop together...
But the result is cool i find... :D
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 01:41, 24 December 09
Also solved the flicker-problem with interlaced pictures (Climax demo, O-P title screen, Cheat part of AE2005 demo etc...)

You will be able to De-Interlace these screens now!
The monitor slows down to 25hz and shows 2 images together (one is painted with 50% transparency over the second)

Result:
(http://cpc-live.com/deinterlace.png)

(http://cpc-live.com/deinterlace2.png)
This is NO Photoshop-Effect!!!
Title: Re: Virtual keyboard idea for emulators
Post by: TFM on 02:29, 24 December 09
Hi there!

Have been watching a couple of interlaced demo with it! Just A-W-E-S-O-M-E !!!

That's my best X-Mas present!!!
Title: Re: Virtual keyboard idea for emulators
Post by: Devilmarkus on 01:18, 25 December 09
Some flipped screens here: (de-interlaced with JavaCPC, created with JavaCPC Paint 1.1)
(http://cpc-live.com/interlace1.png)

(http://cpc-live.com/interlace2.png)

(http://cpc-live.com/interlace3.png)

(http://cpc-live.com/interlace4.png)

Technic: 2 screens, 1 is MODE 0 , the 2nd is MODE 1, booth are swapping each vSync
Title: Re: Virtual keyboard idea for emulators
Post by: TFM on 01:22, 25 December 09
Is it a CPC-Plus-Plus ?
Title: Re: Virtual keyboard idea for emulators
Post by: Gryzor on 09:43, 25 December 09
These look feaking awesome...
Title: Re: Virtual keyboard idea for emulators
Post by: nurgle on 22:14, 26 December 09
Quote from: Devilmarkus on 01:27, 21 December 09
Something funny in the coders-world:
http://cpc-live.com/java_wtf.png

:o :o :o :o :o :o :o :o :o :o :o :o :o

That reminds me of a screenshot I printed out in the nintees and hung on my wall when Netscape 2 reported "No plugin for mime type text/html found"  ;D
Powered by SMFPacks Menu Editor Mod