Press a key without pressing it

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

Moderators: cheriff, TyRaNiD

Post Reply
Tsukasa
Posts: 12
Joined: Mon Jul 04, 2005 6:28 am

Press a key without pressing it

Post by Tsukasa »

Hi

I've a simple question:
Is it possible to code a program which is able to press automatically a predefined button in a certain time?

Thanks in advance
lS[UMD/2kdlSU]
Posts: 8
Joined: Wed Oct 26, 2005 10:08 pm
Location: Shiga, Japan
Contact:

Re: Press a key without pressing it

Post by lS[UMD/2kdlSU] »

Tsukasa wrote:Hi

I've a simple question:
Is it possible to code a program which is able to press automatically a predefined button in a certain time?

Thanks in advance
Possible :)
You have to patch the sceCtrl**** stub(if you want to take a effect to a module)
or function body(if you want to take a effect to all modules).
I've tried patching sceCtrlReadBufferPositive stub in "game" module and it worked:)

Code: Select all

// The part of the test code
PspCtrlButtons mask_and;
PspCtrlButtons mask_or;

int patched_sceCtrlReadBufferPositive(SceCtrlData *pad_data, int count)
{
  int result = sceCtrlReadBufferPositive(pad_data, count);
  pad->Buttons &= mask_and;
  pad->Buttons |= mask_or;
  return result;
}
lS[UMD/2kdlSU] - now working as 67...
----------------------------------------------
site: jap | eng
jap blog: here
pipspsp
Posts: 4
Joined: Sat May 13, 2006 1:43 am

Post by pipspsp »

im not a c coder, but shouldn't you use the function that the button executes?


if (pad.Buttons & PSP_CTRL_SQUARE){
printf("Square pressed \n");
}

couldn't you just change the if

if ("time" = "when i want it"){
printf("Square pressed \n");
}
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

pipspsp wrote:im not a c coder, but shouldn't you use the function that the button executes?


if (pad.Buttons & PSP_CTRL_SQUARE){
printf("Square pressed \n");
}

couldn't you just change the if

if ("time" = "when i want it"){
printf("Square pressed \n");
}
But maybe he is running code in the background and wants to generate the press for a another program.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

What possible use could this have?
Shoot Pixels Not People!
Makeshift Development
User avatar
dot_blank
Posts: 498
Joined: Wed Sep 28, 2005 8:47 am
Location: Brasil

Post by dot_blank »

err why not just skip the controller input for function
for using the function you want at a given time
to execute at that time ...controller input is after all
just input to another function :P
10011011 00101010 11010111 10001001 10111010
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Drakonite wrote:What possible use could this have?
I'm not him, but maybe he wants to generate events for another program, or for a game, maybe a list of events in specific times to automatize some things.

Another possible use of this would be something like VNC, but at the contrary: controlling the psp with a computer or with another psp.
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

moonlight wrote: I'm not him, but maybe he wants to generate events for another program, or for a game, maybe a list of events in specific times to automatize some things.
...and we don't hack official games here.
Shoot Pixels Not People!
Makeshift Development
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Drakonite wrote:
moonlight wrote: I'm not him, but maybe he wants to generate events for another program, or for a game, maybe a list of events in specific times to automatize some things.
...and we don't hack official games here.
I didn't mention the word official, it can be whatever game ;)
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

moonlight wrote:
Drakonite wrote:
moonlight wrote: I'm not him, but maybe he wants to generate events for another program, or for a game, maybe a list of events in specific times to automatize some things.
...and we don't hack official games here.
I didn't mention the word official, it can be whatever game ;)
Thats still not really within our rules... If it's your game, you don't need to fake button presses like this.. and if it's someone elses, we really don't hack games like that here.
Shoot Pixels Not People!
Makeshift Development
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Drakonite wrote:
moonlight wrote:
Drakonite wrote: ...and we don't hack official games here.
I didn't mention the word official, it can be whatever game ;)
Thats still not really within our rules... If it's your game, you don't need to fake button presses like this.. and if it's someone elses, we really don't hack games like that here.
But still can be used for other things.
For example the psp vnc server concept. Useful? Probably not, but like a curiosity or proof of concept is right.
Devun_06
Posts: 15
Joined: Sat Jun 17, 2006 7:01 pm

Post by Devun_06 »

Well, I'd love to see how this is done, simply because it's the only way I see a program being able to turn off the PSP's screen and I want to introduce a nice sleep feature within my own program/eboot.
Zettablade
Posts: 71
Joined: Fri May 05, 2006 5:59 pm

Post by Zettablade »

Same here. So, uh, well? What is the code! lol sorry. I've been wanting to know all day...
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

Maybe a little late, but...

Post by vista200 »

I tried some ways and i found a solution:

You just have to add the PSP_CTRL_XXXXX to pad.Buttons like here:

Code: Select all

SceCtrlData pad;

while (1)
{
	sceCtrlReadBufferPositive(&pad, 1);
	pspDebugScreenSetXY(0, 0);
	printf("%i\n", pad.Buttons); // standard pad, nothing pressed
	pad.Buttons = pad.Buttons + PSP_CTRL_CROSS;
	printf("%i\n", pad.Buttons); // changed pad, where CROSS is pressed
	if (pad.Buttons & PSP_CTRL_CROSS) { printf("X is pressed!\n"); }
}
and tada, you see the message, that CROSS is pressed!

It works for me on 3.90 M33-2 with 1.50 Kernel

This is very useful when remote controlling the psp's music player! You just add your codes of your remote control and then switch songs with the remote.

Thus far from my side,
vista200
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Did you resume such an old post to say such wrong things?? Once you get pad data structure, that is YOUR LOCAL COPY of a system struct, not the struct itself....if you modify it in your code, then your code is the scope of your variable, and other processes CANNOT see the change: you definitely cannot drive the xmb mp3 player with this nonsense...local and global scopes:things i learned in a BASICA course when i was eight.
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

XmbController :D, LocoRoco motion :D, vshanalog, JoySens, RemoteJoy, etc
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

KickinAezz wrote:XmbController :D, LocoRoco motion :D, vshanalog, JoySens, RemoteJoy, etc
Ok, but none of these are made with that crappy code...they do it hooking sys function calls...i guess piKey sources are a good place to start learning how to do such a thing.....IF you can already code c and distinguish between local/global/process/system scopes.
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

jean wrote:
KickinAezz wrote:XmbController :D, LocoRoco motion :D, vshanalog, JoySens, RemoteJoy, etc
Ok, but none of these are made with that crappy code...they do it hooking sys function calls...i guess piKey sources are a good place to start learning how to do such a thing.....IF you can already code c and distinguish between local/global/process/system scopes.
Ofcourse! First two seem familiar to me, cuz they're are mine ;)
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

@KickinAezz
Oh, sorry i didn't know :)))) ....greetings for those good pieces of software...oh, and by "IF you can already code ..." i did not mean YOU, of course
hi!
User avatar
Leot91
Posts: 6
Joined: Wed Jun 04, 2008 3:36 am
Location: California
Contact:

Post by Leot91 »

Drakonite wrote:What possible use could this have?
I just thought of a good idea for this.
The possiblitys are endless.
My current psp status
3.71 M33 - 2, w/ 1.50 patch.
Type - Fat psp fully working
Pandora batt on hand.
** Im a willing betta tester **
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Posted: Fri May 12, 2006 11:37 pm Post subject:...
This post is old as my grandpa's ass, and all the "endless" possiblilities have been explored...take a look to the ton of homebrew starting with pikey
Mopeto
Posts: 1
Joined: Fri Jun 27, 2008 12:35 pm

Post by Mopeto »

I dont know if this works but the pump it up zero game have "replay" function which only press the butons you did.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Don't feel attacked, but....no, it's not the point.
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

jean wrote:
Posted: Fri May 12, 2006 11:37 pm Post subject:...
This post is old as my grandpa's ass, and all the "endless" possiblilities have been explored...take a look to the ton of homebrew starting with pikey
Slight exaggeration there jean, or your grandpa is only two years old :)
Post Reply