Maybe mouse_mode = 1 has to be mouse_mode = 2;
And you better can't call the mouse_map and the mouse_mode in the while(1) loop, i guess.