Name
Pass

17. Using input devices

16. Library | | 18. Configuration and parameters

A very fun part of LD4DStudio can be the usage of 'alternative input devices'. Normally you use a mouse and a keyboard for controlling your application, but many of us have more stuff laying around for example a joystick or gamepad. So while developing LD4DStudio I thought why not use those things too :)

Joysticks

Joysticks (or gamepads) I kinda hate them for playing games but I just came to love them while using one in LD4DStudio. Imagine a technic car on screen, fully animated mechanical works (steering, drive gear etc). Wouldn't it be neat to control it like a remote controlled car? Well with a gamepad configured for use in LD4DStudio you can!

For starters you need some kind of a joystick plugged into your system. After that you must add a profile for it in the "Joysticks" object beneath "Input devices" object. This is done by simply clicking the 'rescan' button of the object. If your device was connected at LD4DStudio startup it will already be present.

If your device is compatible you should end up with a "Joystick 1" object. This object has no buttons and only a name property. If you have more then one joystick you might want to give them more meaningfull names (like the make and model). LD4DStudio will try to bind profiles to the same physical device each time you start, but with multiple identical devices they might swap now and then.

Let's open the object window, because that's where the real action is.

Joystick window

The above shows the newly initialized window for my Logitech Dual Action game pad. If you have a different device it will not differ too much. You might just have less or more enabled axes and buttons.

Axis configuration

A joystick can have up to six axes. An axis is freely movable value controlled by a lever. Most joystick levers control two axes at once. You can therefore move them up/down and left/right. The more advanced (die hard gamer) joysticks have two of those levers and therefore give us four axes.

By moving the joystick levers you will see feedback in the window. The white areas will indicate movement by drawing green bars indicating the position of the axis/lever. For each axis you can configure two settings, namely: 'Reverse' and 'dead zone'.

'Reverse' is used to flip the reading of the axis. This is useful to ensure similar movement (e.g. right indication if lever is up/right and left indication if lever is down/right).

'Dead zone' is a percentage you can set to indicate the amount of movement to ignore before reporting actual movement. Most joysticks are pretty sensitive and moving the lever up will also result in slight left/right movement. By setting a higher dead zone percentage you can ignore these unwanted movements.

Button configuration

A joystick can have up to 16 buttons on it. You can assign a application action to any or all of them by selecting the desired action with the dropdown list located next to the button you want to use. To help you learn which button is which all buttons have a indicator for them. These will light up when you press a button.

Using the lights you can assign some useful actions to buttons. At the moment all actions are animation player related. You can choose from the following:

  • Pl. fast play
  • Pl. fast reverse
  • Pl. first
  • Pl. clear interval
  • Pl. interval enabled
  • Pl. interval end
  • Pl. interval start
  • Pl. last
  • Pl. loop
  • Pl. next frame
  • Pl. pause
  • Pl. play
  • Pl. prev frame
  • Pl. reverse
  • Pl. simulate
  • Pl. slow play
  • Pl. slow reverse
  • Pl. stop

I ended up configuring my joystick like below, but of course you're free to what you want.

Joystick window

Linking a joystick

When you're done configuring it's time to play around with it. To have the joystick actual control something you have to link it to a target. You can link a joystick to two objects at once, an Animation object and a control panel group object.

Let's begin with the animation object. First we need an open project to play with. Let's take the infamous excavator project. Open the project and locate/open the animation player window. The animation object has the following toolbar.

Toolbar

You might have noticed the 'joystick shaped' button before. With it you can link this animation object to a joystick. By pressing it it will be immediately linked unless you have more then one joystick. In that case you will get a selection dialog first to indicate which joystick to link.

Nothing seems to happen but see what happens if you press the joystick button you associated with play (Pl. play).

Even more fun is using the levers so lets link a control panel group. You do this much the same way, locate a control panel group and press it's joystick shaped button. When you do this you will bind the first slider / control to the first joystick axis, the second slider/control to the second joystick axis and so on.

The result, is quite fun, but somewhat unorganized if using for example the "control panel group 1" object. It's best to create a control group just for the joystick. This way you can set the order of sliders in such a way the movements of the character make sense while controlling the joystick.

The group below results in me controlling the excavator quite nicely.

Control group

I used a dummy to skip axis 3, this way I control the lowerArm by up/down (axis 4) movement instead of left/right (axis 3). Please note this all depends on the kind of joystick/gamepad you're using. It's up to you to setup a satisfying environment.

When you have troubles with the joystick, i.e. nothing is moving, check the 'simulate' property of the animation object. It should be disabled for this particular setup. The need to enable or disable it depends on the kind of sequences you have set up.

With 'simulate' on true the current animation frame will be recalculated on each redraw. If the animation element you control by a joystick axis is used in any of the sequences its value will be reset on each redraw. This results in 'freezing' the image and thus ignoring your joystick movements.

However, with sequences that calculate all kinds of mechanical dependencies (e.g. steering gears), keeping the 'simulate' property true will give you very nice results. Take for example the technicCar sample. Linking your joystick to the steeringWheel animation element (via a control panel group) let's you literally steer the car, because every time you change the steer angle (by joystick) all connected gears will be calculated to different angles.

If you no longer wish to control an animation or control group with the joystick, click the link information at the top. A dialog will ask if you want to remove the link, after choosing 'yes' the link will be gone.

Tablets

I always wanted to use a tablet in my software, and with the basic models getting cheaper I decided to just buy one to see if I can do something useful with it in LD4DStudio. The result is the Tablet functionality I will describe here.

A tablet is basically a second highly precise mouse whom is used 'absolute' instead of 'relative'. This means if you tab the table board at the top left, your mouse cursor will jump to that location on screen as well. Having a second mouse is nice but they both control the same cursor on screen unless the current application supports special tablet functionality.

While LD4DStudio is active your tablet will not be controlling the normal mouse cursor. Instead the program will use the location you are pointing at with the tablet pen much like a touchscreen.

Tablet sheets

For this to work you must know where to tab for a certain function (like start playing the animation). This is done by printing a tablet sheet whom you use as a overlay on your tablet. Most tablets have a special transparent sheet or panel you can you use for attaching a piece of paper.

So if you want to use your tablet with LD4DStudio you fist have to select and print such a 'guidance' sheet. This can be done from the 'tablet' object by clicking the '..' button of the 'sheet' property. Doing so will open the below dialog.

Tablet sheet selection dialog

By default the 'genericA5_nr1.xml' sheet will be assigned to your tablet. But a LD4DStudio installation comes with more then one sheet. These are placed in the 'tabletSheets' directory at your installation location. All available sheets in that directory will be listed in the top left list box. At the right of it you'll see a short description associated with the selected sheet. And most importantly the main area shows a preview of the selected sheet.

If you really want, you can create your own custom sheet, for more information on this go to the technical section.

Printing a tablet sheet

When you selected the sheet you want to use, you must print it and use it as a overlay on your tablet. This is done clicking the 'print' button. It will open below dialog.

Tablet print dialog

The dialog lets you configure a couple of options regarding to which printer to use and how to 'scale' the sheet to your situation. Most cheaper tablets are of size 'A5', but you can buy tablets as big as 'A3'. Nothing wrong with all that but to optimal use your tablet you should scale the sheet to such a size it pretty much covers your whole tablet. So you typically will select the 'A' size of your tablet in the 'limit to' field.

The field is called 'limited to' because most printers use A4 (or letter) type sheets. So to print an A5 tablet sheet only half of the A4 paper will be used. This means you probably will need to get some scissors ready before you can use the printed sheet.

The field 'margin' is used to set the margin (within the selected 'limit to' size) to be used from all sides, to insure the tablet sheet will be within the tablets 'active' area.

Last option lets you enable / disable printing in landscape. You usually want to print in landscape to ensure the A5 space fits nicely on your paper sheet.

When all options are set you can print the sheet by simply clicking the 'print' button, this will produce something like the below PDF preview (but on real paper of course).

Print results

After attaching it to your tablet you should end up with something like below.

Complete tablet

Calibration

Now you have a complete tablet setup it's time to open the 'tablet' object's edit window. Doing so will result in something like the picture below.

Tablet window overview

The window isn't that exciting yet it 'says' calibration is needed. Calibration is a two step process which tells LD4DStudio 'where' the tablet sheet is on the active space of the 'tablet'. This information is needed in order to translate the tablet pen position to objects drawn on the sheet (like a button or slider).

Calibrating your tablet is very simple just click the first button in the windows main toolbar. Doing so the first time will result in a message dialog saying 'Tablet needs to be enabled'. So lets first enable the tablet by setting the 'enable' property in it's object to 'true'.

Afterwards click the calibration button again, this time the text in the window will change to 'Tab the calibration circles', these are the two circles at the top left and bottom right of the sheet. To get the best calibration try to tab them in their dead center. The order you tab them in does not matter. When you tapped the second circle the tablet window will preview the sheet in relation to it's position on the tablet. This should look something like the below picture.

Tablet window overview

You now ready to start using your tablet in any LD4DStudio project.

Linking the tablet to an animation

Just like the joysticks you need to link an 'animation' or 'control panel group' object to the tablet for to make controlling something with your tablet possible. Let's start with linking an animation. Open, for example, the excavator project and select the 'animation 1' object. Now press the below button.

Link button

This will link this animation object to your tablet. Now, at the top left of the (default) tablet sheet you'll see a series of rectangular buttons with 'playback deck' icons on them.

Buttons on sheet

These represent the buttons just like the ones you you know from the animation window bottom bar. Tapping any of the buttons on the sheet should have the same effect as clicking it in the animation window. Tab the play button for example (the fifth button at the top), this should start the playback of the excavator animation on screen.

Besides the 12 playback buttons you can also control the current playback position and even change the interval. this is done with the bottom row of 'virtual' slider and buttons. Put the animation in pause and (while holding the pen down) try to slide you pen inside the large rectangle from side to side. You'll see this will move the position indicator on screen, and the monitor will change as well.

At the top right of the tablet sheet you'll find same additional sliders and buttons, see below.

Buttons on sheet

The first 'bar' you can use to control playback speed while holding and moving your pen in the rectangle. Moving right from the center will play backwards in speeds increasing the further you move right. Moving left from the center will forwards in speed increasing the further you move.

The second 'bar' works much the same but it uses slow motion instead of fast play. The last three buttons control, 'I: Interval on/off', 'L: Loop on/off' and 'S: Simulate on/off'.

Linking the tablet to control panel groups

Also just like the joysticks you can link your tablet to 'control panel groups', but depending on the sheet your using, you optionally can link multiple groups at once. The default tablet sheet we've been working with up till now supports two groups, namely "Analog" and "Binary". These are targeted at one group containing up to 10 analog sliders, and one group containing up to 5 binary switches.

Before we link any control panel group, be sure 'simulate' is disabled because it will 'lock' most of the joint animation elements in the excavator project.

Let's link the 'Analog' group to the 'ControlGroup2' group (the one with the main joint sliders on it'. Make sure the said control panel group is current in the control panel window. If so clicking the below button, this will open a dialog asking to which tablet sheet control group you want to link.

Link button

Select group dialog

Select 'analog' and click 'select'. You can now control the sliders in this control panel group using the left vertical collection of 'virtual' sliders on your tablet sheet (see picture).

Sliders on sheet

These sliders are somewhat more advanced then the previously discussed one. They allow multiple ways of controlling the associated animation element. By moving the pen in the top 'diamond' shaped part of the slider rectangle you will be controlling the element relative. So moving the pen up will increase the value and moving it down will decrease it, no matter where you start moving inside the rectangle.

The below part of the slider rectangle (The part with two vertical lines) let you control the slider absolute, so depending on where the pen is a value will be calculated. This is basically the same as the sliders on screen.

In the middle of the slider you'll see two small buttons (one downwards arrow, one circle). The 'arrow' will round the current value just like the END key in the control panel. Tapping the 'circle' will reset the element to it's rest value, just like the HOME in the control panel.

Last thing you can try is linking the second (binary) group to a control panel group. For this to work you first need to create a new control panel group with some binary controls on it. You should be able to this (read the control panel chapter) and end up with something like below.

Binary control panel group

Of course you're free to choose different kind of elements. Now link the new control panel group to the "Binary" tablet sheet control group. When you do this you'll be able to control the 'switches' in the control panel group using the below 'buttons' on the sheet.

Buttons on sheet

These buttons are very basic, tapping the left top of one of them (notice the diagonal line) will set the element to 'false' and tapping the right bottom will set it to 'true'.

Thats it, you are now familiar with basic tablet use. I suggest you just try controlling more animations to get the real hang of it all. If you are experiancing some problems be sure to check the FAQ section of the site for some solutions to common problems.

16. Library | | 18. Configuration and parameters
Best viewed with Firefox 2, Seamonkey or IE 7 at 1024x768 or higher resolution.
 
LEGO is a registered trademark of the LEGO Group, which does not sponsor, endorse, or authorize this website.