findlayshaquan65 / nulldc

Automatically exported from code.google.com/p/nulldc
0 stars 0 forks source link

PuruPuru: Keyboard input is horribly slow #320

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Select the PuruPuru input plugin from the Select Plugins dialog.
2. Run any game, or even just start the BIOS.

What is the expected output? What do you see instead?

With any other plugin, I get near-perfect full speed emulation in most games. 
When I use the PuruPuru plugin for my gamepad, however, emulation speed drops 
to ~35%. As soon as I hit Unplug to unload PuruPuru, emulation speed returns to 
normal.

What version of the product are you using? What build? What plugins?

I use version: 1.0.4 r85, the latest as of 11/12/10

I use the following plugins:

PowerVR Plugin: Oct 30 2010
GDRom Plugin: Nov 5 2010 (my birthday!)
AICA Plugin: Oct 31 2010
ARM7 Plugin: Oct 31 2010
Maple Plugin(s): Oct 31 2010
Ext.Device Plugin: Oct 31 2010

My system specifications are as follows:

Operating System: XP SP 3
CPU: Pentium D 820 (2.8GHz)
Video Card: Nvidia 8500GT (overclocked: 630MHz core, 1260 shader, 375 memory)
Sound Card: SB Audigy 4 (non-pro)
Memory: 2GB DDR2
Additional related hardware and/or software:

The gamepad I am using is a N64/PS2 to USB converter. Here: 
http://www.amazon.com/Nintendo-64-N64-2in1-Controller-Adapter/dp/8565000168

I currently have an N64 controller in it.

Please provide any additional information below:

Even though it is very slow, it seems to be working okay; there isn't any 
emulation errors at all, and it appears to be correctly registering analog 
input.

Please help. It would really be nice to have analog control instead of digital. 
Trying to play Sonic Adventures with digital movement control is impossible!

Is there some kind of logging mode that I can enable?

Original issue reported on code.google.com by jzachar...@gmail.com on 13 Nov 2010 at 12:02

GoogleCodeExporter commented 9 years ago
I probably destroyed it somehow. Try using the plugin from r22.

Original comment by KrossX3 on 13 Nov 2010 at 5:59

GoogleCodeExporter commented 9 years ago
Yes, that seems to work, HOWEVER, r22's PuruPuru cannot do diagonal analog 
directions, which makes it kind of useless. I'll try other revisions' plugins I 
guess.

Original comment by jzachar...@gmail.com on 14 Nov 2010 at 4:58

GoogleCodeExporter commented 9 years ago
Got it, r27's works with diagonals. I'll keep trying different revisions and 
see where it starts to go funny with the speed.

Original comment by jzachar...@gmail.com on 14 Nov 2010 at 5:08

GoogleCodeExporter commented 9 years ago
Ah, it's all the way back to r42, I see. That is, r42's PuruPuru works, and 
r43's does not. I'm not really sure why. The only change to Puru in that 
revision is "Now supports input from Keyboard. (and mouse buttons too)." Maybe 
I'm an isolated case, because I have a fancy keyboard with extra buttons. 
Specifically, it's a Saitek Cyborg Keyboard, Revision 1. It needs proprietary 
drivers from their site to work right. Can I provide more information?

Original comment by jzachar...@gmail.com on 14 Nov 2010 at 6:10

GoogleCodeExporter commented 9 years ago
No, that should be enough. Thanks.

Original comment by KrossX3 on 14 Nov 2010 at 2:15

GoogleCodeExporter commented 9 years ago
Try this one: http://www.mediafire.com/?xk104oczacs8qj4
See if it works any better. Make sure to have keyboard input disabled though.

Original comment by KrossX3 on 14 Nov 2010 at 2:59

GoogleCodeExporter commented 9 years ago
Yep, that did the trick! But you're right, keyboard input makes it slow down 
again.

Original comment by jzachar...@gmail.com on 14 Nov 2010 at 8:06

GoogleCodeExporter commented 9 years ago
That's it then. It seems using GetAsyncKeyState is quite expensive, on your 
system at least.

Original comment by KrossX3 on 14 Nov 2010 at 9:04

GoogleCodeExporter commented 9 years ago
Well, my machine is 6 years old...it's getting pretty tired.

Original comment by jzachar...@gmail.com on 14 Nov 2010 at 9:09

GoogleCodeExporter commented 9 years ago
Does using Keyboard Only still cause a slowdown? And how about using the 
drk_maple plugin for keyboard input?

Original comment by KrossX3 on 14 Nov 2010 at 9:26

GoogleCodeExporter commented 9 years ago
Yep, keyboard only does it. However, drk_maple doesn't cause the slowdown. I 
used Xmapple before with drk_mapple.

Original comment by jzachar...@gmail.com on 14 Nov 2010 at 9:33

GoogleCodeExporter commented 9 years ago
Give this one a try.. see if it improves at least a little. Warning! It's a 
very experimental version and your computer may explode.

http://www.mediafire.com/?fqj2k6bm09puwpv

Original comment by KrossX3 on 27 Nov 2010 at 6:37

GoogleCodeExporter commented 9 years ago
Yeah hold on, I'm out of town from turkey day and don't have my computer, I'll 
try it on Monday.

Original comment by jzachar...@gmail.com on 27 Nov 2010 at 12:28

GoogleCodeExporter commented 9 years ago
OK, just tried it, did NOT work, same behavior as before. Again, drk_maple 
works fine for this revision.

Original comment by jzachar...@gmail.com on 29 Nov 2010 at 4:37

GoogleCodeExporter commented 9 years ago
Yah, thought so. Still worth to try. Gonna have to just use the Events.

Original comment by KrossX3 on 29 Nov 2010 at 5:16

GoogleCodeExporter commented 9 years ago
@KrossX3:

A quick optimization would be to parse off the configuration file
the used keys , then put them in a buffer as reference.

Remove the 255 get key state calls , and iterate through the referenced keys 
and update their state.

The next thing to do is to replace some hardcoded branches with constant maps , 
then do simple iteration<->mapping.

Original comment by Dimitris...@gmail.com on 29 Nov 2010 at 3:06

GoogleCodeExporter commented 9 years ago
Oh, that's an interesting one. But you would still be checking for up to 16 or 
so keys for each controller connected using keyboard, as opposted to just 
update the key(s) in use. It could take like 64 checks top, as opposted to just 
3-4 checks for a normal keyboard in use when using the KeyDown/Up events.

Original comment by KrossX3 on 29 Nov 2010 at 10:11

GoogleCodeExporter commented 9 years ago
@KrossX3:

Here is what im thinking :

1.Remove the 255 calls
2.Use the configuration file to fill the key buffer for each controller port
3.Drop completely the winap getkeystate and create an SDL input mapper function
during initialization
4.Make use of SDL_PollEvent http://sdl.beuc.net/sdl.wiki/SDL_PollEvent
for efficient event handling.It makes use of WINAPI's low level input
messages and reports any input event to the event structure passed in.
This applies for controllers and everything.
5.Optimize 2/3byte compares.

Examples:

3byte compares , can be replaced with 1 24bit load,
and hex constants:

This :
if(input[0] == L'L' && input[1] == L'X' && input[2] == '+')
..huge else if branch follows...

Turns to :

switch( (u32)( (input[0] << 24) | (input[1] << 16) | (input[2] << 8) )
{
    case 0x768843:
        code
    return ..;

    case ...
}

2byte compares , can be replaced with 1 16bit load,
and hex constants:

if(input[0] == L'L' && input[1] == L'X')
..huge else if branch follows...

Turns to :

switch( (u16)( (input[0] << 8) | input[1] )
{
    case 0x7688:
        code
    return ..;

    case ...
}

:)

Original comment by Dimitris...@gmail.com on 30 Nov 2010 at 6:02

GoogleCodeExporter commented 9 years ago
Great! That sounds like a plan. :)

Now get in the IRC already!

Original comment by KrossX3 on 30 Nov 2010 at 6:50

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I tried to go to #nullDC, but I forgot I'm running a Tor relay on another 
machine, and because I'm behind a router, I got IP banned from EFnet for awhile 
because of this. Ho hum...

Original comment by jzachar...@gmail.com on 4 Dec 2010 at 2:55

GoogleCodeExporter commented 9 years ago
Don't worry, I was telling DimitrisV22 to get into the IRC. 

Original comment by KrossX3 on 4 Dec 2010 at 4:49

GoogleCodeExporter commented 9 years ago
Can this be checked again with r120 please?

Original comment by KrossX3 on 20 Dec 2010 at 10:44

GoogleCodeExporter commented 9 years ago
I would test it, but I'm away from my machine again, and I'm currently fighting 
insomnia...it's 5:30AM now, or thereabouts. So I'll test it later.

Original comment by jzachar...@gmail.com on 21 Dec 2010 at 1:31

GoogleCodeExporter commented 9 years ago
Well, I just tried it. It is much better than it was, but it's not quite to 
running completely full speed yet. It's around 90-95%, so there is quite a bit 
of sound skipping. When I have no keyboard input, the sound is fine. I don't 
know how much more you want to optimize it, but it's kind of a moot point to me 
because I can play fine with a gamepad.

Original comment by jzachar...@gmail.com on 22 Dec 2010 at 3:53

GoogleCodeExporter commented 9 years ago

One of the main things causing huge latency is the event handling/processing.
It would be wise to start fixing that first before anything else.

Original comment by Dimitris...@gmail.com on 22 Dec 2010 at 4:59

GoogleCodeExporter commented 9 years ago
How about this one: http://www.mediafire.com/?rc7rl05u1ue1i80

Original comment by KrossX3 on 22 Dec 2010 at 6:19

GoogleCodeExporter commented 9 years ago
Okay, that one seems to be running at full speed. Thankies.

Original comment by jzachar...@gmail.com on 23 Dec 2010 at 4:40

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r125.

Original comment by KrossX3 on 23 Dec 2010 at 2:20