# Programmable Input Emulator 0.41 Introduction

(Don't forget to also read the Documentation.rtf file)

The GlovePIE Programmable Input Emulator (previously known as PIE) emulates input devices by using other input devices.
This means you can use the joystick in a keyboard only game (eg. DOOM3) or the keyboard in a joystick only game (eg. Return Of The King Co-op mode). Or you can control any game with a virtual reality glove. Or you can create macros to do complex moves at the touch of a button (eg. Mortal Kombat). Or you can play musical instruments from your PC.
This is still a beta version, so it will be buggy and incomplete.

## You can emulate:

- the mouse
- the keyboard (on windows 2000 and XP)
- Multiple joysticks or gamepads (if you download and install PPJoy)
- Multiple MIDI devices (if you download and install Midi Yoke or Hubi's loopback driver)
- Microphone input (in theory)

## You can get input from:

- multiple mice
- multiple keyboards
- multiple joysticks or gamepads
- Multiple Essential Reality P5 virtual reality gloves
- multiple MIDI devices
- a microphone

## Requirements:

- DirectX 8 or higher
- PPJoy if you want to use virtual joysticks
- Midi Yoke if you want to emulate MIDI input
- Windows 2000 or above if you want to emulate the keyboard
- SAPI 5.0 (Comes with Windows XP and Office XP) or SAPI 5.1 if you want speech synthesis and recognition

I highly recommend buying an Essential Reality P5 virtual reality glove. They are very cheap. You can do wonderous things with a virtual reality glove and PIE! Actually you should buy two since they are cheap and you save on shipping if you buy both at once.

## Installing:

Just extract the ZIP file into whatever folder you want. There is no installation program.
You will also need to download and install PPJoy and Midi Yoke if you want to use them. After you install PPJoy you need to create at least one virtual joystick.
You should associate .PIE files with GlovePIE in windows, so you can just click on PIE scripts and open them in GlovePIE.

## Uninstalling:

Just delete the folder you installed GlovePIE into.
You may also want to remove or change the association for .PIE files.

## Running:

You can start GlovePIE by double clicking on its icon in windows explorer, or by double clicking on a .PIE file if you have set up the associations. You can also start it from a command prompt (aka DOS window), or create a shortcut to it on your desktop, quick-launch bar, or start menu.
By default, when PIE starts it displays an empty script window. You can write a new PIE script there, or you can load an existing file from the file menu. But it will not actually do anything until you choose "Run" from the "Run!" menu. Then it will check your script for errors and run it. If there are any errors it will just ignore those lines. When you have finished playing you can choose "Stop" from the "Run!" menu. PIE will not emulate anything unless it is running. Exiting PIE by closing its window will stop all emulation. You can also just check your program for errors without running it by choosing "Check for errors" from the "Run" menu. If there are any errors a box will pop up at the bottom of the window with a list of errors and line numbers. If nothing appears then there are no errors. You can tell when your script is running because the title bar at the top of the window will change.
If you run PIE from the command prompt or a shortcut then you can specify command line parameters. You must use quotation marks around any parameter which includes a space.

filename.PIE | The name of a PIE script to open. You may or may not include the .PIE extension. The script will not do anything until you choose "Run" from the "Run!" menu.
    -filename.PIE
| The name of a PIE script to open and run. You may or may not include the .PIE extension. It will start running automatically
    /r:filename.EXE
| The name of a .EXE file or other program to start running automatically when PIE starts. This allows you to start the game and PIE at the same time.

## Menus:

PIE has the following menus:

File |  | Standard file menu. Except the only way to save files is by choosing "Save As..."
File | New | Clears the script window. You will lose your work if you haven't saved it.
File | Open... | Load a PIE script file. This will not start it running until you choose "Run" from the "Run!" menu. You will lose your work if you haven't saved it.
File | Save As... | The only way to save a file. If you don't use this you will lose your work! You need to choose the filename every time. Sorry.
File | Exit | Quit PIE and stop emulating anything. Please save your work before you choose this. It will NOT ask you whether you want to save.
Edit |  | Standard edit commands
Run! |  | The Run menu is for running and checking your script. It won't emulate anything unless it is running.
Run! | Check for errors | Check the script for errors. This was called "Compile" in the previous version. Only use this while your program is not running. A box will pop up at the bottom of the window if there are any errors. Errors will also be highlighted in red. You can single-click on an error in the box to go to that line.
Run! | Run | Start your script going. This starts the actual emulation process. Basically it will just loop through your script about 40 times per second. If there are any errors they will be highlighted and included in the error box, but the script will still run and just ignore those lines. The script will keep running until you chose "Stop" from the "Run!" menu, or try to close the PIE window. While running, your script may move the cursor around or press keys which may do bad things to the PIE window if it is in the foreground. I recommend starting notepad and placing it in the foreground while you are running a script that presses keys.
Run! | Stop | Stops your script running. You should do this before you check for errors or run your program again. You don't need to do this before closing the window, that will stop it automatically.
Settings |  | Turns the P5 gloves' mouse mode off, or brings up Control Panel applets for the various input devices PIE uses.
Settings | Turn P5 Mouse Mode Off | If you have any P5 virtual reality gloves connected, this will switch off mouse mode for all of them. Don't do this while your script is running or the P5 will no longer work with it.
Settings | Control Panel | Starts control panel
Settings | P5 | This will bring up the P5 control panel (for your virtual reality glove) if it is installed. You can calibrate or test your bend sensors, change the mouse mode settings, or test the buttons. This is the original Essential Reality version that only supports a single glove. If you want to calibrate or change the settings for multiple gloves, you should download the Dual Mode Driver and use its VBControlPanel instead.
Settings | PPJoy | Brings up the PPJoy control panel, if PPJoy is installed. This allows you to add virtual joysticks or set the number of buttons, axes and hats the virtual joystick has. You can also chose which axes or hats correspond to analog0 to analog15, and what buttons or hats correspond to digital0 to digital31.
Settings | Joystick | Brings up the Game Controllers or Joystick control panel. It allows you to test your virtual joystick. I don't recommend calibrating virtual joysticks.
Settings | Mouse | Brings up the mouse control panel.
Settings | Keyboard | Brings up the keyboard control panel.
Settings | MIDI | Brings up the closest thing to a MIDI control panel. This should allow you to chose which MIDI device you want to use as the default output.
Settings | Speech | Tries to bring up the Speech control panel to change the default text to speech voice. This may not work if the SAPI is not installed in the default directory.
TroubleShooter |  | This menu allows you to disable features that you don't think are working or are giving you errors. The settings are not saved between sessions. It was designed for an error some people got with the joystick, but those error messages no longer appear so it is unnecessary.
Help |  | Get help on PIE.

## Scripting Tutorial:

### Tutorial 1 - easy stuff

Lets make a pie script to simulate pressing the W, A, S and D keys when you press the arrow keys.
This will not work on Windows 98.
Start up PIE.
Choose the "File" Menu, then click "New". This will clear whatever was in the big white box so you can type your own script.
We want the W key to be controlled by the up key so type this on one line then press Enter:
W = Up
This is a working PIE Script so you can test it by choosing the "Run!" menu and clicking "Run".
Whenever you press the up arrow key (on the cursor pad, not the numeric keypad) it will type a "w". Try it out! This will work in any program.
Note that it will still move the cursor up. The Up arrow key still has its original function, but it emulates a w at the same time. Try holding down shift and pressing Up. It will type a capital W, unless capslock is on. Unlike the real "W" key, holding down the Up arrow will only type a single "w".
Now chose the "Run!" menu and click "Stop". This will return our keyboard to normal.
Now do the other keys like this:
A = Left
S = Down
D = Right
(Don't worry if the S is orange, that is because S is also an abbreviation for seconds).
Save your script as Tutorial1.PIE by chosing the "File" menu then "Save As...".
And run it again. Stop it when you have finished playing.
You can change it to use any keys you want. You can even use keys that don't exist on your keyboard, like the MediaPlay key which is on some multimedia keyboards. If you don't know what a key is called, just guess. It is not fussy about the key names. You could have written this and it would still work:
W = UpArrow
A = CursorLeft
If you want to make it clear that it is a key on the keyboard, you can type this:
key.W = key.Up
(When you type the dot it will pop up with a list of keys. If you can't get out of this, click somewhere in the PIE window. Then press Control + Space and the list will pop up again, but this time it should work. If not, choose the "Troubleshooter" menu and click "Disable Code Completion")
or this:
keyboard.W = keyboard.Up
or even this:
keyboard's W = UpArrow of Keyboard

### Tutorial 2 - emulating a joystick

This time we will control a virtual joystick using the keyboard.
This will only work if you have downloaded and installed PPJoy.
This is not really much harder to do in PIE than the keyboard, but we have know how to use PPJoy and the joystick control panel first. So please be patient.
Start PIE.
Click File/New.
But before we write our script, we need to make sure PPJoy is set up correctly.
Chose the "Settings" menu and click "PPJoy".
If PPJoy is installed it should pop up with a window titled "PPJoy Joystick and Gamepad Configuration Utility".
There is a big white list box in the middle of the window with the heading "Configured joysticks". One of the items in the list needs to be "Virtual Joystick 1".
If Virtual Joystick 1 is not there, or the box is empty then you need to do the following:

- click the "Add..." button.
- Where it says "Parallel port" choose "Virtual port"
- Where it says "Controller number" choose "Controller 1"
- Click the "Add" button
- Now wait and go through the hardware setup dialog boxes that pop up
- Choose the default options in any dialog boxes
- Be patient, it needs to find and install several drivers

Regardless of whether it was there before, or you just added it, you should have a "Virtual Joystick 1" in the list box. Select it and choose "Mapping". It will pop up with the dialog box saying "Welcome to the Joystick/Pad mapping wizard". If it doesn't work then you probably weren't patient enough in the previous step. Choose "Set a custom mapping for this controller" (which should already be selected) and click "Next >". Now you can choose how many axes, buttons and hats the virtual joystick should have, and which axes they are. Leave the default settings and click "Next >". Now you can choose which analog inputs control which axes. You will notice that analog0 controls the x axis (horizontal), and analog1 controls the y axis (vertical). These are good defaults so click "Next >". Now you can choose which digital inputs should control which buttons. Notice digital 0 controls joystick button 1, and digital 1 controls joystick button 2. These are also good defaults so choose next. Now you can choose which analog or digital inputs control the imaginary hats on the top of the joystick. One will be controlled by digitals 16-19 and the other will be controlled by analog 8. These are good defaults too, so click Next and then Finish.
Click "Done" in the PPJoy control panel and go back to PIE.
We can test the virtual joystick we just made by choosing the "Settings" menu and chosing "Joystick". This will open up the joystick control panel. Choose PPJoy Virtual Joystick 1 and click "Properties". Now it will pop up with another dialog box, choose the "Test" tab. This displays all the axes and buttons on the virtual joystick. They should all be in the middle.
Now lets make a PIE script to control the virtual joystick. Assuming your screen resolution is 1024 by 768, Type the following:
ppjoy.analog0 = (mouse.cursorposx - 512) / 512
Remember how analog 0 was the x axis in the mapping before? Well it was.
The above line sets the analog 0 value for virtual joystick 1 to a number between -1 and 1 depending on the location of the mouse cursor on the screen.
Now run your script by choosing Run/Run on the menu. Go back to the Joystick control panel's test tab and see how the horizontal position of the cross in the box is controlled by the mouse.
Now let's do the same for the y axis (384 is half the screen height):
ppjoy.analog1 = (mouse.cursorposy - 384) / 384
This works because PIE uses joystick values between -1 and 1. The cursor position is in pixels from 0 to 767. Subtracting 384 gives a value between -384 and 383. Dividing by 384 gives a value between -1 and (almost) 1.
There is an easier way to do the exact same above calculations in PIE:
ppjoy.analog0 = MapRange(mouse.cursorposx, 0,1023, -1,1)
ppjoy.analog1 = MapRange(mouse.cursorposy, 0,767, -1,1)
Now let's do the buttons:
ppjoy.digital0 = mouse.LeftButton
ppjoy.digital1 = mouse.RightButton
ppjoy.digital2 = mouse.MiddleButton
ppjoy.digital3 = mouse.XButton1
ppjoy.digital4 = mouse.XButton2
Now run your script and test it in the joystick control panel or a game. You should be able to control the joystick with the mouse.
If you wanted to control virtual joystick 2, you would just change ppjoy to ppjoy2.
eg. ppjoy2.digital0 = mouse.LeftButton