mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-09 07:18:34 -04:00
Add gamepad controller bindings for left stick and right stick press to Web, Android and Xbox builds
This commit is contained in:
parent
dd6fe33121
commit
fd612bd95a
@ -2,15 +2,32 @@ BUILD_DIR := build-dreamcast
|
||||
SOURCE_DIRS := src third_party/bearssl/src
|
||||
|
||||
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
|
||||
OBJS := $(notdir $(C_FILES:%.c=%.o))
|
||||
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
|
||||
CFLAGS :=-g -O1 -pipe -fno-math-errno
|
||||
|
||||
TARGET := ClassiCube-dc.elf
|
||||
TARGET := ClassiCube-dc
|
||||
|
||||
ifeq ($(strip $(KOS_BASE)),)
|
||||
$(error "Please set KOS variables in your environment.")
|
||||
endif
|
||||
|
||||
include $(KOS_BASE)/Makefile.rules
|
||||
default: $(BUILD_DIR) $(TARGET)-scr.bin
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
kos-cc -o $(TARGET) $(OBJS)
|
||||
$(BUILD_DIR)/%.o: src/%.c
|
||||
kos-cc $(CFLAGS) -c $< -o $@
|
||||
|
||||
$(BUILD_DIR)/%.o: third_party/bearssl/src/%.c
|
||||
kos-cc $(CFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
$(TARGET).elf: $(OBJS)
|
||||
kos-cc $< -o $@
|
||||
|
||||
$(TARGET).bin: $(TARGET).elf
|
||||
sh-elf-objcopy -R .stack -O binary $(TARGET).elf $(TARGET).bin
|
||||
|
||||
# https://dcemulation.org/phpBB/viewtopic.php?t=105269
|
||||
$(TARGET)-scr.bin: $(TARGET).bin
|
||||
$(KOS_BASE)/utils/scramble/scramble $(TARGET).bin $(TARGET)-scr.bin
|
@ -5,7 +5,7 @@ TARGET := ClassiCube-vita
|
||||
BUILD_DIR := build-vita
|
||||
SOURCE_DIRS := src third_party/bearssl/src
|
||||
|
||||
CFLAGS += -Wl,-q -Ithird_party/bearssl/inc -O1
|
||||
CFLAGS += -Wl,-q -O1
|
||||
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
|
||||
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o)))
|
||||
|
||||
@ -41,7 +41,7 @@ $(BUILD_DIR)/%.o : src/%.c
|
||||
arm-vita-eabi-gcc -c $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/%.o : third_party/bearssl/src/%.c
|
||||
arm-vita-eabi-gcc -c $(CFLAGS) -o $@ $<
|
||||
arm-vita-eabi-gcc -c $(CFLAGS) -Ithird_party/bearssl/inc -o $@ $<
|
||||
|
||||
# TODO: There's gotta be a better way of .o to .c than this
|
||||
|
||||
|
@ -191,7 +191,8 @@ static void ClearTouches(void) { }
|
||||
#define Pad_Names \
|
||||
"PAD_A", "PAD_B", "PAD_X", "PAD_Y", "PAD_L", "PAD_R", \
|
||||
"PAD_LEFT", "PAD_RIGHT", "PAD_UP", "PAD_DOWN", \
|
||||
"PAD_START", "PAD_SELECT", "PAD_ZL", "PAD_ZR"
|
||||
"PAD_START", "PAD_SELECT", "PAD_ZL", "PAD_ZR", \
|
||||
"PAD_LSTICK", "PAD_RSTICK"
|
||||
|
||||
/* Names for each input button when stored to disc */
|
||||
static const char* const storageNames[INPUT_COUNT] = {
|
||||
|
@ -48,6 +48,7 @@ enum InputButtons {
|
||||
CCPAD_A, CCPAD_B, CCPAD_X, CCPAD_Y, CCPAD_L, CCPAD_R,
|
||||
CCPAD_LEFT, CCPAD_RIGHT, CCPAD_UP, CCPAD_DOWN,
|
||||
CCPAD_START, CCPAD_SELECT, CCPAD_ZL, CCPAD_ZR,
|
||||
CCPAD_LSTICK, CCPAD_RSTICK,
|
||||
|
||||
INPUT_COUNT,
|
||||
|
||||
|
@ -26,6 +26,7 @@ static void RefreshWindowBounds(void) {
|
||||
Event_RaiseVoid(&WindowEvents.Resized);
|
||||
}
|
||||
|
||||
// https://developer.android.com/ndk/reference/group/input
|
||||
static int MapNativeKey(int code) {
|
||||
if (code >= AKEYCODE_0 && code <= AKEYCODE_9) return (code - AKEYCODE_0) + '0';
|
||||
if (code >= AKEYCODE_A && code <= AKEYCODE_Z) return (code - AKEYCODE_A) + 'A';
|
||||
@ -96,6 +97,8 @@ static int MapNativeKey(int code) {
|
||||
|
||||
case AKEYCODE_BUTTON_START: return CCPAD_START;
|
||||
case AKEYCODE_BUTTON_SELECT: return CCPAD_SELECT;
|
||||
case AKEYCODE_BUTTON_THUMBL: return CCPAD_LSTICK;
|
||||
case AKEYCODE_BUTTON_THUMBR: return CCPAD_RSTICK;
|
||||
}
|
||||
return INPUT_NONE;
|
||||
}
|
||||
|
@ -540,8 +540,10 @@ static void ProcessGamepadButtons(EmscriptenGamepadEvent* ev) {
|
||||
Input_SetNonRepeatable(CCPAD_ZL, GetGamepadButton(6));
|
||||
Input_SetNonRepeatable(CCPAD_ZR, GetGamepadButton(7));
|
||||
|
||||
Input_SetNonRepeatable(CCPAD_SELECT, GetGamepadButton(8));
|
||||
Input_SetNonRepeatable(CCPAD_START, GetGamepadButton(9));
|
||||
Input_SetNonRepeatable(CCPAD_SELECT, GetGamepadButton( 8));
|
||||
Input_SetNonRepeatable(CCPAD_START, GetGamepadButton( 9));
|
||||
Input_SetNonRepeatable(CCPAD_LSTICK, GetGamepadButton(10));
|
||||
Input_SetNonRepeatable(CCPAD_RSTICK, GetGamepadButton(11));
|
||||
|
||||
Input_SetNonRepeatable(CCPAD_UP, GetGamepadButton(12));
|
||||
Input_SetNonRepeatable(CCPAD_DOWN, GetGamepadButton(13));
|
||||
|
@ -130,6 +130,8 @@ static void HandleButtons(xid_gamepad_in* gp) {
|
||||
|
||||
Input_SetNonRepeatable(CCPAD_START, mods & XINPUT_GAMEPAD_START);
|
||||
Input_SetNonRepeatable(CCPAD_SELECT, mods & XINPUT_GAMEPAD_BACK);
|
||||
Input_SetNonRepeatable(CCPAD_LSTICK, mods & XINPUT_GAMEPAD_LEFT_THUMB);
|
||||
Input_SetNonRepeatable(CCPAD_RSTICK, mods & XINPUT_GAMEPAD_RIGHT_THUMB);
|
||||
|
||||
Input_SetNonRepeatable(CCPAD_LEFT, mods & XINPUT_GAMEPAD_DPAD_LEFT);
|
||||
Input_SetNonRepeatable(CCPAD_RIGHT, mods & XINPUT_GAMEPAD_DPAD_RIGHT);
|
||||
|
Loading…
x
Reference in New Issue
Block a user