I sent this to KennyTM (has all the private framework headers on GitHub) but I figured I\'d ask here too just in case someone has some good ideas or any way to help me out.<
First, what's the simplest way to declare a GSEvent and send it?
It depends on the type of the GSEvent. Some events have convenient functions that can be created and sent in one step, e.g. GSEventLockDevice()
. But HID events (touches, key presses, etc.) do not have these simple functions. The reason is likely because GSEventLockDevice()
etc are to be sent from the app to SpringBoard, but HID events are sent from SpringBoard to an app. Therefore, only the SpringBoard team needs to know how to construct a complicated GSEvent.
Anyway, to create a HID event (e.g. accelerometer event) you don't need to create a GSEvent. Just use GSSendEvent()
:
// (not tested.)
GSAccelerometerInfo accel = {0.0f, 0.0f, 1.0f};
GSEventRecord header;
memset(&header, 0, sizeof(header));
header.type = kGSEventAccelerate;
header.infoSize = sizeof(accel);
header.timestamp = mach_absolute_time();
// fill in other members.
struct {
GSEventRecord record;
GSAccelerometerInfo info;
} record = {header, accel};
// ... see below ...
GSSendEvent(&record, thePortOfApp);
But what is "the port of app"? Unfortunately there's no function to get that. As of 3.1, the name of the mach port is same as its bundle ID, so you could use:
mach_port_t thePortOfApp = GSCopyPurpleNamedPort("com.unknown.appBundleID");
...
mach_port_deallocate(mach_task_self(), thePortOfApp); // remember to release the port.
Also, do I have to write or do anything special if I want this utility to operate all applications as well as Springboard?
As far as I know, no.
For the other two, probably you should split them into individual questions.