added a simple joystick api example, since we didn't have one.
This commit is contained in:
@@ -84,10 +84,12 @@ ifneq ($(filter disk samples.%,$(MAKECMDGOALS)),)
|
|||||||
EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
|
EMD := $(wildcard $(TARGET_PATH)/$(SYS)/drv/emd/*)
|
||||||
MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
|
MOU := $(wildcard $(TARGET_PATH)/$(SYS)/drv/mou/*)
|
||||||
TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
|
TGI := $(wildcard $(TARGET_PATH)/$(SYS)/drv/tgi/*)
|
||||||
|
JOY := $(wildcard $(TARGET_PATH)/$(SYS)/drv/joy/*)
|
||||||
|
|
||||||
EMD := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/emd/,$(notdir $(filter %.emd,$(EMD))))
|
EMD := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/emd/,$(notdir $(filter %.emd,$(EMD))))
|
||||||
MOU := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/mou/,$(notdir $(filter %.mou,$(MOU))))
|
MOU := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/mou/,$(notdir $(filter %.mou,$(MOU))))
|
||||||
TGI := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/tgi/,$(notdir $(filter %.tgi,$(TGI))))
|
TGI := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/tgi/,$(notdir $(filter %.tgi,$(TGI))))
|
||||||
|
JOY := $(addprefix $(SUBST_TARGET_PATH)/$(SYS)/drv/joy/,$(notdir $(filter %.joy,$(JOY))))
|
||||||
|
|
||||||
# This one comes with the VICE emulator.
|
# This one comes with the VICE emulator.
|
||||||
# See http://vice-emu.sourceforge.net/
|
# See http://vice-emu.sourceforge.net/
|
||||||
@@ -180,6 +182,7 @@ EXELIST_apple2 = \
|
|||||||
enumdevdir \
|
enumdevdir \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
mousedemo \
|
mousedemo \
|
||||||
multdemo \
|
multdemo \
|
||||||
@@ -213,10 +216,14 @@ EXELIST_atari2600 = \
|
|||||||
EXELIST_atari5200 = \
|
EXELIST_atari5200 = \
|
||||||
notavailable
|
notavailable
|
||||||
|
|
||||||
|
EXELIST_atari7800 = \
|
||||||
|
notavailable
|
||||||
|
|
||||||
EXELIST_atmos = \
|
EXELIST_atmos = \
|
||||||
ascii \
|
ascii \
|
||||||
checkversion \
|
checkversion \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
sieve \
|
sieve \
|
||||||
terminal \
|
terminal \
|
||||||
@@ -231,6 +238,7 @@ EXELIST_c64 = \
|
|||||||
enumdevdir \
|
enumdevdir \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
mousedemo \
|
mousedemo \
|
||||||
multdemo \
|
multdemo \
|
||||||
@@ -254,6 +262,7 @@ EXELIST_c128 = \
|
|||||||
enumdevdir \
|
enumdevdir \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
mousedemo \
|
mousedemo \
|
||||||
sieve \
|
sieve \
|
||||||
@@ -266,13 +275,15 @@ EXELIST_c16 = \
|
|||||||
checkversion \
|
checkversion \
|
||||||
enumdevdir \
|
enumdevdir \
|
||||||
tinyshell \
|
tinyshell \
|
||||||
hello
|
hello \
|
||||||
|
joydemo
|
||||||
|
|
||||||
EXELIST_cbm510 = \
|
EXELIST_cbm510 = \
|
||||||
ascii \
|
ascii \
|
||||||
checkversion \
|
checkversion \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mousedemo \
|
mousedemo \
|
||||||
terminal \
|
terminal \
|
||||||
tinyshell \
|
tinyshell \
|
||||||
@@ -297,6 +308,7 @@ EXELIST_cx16 = \
|
|||||||
enumdevdir \
|
enumdevdir \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
mousedemo \
|
mousedemo \
|
||||||
sieve \
|
sieve \
|
||||||
@@ -308,7 +320,6 @@ EXELIST_gamate = \
|
|||||||
|
|
||||||
EXELIST_geos-cbm = \
|
EXELIST_geos-cbm = \
|
||||||
ascii \
|
ascii \
|
||||||
checkversion \
|
|
||||||
diodemo
|
diodemo
|
||||||
|
|
||||||
EXELIST_geos-apple = \
|
EXELIST_geos-apple = \
|
||||||
@@ -329,19 +340,22 @@ EXELIST_mega65 = \
|
|||||||
tinyshell
|
tinyshell
|
||||||
|
|
||||||
EXELIST_nes = \
|
EXELIST_nes = \
|
||||||
hello
|
hello \
|
||||||
|
joydemo
|
||||||
|
|
||||||
EXELIST_osic1p = \
|
EXELIST_osic1p = \
|
||||||
notavailable
|
notavailable
|
||||||
|
|
||||||
EXELIST_pce = \
|
EXELIST_pce = \
|
||||||
hello
|
hello \
|
||||||
|
joydemo
|
||||||
|
|
||||||
EXELIST_pet = \
|
EXELIST_pet = \
|
||||||
ascii \
|
ascii \
|
||||||
checkversion \
|
checkversion \
|
||||||
enumdevdir \
|
enumdevdir \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
tinyshell \
|
tinyshell \
|
||||||
sieve
|
sieve
|
||||||
|
|
||||||
@@ -351,6 +365,7 @@ EXELIST_plus4 = \
|
|||||||
enumdevdir \
|
enumdevdir \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
terminal \
|
terminal \
|
||||||
tinyshell \
|
tinyshell \
|
||||||
@@ -377,6 +392,7 @@ EXELIST_telestrat = \
|
|||||||
checkversion \
|
checkversion \
|
||||||
gunzip65 \
|
gunzip65 \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
sieve \
|
sieve \
|
||||||
tgidemo
|
tgidemo
|
||||||
@@ -386,6 +402,7 @@ EXELIST_vic20 = \
|
|||||||
checkversion \
|
checkversion \
|
||||||
enumdevdir \
|
enumdevdir \
|
||||||
hello \
|
hello \
|
||||||
|
joydemo \
|
||||||
mandelbrot \
|
mandelbrot \
|
||||||
sieve \
|
sieve \
|
||||||
tgidemo
|
tgidemo
|
||||||
@@ -541,7 +558,7 @@ samples.d64: samples
|
|||||||
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
|
@$(C1541) -format "samples,00" d64 $@ >$(NULLDEV)
|
||||||
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
|
$(foreach file,$(EXELIST_$(SYS)),$(D64_WRITE_PRG_recipe))
|
||||||
$(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
|
$(foreach file,$(OVERLAYLIST),$(D64_WRITE_PRG_recipe))
|
||||||
$(foreach file,$(EMD) $(MOU) $(TGI),$(D64_WRITE_SEQ_recipe))
|
$(foreach file,$(EMD) $(MOU) $(JOY) $(TGI),$(D64_WRITE_SEQ_recipe))
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Rule to make an Apple II disk with all samples. Needs the AppleCommander
|
# Rule to make an Apple II disk with all samples. Needs the AppleCommander
|
||||||
@@ -566,7 +583,7 @@ samples.dsk: samples
|
|||||||
cp prodos.dsk $@
|
cp prodos.dsk $@
|
||||||
$(foreach file,$(EXELIST_$(SYS)),$(DSK_WRITE_BIN_recipe))
|
$(foreach file,$(EXELIST_$(SYS)),$(DSK_WRITE_BIN_recipe))
|
||||||
$(foreach file,$(OVERLAYLIST),$(DSK_WRITE_REL_recipe))
|
$(foreach file,$(OVERLAYLIST),$(DSK_WRITE_REL_recipe))
|
||||||
$(foreach file,$(EMD) $(MOU) $(TGI),$(DSK_WRITE_REL_recipe))
|
$(foreach file,$(EMD) $(MOU) $(JOY) $(TGI),$(DSK_WRITE_REL_recipe))
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Rule to make an Atari disk with all samples. Needs the dir2atr program
|
# Rule to make an Atari disk with all samples. Needs the dir2atr program
|
||||||
@@ -585,7 +602,7 @@ samples.atr: samples
|
|||||||
cp "dup.sys" atr/dup.sys
|
cp "dup.sys" atr/dup.sys
|
||||||
@$(foreach file,$(EXELIST_$(SYS)),$(ATR_WRITE_recipe))
|
@$(foreach file,$(EXELIST_$(SYS)),$(ATR_WRITE_recipe))
|
||||||
@$(foreach file,$(OVERLAYLIST),$(ATR_WRITE_recipe))
|
@$(foreach file,$(OVERLAYLIST),$(ATR_WRITE_recipe))
|
||||||
@$(foreach file,$(EMD) $(MOU) $(TGI),$(ATR_WRITE_recipe))
|
@$(foreach file,$(EMD) $(MOU) $(JOY) $(TGI),$(ATR_WRITE_recipe))
|
||||||
$(DIR2ATR) -d -b MyDos4534 3200 $@ atr
|
$(DIR2ATR) -d -b MyDos4534 3200 $@ atr
|
||||||
@$(RMDIR) atr
|
@$(RMDIR) atr
|
||||||
|
|
||||||
|
|||||||
91
samples/joydemo.c
Normal file
91
samples/joydemo.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <joystick.h>
|
||||||
|
|
||||||
|
#ifndef DYN_DRV
|
||||||
|
# define DYN_DRV 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define USECONIO
|
||||||
|
|
||||||
|
#ifdef USECONIO
|
||||||
|
#include <conio.h>
|
||||||
|
#define PRINTF cprintf
|
||||||
|
#define CR "\n\r"
|
||||||
|
#else
|
||||||
|
#define PRINTF printf
|
||||||
|
#define CR "\n"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
unsigned char num_joy;
|
||||||
|
unsigned char raw_value;
|
||||||
|
unsigned char i;
|
||||||
|
unsigned char err;
|
||||||
|
unsigned char y;
|
||||||
|
#ifdef USECONIO
|
||||||
|
clrscr();
|
||||||
|
#endif
|
||||||
|
PRINTF("Driver init..." CR);
|
||||||
|
|
||||||
|
#if DYN_DRV
|
||||||
|
/* Load and initialize the driver */
|
||||||
|
if ((err = joy_load_driver (joy_stddrv))) {
|
||||||
|
PRINTF ("Driver load error (code %d)." CR
|
||||||
|
"Warning: This program needs the JOY" CR
|
||||||
|
"driver on disk!" CR, err);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
PRINTF("Driver loaded OK" CR);
|
||||||
|
#else
|
||||||
|
/* Install the driver */
|
||||||
|
joy_install (joy_static_stddrv);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
num_joy = joy_count();
|
||||||
|
|
||||||
|
PRINTF("Driver reported %d joysticks." CR "waiting for input..." CR, num_joy);
|
||||||
|
|
||||||
|
/* wait for something to happen on any joystick input */
|
||||||
|
{
|
||||||
|
unsigned char wait = 1;
|
||||||
|
while (wait) {
|
||||||
|
for (i = 0; i < num_joy; ++i) {
|
||||||
|
raw_value = joy_read(i);
|
||||||
|
if (raw_value) {
|
||||||
|
wait = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* read all joysticks and print the raw value(s) */
|
||||||
|
#ifdef USECONIO
|
||||||
|
y = wherey();
|
||||||
|
#endif
|
||||||
|
while (1) {
|
||||||
|
#ifdef USECONIO
|
||||||
|
gotoxy(0, y);
|
||||||
|
#endif
|
||||||
|
for (i = 0; i < num_joy; ++i) {
|
||||||
|
raw_value = joy_read(i);
|
||||||
|
PRINTF("%02x ", raw_value);
|
||||||
|
}
|
||||||
|
PRINTF(CR);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if DYN_DRV
|
||||||
|
/* Unload the driver */
|
||||||
|
joy_unload ();
|
||||||
|
#else
|
||||||
|
/* Uninstall the driver */
|
||||||
|
joy_uninstall ();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Done */
|
||||||
|
PRINTF ("Done" CR);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user