News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Devilmarkus

Virtual keyboard idea for emulators

Started by Devilmarkus, 22:36, 07 December 09

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

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)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

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/
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

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 :)

Devilmarkus

You can also pre-select keys now for a sequence.
These keys are all pressed together if needed.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

I made the keyboard "more nostalgic" ;)
I scanned parts of my 6128 and included them into the keyboard GUI....
The result is here:


I am just adding some other features, trying to find some bugs and will release it on 24.12.2009! ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release


Gryzor

Wow! I don't know what it does to the size overhead, but it certainly looks lovely!

Devilmarkus

#7
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.



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.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

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...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

#9
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:
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

robcfg

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!

Devilmarkus

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)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

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!

Devilmarkus

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!!!!
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

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...

Devilmarkus

BTW.: For those of you who want to see the new display-filter:


The screen is still flickering. I put booth screens with photoshop together...
But the result is cool i find... :D
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

#17
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:



This is NO Photoshop-Effect!!!
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

TFM

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!!!
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Devilmarkus

Some flipped screens here: (de-interlaced with JavaCPC, created with JavaCPC Paint 1.1)








Technic: 2 screens, 1 is MODE 0 , the 2nd is MODE 1, booth are swapping each vSync
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

TFM

TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Gryzor


nurgle

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