Author Topic: Virtual keyboard idea for emulators  (Read 4271 times)

0 Members and 1 Guest are viewing this topic.

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Virtual keyboard idea for emulators
« on: 23: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)
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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #1 on: 00:01, 08 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/
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.372
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3062
  • Likes Given: 5584
Re: Virtual keyboard idea for emulators
« Reply #2 on: 12: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 :)

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #3 on: 15:52, 08 December 09 »
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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #4 on: 01: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:


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

Offline Octoate

  • CPC6128
  • ****
  • Posts: 290
  • Country: de
    • Octoate.de
  • Liked: 62
  • Likes Given: 326
Re: Virtual keyboard idea for emulators
« Reply #5 on: 15:16, 11 December 09 »
Cool 8)!
--

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.372
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3062
  • Likes Given: 5584
Re: Virtual keyboard idea for emulators
« Reply #6 on: 16:53, 11 December 09 »
Wow! I don't know what it does to the size overhead, but it certainly looks lovely!

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #7 on: 23: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.



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.
« Last Edit: 23:34, 12 December 09 by 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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #8 on: 18:30, 13 December 09 »
BTW.: The java source for this is quite simple:
jemu.system.cpc.Keyboard.java:

Code: [Select]
  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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #9 on: 22: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:
« Last Edit: 02:25, 17 December 09 by 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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #10 on: 02: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
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

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.267
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 1009
  • Likes Given: 2365
Re: Virtual keyboard idea for emulators
« Reply #11 on: 13: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!

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #12 on: 10: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)
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.372
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3062
  • Likes Given: 5584
Re: Virtual keyboard idea for emulators
« Reply #13 on: 16: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!

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #14 on: 16: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!!!!
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.372
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3062
  • Likes Given: 5584
Re: Virtual keyboard idea for emulators
« Reply #15 on: 16: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...

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #16 on: 18:42, 23 December 09 »
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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #17 on: 02: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:



This is NO Photoshop-Effect!!!
« Last Edit: 02:44, 24 December 09 by 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

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: Virtual keyboard idea for emulators
« Reply #18 on: 03: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!!!
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
  • Liked: 1014
  • Likes Given: 926
Re: Virtual keyboard idea for emulators
« Reply #19 on: 02:18, 25 December 09 »
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

Offline TFM

  • Visit the mysteries of the CPC at www.futureos.de
  • Supporter
  • 6128 Plus
  • *
  • Posts: 9.899
  • Country: aq
  • Space Chicken for FutureOS is free!
    • index.php?action=treasury
    • FutureOS - The revolution on CPC!
  • Liked: 1976
  • Likes Given: 4650
Re: Virtual keyboard idea for emulators
« Reply #20 on: 02:22, 25 December 09 »
Is it a CPC-Plus-Plus ?
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 15.372
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
  • Liked: 3062
  • Likes Given: 5584
Re: Virtual keyboard idea for emulators
« Reply #21 on: 10:43, 25 December 09 »
These look feaking awesome...

Offline nurgle

  • CPC6128
  • ****
  • Posts: 200
  • Country: de
    • index.php?action=treasury
  • Liked: 7
  • Likes Given: 12
Re: Virtual keyboard idea for emulators
« Reply #22 on: 23:14, 26 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