diff -urpN ./trunk/configure ./led_edit/configure
|
old
|
new
|
|
| 4784 | 4784 | |
| 4785 | 4785 | |
| 4786 | 4786 | |
| 4787 | | ac_config_files="$ac_config_files Makefile defs.mak common/include/lib.mak doc/Makefile man/Makefile libcwiid/Makefile libcwiid/cwiid.pc wmdemo/Makefile wmgui/Makefile wminput/Makefile wminput/plugins/Makefile wminput/plugins/ir_ptr/Makefile wminput/plugins/acc/Makefile wminput/plugins/nunchuk_acc/Makefile lswm/Makefile python/Makefile" |
| | 4787 | ac_config_files="$ac_config_files Makefile defs.mak common/include/lib.mak doc/Makefile man/Makefile libcwiid/Makefile libcwiid/cwiid.pc wmdemo/Makefile wmgui/Makefile wminput/Makefile wminput/plugins/Makefile wminput/plugins/ir_ptr/Makefile wminput/plugins/acc/Makefile wminput/plugins/nunchuk_acc/Makefile wminput/plugins/led/Makefile lswm/Makefile python/Makefile" |
| 4788 | 4788 | |
| 4789 | 4789 | cat >confcache <<\_ACEOF |
| 4790 | 4790 | # This file is a shell script that caches the results of configure |
| … |
… |
|
| 5353 | 5353 | "wminput/plugins/ir_ptr/Makefile") CONFIG_FILES="$CONFIG_FILES wminput/plugins/ir_ptr/Makefile" ;; |
| 5354 | 5354 | "wminput/plugins/acc/Makefile") CONFIG_FILES="$CONFIG_FILES wminput/plugins/acc/Makefile" ;; |
| 5355 | 5355 | "wminput/plugins/nunchuk_acc/Makefile") CONFIG_FILES="$CONFIG_FILES wminput/plugins/nunchuk_acc/Makefile" ;; |
| | 5356 | "wminput/plugins/led/Makefile") CONFIG_FILES="$CONFIG_FILES wminput/plugins/led/Makefile" ;; |
| 5356 | 5357 | "lswm/Makefile") CONFIG_FILES="$CONFIG_FILES lswm/Makefile" ;; |
| 5357 | 5358 | "python/Makefile") CONFIG_FILES="$CONFIG_FILES python/Makefile" ;; |
| 5358 | 5359 | |
diff -urpN ./trunk/wminput/configs/acc_led ./led_edit/wminput/configs/acc_led
|
old
|
new
|
|
| | 1 | #acc_led |
| | 2 | |
| | 3 | include buttons |
| | 4 | |
| | 5 | Plugin.acc.X = REL_X |
| | 6 | Plugin.acc.Y = REL_Y |
| | 7 | |
| | 8 | # You can set Plugin.led.Led[1->4) to 1 |
| | 9 | # to have that led be active all the time |
| | 10 | Plugin.led.Led4 = 1 |
| | 11 | |
| | 12 | # Setting battery to 1 enables the battery check function |
| | 13 | # By default the keypress is A + B |
| | 14 | # You can change this by setting Plugin.led.Button to any |
| | 15 | # wiimote or attachment button |
| | 16 | Plugin.led.Battery = 1 |
diff -urpN ./trunk/wminput/Makefile.in ./led_edit/wminput/Makefile.in
|
old
|
new
|
|
| 43 | 43 | install_configs: |
| 44 | 44 | install -d $(WMINPUT_CONFIG_DIR) |
| 45 | 45 | install configs/* $(WMINPUT_CONFIG_DIR) |
| 46 | | ln -sf acc_ptr $(WMINPUT_CONFIG_DIR)/default |
| | 46 | ln -sf acc_led $(WMINPUT_CONFIG_DIR)/default |
| 47 | 47 | |
| 48 | 48 | #uninstall_configs: |
| 49 | 49 | # rm -f $(WMINPUT_CONFIG_DIR)/default |
diff -urpN ./trunk/wminput/plugins/ir_ptr/ir_ptr.c ./led_edit/wminput/plugins/ir_ptr/ir_ptr.c
|
old
|
new
|
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /* LEDs */ |
| | 150 | /* Commented out so it doesn't overide led plugin. |
| | 151 | * It shouldn't matter, since only one IR source |
| | 152 | * is used now anyways. If the pointer is moving, |
| | 153 | * it sees a source. |
| 150 | 154 | switch (src_index) { |
| 151 | 155 | case 0: |
| 152 | 156 | flag = CWIID_LED1_ON; |
| … |
… |
|
| 164 | 168 | flag = 0; |
| 165 | 169 | break; |
| 166 | 170 | } |
| | 171 | |
| 167 | 172 | if (flag != old_flag) { |
| 168 | 173 | cwiid_set_led(wiimote, flag); |
| 169 | 174 | old_flag = flag; |
| 170 | 175 | } |
| | 176 | */ |
| 171 | 177 | |
| 172 | 178 | if ((src_index == -1) || !ir_mesg->src[src_index].valid) { |
| 173 | 179 | data.axes[0].valid = data.axes[1].valid = 0; |
diff -urpN ./trunk/wminput/plugins/led/led.c ./led_edit/wminput/plugins/led/led.c
|
old
|
new
|
|
| 1 | 1 | #include "wmplugin.h" |
| | 2 | #include <math.h> |
| | 3 | |
| 2 | 4 | |
| 3 | 5 | cwiid_wiimote_t *wiimote; |
| 4 | 6 | |
| … |
… |
|
| 10 | 12 | wmplugin_init_t wmplugin_init; |
| 11 | 13 | wmplugin_exec_t wmplugin_exec; |
| 12 | 14 | |
| 13 | | static int led1 = 0; |
| 14 | | static int led2 = 0; |
| 15 | | static int led3 = 0; |
| 16 | | static int led4 = 0; |
| | 15 | static int Led1 = 0; |
| | 16 | static int Led2 = 0; |
| | 17 | static int Led3 = 0; |
| | 18 | static int Led4 = 0; |
| | 19 | static int Battery = 0; |
| | 20 | static uint8_t Button = CWIID_BTN_A + CWIID_BTN_B; |
| | 21 | |
| | 22 | static void show_battery(); |
| 17 | 23 | |
| 18 | 24 | struct wmplugin_info *wmplugin_info() |
| 19 | 25 | { |
| 20 | 26 | if (!info_init) { |
| 21 | 27 | info.button_count = 0; |
| 22 | 28 | info.axis_count = 0; |
| 23 | | info.param_count = 4; |
| 24 | | info.param_info[0].name = "led1"; |
| | 29 | info.param_count = 6; |
| | 30 | info.param_info[0].name = "Led1"; |
| 25 | 31 | info.param_info[0].type = WMPLUGIN_PARAM_INT; |
| 26 | | info.param_info[0].ptr = &led1; |
| 27 | | info.param_info[1].name = "led2"; |
| | 32 | info.param_info[0].ptr = &Led1; |
| | 33 | info.param_info[1].name = "Led2"; |
| 28 | 34 | info.param_info[1].type = WMPLUGIN_PARAM_INT; |
| 29 | | info.param_info[1].ptr = &led2; |
| 30 | | info.param_info[2].name = "led3"; |
| | 35 | info.param_info[1].ptr = &Led2; |
| | 36 | info.param_info[2].name = "Led3"; |
| 31 | 37 | info.param_info[2].type = WMPLUGIN_PARAM_INT; |
| 32 | | info.param_info[2].ptr = &led3; |
| 33 | | info.param_info[3].name = "led4"; |
| | 38 | info.param_info[2].ptr = &Led3; |
| | 39 | info.param_info[3].name = "Led4"; |
| 34 | 40 | info.param_info[3].type = WMPLUGIN_PARAM_INT; |
| 35 | | info.param_info[3].ptr = &led4; |
| | 41 | info.param_info[3].ptr = &Led4; |
| | 42 | info.param_info[4].name = "Battery"; |
| | 43 | info.param_info[4].type = WMPLUGIN_PARAM_INT; |
| | 44 | info.param_info[4].ptr = &Battery; |
| | 45 | info.param_info[5].name = "Button"; |
| | 46 | info.param_info[5].type = WMPLUGIN_PARAM_INT; |
| | 47 | info.param_info[5].ptr = &Button; |
| 36 | 48 | info_init = 1; |
| 37 | 49 | } |
| 38 | 50 | return &info; |
| … |
… |
|
| 42 | 54 | { |
| 43 | 55 | wiimote = arg_wiimote; |
| 44 | 56 | |
| 45 | | uint8_t led_state = (led1 ? CWIID_LED1_ON : 0) |
| 46 | | | (led2 ? CWIID_LED2_ON : 0) |
| 47 | | | (led3 ? CWIID_LED3_ON : 0) |
| 48 | | | (led4 ? CWIID_LED4_ON : 0); |
| | 57 | uint8_t led_state = (Led1 ? CWIID_LED1_ON : 0) |
| | 58 | | (Led2 ? CWIID_LED2_ON : 0) |
| | 59 | | (Led3 ? CWIID_LED3_ON : 0) |
| | 60 | | (Led4 ? CWIID_LED4_ON : 0); |
| 49 | 61 | |
| 50 | 62 | cwiid_command(wiimote, CWIID_CMD_LED, led_state); |
| | 63 | |
| | 64 | if (wmplugin_set_rpt_mode(id, CWIID_RPT_BTN)) { |
| | 65 | return -1; |
| | 66 | } |
| 51 | 67 | |
| 52 | 68 | return 0; |
| 53 | 69 | } |
| 54 | 70 | |
| 55 | 71 | struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg mesg[]) |
| 56 | 72 | { |
| | 73 | int i; |
| | 74 | uint8_t button; |
| | 75 | struct cwiid_btn_message *btn_mesg; |
| | 76 | |
| | 77 | uint8_t led_state = (Led1 ? CWIID_LED1_ON : 0) |
| | 78 | | (Led2 ? CWIID_LED2_ON : 0) |
| | 79 | | (Led3 ? CWIID_LED3_ON : 0) |
| | 80 | | (Led4 ? CWIID_LED4_ON : 0); |
| | 81 | |
| | 82 | if(Battery != 0) { |
| | 83 | btn_mesg = NULL; |
| | 84 | for (i=0; i < mesg_count; i++) { |
| | 85 | if (mesg[i].type == CWIID_MESG_BTN) { |
| | 86 | btn_mesg = &mesg[i].btn_mesg; |
| | 87 | button = mesg[i].btn_mesg.buttons; |
| | 88 | } |
| | 89 | } |
| | 90 | |
| | 91 | if (!btn_mesg) { |
| | 92 | return NULL; |
| | 93 | } |
| | 94 | |
| | 95 | if(button == Button) { |
| | 96 | show_battery(); |
| | 97 | } |
| | 98 | else { |
| | 99 | cwiid_command(wiimote, CWIID_CMD_LED, led_state); |
| | 100 | } |
| | 101 | } |
| | 102 | |
| 57 | 103 | return &data; |
| 58 | 104 | } |
| | 105 | |
| | 106 | static void show_battery() |
| | 107 | { |
| | 108 | struct cwiid_state state; |
| | 109 | float battery_percent; |
| | 110 | int battery_led; |
| | 111 | |
| | 112 | cwiid_get_state(wiimote, &state); |
| | 113 | |
| | 114 | // calculate battery as a percent, then decide how many leds to light up |
| | 115 | battery_percent = (100*state.battery / CWIID_BATTERY_MAX); |
| | 116 | battery_led = ceil(battery_percent / 25); |
| | 117 | |
| | 118 | switch(battery_led) { |
| | 119 | case 1: |
| | 120 | cwiid_set_led(wiimote, CWIID_LED1_ON); |
| | 121 | break; |
| | 122 | case 2: |
| | 123 | cwiid_set_led(wiimote, CWIID_LED1_ON | CWIID_LED2_ON ); |
| | 124 | break; |
| | 125 | case 3: |
| | 126 | cwiid_set_led(wiimote, CWIID_LED1_ON | CWIID_LED2_ON | CWIID_LED3_ON ); |
| | 127 | break; |
| | 128 | case 4: |
| | 129 | cwiid_set_led(wiimote, CWIID_LED1_ON | CWIID_LED2_ON | CWIID_LED3_ON | CWIID_LED4_ON ); |
| | 130 | break; |
| | 131 | default: |
| | 132 | break; |
| | 133 | } |
| | 134 | } |