Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0001856 [opensim] [REGION] OpenSim Core feature always 2008-07-29 12:40 2008-08-16 12:41
Reporter lmmz View Status public  
Assigned To cfk
Priority normal Resolution fixed  
Status closed   Product Version
Summary 0001856: r5698- control() API not implemented properly
Description I have been experimenting with the llTakeControls() and control() API. I have compared the return from the API on LL grid and on OSGrid. The API is not returning values on OSGrid which are consistent with what is returned on LL grid.

First, on OSGrid, the control() event fires constantly once TAKE_CONTROLS() is accomplished. This causes horrible lag in reading controls. The control() event should only fire when the desired controls are actually hit.

Second, on OSGrid, the control() event returns 512 instead of 256 when controls are actually hit.

Third, our LSL script engine complains that the bool values for control(), changed and held, are integers and cannot be cast to bool. That's wrong.

Here is a script I used to test the API on OSGrid and LL grid. This script was to go in a pinball machine I am making, to control the flippers.


default
{
    state_entry()
    {
        llSay(0, "running");
    }
    
    touch_start(integer x)
    {
        llSay(0,"Want to play? I need to read your keyboard.");
        llSay(0,"Click YES on the permission dialog which will appear at the top right of your screen.");
        llRequestPermissions(llDetectedKey(0), PERMISSION_TAKE_CONTROLS);
    }
    
    
    run_time_permissions(integer perms)
    {
        integer desired_controls =
                
                CONTROL_ROT_LEFT |
                CONTROL_ROT_RIGHT
                ;

        if (perms & PERMISSION_TAKE_CONTROLS) {
            llTakeControls(desired_controls, TRUE, FALSE);
            llSay(0,"You can now use your keyboard's LEFT ARROW and RIGHT ARROW keys as flipper buttons.");
            llSay(0,"You can click RELEASE CONTROLS to get keyboard control back.");
        }
    }
    
    
    
    
    control(key id, integer held, integer change)
    {
        
        llSay(0,"control: held="+(string)held+"and CONTROL_ROT_LEFT="+(string)CONTROL_ROT_LEFT+"and change="+(string)change);
        
        if ( held == 512 & change == 512 & CONTROL_ROT_LEFT == 256 )
        {
            llSay(0,"left flipper held.");
        }
        
        
        else if ( held == 0 & change == 512 & CONTROL_ROT_LEFT == 256)
        {
            llSay(0,"left flipper released.");
        }
        
    }
    
    
    
}
Additional Information
Tags No tags attached.
Git Revision
SVN Revision 5698
Run Mode Grid (Multiple Regions per Sim)
Physics Engine ODE
Environment Mono / Linux32
Mono Version None
Attached Files ? file icon fix_control_event.patch [^] (4,891 bytes) 2008-08-12 10:14

- Relationships

-  Notes
(0004227)
lmmz (reporter)
2008-08-05 18:28

any takers? :)
(0004240)
lmmz (reporter)
2008-08-07 09:45

I hope we can implement better input functionality than the Lab, in the long run.
(0004332)
HomerHorwitz (manager)
2008-08-12 06:35

I'll try to fix the first and the second point. On the third point: They aren't booleans, they are bitmasks (i.e. integers). I don't know where they are cast to boolean, either. The behaviour in SL is:
As long as a taken control is active (e.g. you press the "rotate left" key), the control fires repeatedly with held set. change contains the difference between the last value of held and the current one once, then 0. After all keys are released, you'll get a last event with change set to the last change, then the events stop until next press. So, you might get a sequence like (held, changed):
256, 256
256, 0
256, 0
768, 512
768, 0
512, 256
512, 0
0, 512


lmmz: I hope so, but that isn't exactly an input functionality. It's named "control" for a reason: It maps to the contolling of the agent (you can even use the arrows in the agent-control window to activate the control events). I'd like to see something like a key-event in OpenSim, which returns keys you pressed (and the script requested info on). But that would need a modified viewer, too, of course.
(0004339)
HomerHorwitz (manager)
2008-08-12 10:16

Ok, here's the patch. Changes are:
- In the call of SendControlToScripts, LastCommands was a parameter. Then, in
  the method itself, it is overwritten.
  Either change it outside of the method (and transfer it into it via
  parameter), or access the instance-variable inside of SendControlToScripts,
  but then don't pass it via parameter (as we access it directly anyway).

- Use of YAW_POS/NEG was wrong. YAW_POS means ROT_LEFT, YAW_NEG means
  ROT_RIGHT.

- Streamlined and corrected the code that sends the ControlEvents to the
  scripts. Events should now be sent as described in my previous note
(0004355)
lmmz (reporter)
2008-08-12 21:23

Was this patch implemented? Control() seems to work better now. Control() still fires constantly after the avatar agrees to let a script manage the controls. That shouldn't be happening. Control() should only fire when the chosen control is actually hit. I have tested my script against the Linden grid and confirmed this behavior on Linden grid. Thx for working on this, Homer!
(0004367)
HomerHorwitz (manager)
2008-08-13 03:09

The patch was implemented (otherwise I couldn't have it attached), but not committed to SVN yet. When the patch goes into SVN, a note is added with something like
  'commit as rXXXX'.

You can apply the patch yourself, of course, for testing.
(0004380)
cfk (administrator)
2008-08-13 07:53

commit as r5834

- Issue History
Date Modified Username Field Change
2008-07-29 12:40 lmmz New Issue
2008-07-29 12:40 lmmz SVN Revision => 5698
2008-07-29 12:40 lmmz Run Mode => Grid (Multiple Regions per Sim)
2008-07-29 12:40 lmmz Physics Engine => ODE
2008-07-29 12:40 lmmz Environment => Mono / Linux32
2008-08-05 18:28 lmmz Note Added: 0004227
2008-08-07 09:45 lmmz Note Added: 0004240
2008-08-12 06:35 HomerHorwitz Note Added: 0004332
2008-08-12 10:14 HomerHorwitz File Added: fix_control_event.patch
2008-08-12 10:16 HomerHorwitz Note Added: 0004339
2008-08-12 10:16 HomerHorwitz Status new => patch included
2008-08-12 21:23 lmmz Note Added: 0004355
2008-08-13 03:09 HomerHorwitz Note Added: 0004367
2008-08-13 07:53 cfk Status patch included => resolved
2008-08-13 07:53 cfk Resolution open => fixed
2008-08-13 07:53 cfk Assigned To => cfk
2008-08-13 07:53 cfk Note Added: 0004380
2008-08-16 12:41 cfk Status resolved => closed


Mantis 1.1.1[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker