Skip to content

Commit

Permalink
Fixed indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
whitingjp committed Jul 22, 2014
1 parent 741f119 commit 5b5eea2
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions examples/c/test_responsiveness.c
@@ -1,7 +1,7 @@
/**
* PS Move API - An interface for the PS Move Motion Controller
* Copyright (c) 2014 Jonathan Whiting <jonathan@ignika.com>
* All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -37,51 +37,51 @@

int convert_accel_to_col(int accel)
{
accel = (accel*256)/35000;
if(accel < 0) accel = 0;
if(accel > 255) accel = 255;
return accel;
accel = (accel*256)/35000;
if(accel < 0) accel = 0;
if(accel > 255) accel = 255;
return accel;
}

int main(int argc, char* argv[])
{
int i, c;
c = psmove_count_connected();
printf("Connected controllers: %d\n", c);
if(c==0)
return 1;
int i, c;
c = psmove_count_connected();
printf("Connected controllers: %d\n", c);
if(c==0)
return 1;

PSMove **moves = (PSMove **)malloc(sizeof(PSMove *)*c);
PSMove **moves = (PSMove **)malloc(sizeof(PSMove *)*c);

for(i=0; i<c; i++) {
moves[i] = psmove_connect_by_id(i);
psmove_set_rate_limiting(moves[i], 1);
}
for(i=0; i<c; i++) {
moves[i] = psmove_connect_by_id(i);
psmove_set_rate_limiting(moves[i], 1);
}

bool running = true;
while(running) {
for(i=0; i<c; i++) {
while(psmove_poll(moves[i])) {}
int buttons = psmove_get_buttons(moves[i]);
bool running = true;
while(running) {
for(i=0; i<c; i++) {
while(psmove_poll(moves[i])) {}
int buttons = psmove_get_buttons(moves[i]);
int x, y, z, r, g, b;
psmove_get_accelerometer(moves[i], &x, &y, &z);
r = convert_accel_to_col(x);
g = convert_accel_to_col(y);
b = convert_accel_to_col(z);
if(buttons & Btn_PS)
running = false;
else if(buttons & Btn_MOVE)
psmove_set_leds(moves[i], 255, 255, 255);
else
psmove_set_leds(moves[i], r, g, b);
clock_t t = clock();
if(((t/CLOCKS_PER_SEC) % 5) == 0)
psmove_set_rumble(moves[i], 255);
else
psmove_set_rumble(moves[i], 0);
psmove_update_leds(moves[i]);
}
}
free(moves);
return 0;
if(buttons & Btn_PS)
running = false;
else if(buttons & Btn_MOVE)
psmove_set_leds(moves[i], 255, 255, 255);
else
psmove_set_leds(moves[i], r, g, b);
clock_t t = clock();
if(((t/CLOCKS_PER_SEC) % 5) == 0)
psmove_set_rumble(moves[i], 255);
else
psmove_set_rumble(moves[i], 0);
psmove_update_leds(moves[i]);
}
}
free(moves);
return 0;
}

0 comments on commit 5b5eea2

Please sign in to comment.