EdmondYap/Assignment4

1. Describe your exploration of your device - how you did it and what you found - in detail. You should describe your joystick, what code you wrote to learn about it, how the inputs mapped to the STJoystick interface we provide, ranges of values returned, etc.

I used a Playstation controller with two analog axes, plugged in through a USB adapter. 10 buttons, 2 axes, and the hat were all implemented.

To explore the joystick, I first "opened" a joystick and used the different STJoystick methods to find the number of balls, number of buttons, number of axes, and number of hats the joystick hats (I also intially queried for the joystick name, but decided to discard it). Knowing that there's no balls, I created arrays for the other joystick components. Whenever idle(), I would poll the states for each component by using methods getHat, getAxis, and getButton. To further "explore," I initially printed out all changes in the states (filtering out only for changes to prevent cluttering the console space). This allowed me to determine which button/axis/hat number corresponded to which. It also allowed me to get the range for the axes (simply by using the axes and printing out the values).

I implemented several methods for the texture and controller. I'm not sure if the mapping is similar from controller to controller, so the following may be specifically for the PS. I used the hat to move the texture smoothly left, up, down, right, and in between. I used the 4 buttons on the front (buttons 0-3) for rotating on the X and Y axes. I used buttons 4 and 5 (L1 and R1 on PS) for rotating on the Z axis. These buttons can be held to sustain the effect.

Buttons 6 and 7 (L2 and R2 on PS) are used to speed up or slow down. L2 (button 6) could be tapped to slow down rotation movements and the translation using the hat. Conversely, R2 (button 7) speeds up. Button 9 (Select on PS and possibly "reset" on certain controllers) is used to select between two different textures on the window. These textures can be moved and resetted indepently. Button 8 (Start on PS) can be used to "reset" the current texture. The left analog (Axes 0 and 1) are used to move the image around like the hat, but without the speedup/slowdown effect of L2/R2 (button 6/7). The right analog is used for scaling the image.

10 buttons, 2 axes, and the hat were all implemented.

When the 'Q', 'q', etc. is called, the program calls Close() on our Joystick and deletes the array for states.

Recent