Game Development Reference
In-Depth Information
On the other hand, when the Wiimote sends Input reports back to the host (such as button
presses or joystick movement), the main loop of Listing 8-9 dispatches the event to the
handler (shown in Listing 8-11).
Listing 8-11. JNI Event Handlers for WiiC
static void jni_send_btn_press(int id, const char * btn)
{
jni_send_event(id, "EVT_TYPE=BTNPRESS|BTN=%s", btn);
}
static void jni_send_btn_release(int id, const char * btn)
{
jni_send_event(id, "EVT_TYPE=BTNRELEASE|BTN=%s", btn);
}
void handle_event(struct wiimote_t* wm) {
int id = wm->unid;
/* if a button is pressed, report it */
if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) jni_send_btn_press(id,"A");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_B)) jni_send_btn_press(id,"B");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_UP)) jni_send_btn_press(id,"UP");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_DOWN)) jni_send_btn_press(id,"DOWN");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_LEFT)) jni_send_btn_press(id,"LEFT");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_RIGHT)) jni_send_btn_press(id,"RIGHT");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_MINUS)) jni_send_btn_press(id,"MINUS");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_PLUS)) jni_send_btn_press(id,"PLUS");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_ONE)) jni_send_btn_press(id,"ONE");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_TWO)) jni_send_btn_press(id,"TWO");
if (IS_PRESSED(wm, WIIMOTE_BUTTON_HOME)) jni_send_btn_press(id,"HOME");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_A)) jni_send_btn_release(id,"A");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_B)) jni_send_btn_release(id,"B");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_UP)) jni_send_btn_release(id,"UP");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_DOWN)) jni_send_btn_release(id,"DOWN");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_LEFT)) jni_send_btn_release(id,"LEFT");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_RIGHT))jni_send_btn_release(id,"RIGHT");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_MINUS))jni_send_btn_release(id,"MINUS");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_PLUS)) jni_send_btn_release(id,"PLUS");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_ONE)) jni_send_btn_release(id,"ONE");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_TWO)) jni_send_btn_release(id,"TWO");
if (IS_RELEASED(wm, WIIMOTE_BUTTON_HOME)) jni_send_btn_release(id,"HOME");
/* show events specific to supported expansions */
if (wm->exp.type == EXP_NUNCHUK) {
// nunchuk
struct nunchuk_t* nc = (nunchuk_t*)&wm->exp.nunchuk;
 
Search WWH ::




Custom Search