Skip to content
This repository has been archived by the owner on Oct 13, 2019. It is now read-only.

Commit

Permalink
Start of pad example
Browse files Browse the repository at this point in the history
  • Loading branch information
CTurt committed Aug 26, 2015
1 parent 2d0b72f commit af66182
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
39 changes: 39 additions & 0 deletions examples/pad/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
TEXT := 0x926200000
DATA := 0x926300000

CC := gcc
AS := gcc
OBJCOPY := objcopy
ODIR := build
SDIR := source
IDIRS := -I$(PS4SDK)/include -I. -Iinclude
LDIRS := -L$(PS4SDK) -L. -Llib
CFLAGS := $(IDIRS) -O2 -fno-builtin -nostartfiles -nostdlib -Wall -masm=intel -march=btver2 -mtune=btver2 -m64 -mabi=sysv -mcmodel=large -DTEXT_ADDRESS=$(TEXT) -DDATA_ADDRESS=$(DATA)
SFLAGS := -nostartfiles -nostdlib -march=btver2 -mtune=btver2
LFLAGS := $(LDIRS) -Ttext=$(TEXT) -Tdata=$(DATA)
CFILES := $(wildcard $(SDIR)/*.c)
SFILES := $(wildcard $(SDIR)/*.s)
OBJS := $(patsubst $(SDIR)/%.c, build/%.o, $(CFILES)) $(patsubst $(SDIR)/%.s, build/%.o, $(SFILES))

LIBS := -lPS4-SDK

TARGET = $(shell basename $(CURDIR)).bin

$(TARGET): $(ODIR) $(OBJS)
$(CC) $(PS4SDK)/crt0.s $(ODIR)/*.o -o temp.t $(CFLAGS) $(LFLAGS) $(LIBS)
$(OBJCOPY) -O binary temp.t $(TARGET)
rm -f temp.t

$(ODIR)/%.o: $(SDIR)/%.c
$(CC) -c -o $@ $< $(CFLAGS)

$(ODIR)/%.o: $(SDIR)/%.s
$(AS) -c -o $@ $< $(SFLAGS)

$(ODIR):
@mkdir $@

.PHONY: clean

clean:
rm -f $(TARGET) $(ODIR)/*.o
22 changes: 22 additions & 0 deletions examples/pad/source/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "ps4.h"

unsigned char data[512];

int _main(void) {
// Init and resolve libraries
initPad();


// Browser /user/home/ to see all user IDs (in hex)
int userID = 0x10000000;

int pad = scePadOpen(userID, 0, 0, NULL);

scePadRead(pad, data, 1);

scePadClose(pad);


// Return to browser
return 0;
}
2 changes: 1 addition & 1 deletion include/pad.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

extern int (*scePadInit)(void);
extern int (*scePadOpen)(int, int, int, void *);
extern int (*scePadOpen)(int userID, int, int, void *);
extern int (*scePadClose)(int handle);
extern int (*scePadRead)(int handle, void *data, int count);

Expand Down
2 changes: 1 addition & 1 deletion source/pad.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "pad.h"

int (*scePadInit)(void);
int (*scePadOpen)(int, int, int, void *);
int (*scePadOpen)(int userID, int, int, void *);
int (*scePadClose)(int handle);
int (*scePadRead)(int handle, void *data, int count);

Expand Down

0 comments on commit af66182

Please sign in to comment.