Best way to send key presses/releases through socket

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
lgnr
Posts: 12
Joined: Thu Dec 17, 2009 2:57 am

Best way to send key presses/releases through socket

Post by lgnr »

Hi everyone.
I'm trying to create an simple app to send key presses/releases to be interpreted using WinAPI. Everything went fine, its all working. But now i've run into this problem:
I'm using SceCtrlLatch to get the changes on key states and send the 'events' (presses and releases) throught a simple UDP socket.
The problem is sometimes when you press two keys at the 'same' time (or in a short time) it does not send that packet or psp does not recongnize that.If that is a key release, it becomes really anoying, cause if you're running an emulator, it does not get the key release and mario keeps running foward, for example.
So my question is: what is the best way of doing it? Should i send them over TCP or anything like that?
Thanks in advance.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Application layer wifi is not suitable for sending keypresses in the first place. You will lose something.
victorprosa
Posts: 37
Joined: Wed Jan 14, 2009 5:53 am

Post by victorprosa »

Torch wrote:Application layer wifi is not suitable for sending keypresses in the first place. You will lose something.
Except if the PSP client sends like 5 times the single key press information in for example 100ms...

in reciever, you configure it to ignore key repeat in a 100ms interval...


Information loss problem solved? xD
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

You shouldn't use UDP if you're going to merely transmit keystrokes. Use TCP instead. Here a few hints about why to do so:

http://en.wikipedia.org/wiki/Transmissi ... a_transfer
Torch wrote:Application layer wifi is not suitable for sending keypresses in the first place. You will lose something.
I completely disagree. How can you play games over ad-hoc Wifi then? TCP is a reliable protocol. You don't have to lose a single thing.
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

m0skit0 wrote:I completely disagree. How can you play games over ad-hoc Wifi then? TCP is a reliable protocol. You don't have to lose a single thing.
Games send updates of the game state, not button presses. And much much less frequently than button sampling rate. There is no way you can play something like Tekken if it sent button presses, where there are moves that require timing accurate up to 1/60th of a second known as just frame or single frame moves. Buttons are interpreted on the client side and only the resulting application action is sent to the server.
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

(PLZ DELETE)
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
lgnr
Posts: 12
Joined: Thu Dec 17, 2009 2:57 am

Post by lgnr »

Thanks for every answer. It was really helpful.
But the question is another:
The PSP CANNOT read every key press if there are too many at the same time.
I mean, i found that is not reliable to send one key press when the key is pressed.
Perhaps it would be nicier to send all the key states instead of each button at a time?
Any thoughts on that, guys?

Thanks a lot again!
m0skit0
Posts: 191
Joined: Tue Jun 02, 2009 8:58 pm

Post by m0skit0 »

Send game status or better, only modifications that had ocurred. Do not send keypresses, process them and send game status as Torch already explained.
The Incredible Bill Gates wrote:The obvious mathematical breakthrough would be development of an easy way to factor large prime numbers.
Post Reply