query for the controller APIs..

Are different controllers supported by simulator
Aim to check different controllers on the simulator.
Actually, I tried on the simulator, using controller APIs. It is showing that 3 controllers are attached to the simulator (remote controller, keyboard and mouse). I wrote a script in which I created two events and initialised them using initControllerKeyEvent Api. First Event was initialised with parameter ' id ' having value of keyboard id and the key value was ' 0x30 ' for VK_1' key code, and the second Event was initialised with parameter ' id ' having value of mouse id and the key value was ' 0x01 ' for VK_MOUSE_1' key code.
Expected output : On dispatching these events, two different images should be generated according to the event that got dispatched, i.e on pressing VK_1 ( key 1 of keyboard ), a square should get generated and on pressing VK_MOUSE_1 ( first button of mouse ), a circle should have got generated.
Actual output : Dispatching of event is taking place irrespective of the key code that I inputted as the parameter.On pressing any key,the event is getting dispatched and also irrespective of the controller.
Please tell the possible ways to check different controllers..
Thanks in Advance
Azaz




Answer this question

query for the controller APIs..

  • precious1026

    Not sure I understand fully, but it appears that you actually created events in script and then dispatched them How is that related to telling different controllers apart

    You will always get a controller_key event whenever a key is pressed, what you could do is add an event listener for controller_key_up or controller_key_down, and then examine the controller id. you could then tell which controller it came from.

    You cannot tell in Markup, an AccessKey doesn't care about which controller activated it.


  • Guostong

    Well, I don't see where in your code "fun()" ever gets called, and when it is, it will immediately send both key events, which is not the same as a person pressing the key.
  • phamilton7733

    Hi,
    Thanks a lot.
    I got the problem solved as you said by using key handler and switch cases for the key value.
    But the code that I have sent, whats wrong with that I think that should also work....but unfortunately not working as expected.

    Regards
    Azaz


  • d_xflow

    Hi Bryan,
    Thanks for the reply .
    Actually I am trying to check the functionality of two different controllers attached to the player.
    For that I have created an object in markup. In this object, a Circle should appear when key 1 of keyboard is pressed, and square should appear when VK_MOUSE_1 is pressed. I created two events and initialised them with different controller ids and respective key on the controller (i.e VK_1 on keyboard and VK_MOUSE_1 on mouse). I made Event 1 for controller key down for keyboard and Event 2 for controller key up for mouse.
    I have not defined any access key in markup for these keys.Beloh is the code :
    The function 'fun' will be called on markup loading.

    ///////////////////////////// start ////////////////////////
    /* Mark up*/
    <head>
    <body....>
    <div....>
    <object id="daObj2" type="application/x-graphic" style:height="1070px" style:width="1910px" style:position="absolute">
    <param...../>
    <param...../>
    </object>
    </div>
    <body>
    </head>

    /* script */

    function fun(e)
    {
    var event1;
    event1 = document.createEvent("controller_key_down");
    event1.initControllerKeyEvent("controller_key_down",true,true,1,900,400,100,200,0,0,0x30,"VK_1",0,0);
    document.getElementById("daObj2").dispatchEvent(event1);

    var event2;
    event2 = document.createEvent("controller_key_up");
    event2.initControllerKeyEvent("controller_key_up",true,true,2,900,400,100,200,0,0,0x01,"VK_MOUSE_1",0,0);
    document.getElementById("daObj2").dispatchEvent(event2);
    }

    function event1(e)
    {
    obj= getDrawingArea_obj2("daObj2");
    var color1=Drawing.createColor(60,179,113,127);
    var brush1=Drawing.createSolidBrush(color1);
    var color2=Drawing.createColor(128,128,0,255);
    var pen1=Drawing.createPen(color2,10);
    obj= getDrawingArea_obj2("daObj2");
    obj.drawEllipseCoord(pen1,brush1,300,300,650,600);
    }

    function event2(e)
    {
    obj= getDrawingArea_obj2("daObj2");
    var color3=Drawing.createColor(102,205,170,127);
    var brush2=Drawing.createSolidBrush(color3);
    var color4=Drawing.createColor(65,105,225,255);
    var pen2=Drawing.createPen(color4,10);
    obj.drawRectangleCoord(pen2,brush2,p,q,300,300);
    }
    addEventListener("controller_key_down",event1,false);
    addEventListener("controller_key_up",event2,false);

    ////////////// ends ///////////
    Please see if there is any problem in the code...
    thanks in advance
    Azaz


  • query for the controller APIs..