Skip to content

Joystick support (final) #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d189e66
Re-do of Joystick support: dynamic alloc, reset
Mar 17, 2012
d20ede6
Joystick Example.
Mar 17, 2012
adbb468
Fix for Open Pandora --bpp arg selection.
Mar 17, 2012
6253a45
Basic button support.
Mar 17, 2012
b6990e5
Slight tweaks to the joystick demo.
Mar 17, 2012
c6f8656
Unneeded whitespace.
Mar 17, 2012
e564215
Whitepsace
Mar 17, 2012
741a081
Added to support mouse scrolling, page up, page down, home, and end
cobrajs Mar 21, 2012
55b197e
Merge pull request #1 from cobrajs/editorchanges
seclorum Mar 22, 2012
30cedc7
Add support for drawing polygons
cobrajs Mar 23, 2012
1b31c17
Reworked a bit, and added some error trapping
cobrajs Mar 23, 2012
63c6660
Added filled() binding to set the filled state
cobrajs Mar 23, 2012
58ffaa4
Merge branch 'polygon'
cobrajs Mar 24, 2012
c45dfab
Merged, added filled stuff for polygon
cobrajs Mar 24, 2012
f2a8f54
Added functions to the README
cobrajs Mar 24, 2012
eb1178e
Added tiling support to sprites
cobrajs Mar 24, 2012
c99f611
Merge pull request #2 from cobrajs/master
seclorum Mar 24, 2012
58b1161
add joystick support to flames.lua
seclorum Apr 1, 2012
2392e99
consistency check
seclorum Apr 1, 2012
9175910
add joystick support to flames, include new gridify sample
Apr 4, 2012
c566aed
Merge.
Apr 4, 2012
265a1bb
fix for case where no joysticks are available
Apr 4, 2012
6879ff3
Update README.md
seclorum Apr 4, 2012
074639f
slight edit
Apr 4, 2012
fbe0b30
fix for joystick note
Apr 4, 2012
b06cf64
Fixup of gridifuy.lua sample.
Apr 4, 2012
20279c3
timeout demo started
seclorum Apr 11, 2012
8c13a7e
joystick support for timeout.lua
seclorum Apr 11, 2012
c0ef305
color support in timeout.lua
seclorum Apr 11, 2012
c9e3a01
Merge branch 'master' of github.com:seclorum/load81
Apr 12, 2012
081392d
joystick check
Apr 12, 2012
6b2ee93
comments
seclorum Apr 15, 2012
e524e98
Merge branch 'master' of https://github.com/seclorum/load81
seclorum Apr 15, 2012
a6e6074
fix of merge hiccup
seclorum Apr 15, 2012
7a338a6
tweaks
May 2, 2012
5d167aa
Merge branch 'master' of github.com:seclorum/load81
May 2, 2012
a8adc33
pull antirez
seclorum Jul 14, 2016
47a35ef
Adjust Makefile to use sdl-config instead of pkg-config
Sep 12, 2016
8b74739
Add Darwin-specific hooks to compile against SDL_gfx/etc. from homebr…
seclorum Sep 14, 2016
86fbc71
Include LFS in Lua Build
seclorum Sep 14, 2016
7e36ea5
add lfs hook
seclorum Sep 15, 2016
29c5d9b
Add LFS
seclorum Sep 15, 2016
eb3927b
localized headers instead of system headers
seclorum Sep 15, 2016
b5c9459
export LFS for use in LOAD81
seclorum Sep 15, 2016
3976c8e
include lfs in lualibs[]
seclorum Sep 15, 2016
c08025b
global luaopen_lfs export
seclorum Sep 15, 2016
d632917
Put libs back in place properly
seclorum Sep 16, 2016
fae5aa3
Add debian package control dir
seclorum Sep 16, 2016
f5c5716
clean
Oct 7, 2016
b72f00f
gridify example
seclorum Oct 7, 2016
c9227b1
filelist example
seclorum Oct 7, 2016
41ca649
runner to contrib
seclorum Oct 7, 2016
b730212
/usr/include for build
seclorum Oct 7, 2016
d6b5374
Makefile converted to CMake
seclorum Dec 30, 2024
8270a50
xattr: commented-out for now
seclorum Dec 30, 2024
38ee8dc
SDL_PumpEvents: prior to big-load ops
seclorum Dec 30, 2024
fff18b4
macos: tools to make a bundle and set xattr for an .app
seclorum Dec 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 103 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
cmake_minimum_required(VERSION 3.10)
project(load81 C)

# Set CMake to use C99 standard
set(CMAKE_C_STANDARD 99)

# Find SDL and required SDL extensions
find_package(SDL REQUIRED)
find_library(SDL_IMAGE_LIBRARY SDL_image REQUIRED)
find_library(SDL_GFX_LIBRARY SDL_gfx REQUIRED)


# Include directories
include_directories(
${SDL_INCLUDE_DIR}
${SDL_GFX_INCLUDE_DIR}
${SDL_IMAGE_INCLUDE_DIR}
${SDL_MIXER_INCLUDE_DIR}
${SDL_NET_INCLUDE_DIR}
${SDL_RTF_INCLUDE_DIR}
${SDL_SOUND_INCLUDE_DIR}
${SDL_TTF_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/lua/src
)

# Platform-specific customizations
if(APPLE)
include_directories(
/usr/local/Cellar/sdl_gfx/2.0.27/include/SDL/
/usr/local/Cellar/sdl_image/1.2.12_10/include/SDL/
/usr/local/Cellar/sdl_mixer/1.2.12_6/include/SDL/
/usr/local/Cellar/sdl_net/1.2.8_1/include/SDL/
/usr/local/Cellar/sdl_rtf/0.1.0/include/SDL/
/usr/local/Cellar/sdl_sound/1.0.3_2/include/SDL/
/usr/local/Cellar/sdl_ttf/include/SDL)
endif()

# Find SDL dependencies
#find_package(SDL_gfx REQUIRED)
#find_package(SDL_image REQUIRED)


# Compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -Wall -W")

# Source files
set(SOURCES
load81.c
editor.c
framebuffer.c
)

# Lua library target
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/lua/src/liblua.a
COMMAND ${CMAKE_MAKE_PROGRAM} ansi
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lua
COMMENT "Building Lua library"
)

add_custom_target(liblua ALL
DEPENDS ${CMAKE_SOURCE_DIR}/lua/src/liblua.a
)

# Add the library to the linker path
add_library(lua_lib STATIC IMPORTED)
set_target_properties(lua_lib PROPERTIES
IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/lua/src/liblua.a
)

# Define the executable
add_executable(load81 ${SOURCES})

# Custom command to set macOS quarantine attribute
#add_custom_command(
# TARGET load81 POST_BUILD
# COMMAND bash -c "/usr/bin/xattr -w com.apple.quarantine \"0002;\$(printf %x \$(date +%s));load81;\$(/usr/bin/uuidgen)\" load81"
# COMMENT "Setting macOS quarantine attribute for load81"
#)

# Link the libraries
target_link_libraries(load81
lua_lib
m
${SDL_LIBRARY}
${SDL_GFX_LIBRARY}
${SDL_IMAGE_LIBRARY}
)

# Ensure liblua is built before load81
add_dependencies(load81 liblua)

# Add custom clean targets
add_custom_target(clean-lua
COMMAND ${CMAKE_MAKE_PROGRAM} clean
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lua
)

add_custom_target(distclean
COMMAND ${CMAKE_BUILD_TOOL} clean
COMMAND ${CMAKE_MAKE_PROGRAM} clean
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/lua
)
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

PKGS=sdl SDL_gfx SDL_image
CFLAGS=-O2 -Wall -W -Ilua/src `pkg-config --cflags $(PKGS)`
LDLIBS=lua/src/liblua.a -lm `pkg-config --libs $(PKGS)`
CFLAGS=-O2 -Wall -W -Ilua/src `sdl-config --cflags`
LDLIBS=lua/src/liblua.a -lm `sdl-config --libs` -lSDL_gfx -lSDL_image

# Customizations per-OS
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
CFLAGS+=-I/usr/local/Cellar//sdl_gfx/2.0.25/include/SDL/ -I/usr/local/Cellar//sdl_image/1.2.12_3/include/SDL/
endif

all: load81

Expand All @@ -20,3 +27,4 @@ distclean: clean

dep:
$(CC) -MM *.c

34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,30 @@ PROGRAMMING INTERFACE
Drawing functions:

* fill(r,g,b,alpha): select the drawing color.
* filled(filled): set the filled state (true or false)
* background(r,g,b): paint the whole background with the specified color.
* rect(x,y,width,height): draw a rectangle at x,y (left-bottom corner).
* ellipse(x,y,width,height): draw an ellipse centered at x,y.
* line(x1,y1,x2,y2): draw a line from x1,y1 to x2,y2.
* text(x,y,string): print the specified text at x,y using a bitmap font.
* triangle(x1,y1,x2,y2,x3,y3): draw a triangle with the specified vertex.
* getpixel(x,y): return the red,gree,blue value of the specified pixel.
* sprite(file,x,y,[rotation],[antialiasing]): draw sprite at coordinates with the specified rotation (in degrees, default 0) and antialiasing (default false).
* polygon(xv, yv): draw a polygon using a table of X values and a table of Y values.

Sprite functions:

* sprite(file,[x,y,[rotation],[antialiasing]]): draw sprite at coordinates with the specified rotation (in degrees, default 0) and antialiasing (default false).

Returns a sprite userdata object, with the following functions

* getHeight(): returns the height of the sprite.
* getWidth(): returns the height of the sprite.
* getTiles(): returns x,y for the number of tiles horizontally and vertically.
* setTiles(x,y): set the number of tiles horizontally and vertically.
* getTileSize(): return w,h for the size of a tile, calculated from the width and height of the image divided by the number of tiles horizontally and vertically.
* getTileNum(): returns the number of tiles.
* tile(x,y,tileNum,[rotation],[antialiasing]): draw a tile using tileNum at coordinates with the specified rotation (in degrees, default 0) and antialiasing (default: false).
* draw(x,y,[rotation],[antialiasing]): draw sprite at coordinates with the specified rotation (in degrees, default 0) and antialiasing (default: false).

Control functions:

Expand Down Expand Up @@ -106,6 +122,22 @@ if a button is pressed use:

Mouse buttons are called '1', '2', '3', ... and so forth.

JOYSTICK EVENTS
===
Joystick support is available by directly accessing the joystick[] table.
For example:

joystick[1].x / joystick[1].y = X/Y position of Joystick1
joystick[1].button = button state of Joystick1
joystick[1].name = "hardware name of the Joystick1"

joystick.count contains the number of joysticks detected by LOAD81 on
startup, and will be 0 if no joysticks are available. Max # of Joysticks
is currently set at 8.

See examples/joysticks.lua and examples/flames.lua for how to use the
joystick.

LICENSE
===

Expand Down
1 change: 1 addition & 0 deletions contrib/Pandora/PND_Resources/defconf/profile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ filepath=./examples/
exepath=./load81 --full
extarg=--width;0;%na%;800
extarg=--height;0;%na%;480
extarg=--bpp;0;%na%;0
extarg=;0;%na%;%filename%

# Custom Entries Settings
13 changes: 13 additions & 0 deletions contrib/PocketCHIP/runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# runs load81, resetting it if any file-changes occur in the
# WATCHDIR, for example, the onboard examples/ .. any changes
# to the dir will re-load load81 ..
#!/bin/bash
export DISPLAY=:0
WATCHDIR=./examples/
inotifywait -m -e close_write $WATCHDIR | \
while read -r notifile event filename ; \
do \
echo "notifile: $notifile event: $event filename: $filename"
killall load81 ; \
./load81 --width 480 --height 272 $notifile/$filename & \
done
11 changes: 11 additions & 0 deletions contrib/debian_pocketchip/load81_0.0-2/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: load81
Version: 0.1-1
Section: base
Priority: optional
Architecture: armhf
Maintainer: seclorum <seclorum@icloud.com>
Depends: libsdl-gfx1.2-5 (>=1.2), libsdl-image1.2 (>=1.2)
Description: antirez' LOAD81 packaged for PocketCHIP.
antirez (http://github.com/antirez/load81) created the wonderful
load81 development environment, which provides an editor to
create small apps in the Lua programming language.
1 change: 1 addition & 0 deletions contrib/debian_pocketchip/makedeb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dpkg-deb --build load81_0.0-2/
Loading