~ubuntu-branches/ubuntu/precise/csound/precise

« back to all changes in this revision

Viewing changes to Opcodes/wiimote.c

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler
  • Date: 2012-04-19 09:26:46 UTC
  • mfrom: (3.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20120419092646-96xbj1n6atuqosk2
Tags: 1:5.17.6~dfsg-1
* New upstream release
 - Do not build the wiimote opcodes (we need wiiuse).
* Add new API function to symbols file
* Disable lua opcodes, they were broken. Requires OpenMP to be enabled.
* Backport fixes from upstream:
  - Link dssi4cs with dl. Backport
  - Fix building of CsoundAC

Show diffs side-by-side

added added

removed removed

Lines of Context:
80
80
    MYFLT     *num;
81
81
 } WIIRANGE;
82
82
 
83
 
#define WIIMOTE_STATE_CONNECTED         (0x0008)
 
83
#ifdef WIIUSE_0_12
 
84
#  define WIIMOTE_STATE_CONNECTED          (0x0008)
 
85
#else
 
86
#  define WIIMOTE_STATE_CONNECTED          (0x0010)
 
87
#endif
84
88
 
85
89
int wiimote_find(CSOUND *csound, WIIMOTE *p)
86
90
{
116
120
      return csound->InitError(csound, Str("unable to open wiimote\n"));
117
121
    }
118
122
    /* Initialise ranges */
119
 
    for (i=0; i<max_wiimotes; i++) {
 
123
    for (i=0; i<n; i++) {
120
124
      wiiuse_set_leds(wiimotes[i], WIIMOTE_LED_1<<i);
121
125
      wiirange[i].axis_x_min    = FL(0.0);
122
126
      wiirange[i].axis_x_scale  = FL(1.0);
136
140
      wiiuse_motion_sensing(wiimotes[i], 1);
137
141
    }
138
142
    p->wii = wiimotes;
139
 
    p->max_wiimotes = max_wiimotes;
 
143
    p->max_wiimotes = n;
140
144
    *p->res = FL(1.0);
141
145
    return OK;
142
146
}
160
164
        csound->Warning(csound,
161
165
                        Str("wiimote %i disconnected\n"), wiimotes[i]->unid);
162
166
        *p->res = FL(0.0);
163
 
        return;
 
167
        return OK;
164
168
      case WIIUSE_NUNCHUK_INSERTED:
165
169
        /*
166
170
         *      This is a good place to set any nunchuk specific
207
211
    wiirange_t *wiir = p->wiir;
208
212
    int n = (int)*p->num;
209
213
    int kontrol = (int)(*p->kControl+FL(0.5));
210
 
    if (UNLIKELY(n>=MAX_WIIMOTES || !(wii[n]->state & WIIMOTE_STATE_CONNECTED)))
 
214
    if (UNLIKELY(n>=MAX_WIIMOTES || !(wii[n]->state & WIIMOTE_STATE_CONNECTED))) {
 
215
      printf("state of wii %d is %x\n", n, wii[n]->state);
211
216
      return csound->PerfError(csound, Str("wiimote %d does not exist"), n);
 
217
    }
212
218
    if (kontrol<0) {
213
219
      printf("%f -- %.4x: "
214
220
             "tilt=[%f %f];\nforce=(%f %f %f)\n",
401
407
 
402
408
#define S(x)    sizeof(x)
403
409
 
404
 
static OENTRY localops[] = {
 
410
static OENTRY wiimote_localops[] = {
405
411
  {"wiiconnect", S(WIIMOTE), 3, "i", "oo", (SUBR)wiimote_find, (SUBR)wiimote_poll },
406
412
  {"wiidata", S(WIIMOTE), 3, "k", "ko", (SUBR)wii_data_init, (SUBR)wii_data },
407
413
  {"wiisend", S(WIIMOTES), 3, "", "kko", (SUBR)wii_data_inits, (SUBR)wii_send },
408
414
  {"wiirange", S(WIIRANGE), 1, "", "iiio", (SUBR)wiimote_range, NULL, NULL }
409
415
};
410
416
 
411
 
LINKAGE
 
417
LINKAGE1(wiimote_localops)