Unix line endings and remove trailing spaces
This commit is contained in:
@@ -6,7 +6,7 @@ if(SDL_FOUND AND OPENGL_FOUND AND GLUT_FOUND)
|
||||
include_directories(../src ${SDL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR} ${GLUT_INCLUDE_DIRS})
|
||||
add_executable(wiiuseexample-sdl sdl.c)
|
||||
target_link_libraries(wiiuseexample-sdl wiiuse ${SDL_LIBRARY} ${OPENGL_LIBRARIES} ${GLUT_LIBRARIES})
|
||||
|
||||
|
||||
if(INSTALL_EXAMPLES)
|
||||
install(TARGETS wiiuseexample-sdl
|
||||
RUNTIME DESTINATION bin COMPONENT examples)
|
||||
|
||||
@@ -55,14 +55,14 @@ wiimote** wiimotes = NULL;
|
||||
|
||||
int last_dots[4][2] = {{0}};
|
||||
int xcoord = 0;
|
||||
int ycoord = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
int ycoord = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
DWORD last_render;
|
||||
#else
|
||||
struct timeval last_render;
|
||||
int last_sec = 0;
|
||||
int fps = 0;
|
||||
int last_sec = 0;
|
||||
int fps = 0;
|
||||
#endif
|
||||
|
||||
enum render_mode_t {
|
||||
@@ -125,8 +125,8 @@ void handle_event(struct wiimote_t* wm) {
|
||||
wiiuse_set_ir(wm, 1);
|
||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_DOWN))
|
||||
wiiuse_set_ir(wm, 0);
|
||||
|
||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B))
|
||||
|
||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_B))
|
||||
wiiuse_toggle_rumble(wm);
|
||||
|
||||
if (IS_JUST_PRESSED(wm, WIIMOTE_BUTTON_ONE)) {
|
||||
@@ -161,8 +161,8 @@ int can_render() {
|
||||
/* quick fps limit to ~60fps -- not too fancy, could be better */
|
||||
#ifdef WIN32
|
||||
if (GetTickCount() < (last_render + 16))
|
||||
return 0;
|
||||
last_render = GetTickCount();
|
||||
return 0;
|
||||
last_render = GetTickCount();
|
||||
return 1;
|
||||
#else
|
||||
struct timeval now;
|
||||
@@ -204,23 +204,23 @@ void display() {
|
||||
float size = 5;
|
||||
|
||||
if (!can_render())
|
||||
return;
|
||||
return;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glLoadIdentity();
|
||||
|
||||
if (render_mode == IR) {
|
||||
/* draw the IR stuff */
|
||||
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
/* green center */
|
||||
glColor3f(0.0, 1.0, 0.0);
|
||||
DRAW_TRIANGLE(width/2, height/2, 0, size);
|
||||
glEnd();
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
/* green center */
|
||||
glColor3f(0.0, 1.0, 0.0);
|
||||
DRAW_TRIANGLE(width/2, height/2, 0, size);
|
||||
glEnd();
|
||||
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
|
||||
glBegin(GL_TRIANGLES);
|
||||
/* red ir */
|
||||
@@ -258,7 +258,7 @@ void display() {
|
||||
|
||||
|
||||
glutSolidTeapot(1);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
@@ -287,8 +287,8 @@ void set_material(struct material_t* mptr) {
|
||||
}
|
||||
|
||||
|
||||
void resize_window(GLint new_width, GLint new_height) {
|
||||
int wm;
|
||||
void resize_window(GLint new_width, GLint new_height) {
|
||||
int wm;
|
||||
|
||||
width = new_width;
|
||||
height = new_height;
|
||||
@@ -313,8 +313,8 @@ void resize_window(GLint new_width, GLint new_height) {
|
||||
|
||||
width = new_width;
|
||||
height = new_height;
|
||||
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm)
|
||||
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm)
|
||||
wiiuse_set_ir_vres(wiimotes[wm], width, height);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ int main(int argc, char** argv) {
|
||||
#else
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
#endif
|
||||
int found, connected;
|
||||
int found, connected;
|
||||
int wm;
|
||||
|
||||
//printf("wiiuse version = %s\n", wiiuse_version());
|
||||
@@ -340,7 +340,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
return 0;
|
||||
}
|
||||
wiiuse_set_leds(wiimotes[0], WIIMOTE_LED_1 | WIIMOTE_LED_4);
|
||||
wiiuse_set_leds(wiimotes[1], WIIMOTE_LED_2 | WIIMOTE_LED_4);
|
||||
wiiuse_set_leds(wiimotes[1], WIIMOTE_LED_2 | WIIMOTE_LED_4);
|
||||
wiiuse_rumble(wiimotes[0], 1);
|
||||
|
||||
#ifndef WIN32
|
||||
@@ -350,29 +350,29 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
#endif
|
||||
|
||||
wiiuse_rumble(wiimotes[0], 0);
|
||||
|
||||
/* enable IR and motion sensing for all wiimotes */
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
|
||||
|
||||
/* enable IR and motion sensing for all wiimotes */
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm) {
|
||||
wiiuse_motion_sensing(wiimotes[wm], 1);
|
||||
wiiuse_set_ir(wiimotes[wm], 1);
|
||||
}
|
||||
wiiuse_set_ir(wiimotes[wm], 1);
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
printf("Failed to initialize SDL: %s\n", SDL_GetError());
|
||||
return 0;
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("wiiuse SDL IR Example", "wiiuse SDL IR Example");
|
||||
|
||||
SDL_WM_SetCaption("wiiuse SDL IR Example", "wiiuse SDL IR Example");
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
|
||||
|
||||
/* set window size */
|
||||
width = wiimotes[0]->ir.vres[0];
|
||||
height = wiimotes[0]->ir.vres[1];
|
||||
SDL_SetVideoMode(width, height, 16, SDL_RESIZABLE | SDL_OPENGL);
|
||||
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm)
|
||||
SDL_SetVideoMode(width, height, 16, SDL_RESIZABLE | SDL_OPENGL);
|
||||
|
||||
for (wm = 0; wm < MAX_WIIMOTES; ++wm)
|
||||
wiiuse_set_ir_vres(wiimotes[wm], width, height);
|
||||
|
||||
/* set OpenGL stuff */
|
||||
@@ -388,15 +388,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
/* set the size of the window */
|
||||
resize_window(width, height);
|
||||
|
||||
display();
|
||||
|
||||
#ifdef WIN32
|
||||
display();
|
||||
|
||||
#ifdef WIN32
|
||||
last_render = GetTickCount();
|
||||
#endif
|
||||
|
||||
while (1) {
|
||||
SDL_Event event;
|
||||
|
||||
|
||||
if (SDL_PollEvent(&event)) {
|
||||
switch (event.type) {
|
||||
case SDL_VIDEORESIZE:
|
||||
@@ -437,6 +437,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
}
|
||||
}
|
||||
|
||||
display();
|
||||
display();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user