antirez / load81

SDL based Lua programming environment for kids similar to Codea
BSD 2-Clause "Simplified" License
599 stars 62 forks source link

Feature: Joystick support for up to 8 Devices. #52

Closed seclorum closed 12 years ago

seclorum commented 12 years ago

I have re-implemented Joystick support.

This patch adds Joystick support to LOAD81. It allows up to 8 devices to be used within the Lua environment, and for that purpose adds a new global Lua table called 'joystick', with fields x, y, and name, where:

x = X-axis value of the joystick y = Y-axis value of the joystick name = name of the joystick device

This patch includes Joystick button support (1-button per Joystick, for now..)

Tested on Open Pandora hardware, and Macbook Pro with paired iControlpad controllers. On Open Pandora hardware, joysticks will be named thus:

joystick[1].name = "gpio-keys" (Special feature of Open Pandora, for hardware hackers mostly) joystick[2].name = "nub0" (The Left nub) joystick[3].name = "nub1" (The Right nub) joystick[2].button = 0 or 1, depending on if button = up or button = down

seclorum commented 12 years ago

Also, joystick.count now contains the total joysticks found, and the global Joystick table is re-scanned every time a switch from editor to program is done, so it should work to find new joysticks plugged in during editing.

seclorum commented 12 years ago

Also to note: all points addressed in previous commit rejection.