Browse Source

joystick support for lolshield (A0-up,A1-down,A2-left,A3-right,A5-fire)

feature/2015
Christian Kroll 11 years ago
parent
commit
720d547f4a
  1. 6
      profiles/FFM-Jochen
  2. 20
      profiles/FFM-LedBrett
  3. 11
      profiles/LoL-Shield_Leonardo
  4. 11
      profiles/LoL-Shield_Mega2560
  5. 11
      profiles/LoL-Shield_Uno-Duemilanove-Diavolino
  6. 14
      profiles/borg-16
  7. 16
      profiles/borg-ancient
  8. 14
      profiles/borg-andre
  9. 17
      profiles/borg-ls
  10. 27
      profiles/borgjacke
  11. 3
      src/joystick/Makefile
  12. 109
      src/joystick/config.in
  13. 62
      src/joystick/joystick.h
  14. 89
      src/joystick/lolshield_joystick.c

6
profiles/FFM-Jochen

@ -37,7 +37,12 @@ SCROLL_X_SPEED=10
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#COMMODORE C64 - All your base are belong to us!!!" SCROLLTEXT_TEXT="</#COMMODORE C64 - All your base are belong to us!!!"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
# JOYSTICK_SUPPORT is not set # JOYSTICK_SUPPORT is not set
JOYSTICK_CHOICE="JOY_PARALLEL"
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
# MENU_SUPPORT is not set # MENU_SUPPORT is not set
@ -83,6 +88,7 @@ GOL_DELAY=10
GOL_CYCLES=360 GOL_CYCLES=360
# ANIMATION_BREAKOUT is not set # ANIMATION_BREAKOUT is not set
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
# ANIMATION_MOIRE is not set
# ANIMATION_LTN_ANT is not set # ANIMATION_LTN_ANT is not set
# ANIMATION_TIME is not set # ANIMATION_TIME is not set
TIME_MASTER_ADDR=0x00 TIME_MASTER_ADDR=0x00

20
profiles/FFM-LedBrett

@ -33,10 +33,16 @@ SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#www.hackerspace-ffm.de" SCROLLTEXT_TEXT="</#www.hackerspace-ffm.de"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
# PARALLEL_JOYSTICK_SUPPORT is not set JOYSTICK_CHOICE=JOY_LEDBRETT
# NES_PAD_SUPPORT is not set
# RFM12_JOYSTICK_SUPPORT is not set #
# Joystick Settings
#
HC165_JOYSTICK_SUPPORT=y HC165_JOYSTICK_SUPPORT=y
HC165_JOYSTICK_PORT_LOAD=PORTD HC165_JOYSTICK_PORT_LOAD=PORTD
HC165_JOYSTICK_BIT_LOAD=2 HC165_JOYSTICK_BIT_LOAD=2
@ -85,6 +91,7 @@ GOL_DELAY=100
GOL_CYCLES=360 GOL_CYCLES=360
# ANIMATION_BREAKOUT is not set # ANIMATION_BREAKOUT is not set
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
# ANIMATION_MOIRE is not set
# ANIMATION_LTN_ANT is not set # ANIMATION_LTN_ANT is not set
# ANIMATION_TIME is not set # ANIMATION_TIME is not set
TIME_MASTER_ADDR=0x00 TIME_MASTER_ADDR=0x00
@ -94,9 +101,16 @@ ANIMATION_BMSCROLLER=y
ANIMATION_AMPHIBIAN=y ANIMATION_AMPHIBIAN=y
# ANIMATION_LOGO_OOS is not set # ANIMATION_LOGO_OOS is not set
# ANIMATION_FAIRYDUST is not set # ANIMATION_FAIRYDUST is not set
#
# Fixed-point math patterns
#
ANIMATION_PLASMA=y ANIMATION_PLASMA=y
FP_PLASMA_DELAY=1
ANIMATION_PSYCHEDELIC=y ANIMATION_PSYCHEDELIC=y
FP_PSYCHO_DELAY=15
ANIMATION_BLACKHOLE=y ANIMATION_BLACKHOLE=y
# ANIMATION_SQUARES is not set
ANIMATION_TESTS=y ANIMATION_TESTS=y
ANIMATION_OFF=y ANIMATION_OFF=y

11
profiles/LoL-Shield_Leonardo

@ -34,12 +34,13 @@ SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#Borgware 2D" SCROLLTEXT_TEXT="</#Borgware 2D"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
# PARALLEL_JOYSTICK_SUPPORT is not set JOYSTICK_CHOICE=JOY_LOLSHIELD
# NES_PAD_SUPPORT is not set LOLSHIELD_JOYSTICK_SUPPORT=y
# RFM12_JOYSTICK_SUPPORT is not set
# HC165_JOYSTICK_SUPPORT is not set
NULL_JOYSTICK_SUPPORT=y
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
# MENU_SUPPORT is not set # MENU_SUPPORT is not set

11
profiles/LoL-Shield_Mega2560

@ -34,12 +34,13 @@ SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#Borgware 2D" SCROLLTEXT_TEXT="</#Borgware 2D"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
# PARALLEL_JOYSTICK_SUPPORT is not set JOYSTICK_CHOICE=JOY_LOLSHIELD
# NES_PAD_SUPPORT is not set LOLSHIELD_JOYSTICK_SUPPORT=y
# RFM12_JOYSTICK_SUPPORT is not set
# HC165_JOYSTICK_SUPPORT is not set
NULL_JOYSTICK_SUPPORT=y
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
# MENU_SUPPORT is not set # MENU_SUPPORT is not set

11
profiles/LoL-Shield_Uno-Duemilanove-Diavolino

@ -34,12 +34,13 @@ SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#Borgware 2D" SCROLLTEXT_TEXT="</#Borgware 2D"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
# PARALLEL_JOYSTICK_SUPPORT is not set JOYSTICK_CHOICE=JOY_LOLSHIELD
# NES_PAD_SUPPORT is not set LOLSHIELD_JOYSTICK_SUPPORT=y
# RFM12_JOYSTICK_SUPPORT is not set
# HC165_JOYSTICK_SUPPORT is not set
NULL_JOYSTICK_SUPPORT=y
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
# MENU_SUPPORT is not set # MENU_SUPPORT is not set

14
profiles/borg-16

@ -42,7 +42,16 @@ SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#www.das-labor.org" SCROLLTEXT_TEXT="</#www.das-labor.org"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
JOYSTICK_CHOICE=JOY_PARALLEL
#
# Joystick Settings
#
PARALLEL_JOYSTICK_SUPPORT=y PARALLEL_JOYSTICK_SUPPORT=y
JOYSTICK_PIN_UP=PINB JOYSTICK_PIN_UP=PINB
JOYSTICK_BIT_UP=0 JOYSTICK_BIT_UP=0
@ -54,8 +63,6 @@ JOYSTICK_PIN_RIGHT=PINB
JOYSTICK_BIT_RIGHT=3 JOYSTICK_BIT_RIGHT=3
JOYSTICK_PIN_FIRE=PIND JOYSTICK_PIN_FIRE=PIND
JOYSTICK_BIT_FIRE=3 JOYSTICK_BIT_FIRE=3
# NES_PAD_SUPPORT is not set
# RFM12_JOYSTICK_SUPPORT is not set
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
MENU_SUPPORT=y MENU_SUPPORT=y
@ -101,6 +108,7 @@ GOL_DELAY=100
GOL_CYCLES=360 GOL_CYCLES=360
# ANIMATION_BREAKOUT is not set # ANIMATION_BREAKOUT is not set
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
# ANIMATION_MOIRE is not set
# ANIMATION_LTN_ANT is not set # ANIMATION_LTN_ANT is not set
# ANIMATION_TIME is not set # ANIMATION_TIME is not set
TIME_MASTER_ADDR=0x00 TIME_MASTER_ADDR=0x00
@ -114,12 +122,12 @@ ANIMATION_FAIRYDUST=y
# #
# Fixed-point math patterns # Fixed-point math patterns
# #
FP_DOUBLE_BUFFERING=y
ANIMATION_PLASMA=y ANIMATION_PLASMA=y
FP_PLASMA_DELAY=1 FP_PLASMA_DELAY=1
ANIMATION_PSYCHEDELIC=y ANIMATION_PSYCHEDELIC=y
FP_PSYCHO_DELAY=15 FP_PSYCHO_DELAY=15
# ANIMATION_BLACKHOLE is not set # ANIMATION_BLACKHOLE is not set
# ANIMATION_SQUARES is not set
ANIMATION_TESTS=y ANIMATION_TESTS=y
ANIMATION_OFF=y ANIMATION_OFF=y

16
profiles/borg-ancient

@ -33,6 +33,11 @@ SCROLLTEXT_BUFFER_SIZE=128
SCROLL_X_SPEED=20 SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#LABOR BORG - WIDERSTAND IST ZWECKLOS" SCROLLTEXT_TEXT="</#LABOR BORG - WIDERSTAND IST ZWECKLOS"
# RFM12_SUPPORT is not set
#
# Joystick Support
#
# JOYSTICK_SUPPORT is not set # JOYSTICK_SUPPORT is not set
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
# MENU_SUPPORT is not set # MENU_SUPPORT is not set
@ -79,6 +84,7 @@ GOL_DELAY=100
GOL_CYCLES=360 GOL_CYCLES=360
# ANIMATION_BREAKOUT is not set # ANIMATION_BREAKOUT is not set
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
# ANIMATION_MOIRE is not set
# ANIMATION_LTN_ANT is not set # ANIMATION_LTN_ANT is not set
# ANIMATION_TIME is not set # ANIMATION_TIME is not set
TIME_MASTER_ADDR=00 TIME_MASTER_ADDR=00
@ -87,9 +93,17 @@ TIME_UPDATE_TIMEOUT=50
# ANIMATION_LABORLOGO is not set # ANIMATION_LABORLOGO is not set
# ANIMATION_AMPHIBIAN is not set # ANIMATION_AMPHIBIAN is not set
# ANIMATION_LOGO_OOS is not set # ANIMATION_LOGO_OOS is not set
# ANIMATION_LOGO_28C3 is not set # ANIMATION_FAIRYDUST is not set
#
# Fixed-point math patterns
#
ANIMATION_PLASMA=y ANIMATION_PLASMA=y
FP_PLASMA_DELAY=1
ANIMATION_PSYCHEDELIC=y ANIMATION_PSYCHEDELIC=y
FP_PSYCHO_DELAY=15
# ANIMATION_BLACKHOLE is not set
# ANIMATION_SQUARES is not set
# ANIMATION_TESTS is not set # ANIMATION_TESTS is not set
# ANIMATION_OFF is not set # ANIMATION_OFF is not set

14
profiles/borg-andre

@ -39,7 +39,16 @@ SCROLL_X_SPEED=20
SCROLL_Y_SPEED=20 SCROLL_Y_SPEED=20
SCROLLTEXT_TEXT="</#www.das-labor.org" SCROLLTEXT_TEXT="</#www.das-labor.org"
# RFM12_SUPPORT is not set # RFM12_SUPPORT is not set
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
JOYSTICK_CHOICE=JOY_PARALLEL
#
# Joystick Settings
#
PARALLEL_JOYSTICK_SUPPORT=y PARALLEL_JOYSTICK_SUPPORT=y
JOYSTICK_PIN_UP=PINB JOYSTICK_PIN_UP=PINB
JOYSTICK_BIT_UP=0 JOYSTICK_BIT_UP=0
@ -51,8 +60,6 @@ JOYSTICK_PIN_RIGHT=PINB
JOYSTICK_BIT_RIGHT=3 JOYSTICK_BIT_RIGHT=3
JOYSTICK_PIN_FIRE=PIND JOYSTICK_PIN_FIRE=PIND
JOYSTICK_BIT_FIRE=3 JOYSTICK_BIT_FIRE=3
# NES_PAD_SUPPORT is not set
# RFM12_JOYSTICK_SUPPORT is not set
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
MENU_SUPPORT=y MENU_SUPPORT=y
@ -98,6 +105,7 @@ GOL_DELAY=100
GOL_CYCLES=360 GOL_CYCLES=360
ANIMATION_BREAKOUT=y ANIMATION_BREAKOUT=y
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
ANIMATION_MOIRE=y
ANIMATION_LTN_ANT=y ANIMATION_LTN_ANT=y
# ANIMATION_TIME is not set # ANIMATION_TIME is not set
TIME_MASTER_ADDR=00 TIME_MASTER_ADDR=00
@ -111,12 +119,12 @@ ANIMATION_FAIRYDUST=y
# #
# Fixed-point math patterns # Fixed-point math patterns
# #
FP_DOUBLE_BUFFERING=y
ANIMATION_PLASMA=y ANIMATION_PLASMA=y
FP_PLASMA_DELAY=1 FP_PLASMA_DELAY=1
ANIMATION_PSYCHEDELIC=y ANIMATION_PSYCHEDELIC=y
FP_PSYCHO_DELAY=15 FP_PSYCHO_DELAY=15
ANIMATION_BLACKHOLE=y ANIMATION_BLACKHOLE=y
ANIMATION_SQUARES=y
# ANIMATION_TESTS is not set # ANIMATION_TESTS is not set
# ANIMATION_OFF is not set # ANIMATION_OFF is not set

17
profiles/borg-ls

@ -36,7 +36,13 @@ SCROLLTEXT_BUFFER_SIZE=128
SCROLL_X_SPEED=10 SCROLL_X_SPEED=10
SCROLL_Y_SPEED=30 SCROLL_Y_SPEED=30
SCROLLTEXT_TEXT=">5+:<5|90>6:<6|78>:p10d50/#Labor#<5;>5|30<6;>6|40<6;p10+d50/# Borg#2d50-+/#Widerstand#ist#d50-b20p15#ZWECKLOS !" SCROLLTEXT_TEXT=">5+:<5|90>6:<6|78>:p10d50/#Labor#<5;>5|30<6;>6|40<6;p10+d50/# Borg#2d50-+/#Widerstand#ist#d50-b20p15#ZWECKLOS !"
# RFM12_SUPPORT is not set
#
# Joystick Support
#
# JOYSTICK_SUPPORT is not set # JOYSTICK_SUPPORT is not set
JOYSTICK_CHOICE="JOY_PARALLEL"
CAN_SUPPORT=y CAN_SUPPORT=y
SPI_HARDWARE=y SPI_HARDWARE=y
SPI_PORTIDX=1 SPI_PORTIDX=1
@ -91,6 +97,7 @@ GOL_DELAY=12
GOL_CYCLES=180 GOL_CYCLES=180
# ANIMATION_BREAKOUT is not set # ANIMATION_BREAKOUT is not set
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
# ANIMATION_MOIRE is not set
# ANIMATION_LTN_ANT is not set # ANIMATION_LTN_ANT is not set
ANIMATION_TIME=y ANIMATION_TIME=y
TIME_MASTER_ADDR=00 TIME_MASTER_ADDR=00
@ -99,9 +106,17 @@ TIME_UPDATE_TIMEOUT=50
# ANIMATION_LABORLOGO is not set # ANIMATION_LABORLOGO is not set
# ANIMATION_AMPHIBIAN is not set # ANIMATION_AMPHIBIAN is not set
# ANIMATION_LOGO_OOS is not set # ANIMATION_LOGO_OOS is not set
# ANIMATION_LOGO_28C3 is not set # ANIMATION_FAIRYDUST is not set
#
# Fixed-point math patterns
#
# ANIMATION_PLASMA is not set # ANIMATION_PLASMA is not set
FP_PLASMA_DELAY=1
# ANIMATION_PSYCHEDELIC is not set # ANIMATION_PSYCHEDELIC is not set
FP_PSYCHO_DELAY=15
# ANIMATION_BLACKHOLE is not set
# ANIMATION_SQUARES is not set
ANIMATION_TESTS=y ANIMATION_TESTS=y
ANIMATION_OFF=y ANIMATION_OFF=y

27
profiles/borgjacke

@ -49,9 +49,12 @@ BIT_MISO=6
BIT_SCK=7 BIT_SCK=7
PORT_SS=PORTB PORT_SS=PORTB
BIT_SS=4 BIT_SS=4
#
# Joystick Support
#
JOYSTICK_SUPPORT=y JOYSTICK_SUPPORT=y
# PARALLEL_JOYSTICK_SUPPORT is not set JOYSTICK_CHOICE=JOY_RFM12
# NES_PAD_SUPPORT is not set
RFM12_JOYSTICK_SUPPORT=y RFM12_JOYSTICK_SUPPORT=y
# CAN_SUPPORT is not set # CAN_SUPPORT is not set
MENU_SUPPORT=y MENU_SUPPORT=y
@ -65,7 +68,7 @@ GAME_TETRIS=y
# GAME_TETRIS_FP is not set # GAME_TETRIS_FP is not set
GAME_SPACE_INVADERS=y GAME_SPACE_INVADERS=y
GAME_SNAKE=y GAME_SNAKE=y
# GAME_BREAKOUT is not set GAME_BREAKOUT=y
# #
# Animations # Animations
@ -91,14 +94,15 @@ MATRIX_STREAMER_NUM=30
MATRIX_CYCLES=500 MATRIX_CYCLES=500
MATRIX_DELAY=60 MATRIX_DELAY=60
ANIMATION_RANDOM_BRIGHT=y ANIMATION_RANDOM_BRIGHT=y
# ANIMATION_STONEFLY is not set ANIMATION_STONEFLY=y
# ANIMATION_FLYINGDOTS is not set ANIMATION_FLYINGDOTS=y
ANIMATION_GAMEOFLIFE=y ANIMATION_GAMEOFLIFE=y
GOL_DELAY=100 GOL_DELAY=100
GOL_CYCLES=360 GOL_CYCLES=360
# ANIMATION_BREAKOUT is not set ANIMATION_BREAKOUT=y
# ANIMATION_MHERWEG is not set # ANIMATION_MHERWEG is not set
# ANIMATION_LTN_ANT is not set ANIMATION_MOIRE=y
ANIMATION_LTN_ANT=y
# ANIMATION_TIME is not set # ANIMATION_TIME is not set
TIME_MASTER_ADDR=0x00 TIME_MASTER_ADDR=0x00
TIME_UPDATE_TIMEOUT=23 TIME_UPDATE_TIMEOUT=23
@ -107,9 +111,16 @@ ANIMATION_LABORLOGO=y
# ANIMATION_AMPHIBIAN is not set # ANIMATION_AMPHIBIAN is not set
# ANIMATION_LOGO_OOS is not set # ANIMATION_LOGO_OOS is not set
# ANIMATION_FAIRYDUST is not set # ANIMATION_FAIRYDUST is not set
#
# Fixed-point math patterns
#
ANIMATION_PLASMA=y ANIMATION_PLASMA=y
FP_PLASMA_DELAY=1
ANIMATION_PSYCHEDELIC=y ANIMATION_PSYCHEDELIC=y
# ANIMATION_BLACKHOLE is not set FP_PSYCHO_DELAY=15
ANIMATION_BLACKHOLE=y
ANIMATION_SQUARES=y
ANIMATION_TESTS=y ANIMATION_TESTS=y
ANIMATION_OFF=y ANIMATION_OFF=y

3
src/joystick/Makefile

@ -18,6 +18,9 @@ endif
ifeq ($(HC165_JOYSTICK_SUPPORT), y) ifeq ($(HC165_JOYSTICK_SUPPORT), y)
SRC = hc165_joystick.c SRC = hc165_joystick.c
endif endif
ifeq ($(LOLSHIELD_JOYSTICK_SUPPORT), y)
SRC = lolshield_joystick.c
endif
ifeq ($(NULL_JOYSTICK_SUPPORT), y) ifeq ($(NULL_JOYSTICK_SUPPORT), y)
SRC = null_joystick.c SRC = null_joystick.c
endif endif

109
src/joystick/config.in

@ -1,18 +1,36 @@
dep_bool_menu "joystick support" JOYSTICK_SUPPORT y mainmenu_option next_comment
comment "Joystick Support"
if [ "$JOYSTICK_SUPPORT" = "y" ]; then bool "Joystick Support" JOYSTICK_SUPPORT n
###################### Parallel joystick menu #################################
dep_bool_menu "parallel joystick support" PARALLEL_JOYSTICK_SUPPORT y if [ "x$JOYSTICK_CHOICE" == "x" ] ; then
define_string JOYSTICK_CHOICE "JOY_PARALLEL"
fi
if [ "$PARALLEL_JOYSTICK_SUPPORT" = "y" ]; then if [ "$JOYSTICK_SUPPORT" = "y" ]; then
choice 'Pin up' \ choice 'Joystick Type' \
"Atari-9-Pin JOY_PARALLEL \
NES-Game-Pad JOY_NES_PAD \
RFM12 JOY_RFM12 \
LED-Brett JOY_LEDBRETT \
LoL-Shield JOY_LOLSHIELD \
None JOY_NULL" \
'Atari-9-Pin' JOYSTICK_CHOICE
###################### parallel joystick menu #################################
if [ "$JOYSTICK_CHOICE" == "JOY_PARALLEL" ]; then
mainmenu_option next_comment
comment "Joystick Settings"
define_bool PARALLEL_JOYSTICK_SUPPORT y
choice 'Pin up' \
"PINA PINA \ "PINA PINA \
PINB PINB \ PINB PINB \
PINC PINC \ PINC PINC \
PIND PIND" \ PIND PIND" \
'PINB' JOYSTICK_PIN_UP 'PINB' JOYSTICK_PIN_UP
choice 'Bit up' \ choice 'Bit up' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -23,14 +41,14 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit0' JOYSTICK_BIT_UP 'Bit0' JOYSTICK_BIT_UP
choice 'Pin down' \ choice 'Pin down' \
"PINA PINA \ "PINA PINA \
PINB PINB \ PINB PINB \
PINC PINC \ PINC PINC \
PIND PIND" \ PIND PIND" \
'PINB' JOYSTICK_PIN_DOWN 'PINB' JOYSTICK_PIN_DOWN
choice 'Bit down' \ choice 'Bit down' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -41,14 +59,14 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit1' JOYSTICK_BIT_DOWN 'Bit1' JOYSTICK_BIT_DOWN
choice 'Pin left' \ choice 'Pin left' \
"PINA PINA \ "PINA PINA \
PINB PINB \ PINB PINB \
PINC PINC \ PINC PINC \
PIND PIND" \ PIND PIND" \
'PINB' JOYSTICK_PIN_LEFT 'PINB' JOYSTICK_PIN_LEFT
choice 'Bit left' \ choice 'Bit left' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -59,14 +77,14 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit2' JOYSTICK_BIT_LEFT 'Bit2' JOYSTICK_BIT_LEFT
choice 'Pin right' \ choice 'Pin right' \
"PINA PINA \ "PINA PINA \
PINB PINB \ PINB PINB \
PINC PINC \ PINC PINC \
PIND PIND" \ PIND PIND" \
'PINB' JOYSTICK_PIN_RIGHT 'PINB' JOYSTICK_PIN_RIGHT
choice 'Bit right' \ choice 'Bit right' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -77,14 +95,14 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit3' JOYSTICK_BIT_RIGHT 'Bit3' JOYSTICK_BIT_RIGHT
choice 'Pin fire' \ choice 'Pin fire' \
"PINA PINA \ "PINA PINA \
PINB PINB \ PINB PINB \
PINC PINC \ PINC PINC \
PIND PIND" \ PIND PIND" \
'PIND' JOYSTICK_PIN_FIRE 'PIND' JOYSTICK_PIN_FIRE
choice 'Bit fire' \ choice 'Bit fire' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -94,37 +112,40 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit6 6 \ Bit6 6 \
Bit7 7" \ Bit7 7" \
'Bit3' JOYSTICK_BIT_FIRE 'Bit3' JOYSTICK_BIT_FIRE
fi
endmenu endmenu
fi
############################################################################### ###############################################################################
###################### NES-Pad menu ################################# ###################### NES-Pad menu ###########################################
dep_bool_menu "nes-pad support" NES_PAD_SUPPORT y if [ "$JOYSTICK_CHOICE" == "JOY_NES_PAD" ]; then
mainmenu_option next_comment
comment "Joystick Settings"
define_bool NES_PAD_SUPPORT y
if [ "$NES_PAD_SUPPORT" = "y" ]; then choice 'Port clk' \
choice 'Port clk' \
"PORTA PORTA \ "PORTA PORTA \
PORTB PORTB \ PORTB PORTB \
PORTC PORTC \ PORTC PORTC \
PORTD PORTD" \ PORTD PORTD" \
'PORTB' NES_PAD_PORT_CLK 'PORTB' NES_PAD_PORT_CLK
choice 'Port ds' \ choice 'Port ds' \
"PORTA PORTA \ "PORTA PORTA \
PORTB PORTB \ PORTB PORTB \
PORTC PORTC \ PORTC PORTC \
PORTD PORTD" \ PORTD PORTD" \
'PORTB' NES_PAD_PORT_PL 'PORTB' NES_PAD_PORT_PL
choice 'Pin pl' \ choice 'Pin pl' \
"PORTA PORTA \ "PORTA PORTA \
PORTB PORTB \ PORTB PORTB \
PORTC PORTC \ PORTC PORTC \
PORTD PORTD" \ PORTD PORTD" \
'PORTB' NES_PAD_PORT_DS 'PORTB' NES_PAD_PORT_DS
choice 'Bit clk' \ choice 'Bit clk' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -135,7 +156,7 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit0' NES_PAD_BIT_CLK 'Bit0' NES_PAD_BIT_CLK
choice 'Bit pl' \ choice 'Bit pl' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -146,7 +167,7 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit1' NES_PAD_BIT_PL 'Bit1' NES_PAD_BIT_PL
choice 'Bit ds' \ choice 'Bit ds' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -157,28 +178,31 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit7 7" \ Bit7 7" \
'Bit2' NES_PAD_BIT_DS 'Bit2' NES_PAD_BIT_DS
endmenu
fi fi
endmenu
############################################################################### ###############################################################################
###################### RFM12 joystick menu #################################### ###################### RFM12 joystick menu ####################################
dep_bool_menu "RFM12 Joystick support" RFM12_JOYSTICK_SUPPORT y if [ "$JOYSTICK_CHOICE" == "JOY_RFM12" ]; then
define_bool RFM12_JOYSTICK_SUPPORT y
endmenu fi
###############################################################################
###################### 74HC165 joystick menu ################################# ###################### 74HC165 joystick menu #################################
dep_bool_menu "74HC165 joystick support" HC165_JOYSTICK_SUPPORT y if [ "$JOYSTICK_CHOICE" == "JOY_LEDBRETT" ]; then
mainmenu_option next_comment
comment "Joystick Settings"
if [ "$HC165_JOYSTICK_SUPPORT" = "y" ]; then define_bool HC165_JOYSTICK_SUPPORT y
choice 'Port load' \
choice 'Port load' \
"PORTA PORTA \ "PORTA PORTA \
PORTB PORTB \ PORTB PORTB \
PORTC PORTC \ PORTC PORTC \
PORTD PORTD" \ PORTD PORTD" \
'PORTD' HC165_JOYSTICK_PORT_LOAD 'PORTD' HC165_JOYSTICK_PORT_LOAD
choice 'Bit load' \ choice 'Bit load' \
"Bit0 0 \ "Bit0 0 \
Bit1 1 \ Bit1 1 \
Bit2 2 \ Bit2 2 \
@ -188,15 +212,22 @@ if [ "$JOYSTICK_SUPPORT" = "y" ]; then
Bit6 6 \ Bit6 6 \
Bit7 7" \ Bit7 7" \
'Bit2' HC165_JOYSTICK_BIT_LOAD 'Bit2' HC165_JOYSTICK_BIT_LOAD
fi
endmenu endmenu
fi
############################################################################### ###############################################################################
###################### null joystick menu #################################### ###################### LoL Shield joystick menu ###############################
bool "null joystick support" NULL_JOYSTICK_SUPPORT n if [ "$JOYSTICK_CHOICE" == "JOY_NULL" ]; then
define_bool NULL_JOYSTICK_SUPPORT y
fi
############################################################################### ###############################################################################
###################### null joystick menu #####################################
if [ "$JOYSTICK_CHOICE" == "JOY_LOLSHIELD" ]; then
define_bool LOLSHIELD_JOYSTICK_SUPPORT y
fi
###############################################################################
fi fi

62
src/joystick/joystick.h

@ -1,6 +1,10 @@
#ifndef JOYSTICK_H #ifndef JOYSTICK_H
#define JOYSTICK_H #define JOYSTICK_H
#ifdef __AVR__
# include <avr/io.h>
#endif
#include "../config.h" #include "../config.h"
extern unsigned char waitForFire; extern unsigned char waitForFire;
@ -49,7 +53,63 @@ void joy_init();
# define JOYISRIGHT (0) # define JOYISRIGHT (0)
# define JOYISFIRE (0) # define JOYISFIRE (0)
# else # elif defined (LOLSHIELD_JOYSTICK_SUPPORT)
# if defined (__AVR_ATmega48__) || \
defined (__AVR_ATmega48P__) || \
defined (__AVR_ATmega88__) || \
defined (__AVR_ATmega88P__) || \
defined (__AVR_ATmega168__) || \
defined (__AVR_ATmega168P__) || \
defined (__AVR_ATmega328__) || \
defined (__AVR_ATmega328P__)
/*
* A0 => PC0 => JOYISUP
* A1 => PC1 => JOYISDOWN
* A2 => PC2 => JOYISLEFT
* A3 => PC3 => JOYISRIGHT
* A4 => PC4 => NC (JOYIS2GND)
* A5 => PC5 => JOYISFIRE
*/
# define JOYISUP (!(PINC & _BV(PINC0)))
# define JOYISDOWN (!(PINC & _BV(PINC1)))
# define JOYISLEFT (!(PINC & _BV(PINC2)))
# define JOYISRIGHT (!(PINC & _BV(PINC3)))
# define JOYISFIRE (!(PINC & _BV(PINC5)))
# elif defined (__AVR_ATmega32U4__)
/*
* A0 => PF7 => JOYISUP
* A1 => PF6 => JOYISDOWN
* A2 => PF5 => JOYISLEFT
* A3 => PF4 => JOYISRIGHT
* A4 => PF1 => NC (JOYIS2GND)
* A5 => PF0 => JOYISFIRE
*/
# define JOYISUP (!(PINF & _BV(PINF7)))
# define JOYISDOWN (!(PINF & _BV(PINF6)))
# define JOYISLEFT (!(PINF & _BV(PINF5)))
# define JOYISRIGHT (!(PINF & _BV(PINF4)))
# define JOYISFIRE (!(PINF & _BV(PINF0)))
# elif defined (__AVR_ATmega1280__) || \
defined (__AVR_ATmega2560__)
/*
* A0 => PF0 => JOYISUP
* A1 => PF1 => JOYISDOWN
* A2 => PF2 => JOYISLEFT
* A3 => PF3 => JOYISRIGHT
* A4 => PF4 => NC (JOYIS2GND)
* A5 => PF5 => JOYISFIRE
*/
# define JOYISUP (!(PINF & _BV(PINF0)))
# define JOYISDOWN (!(PINF & _BV(PINF1)))
# define JOYISLEFT (!(PINF & _BV(PINF2)))
# define JOYISRIGHT (!(PINF & _BV(PINF3)))
# define JOYISFIRE (!(PINF & _BV(PINF5)))
# else
# error "Unsupported Arduino board!"
# endif
# elif defined (PARALLEL_JOYSTICK_SUPPORT)
# define JOYISUP (!(JOYSTICK_PIN_UP & (1<<JOYSTICK_BIT_UP ))) # define JOYISUP (!(JOYSTICK_PIN_UP & (1<<JOYSTICK_BIT_UP )))
# define JOYISDOWN (!(JOYSTICK_PIN_DOWN & (1<<JOYSTICK_BIT_DOWN ))) # define JOYISDOWN (!(JOYSTICK_PIN_DOWN & (1<<JOYSTICK_BIT_DOWN )))

89
src/joystick/lolshield_joystick.c

@ -0,0 +1,89 @@
/**
* @file lolshield_joystick.c
* @brief Driver for Jimmie Rodgers' LoL Shield
* @author Christian Kroll
* @date 2014
* @copyright GNU Public License 2 or later
* @see http://jimmieprodgers.com/kits/lolshield/
*
* This driver prepares the A0-A5 pins of an Ardunino device to serve as
* joystick input lines.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <avr/io.h>
void joy_init(){
#if defined (__AVR_ATmega48__) || \
defined (__AVR_ATmega48P__) || \
defined (__AVR_ATmega88__) || \
defined (__AVR_ATmega88P__) || \
defined (__AVR_ATmega168__) || \
defined (__AVR_ATmega168P__) || \
defined (__AVR_ATmega328__) || \
defined (__AVR_ATmega328P__)
/*
* A0 => PC0 => JOYISUP
* A1 => PC1 => JOYISDOWN
* A2 => PC2 => JOYISLEFT
* A3 => PC3 => JOYISRIGHT
* A4 => PC4 => NC (JOYIS2GND)
* A5 => PC5 => JOYISFIRE
*/
// set joystick pins to input
DDRC &= ~(_BV(PINC0) | _BV(PINC1) | _BV(PINC2) |
_BV(PINC3) | _BV(PINC4) | _BV(PINC5));
// activate pullups
PORTC |= _BV(PINC0) | _BV(PINC1) | _BV(PINC2) |
_BV(PINC3) | _BV(PINC4) | _BV(PINC5);
#elif defined (__AVR_ATmega32U4__)
/*
* A0 => PF7 => JOYISUP
* A1 => PF6 => JOYISDOWN
* A2 => PF5 => JOYISLEFT
* A3 => PF4 => JOYISRIGHT
* A4 => PF1 => NC (JOYIS2GND)
* A5 => PF0 => JOYISFIRE
*/
// set joystick pins to input
DDRF &= ~(_BV(PINF7) | _BV(PINF6) | _BV(PINF5) |
_BV(PINF4) | _BV(PINF1) | _BV(PINF0));
// activate pullups
PORTF |= _BV(PINF7) | _BV(PINF6) | _BV(PINF5) | _BV(PINF4) |
_BV(PINF1) | _BV(PINF0);
#elif defined (__AVR_ATmega1280__) || \
defined (__AVR_ATmega2560__)
/*
* A0 => PF0 => JOYISUP
* A1 => PF1 => JOYISDOWN
* A2 => PF2 => JOYISLEFT
* A3 => PF3 => JOYISRIGHT
* A4 => PF4 => NC (JOYIS2GND)
* A5 => PF5 => JOYISFIRE
*/
// set joystick pins to input
DDRF &= ~(_BV(PINF0) | _BV(PINF1) | _BV(PINF2) |
_BV(PINF3) | _BV(PINF4) | _BV(PINF5));
// activate pullups
PORTF |= _BV(PINF0) | _BV(PINF1) | _BV(PINF2) |
_BV(PINF3) | _BV(PINF4) | _BV(PINF5);
#else
# error "Unsupported Arduino board!"
#endif
}
Loading…
Cancel
Save