I'm using an XBox360 controller to test the Controller code for my game. The A button (joy_1) is supposed to click whichever button the mouse cursor is hovering over at the time. I'm changing the mouse position with this code
mouse_pos.x += joy_force.x;
mouse_pos.y += joy_force.y
The mouse cursor moves but the buttons don't display their mouse_over images or run their mouse_over functions unless I use my real mouse to make sure the mouse pointer is in the game window. If my PC's mouse pointer is outside the game window, my XBox Controller will still move the mouse pointer within the game window.
The bigger problem is the fact that I can't tell the Controller to click on the button the mouse is on. Someone here gave me a snippet that works, but I have to write a different mouse_over function for EACH button telling it to constantly check whether the mouse is over the button and then whether the joy_1 button was pressed, then wait for the button to be released before running the specific function mapped to that button.
Basically, I can't get/set pointers to specific buttons within a panel or get pointers to which functions are mapped to the buttons, so I have to manually write such hover functions for each button. Any snippet that would make this task easier would be highly appreciated.
function ChooseCharacterOne() //function mapped to button
{
//some code here
}
function PadChooseCharacterOne() //typical hover function
{
play_mouse_over_sound();
while(joy_1)
wait(-1);
if(event_type = EVENT_TOUCH)
{
while(event_type != EVENT_RELEASE)
{
if(joy_1)
ChooseCharacterOne();
wait(1);
}
}
button(10, 10, 10, 10, ButtonOnImage, ButtonOffImage, ButtonHoverImage, ChooseCharacterOne, NULL, PadChooseCharacterOne); //typical button code