add WPAD to TestSuite as an example wii/wiimote test. someone can replace it with wiimotiondemo if they want gx goodness, otherwise it's a just a nice simple test ;)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1901 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7d3dbde234
commit
5994897d9a
|
@ -1,4 +1,3 @@
|
|||
#Someone who would use this, please fix it :)
|
||||
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||
|
||||
all:
|
||||
|
@ -6,4 +5,3 @@ all:
|
|||
|
||||
clean:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||
|
||||
|
|
|
@ -15,25 +15,46 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AX", "AX\AX.vcproj", "{9F05
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ARAM", "ARAM\ARAM.vcproj", "{E50732C5-038A-42F7-8C95-8C02A4E2ADA6}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WPAD", "WPAD\WPAD.vcproj", "{BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{F45E42B2-939B-4F02-954B-E68251FD4CCF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F45E42B2-939B-4F02-954B-E68251FD4CCF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F45E42B2-939B-4F02-954B-E68251FD4CCF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F45E42B2-939B-4F02-954B-E68251FD4CCF}.Release|Win32.Build.0 = Release|Win32
|
||||
{87F20A25-A3F8-46A3-AC32-3C16782494B1}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{87F20A25-A3F8-46A3-AC32-3C16782494B1}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{87F20A25-A3F8-46A3-AC32-3C16782494B1}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{87F20A25-A3F8-46A3-AC32-3C16782494B1}.Release|Win32.Build.0 = Release|Win32
|
||||
{62989D24-DB3F-4BD1-A11D-26F0487CD9AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{62989D24-DB3F-4BD1-A11D-26F0487CD9AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{62989D24-DB3F-4BD1-A11D-26F0487CD9AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{62989D24-DB3F-4BD1-A11D-26F0487CD9AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D58C9AD5-7200-488A-B1E8-9250E64CDD45}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D58C9AD5-7200-488A-B1E8-9250E64CDD45}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D58C9AD5-7200-488A-B1E8-9250E64CDD45}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D58C9AD5-7200-488A-B1E8-9250E64CDD45}.Release|Win32.Build.0 = Release|Win32
|
||||
{AA230C1A-42F2-4BDC-9EB8-4AA6DF587E69}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{AA230C1A-42F2-4BDC-9EB8-4AA6DF587E69}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{AA230C1A-42F2-4BDC-9EB8-4AA6DF587E69}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{AA230C1A-42F2-4BDC-9EB8-4AA6DF587E69}.Release|Win32.Build.0 = Release|Win32
|
||||
{9F053346-A33D-4E4F-874E-CBA1AF809FC3}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{9F053346-A33D-4E4F-874E-CBA1AF809FC3}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{9F053346-A33D-4E4F-874E-CBA1AF809FC3}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{9F053346-A33D-4E4F-874E-CBA1AF809FC3}.Release|Win32.Build.0 = Release|Win32
|
||||
{E50732C5-038A-42F7-8C95-8C02A4E2ADA6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E50732C5-038A-42F7-8C95-8C02A4E2ADA6}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E50732C5-038A-42F7-8C95-8C02A4E2ADA6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E50732C5-038A-42F7-8C95-8C02A4E2ADA6}.Release|Win32.Build.0 = Release|Win32
|
||||
{BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}.Release|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -0,0 +1,135 @@
|
|||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
|
||||
include $(DEVKITPPC)/wii_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
CFLAGS = -g -O2 -Wall $(MACHDEP) $(INCLUDE)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwiiuse -lbte -logc -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD := $(CC)
|
||||
else
|
||||
export LD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(LIBOGC_INC)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
-L$(LIBOGC_LIB)
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).dol
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
run:
|
||||
wiiload $(TARGET).dol
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT).dol: $(OUTPUT).elf
|
||||
$(OUTPUT).elf: $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# This rule links in binary data with the .jpg extension
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
|
@ -0,0 +1,84 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="WPAD"
|
||||
ProjectGUID="{BB88F4D5-EB0D-4429-94C3-93B0191BD3DD}"
|
||||
RootNamespace="TestSuite"
|
||||
Keyword="MakeFileProj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="build"
|
||||
IntermediateDirectory="build"
|
||||
ConfigurationType="0"
|
||||
BuildLogFile="build\BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCNMakeTool"
|
||||
BuildCommandLine="make -r 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/’"
|
||||
ReBuildCommandLine="make clean && make -r 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/’"
|
||||
CleanCommandLine="make clean"
|
||||
Output="dolphintest_si.dol"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG"
|
||||
IncludeSearchPath="$(ProjectDir)\include;C:\devkitPro\libogc\include"
|
||||
ForcedIncludes=""
|
||||
AssemblySearchPath=""
|
||||
ForcedUsingAssemblies=""
|
||||
CompileAsManaged=""
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="build"
|
||||
IntermediateDirectory="build"
|
||||
ConfigurationType="0"
|
||||
BuildLogFile="build\BuildLog.htm"
|
||||
>
|
||||
<Tool
|
||||
Name="VCNMakeTool"
|
||||
BuildCommandLine="make -r 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/’"
|
||||
ReBuildCommandLine="make clean && make -r 2>&1 | sed -e 's/\(.[a-zA-Z]\+\):\([0-9]\+\):/\1(\2):/’"
|
||||
CleanCommandLine="make clean"
|
||||
Output="dolphintest_si.dol"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG"
|
||||
IncludeSearchPath="$(ProjectDir)\include;C:\devkitPro\libogc\include"
|
||||
ForcedIncludes=""
|
||||
AssemblySearchPath=""
|
||||
ForcedUsingAssemblies=""
|
||||
CompileAsManaged=""
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\source\dolphintest_wpad.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,215 @@
|
|||
// This file is from wiibrew.org: http://wiibrew.org/wiki/How_to_use_the_Wiimote
|
||||
|
||||
//code by WinterMute
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <ogcsys.h>
|
||||
#include <gccore.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
static GXRModeObj *rmode = NULL;
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
//doreload - a flag that tells the program to quit looping and exit the program to the HBChannel.
|
||||
//dooff - a flag that tells the program to quit looping and properly shutdown the system.
|
||||
int doreload=0, dooff=0;
|
||||
|
||||
//Calling the function will end the while loop and properly exit the program to the HBChannel.
|
||||
void reload(void) {
|
||||
doreload=1;
|
||||
}
|
||||
|
||||
//Calling the function will end the while loop and properly shutdown the system.
|
||||
// QUESTION: why calling the shutdown function direcly here halts the console?
|
||||
void shutdown(void) {
|
||||
dooff=1;
|
||||
}
|
||||
|
||||
//Draw a square on the screen (May draw rectangles as well, I am uncertain).
|
||||
//*xfb - framebuffer
|
||||
//*rmode - !unsure!
|
||||
//w - Width of screen (Used as scale factor in converting fx to pixel coordinates)
|
||||
//h - Height of screen (Used as scale factor in converting fy to pixel coordinates)
|
||||
//fx - X coordinate to draw on the screen (0-w)
|
||||
//fy - Y coordinate to draw on the screen (!unsure!-h)
|
||||
//color - the color of the rectangle (Examples: COLOR_YELLOW, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_BLACK, COLOR_WHITE)
|
||||
void drawdot(void *xfb, GXRModeObj *rmode, float w, float h, float fx, float fy, u32 color) {
|
||||
|
||||
//*fb - !unsure!
|
||||
//px - !unsure!
|
||||
//py - !unsure!
|
||||
//x - !unsure!
|
||||
//y - !unsure!
|
||||
|
||||
u32 *fb;
|
||||
int px,py;
|
||||
int x,y;
|
||||
|
||||
|
||||
fb = (u32*)xfb;
|
||||
|
||||
y = fy * rmode->xfbHeight / h;
|
||||
x = fx * rmode->fbWidth / w / 2;
|
||||
|
||||
for(py=y-4; py<=(y+4); py++) {
|
||||
if(py < 0 || py >= rmode->xfbHeight)
|
||||
continue;
|
||||
for(px=x-2; px<=(x+2); px++) {
|
||||
if(px < 0 || px >= rmode->fbWidth/2)
|
||||
continue;
|
||||
fb[rmode->fbWidth/VI_DISPLAY_PIX_SZ*py + px] = color;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int evctr = 0;
|
||||
void countevs(int chan, const WPADData *data) {
|
||||
evctr++;
|
||||
}
|
||||
|
||||
void print_wiimote_connection_status(int wiimote_connection_status) {
|
||||
switch(wiimote_connection_status) {
|
||||
case WPAD_ERR_NO_CONTROLLER:
|
||||
printf(" Wiimote not connected\n");
|
||||
break;
|
||||
case WPAD_ERR_NOT_READY:
|
||||
printf(" Wiimote not ready\n");
|
||||
break;
|
||||
case WPAD_ERR_NONE:
|
||||
printf(" Wiimote ready\n");
|
||||
break;
|
||||
default:
|
||||
printf(" Unknown Wimote state %d\n",wiimote_connection_status);
|
||||
}
|
||||
}
|
||||
|
||||
void print_wiimote_buttons(WPADData *wd) {
|
||||
printf(" Buttons down:\n ");
|
||||
if(wd->btns_h & WPAD_BUTTON_A) printf("A ");
|
||||
if(wd->btns_h & WPAD_BUTTON_B) printf("B ");
|
||||
if(wd->btns_h & WPAD_BUTTON_1) printf("1 ");
|
||||
if(wd->btns_h & WPAD_BUTTON_2) printf("2 ");
|
||||
if(wd->btns_h & WPAD_BUTTON_MINUS) printf("MINUS ");
|
||||
if(wd->btns_h & WPAD_BUTTON_HOME) printf("HOME ");
|
||||
if(wd->btns_h & WPAD_BUTTON_PLUS) printf("PLUS ");
|
||||
printf("\n ");
|
||||
if(wd->btns_h & WPAD_BUTTON_LEFT) printf("LEFT ");
|
||||
if(wd->btns_h & WPAD_BUTTON_RIGHT) printf("RIGHT ");
|
||||
if(wd->btns_h & WPAD_BUTTON_UP) printf("UP ");
|
||||
if(wd->btns_h & WPAD_BUTTON_DOWN) printf("DOWN ");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_and_draw_wiimote_data(void *screen_buffer) {
|
||||
//Makes the var wd point to the data on the wiimote
|
||||
WPADData *wd = WPAD_Data(0);
|
||||
printf(" Data->Err: %d\n",wd->err);
|
||||
printf(" IR Dots:\n");
|
||||
int i;
|
||||
for(i=0; i<4; i++) {
|
||||
if(wd->ir.dot[i].visible) {
|
||||
printf(" %4d, %3d\n", wd->ir.dot[i].rx, wd->ir.dot[i].ry);
|
||||
drawdot(screen_buffer, rmode, 1024, 768, wd->ir.dot[i].rx, wd->ir.dot[i].ry, COLOR_YELLOW);
|
||||
} else {
|
||||
printf(" None\n");
|
||||
}
|
||||
}
|
||||
//ir.valid - TRUE is the wiimote is pointing at the screen, else it is false
|
||||
if(wd->ir.valid) {
|
||||
float theta = wd->ir.angle / 180.0 * M_PI;
|
||||
|
||||
//ir.x/ir.y - The x/y coordinates that the wiimote is pointing to, relative to the screen.
|
||||
//ir.angle - how far (in degrees) the wiimote is twisted (based on ir)
|
||||
printf(" Cursor: %.02f,%.02f\n",wd->ir.x, wd->ir.y);
|
||||
printf(" @ %.02f deg\n",wd->ir.angle);
|
||||
|
||||
drawdot(screen_buffer, rmode, rmode->fbWidth, rmode->xfbHeight, wd->ir.x, wd->ir.y, COLOR_RED);
|
||||
drawdot(screen_buffer, rmode, rmode->fbWidth, rmode->xfbHeight, wd->ir.x + 10*sinf(theta), wd->ir.y - 10*cosf(theta), COLOR_BLUE);
|
||||
} else {
|
||||
printf(" No Cursor\n\n");
|
||||
}
|
||||
if(wd->ir.raw_valid) {
|
||||
//ir.z - How far away the wiimote is from the screen in meters
|
||||
printf(" Distance: %.02fm\n", wd->ir.z);
|
||||
//orient.yaw - The left/right angle of the wiimote to the screen
|
||||
printf(" Yaw: %.02f deg\n", wd->orient.yaw);
|
||||
} else {
|
||||
printf("\n\n");
|
||||
}
|
||||
printf(" Accel:\n");
|
||||
//accel.x/accel.y/accel.z - analog values for the accelleration of the wiimote
|
||||
//(Note: Gravity pulls downwards, so even if the wiimote is not moving,
|
||||
//one(or more) axis will have a reading as if it is moving "upwards")
|
||||
printf(" XYZ: %3d,%3d,%3d\n",wd->accel.x,wd->accel.y,wd->accel.z);
|
||||
//orient.pitch - how far the wiimote is "tilted" in degrees
|
||||
printf(" Pitch: %.02f\n",wd->orient.pitch);
|
||||
//orient.roll - how far the wiimote is "twisted" in degrees (uses accelerometer)
|
||||
printf(" Roll: %.02f\n",wd->orient.roll);
|
||||
|
||||
print_wiimote_buttons(wd);
|
||||
|
||||
if(wd->ir.raw_valid) {
|
||||
for(i=0; i<2; i++) {
|
||||
drawdot(screen_buffer, rmode, 4, 4, wd->ir.sensorbar.rot_dots[i].x+2, wd->ir.sensorbar.rot_dots[i].y+2, COLOR_GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
if(wd->btns_h & WPAD_BUTTON_1) doreload=1;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
void *xfb[2];
|
||||
u32 type;
|
||||
int fbi = 0;
|
||||
|
||||
VIDEO_Init();
|
||||
PAD_Init();
|
||||
WPAD_Init();
|
||||
|
||||
rmode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
// double buffering, prevents flickering (is it needed for LCD TV? i don't have one to test)
|
||||
xfb[0] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
||||
xfb[1] = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
||||
|
||||
VIDEO_Configure(rmode);
|
||||
VIDEO_SetNextFramebuffer(xfb);
|
||||
VIDEO_SetBlack(FALSE);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||
|
||||
SYS_SetResetCallback(reload);
|
||||
SYS_SetPowerCallback(shutdown);
|
||||
|
||||
WPAD_SetDataFormat(0, WPAD_FMT_BTNS_ACC_IR);
|
||||
WPAD_SetVRes(0, rmode->fbWidth, rmode->xfbHeight);
|
||||
|
||||
while(!doreload && !dooff) {
|
||||
CON_Init(xfb[fbi],0,0,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
|
||||
//VIDEO_ClearFrameBuffer(rmode,xfb[fbi],COLOR_BLACK);
|
||||
printf("\n\n\n");
|
||||
WPAD_ReadPending(WPAD_CHAN_ALL, countevs);
|
||||
int wiimote_connection_status = WPAD_Probe(0, &type);
|
||||
print_wiimote_connection_status(wiimote_connection_status);
|
||||
|
||||
printf(" Event count: %d\n",evctr);
|
||||
if(wiimote_connection_status == WPAD_ERR_NONE) {
|
||||
print_and_draw_wiimote_data(xfb[fbi]);
|
||||
}
|
||||
VIDEO_SetNextFramebuffer(xfb[fbi]);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
fbi ^= 1;
|
||||
}
|
||||
if(doreload) return 0;
|
||||
if(dooff) SYS_ResetSystem(SYS_SHUTDOWN,0,0);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue