When I was making keyboard events with a local CGEventRef, I noticed that even though it was not a pointer, you could "edit" its properties with functions, like so:
CGEventRef eventRef = CGEventCreateKeyboardEvent(....);
CGEventSetFlags(eventRef, ...);
CGEventSetType(eventRef, kCGEventKeyDown);
Then you Postthe event. I know that if you do something like this;
Player p; //assume Player has an x property and a y property (both public)
p.x = 100000; p.y = -431;
void changePlayerPosition(Player player__, int x, int y){
player__.x = x; player__.y = y;
}
changePlayerPostion(10, 43);
std::cout << p.x << p.y; //prints x=1000000 y=-431 even though we tried to edit the values to 10 and 43 in the function
The values do not change even though we edited them in the changePlayerPosition function. I know you can fix this by getting the address of player__ in the argument i.e Player &player__.
That was an example. I guess my real question is, how is CGEventRef eventRefproperties like its flag, type, etc.edited without passing in a pointer or address in functions such as CGEventSetFlags, CGEventSetType, etc. Thank you so much!
