Editing passed bool from define_key

Now I’ve run in to some trouble with a void pointer, so the compiler is no help :\

I have

bool key_map[4];

starting out filled with false.

I have the define key function call

framework.define_key(key_move_forward,"Move Forward",Player::Key_Press,(void*)key_map[forward]);

and the static Key_Press function

void Player::Key_Press(const Event* event,void* data){

I must be editing the bool incorrectly, but I’m not really sure how it’s supposed to be done.

Hi again

let’s see, where you have (void*)key_map[forward]
key_map[forward] is no longer a pointer since the [forward] is there, you’re just trying to set that one element, so I think you need to get its address via: &key_map[forward] and cast as you did: (void*)&key_map[forward] give that a try. I think the function is doing okay, casting back to bool* and de-referencing, and setting the value.


(void*)(&key_map + forward)

It works, thanks! I actually thought that might be it last night, right after turning off my computer :confused: