Changeset 805477a3e8c4bccbd90c78e829870267c783904b
- Timestamp:
- 04/11/07 02:57:27 (6 years ago)
- Children:
- 422e116295dcc983b62bf24728fcbae936c138cb
- Parents:
- 347f3c9b4712bdd7736cfb88396d3ed8a8b8d14f
- git-author:
- L. Donnie Smith <donnie.smith@…> (04/11/07 02:57:27)
- git-committer:
- dsmith <dsmith@…> (04/11/07 02:57:27)
- Files:
-
- 1 added
- 1 removed
- 23 modified
- 10 moved
-
ChangeLog (modified) (1 diff)
-
Makefile.in (modified) (1 diff)
-
README (modified) (1 diff)
-
configure.ac (modified) (2 diffs)
-
libcwiid/Makefile.in (moved) (moved from wiimote/Makefile.in) (1 diff)
-
libcwiid/bluetooth.c (moved) (moved from wiimote/bluetooth.c) (12 diffs)
-
libcwiid/command.c (moved) (moved from wiimote/command.c) (13 diffs)
-
libcwiid/connect.c (moved) (moved from wiimote/connect.c) (19 diffs)
-
libcwiid/cwiid.h (added)
-
libcwiid/cwiid_internal.h (moved) (moved from wiimote/wiimote_internal.h) (5 diffs)
-
libcwiid/event.c (moved) (moved from wiimote/event.c) (41 diffs)
-
libcwiid/queue.c (moved) (moved from wiimote/queue.c)
-
libcwiid/queue.h (moved) (moved from wiimote/queue.h) (1 diff)
-
libcwiid/rw.c (moved) (moved from wiimote/rw.c) (20 diffs)
-
libcwiid/util.c (moved) (moved from wiimote/util.c) (7 diffs)
-
lswm/Makefile.in (modified) (1 diff)
-
lswm/lswm.c (modified) (5 diffs)
-
wiimote/wiimote.h (deleted)
-
wmdemo/Makefile.in (modified) (1 diff)
-
wmdemo/wmdemo.c (modified) (14 diffs)
-
wmgui/Makefile.in (modified) (1 diff)
-
wmgui/main.c (modified) (34 diffs)
-
wminput/Makefile.in (modified) (1 diff)
-
wminput/README (modified) (1 diff)
-
wminput/conf.c (modified) (8 diffs)
-
wminput/conf.h (modified) (3 diffs)
-
wminput/main.c (modified) (28 diffs)
-
wminput/plugins/acc/Makefile.in (modified) (1 diff)
-
wminput/plugins/acc/acc.c (modified) (7 diffs)
-
wminput/plugins/ir_ptr/Makefile.in (modified) (1 diff)
-
wminput/plugins/ir_ptr/ir_ptr.c (modified) (11 diffs)
-
wminput/plugins/nunchuk_acc/Makefile.in (modified) (1 diff)
-
wminput/plugins/nunchuk_acc/nunchuk_acc.c (modified) (8 diffs)
-
wminput/uinput.c (modified) (3 diffs)
-
wminput/wmplugin.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
rf200a0f r805477a 1 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 2 libcwiid 3 * renamed from libwiimote 4 * renamed external data structures 5 6 lswm 7 * updated for libcwiid rename 8 9 wmdemo 10 * updated for libcwiid rename 11 12 wmgui 13 * updated for libcwiid rename 14 15 wminput 16 * updated for libcwiid rename 17 1 18 2007-04-08 Arthur Peters <amp@singingwizard.org> 2 19 wminput -
Makefile.in
r416f60e r805477a 3 3 include @top_builddir@/defs.mak 4 4 5 LIB_DIRS = wiimote5 LIB_DIRS = libcwiid 6 6 BIN_DIRS = wmgui wminput lswm 7 7 DOC_DIRS = man doc -
README
r52f7c50 r805477a 23 23 ------------------------------------------------------------------------------------------------ 24 24 The CWiid package contains the following parts: 25 1. wiimote library - API to the wiimote.25 1.libcwiid - wiimote API. 26 26 2.wmgui - GTK gui to the wiimote. 27 27 3.wminput - an event/joystick/mouse driver for the wiimote. -
configure.ac
r347f3c9 r805477a 1 1 # ChangeLog: 2 # 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 3 # * updated for libcwiid rename 4 # 2 5 # 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 3 6 # * removed --noyywrap from lex … … 93 96 [doc/Makefile] 94 97 [man/Makefile] 95 [ wiimote/Makefile]98 [libcwiid/Makefile] 96 99 [wmdemo/Makefile] 97 100 [wmgui/Makefile] -
libcwiid/Makefile.in
rbdb6c21 r805477a 3 3 include @top_builddir@/defs.mak 4 4 5 LIB_NAME = wiimote5 LIB_NAME = cwiid 6 6 MAJOR_VER = 0 7 7 MINOR_VER = 1 -
libcwiid/bluetooth.c
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-04-07 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * changed wiimote_info.class to btclass22 * * changed cwiid_info.class to btclass 20 23 * 21 24 * 2007-04-03 L. Donnie Smith <cwiid@abstrakraft.org> 22 * * fixed wiimote_find_wiimote seg fault25 * * fixed cwiid_find_wiimote seg fault 23 26 * 24 27 * 2007-04-02 L. Donnie Smith <cwiid@abstrakraft.org> … … 34 37 #include <bluetooth/hci.h> 35 38 #include <bluetooth/hci_lib.h> 36 #include " wiimote_internal.h"39 #include "cwiid_internal.h" 37 40 38 41 /* When filtering wiimotes, in order to avoid having to store the … … 43 46 #define BT_MAX_INQUIRY 256 44 47 /* timeout in 2 second units */ 45 int wiimote_get_info_array(int dev_id, unsigned int timeout, int max_wm,46 struct wiimote_info **wm, uint8_t flags)48 int cwiid_get_bdinfo_array(int dev_id, unsigned int timeout, int max_bdinfo, 49 struct cwiid_bdinfo **bdinfo, uint8_t flags) 47 50 { 48 51 /* TODO: I suppose we'll have to sift through BlueZ source to properly … … 53 56 int dev_count; 54 57 int sock = -1; 55 int wm_count;58 int bdinfo_count; 56 59 int i, j; 57 60 int err = 0; … … 59 62 60 63 /* NULLify for the benefit of error handling */ 61 * wm= NULL;64 *bdinfo = NULL; 62 65 63 66 /* If not given (=-1), get the first available Bluetooth interface */ 64 67 if (dev_id == -1) { 65 68 if ((dev_id = hci_get_route(NULL)) == -1) { 66 wiimote_err(NULL, "No Bluetooth interface found");69 cwiid_err(NULL, "No Bluetooth interface found"); 67 70 return -1; 68 71 } … … 70 73 71 74 /* Get Bluetooth Device List */ 72 if ((flags & BT_NO_WIIMOTE_FILTER) && (max_ wm!= -1)) {73 max_inquiry = max_ wm;75 if ((flags & BT_NO_WIIMOTE_FILTER) && (max_bdinfo != -1)) { 76 max_inquiry = max_bdinfo; 74 77 } 75 78 else { … … 78 81 if ((dev_count = hci_inquiry(dev_id, timeout, max_inquiry, NULL, 79 82 &dev_list, IREQ_CACHE_FLUSH)) == -1) { 80 wiimote_err(NULL, "Error on bluetooth device inquiry");83 cwiid_err(NULL, "Error on bluetooth device inquiry"); 81 84 err = 1; 82 85 goto CODA; … … 84 87 85 88 if (dev_count == 0) { 86 wm_count = 0;89 bdinfo_count = 0; 87 90 goto CODA; 88 91 } … … 90 93 /* Open connection to Bluetooth Interface */ 91 94 if ((sock = hci_open_dev(dev_id)) == -1) { 92 wiimote_err(NULL, "Error opening Bluetooth interface");95 cwiid_err(NULL, "Error opening Bluetooth interface"); 93 96 err = 1; 94 97 goto CODA; … … 96 99 97 100 /* Allocate info list */ 98 if (max_ wm== -1) {99 max_ wm= dev_count;101 if (max_bdinfo == -1) { 102 max_bdinfo = dev_count; 100 103 } 101 if ((* wm = malloc(max_wm * sizeof **wm)) == NULL) {102 wiimote_err(NULL, "Error mallocing wiimote_info array");104 if ((*bdinfo = malloc(max_bdinfo * sizeof **bdinfo)) == NULL) { 105 cwiid_err(NULL, "Error mallocing bdinfo array"); 103 106 err = 1; 104 107 goto CODA; 105 108 } 106 109 107 /* Copy dev_list to info */ 108 for (wm_count=i=0; (i < dev_count) && (wm_count < max_wm); i++) { 110 /* Copy dev_list to bdinfo */ 111 for (bdinfo_count=i=0; (i < dev_count) && (bdinfo_count < max_bdinfo); 112 i++) { 109 113 /* timeout (5000) in milliseconds */ 110 if (hci_remote_name(sock, &dev_list[i].bdaddr, BT_ WM_NAME_LEN,111 (* wm)[wm_count].name, 5000)) {112 wiimote_err(NULL, "Error reading Bluetooth device name");114 if (hci_remote_name(sock, &dev_list[i].bdaddr, BT_NAME_LEN, 115 (*bdinfo)[bdinfo_count].name, 5000)) { 116 cwiid_err(NULL, "Error reading Bluetooth device name"); 113 117 err = 1; 114 118 goto CODA; … … 119 123 (dev_list[i].dev_class[1] != WIIMOTE_CLASS_1) || 120 124 (dev_list[i].dev_class[2] != WIIMOTE_CLASS_2) || 121 (strncmp((*wm)[wm_count].name, WIIMOTE_NAME, BT_WM_NAME_LEN)))) { 125 (strncmp((*bdinfo)[bdinfo_count].name, WIIMOTE_NAME, 126 BT_NAME_LEN)))) { 122 127 continue; 123 128 } 124 bacpy(&(* wm)[wm_count].bdaddr, &dev_list[i].bdaddr);129 bacpy(&(*bdinfo)[bdinfo_count].bdaddr, &dev_list[i].bdaddr); 125 130 for (j=0; j<3; j++) { 126 (* wm)[wm_count].btclass[j] = dev_list[i].dev_class[j];131 (*bdinfo)[bdinfo_count].btclass[j] = dev_list[i].dev_class[j]; 127 132 } 128 wm_count++;133 bdinfo_count++; 129 134 } 130 135 131 if ( wm_count == 0) {132 free(* wm);136 if (bdinfo_count == 0) { 137 free(*bdinfo); 133 138 } 134 else if (wm_count < max_wm) { 135 if ((*wm = realloc(*wm, wm_count * sizeof **wm)) == NULL) { 136 wiimote_err(NULL, "Error reallocing wiimote_info array"); 139 else if (bdinfo_count < max_bdinfo) { 140 if ((*bdinfo = realloc(*bdinfo, bdinfo_count * sizeof **bdinfo)) 141 == NULL) { 142 cwiid_err(NULL, "Error reallocing bdinfo array"); 137 143 err = 1; 138 144 goto CODA; … … 144 150 if (sock != -1) hci_close_dev(sock); 145 151 if (err) { 146 if (* wm) free(*wm);152 if (*bdinfo) free(*bdinfo); 147 153 ret = -1; 148 154 } 149 155 else { 150 ret = wm_count;156 ret = bdinfo_count; 151 157 } 152 158 return ret; 153 159 } 154 160 155 int wiimote_find_wiimote(bdaddr_t *bdaddr, int timeout)161 int cwiid_find_wiimote(bdaddr_t *bdaddr, int timeout) 156 162 { 157 struct wiimote_info *wm;158 int wm_count;163 struct cwiid_bdinfo *bdinfo; 164 int bdinfo_count; 159 165 160 166 if (timeout == -1) { 161 while ((wm_count = wiimote_get_info_array(-1, 2, 1, &wm, 0)) == 0); 162 if (wm_count == -1) { 167 while ((bdinfo_count = cwiid_get_bdinfo_array(-1, 2, 1, &bdinfo, 0)) 168 == 0); 169 if (bdinfo_count == -1) { 163 170 return -1; 164 171 } 165 172 } 166 173 else { 167 wm_count = wiimote_get_info_array(-1, timeout, 1, &wm, 0);168 if ( wm_count == -1) {174 bdinfo_count = cwiid_get_bdinfo_array(-1, timeout, 1, &bdinfo, 0); 175 if (bdinfo_count == -1) { 169 176 return -1; 170 177 } 171 else if ( wm_count == 0) {172 wiimote_err(NULL, "No wiimotes found");178 else if (bdinfo_count == 0) { 179 cwiid_err(NULL, "No wiimotes found"); 173 180 return -1; 174 181 } 175 182 } 176 183 177 bacpy(bdaddr, & wm[0].bdaddr);178 free( wm);184 bacpy(bdaddr, &bdinfo[0].bdaddr); 185 free(bdinfo); 179 186 return 0; 180 187 } -
libcwiid/command.c
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * audited error checking (coda and error handler sections) … … 21 24 * 22 25 * 2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 23 * * added wiimote parameter to wiimote_err calls26 * * added wiimote parameter to cwiid_err calls 24 27 * 25 28 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 30 33 #include <stdint.h> 31 34 #include <unistd.h> 32 #include " wiimote_internal.h"35 #include "cwiid_internal.h" 33 36 34 37 /* IR Sensitivity Block */ … … 39 42 {WRITE_SEQ_RPT, RPT_IR_ENABLE1, (const void *)"\x04", 1, 0}, 40 43 {WRITE_SEQ_RPT, RPT_IR_ENABLE2, (const void *)"\x04", 1, 0}, 41 {WRITE_SEQ_MEM, 0xB00030, (const void *)"\x08", 1, WIIMOTE_RW_REG},42 {WRITE_SEQ_MEM, 0xB00000, ir_block1, sizeof(ir_block1)-1, WIIMOTE_RW_REG},43 {WRITE_SEQ_MEM, 0xB0001A, ir_block2, sizeof(ir_block2)-1, WIIMOTE_RW_REG},44 {WRITE_SEQ_MEM, 0xB00033, (const void *)"\x01", 1, WIIMOTE_RW_REG}44 {WRITE_SEQ_MEM, 0xB00030, (const void *)"\x08", 1, CWIID_RW_REG}, 45 {WRITE_SEQ_MEM, 0xB00000, ir_block1, sizeof(ir_block1)-1, CWIID_RW_REG}, 46 {WRITE_SEQ_MEM, 0xB0001A, ir_block2, sizeof(ir_block2)-1, CWIID_RW_REG}, 47 {WRITE_SEQ_MEM, 0xB00033, (const void *)"\x01", 1, CWIID_RW_REG} 45 48 }; 46 49 … … 48 51 {WRITE_SEQ_RPT, RPT_IR_ENABLE1, (const void *)"\x04", 1, 0}, 49 52 {WRITE_SEQ_RPT, RPT_IR_ENABLE2, (const void *)"\x04", 1, 0}, 50 {WRITE_SEQ_MEM, 0xB00030, (const void *)"\x08", 1, WIIMOTE_RW_REG},51 {WRITE_SEQ_MEM, 0xB00000, ir_block1, sizeof(ir_block1)-1, WIIMOTE_RW_REG},52 {WRITE_SEQ_MEM, 0xB0001A, ir_block2, sizeof(ir_block2)-1, WIIMOTE_RW_REG},53 {WRITE_SEQ_MEM, 0xB00033, (const void *)"\x03", 1, WIIMOTE_RW_REG}53 {WRITE_SEQ_MEM, 0xB00030, (const void *)"\x08", 1, CWIID_RW_REG}, 54 {WRITE_SEQ_MEM, 0xB00000, ir_block1, sizeof(ir_block1)-1, CWIID_RW_REG}, 55 {WRITE_SEQ_MEM, 0xB0001A, ir_block2, sizeof(ir_block2)-1, CWIID_RW_REG}, 56 {WRITE_SEQ_MEM, 0xB00033, (const void *)"\x03", 1, CWIID_RW_REG} 54 57 }; 55 58 … … 60 63 61 64 #define CMD_BUF_LEN 21 62 int wiimote_command(struct wiimote *wiimote, enum wiimote_command command,63 uint8_t flags) {65 int cwiid_command(struct wiimote *wiimote, enum cwiid_command command, 66 uint8_t flags) { 64 67 int ret = 0; 65 68 unsigned char buf[CMD_BUF_LEN]; 66 69 67 70 switch (command) { 68 case WIIMOTE_CMD_STATUS:71 case CWIID_CMD_STATUS: 69 72 buf[0] = 0; 70 73 if (send_report(wiimote, 0, RPT_STATUS_REQ, 1, buf)) { 71 wiimote_err(wiimote, "Error requesting status");72 ret = -1; 73 } 74 break; 75 case WIIMOTE_CMD_LED:74 cwiid_err(wiimote, "Error requesting status"); 75 ret = -1; 76 } 77 break; 78 case CWIID_CMD_LED: 76 79 wiimote->led_rumble_state = ((flags & 0x0F)<<4) | 77 80 (wiimote->led_rumble_state & 0x01); 78 81 buf[0]=wiimote->led_rumble_state; 79 82 if (send_report(wiimote, SEND_RPT_NO_RUMBLE, RPT_LED_RUMBLE, 1, buf)) { 80 wiimote_err(wiimote, "Error setting LEDs");81 ret = -1; 82 } 83 break; 84 case WIIMOTE_CMD_RUMBLE:83 cwiid_err(wiimote, "Error setting LEDs"); 84 ret = -1; 85 } 86 break; 87 case CWIID_CMD_RUMBLE: 85 88 wiimote->led_rumble_state = (wiimote->led_rumble_state & 0xFE) | 86 89 (flags ? 1 : 0); 87 90 buf[0]=wiimote->led_rumble_state; 88 91 if (send_report(wiimote, SEND_RPT_NO_RUMBLE, RPT_LED_RUMBLE, 1, buf)) { 89 wiimote_err(wiimote, "Error setting rumble");90 ret = -1; 91 } 92 break; 93 case WIIMOTE_CMD_RPT_MODE:92 cwiid_err(wiimote, "Error setting rumble"); 93 ret = -1; 94 } 95 break; 96 case CWIID_CMD_RPT_MODE: 94 97 update_rpt_mode(wiimote, flags); 95 98 break; 96 99 default: 97 wiimote_err(wiimote, "Unknown command");100 cwiid_err(wiimote, "Unknown command"); 98 101 ret = -1; 99 102 break; … … 114 117 /* Lock wiimote access */ 115 118 if (pthread_mutex_lock(&wiimote->wiimote_mutex)) { 116 wiimote_err(wiimote, "Error locking rw_mutex");119 cwiid_err(wiimote, "Error locking wiimote_mutex"); 117 120 ret = -1; 118 121 goto CODA; … … 125 128 126 129 /* Pick a report mode based on report flags */ 127 if ((flags & WIIMOTE_RPT_EXT) &&128 ((wiimote->extension == WIIMOTE_EXT_NUNCHUK) ||129 (wiimote->extension == WIIMOTE_EXT_CLASSIC))) {130 if ((flags & WIIMOTE_RPT_IR) &&131 (flags & WIIMOTE_RPT_ACC)) {130 if ((flags & CWIID_RPT_EXT) && 131 ((wiimote->extension == CWIID_EXT_NUNCHUK) || 132 (wiimote->extension == CWIID_EXT_CLASSIC))) { 133 if ((flags & CWIID_RPT_IR) && 134 (flags & CWIID_RPT_ACC)) { 132 135 rpt_mode = RPT_BTN_ACC_IR10_EXT6; 133 136 ir_enable_seq = ir_enable10_seq; 134 137 seq_len = SEQ_LEN(ir_enable10_seq); 135 138 } 136 else if (flags & WIIMOTE_RPT_IR) {139 else if (flags & CWIID_RPT_IR) { 137 140 rpt_mode = RPT_BTN_IR10_EXT9; 138 141 ir_enable_seq = ir_enable10_seq; 139 142 seq_len = SEQ_LEN(ir_enable10_seq); 140 143 } 141 else if (flags & WIIMOTE_RPT_ACC) {144 else if (flags & CWIID_RPT_ACC) { 142 145 rpt_mode = RPT_BTN_ACC_EXT16; 143 146 } 144 else if (flags & WIIMOTE_RPT_BTN) {147 else if (flags & CWIID_RPT_BTN) { 145 148 rpt_mode = RPT_BTN_EXT8; 146 149 } … … 150 153 } 151 154 else { 152 if (flags & WIIMOTE_RPT_IR) {155 if (flags & CWIID_RPT_IR) { 153 156 rpt_mode = RPT_BTN_ACC_IR12; 154 157 ir_enable_seq = ir_enable12_seq; 155 158 seq_len = SEQ_LEN(ir_enable12_seq); 156 159 } 157 else if (flags & WIIMOTE_RPT_ACC) {160 else if (flags & CWIID_RPT_ACC) { 158 161 rpt_mode = RPT_BTN_ACC; 159 162 } … … 165 168 /* Enable IR */ 166 169 /* TODO: only do this when necessary (record old IR mode) */ 167 if ((flags & WIIMOTE_RPT_IR)) {170 if ((flags & CWIID_RPT_IR)) { 168 171 if (exec_write_seq(wiimote, seq_len, ir_enable_seq)) { 169 wiimote_err(wiimote, "Error on IR enable");172 cwiid_err(wiimote, "Error on IR enable"); 170 173 ret = -1; 171 174 goto CODA; … … 173 176 } 174 177 /* Disable IR */ 175 else if ((wiimote->rpt_mode_flags & WIIMOTE_RPT_IR) &176 !(flags & WIIMOTE_RPT_IR)) {178 else if ((wiimote->rpt_mode_flags & CWIID_RPT_IR) & 179 !(flags & CWIID_RPT_IR)) { 177 180 if (exec_write_seq(wiimote, SEQ_LEN(ir_disable_seq), 178 181 ir_disable_seq)) { 179 wiimote_err(wiimote, "Error on IR enable");182 cwiid_err(wiimote, "Error on IR enable"); 180 183 ret = -1; 181 184 goto CODA; … … 187 190 buf[1]=rpt_mode; 188 191 if (send_report(wiimote, 0, RPT_RPT_MODE, RPT_MODE_BUF_LEN, buf)) { 189 wiimote_err(wiimote, "Error setting report state");192 cwiid_err(wiimote, "Error setting report state"); 190 193 ret = -1; 191 194 goto CODA; … … 195 198 196 199 CODA: 197 /* Unlock wiimote_mutex */200 /* Unlock cwiid_mutex */ 198 201 if (pthread_mutex_unlock(&wiimote->wiimote_mutex)) { 199 wiimote_err(wiimote, 200 "Error unlocking wiimote_mutex: deadlock warning"); 202 cwiid_err(wiimote, "Error unlocking wiimote_mutex: deadlock warning"); 201 203 } 202 204 -
libcwiid/connect.c
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * cancel rw operations from wiimote_disconnect22 * * cancel rw operations from cwiid_disconnect 20 23 * 21 24 * 2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> 22 * * wiimote_connect now takes a pointer to bdaddr_t23 * * changed wiimote_findfirst to wiimote_find_wiimote25 * * cwiid_connect now takes a pointer to bdaddr_t 26 * * changed cwiid_findfirst to cwiid_find_wiimote 24 27 * 25 28 * 2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> … … 29 32 * 30 33 * 2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 31 * * added wiimote parameter to wiimote_err calls34 * * added wiimote parameter to cwiid_err calls 32 35 * 33 36 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 43 46 #include <bluetooth/bluetooth.h> 44 47 #include <bluetooth/l2cap.h> 45 #include " wiimote_internal.h"48 #include "cwiid_internal.h" 46 49 #include "queue.h" 47 50 … … 49 52 static int wiimote_id = 0; 50 53 51 wiimote_t *wiimote_connect(bdaddr_t *bdaddr,52 wiimote_mesg_callback_t *mesg_callback, int *id)54 cwiid_wiimote_t *cwiid_connect(bdaddr_t *bdaddr, 55 cwiid_mesg_callback_t *mesg_callback, int *id) 53 56 { 54 57 struct wiimote *wiimote = NULL; … … 57 60 /* Allocate wiimote */ 58 61 if ((wiimote = malloc(sizeof *wiimote)) == NULL) { 59 wiimote_err(NULL, "Error allocatingwiimote");62 cwiid_err(NULL, "Error allocating cwiid_wiimote"); 60 63 goto ERR_HND; 61 64 } … … 68 71 /* Global Lock, Store and Increment wiimote_id */ 69 72 if (pthread_mutex_lock(&global_mutex)) { 70 wiimote_err(NULL, "Error locking global lock");73 cwiid_err(NULL, "Error locking global lock"); 71 74 goto ERR_HND; 72 75 } 73 76 wiimote->id = wiimote_id++; 74 77 if (pthread_mutex_unlock(&global_mutex)) { 75 wiimote_err(wiimote, "Error unlocking global lock");78 cwiid_err(wiimote, "Error unlocking global lock"); 76 79 goto ERR_HND; 77 80 } … … 86 89 /* If BDADDR_ANY is given, find available wiimote */ 87 90 if (bacmp(bdaddr, BDADDR_ANY) == 0) { 88 if ( wiimote_find_wiimote(bdaddr, 2)) {91 if (cwiid_find_wiimote(bdaddr, 2)) { 89 92 goto ERR_HND; 90 93 } … … 105 108 if ((wiimote->ctl_socket = 106 109 socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1) { 107 wiimote_err(wiimote, "Error opening control socket");110 cwiid_err(wiimote, "Error opening control socket"); 108 111 goto ERR_HND; 109 112 } 110 113 if ((wiimote->int_socket = 111 114 socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1) { 112 wiimote_err(wiimote, "Error opening interrupt socket");115 cwiid_err(wiimote, "Error opening interrupt socket"); 113 116 goto ERR_HND; 114 117 } … … 117 120 if (connect(wiimote->ctl_socket, (struct sockaddr *)&ctl_remote_addr, 118 121 sizeof(ctl_remote_addr))) { 119 wiimote_err(wiimote, "Error opening control channel");122 cwiid_err(wiimote, "Error opening control channel"); 120 123 goto ERR_HND; 121 124 } 122 125 if (connect(wiimote->int_socket, (struct sockaddr *)&int_remote_addr, 123 126 sizeof(int_remote_addr))) { 124 wiimote_err(wiimote, "Error opening interrupt channel");127 cwiid_err(wiimote, "Error opening interrupt channel"); 125 128 goto ERR_HND; 126 129 } … … 128 131 /* Create Dispatch Queue */ 129 132 if ((wiimote->dispatch_queue = queue_new()) == NULL) { 130 wiimote_err(wiimote, "Error creating dispatch queue");133 cwiid_err(wiimote, "Error creating dispatch queue"); 131 134 goto ERR_HND; 132 135 } … … 138 141 pthread_cond_init(&wiimote->rw_cond, NULL) || 139 142 pthread_mutex_init(&wiimote->rw_cond_mutex, NULL)) { 140 wiimote_err(wiimote, 141 "Error initializing synchronization variables"); 143 cwiid_err(wiimote, "Error initializing synchronization variables"); 142 144 goto ERR_HND; 143 145 } … … 150 152 if (pthread_create(&wiimote->int_listen_thread, NULL, 151 153 (void *(*)(void *))&int_listen, wiimote)) { 152 wiimote_err(wiimote, 153 "Error creating interrupt channel listener thread"); 154 cwiid_err(wiimote, "Error creating interrupt channel listener thread"); 154 155 goto ERR_HND; 155 156 } … … 158 159 pthread_cancel(wiimote->int_listen_thread); 159 160 pthread_join(wiimote->int_listen_thread, NULL); 160 wiimote_err(wiimote, "Error creating dispatch thread");161 cwiid_err(wiimote, "Error creating dispatch thread"); 161 162 goto ERR_HND; 162 163 } … … 165 166 wiimote->buttons = 0; 166 167 wiimote->rpt_mode_flags = 0; 167 wiimote->extension = WIIMOTE_EXT_NONE;168 wiimote->extension = CWIID_EXT_NONE; 168 169 wiimote->led_rumble_state = 0; 169 wiimote_command(wiimote, WIIMOTE_CMD_LED, 0);170 wiimote_command(wiimote, WIIMOTE_CMD_STATUS, 0);170 cwiid_command(wiimote, CWIID_CMD_LED, 0); 171 cwiid_command(wiimote, CWIID_CMD_STATUS, 0); 171 172 172 173 return wiimote; … … 180 181 if (wiimote->int_socket != -1) { 181 182 if (close(wiimote->int_socket)) { 182 wiimote_err(wiimote, "Error closing interrupt channel");183 cwiid_err(wiimote, "Error closing interrupt channel"); 183 184 } 184 185 } 185 186 if (wiimote->ctl_socket != -1) { 186 187 if (close(wiimote->ctl_socket)) { 187 wiimote_err(wiimote, "Error closing control channel");188 cwiid_err(wiimote, "Error closing control channel"); 188 189 } 189 190 } … … 193 194 } 194 195 195 int wiimote_disconnect(struct wiimote *wiimote)196 int cwiid_disconnect(struct wiimote *wiimote) 196 197 { 197 198 void *pthread_ret; … … 200 201 if (pthread_cancel(wiimote->int_listen_thread)) { 201 202 /* int could exit on it's own, so we don't care */ 202 /* wiimote_err(wiimote, "Error canceling int_listen_thread"); */203 /* cwiid_err(wiimote, "Error canceling int_listen_thread"); */ 203 204 } 204 205 else { 205 206 if (pthread_join(wiimote->int_listen_thread, &pthread_ret)) { 206 wiimote_err(wiimote, "Error joining int_listen_thread");207 cwiid_err(wiimote, "Error joining int_listen_thread"); 207 208 } 208 209 else if (pthread_ret != PTHREAD_CANCELED) { 209 wiimote_err(wiimote, 210 "Invalid return value from int_listen_thread"); 210 cwiid_err(wiimote, "Invalid return value from int_listen_thread"); 211 211 } 212 212 } … … 215 215 wiimote->rw_error = 1; 216 216 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 217 wiimote_err(wiimote, "Error locking rw_cond_mutex: deadlock warning");217 cwiid_err(wiimote, "Error locking rw_cond_mutex: deadlock warning"); 218 218 } 219 219 else { 220 220 if (pthread_cond_signal(&wiimote->rw_cond)) { 221 wiimote_err(wiimote, "Error signaling rw_cond: deadlock warning");221 cwiid_err(wiimote, "Error signaling rw_cond: deadlock warning"); 222 222 } 223 223 if (pthread_mutex_unlock( 224 224 &wiimote->rw_cond_mutex)) { 225 wiimote_err(wiimote, "Error unlocking rw_cond_mutex");225 cwiid_err(wiimote, "Error unlocking rw_cond_mutex"); 226 226 } 227 227 } 228 228 229 229 /* Cancel and detach dispatch_thread */ 230 /* We detach to decouple dispatch (which runs the callback) from wiimote230 /* We detach to decouple dispatch (which runs the callback) from callback 231 231 * code - specifically, a race condition exists for gtk apps */ 232 232 if (pthread_cancel(wiimote->dispatch_thread)) { 233 wiimote_err(wiimote, "Error canceling dispatch_thread");233 cwiid_err(wiimote, "Error canceling dispatch_thread"); 234 234 } 235 235 if (pthread_detach(wiimote->dispatch_thread)) { 236 wiimote_err(wiimote, "Error detaching dispatch_thread");236 cwiid_err(wiimote, "Error detaching dispatch_thread"); 237 237 } 238 238 239 239 /* Close sockets */ 240 240 if (close(wiimote->int_socket)) { 241 wiimote_err(wiimote, "Error closing interrupt channel");241 cwiid_err(wiimote, "Error closing interrupt channel"); 242 242 } 243 243 if (close(wiimote->ctl_socket)) { 244 wiimote_err(wiimote, "Error closing control channel");244 cwiid_err(wiimote, "Error closing control channel"); 245 245 } 246 246 … … 251 251 /* Destroy sync variables */ 252 252 if (pthread_mutex_destroy(&wiimote->wiimote_mutex)) { 253 wiimote_err(wiimote, "Error destroying wiimote_mutex");253 cwiid_err(wiimote, "Error destroying cwiid_mutex"); 254 254 } 255 255 if (pthread_mutex_destroy(&wiimote->rw_mutex)) { 256 wiimote_err(wiimote, "Error destroying rw_mutex");256 cwiid_err(wiimote, "Error destroying rw_mutex"); 257 257 } 258 258 if (pthread_cond_destroy(&wiimote->rw_cond)) { 259 wiimote_err(wiimote, "Error destroying rw_cond");259 cwiid_err(wiimote, "Error destroying rw_cond"); 260 260 } 261 261 if (pthread_mutex_destroy(&wiimote->rw_cond_mutex)) { 262 wiimote_err(wiimote, "Error destroying rw_cond_mutex");262 cwiid_err(wiimote, "Error destroying rw_cond_mutex"); 263 263 } 264 264 -
libcwiid/cwiid_internal.h
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * moved RW error state to separate member 20 23 * 21 24 * 2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> 22 * * removed WIIMOTE_CMP_LEN macro and wiimote_findfirst prototype25 * * removed CWIID_CMP_LEN macro and cwiid_findfirst prototype 23 26 * 24 27 * 2007-03-05 L. Donnie Smith <cwiid@abstrakraft.org> 25 * * added wiimote parameter to wiimote_err prototype28 * * added wiimote parameter to cwiid_err prototype 26 29 * 27 30 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 30 33 */ 31 34 32 #ifndef WIIMOTE_INTERNAL_H33 #define WIIMOTE_INTERNAL_H35 #ifndef CWIID_INTERNAL_H 36 #define CWIID_INTERNAL_H 34 37 35 38 #include <stdint.h> 36 39 #include <pthread.h> 37 #include " wiimote.h"40 #include "cwiid.h" 38 41 39 42 /* Bluetooth magic numbers */ … … 140 143 struct mesg_array { 141 144 int count; 142 union wiimote_mesg *mesg[WIIMOTE_MAX_MESG_COUNT];145 union cwiid_mesg *mesg[CWIID_MAX_MESG_COUNT]; 143 146 }; 144 147 … … 150 153 uint8_t rpt_mode_flags; 151 154 uint16_t buttons; 152 enum wiimote_ext_type extension;153 wiimote_mesg_callback_t *mesg_callback;155 enum cwiid_ext_type extension; 156 cwiid_mesg_callback_t *mesg_callback; 154 157 pthread_t int_listen_thread; 155 158 pthread_t dispatch_thread; … … 172 175 int update_rpt_mode(struct wiimote *wiimote, int8_t flags); 173 176 174 void wiimote_err(struct wiimote *wiimote, const char *str, ...);177 void cwiid_err(struct wiimote *wiimote, const char *str, ...); 175 178 int verify_handshake(struct wiimote *wiimote); 176 179 int send_report(struct wiimote *wiimote, uint8_t flags, uint8_t report, -
libcwiid/event.c
r2547e8f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * fixed incompatible pointer warning in process_error … … 33 36 * 34 37 * 2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 35 * * added wiimote parameter to wiimote_err calls38 * * added wiimote parameter to cwiid_err calls 36 39 * 37 40 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 63 66 * GTK continues to provide an ample testbed for deadlocks. In order to 64 67 * completely isolate the rest of the library from the dispatch thread, 65 * wiimote_disconnect detaches the dispatch thread rather than joins it.66 * To maintain isolation, it is impossible to synchronize wiimote_disconnect68 * cwiid_disconnect detaches the dispatch thread rather than joins it. 69 * To maintain isolation, it is impossible to synchronize cwiid_disconnect 67 70 * and the dispatch thread, so dispatch destroys it's own synchronization 68 * variables. In order to be sure this doesn't happen after wiimote_disconnect71 * variables. In order to be sure this doesn't happen after cwiid_disconnect 69 72 * has freed the memory allocated for those variables, the wiimote struct holds 70 73 * pointers to variables, which dispatch copies on entry. As the complexity … … 105 108 #include <pthread.h> 106 109 #include <unistd.h> 107 #include " wiimote_internal.h"110 #include "cwiid_internal.h" 108 111 #include "queue.h" 109 112 110 113 /* process_* messages (except read and write ) allocate and fill in 111 * wiimote_*_mesg structs from raw wiimote data. Messages are then114 * cwiid_*_mesg structs from raw wiimote data. Messages are then 112 115 * placed at the end of mesg_array. */ 113 116 … … 127 130 128 131 /* process_read and process_write handle copying data between wiimote buffers 129 * and r/w buffers, as well as communication between wiimote_read or130 * wiimote_write */132 * and r/w buffers, as well as communication between cwiid_read or 133 * cwiid_write */ 131 134 static int process_read(struct wiimote *, unsigned char *); 132 135 static int process_write(struct wiimote *); … … 151 154 /* Verify first byte (DATA/INPUT) */ 152 155 if (buf[0] != (BT_TRANS_DATA | BT_PARAM_INPUT)) { 153 wiimote_err(wiimote, "Invalid packet type");156 cwiid_err(wiimote, "Invalid packet type"); 154 157 } 155 158 … … 167 170 case RPT_EXT21: 168 171 if ((mesg_array = malloc(sizeof *mesg_array)) == NULL) { 169 wiimote_err(wiimote, "Error allocating mesg array");172 cwiid_err(wiimote, "Error allocating mesg array"); 170 173 break; 171 174 } … … 243 246 if (queue_queue(wiimote->dispatch_queue, mesg_array)) { 244 247 free_mesg_array(mesg_array); 245 wiimote_err(wiimote, "error dispatching mesg array");248 cwiid_err(wiimote, "error dispatching mesg array"); 246 249 } 247 250 } … … 249 252 case RPT_BTN_ACC_IR36_1: 250 253 case RPT_BTN_ACC_IR36_2: 251 wiimote_err(wiimote, "Unsupported report type received "252 "(interleaved data)");254 cwiid_err(wiimote, "Unsupported report type received " 255 "(interleaved data)"); 253 256 break; 254 257 case RPT_READ_DATA: … … 260 263 break; 261 264 default: 262 wiimote_err(wiimote, "Unknown message type");265 cwiid_err(wiimote, "Unknown message type"); 263 266 break; 264 267 } … … 272 275 { 273 276 struct mesg_array *mesg_array; 274 struct wiimote_error_mesg *error_mesg;277 struct cwiid_error_mesg *error_mesg; 275 278 int ret = 0; 276 279 277 280 /* Error message */ 278 281 if (len == 0) { 279 wiimote_err(wiimote, "Disconnect");282 cwiid_err(wiimote, "Disconnect"); 280 283 } 281 284 else { 282 wiimote_err(wiimote, "Interrupt channel read error");285 cwiid_err(wiimote, "Interrupt channel read error"); 283 286 } 284 287 285 288 if ((mesg_array = malloc(sizeof *mesg_array)) == NULL) { 286 wiimote_err(wiimote, "Error allocating mesg array");289 cwiid_err(wiimote, "Error allocating mesg array"); 287 290 ret = -1; 288 291 goto SKIP_QUEUE_MESG; … … 290 293 mesg_array->count = 1; 291 294 if ((error_mesg = malloc(sizeof *error_mesg)) == NULL) { 292 wiimote_err(wiimote, "Error allocating error message");295 cwiid_err(wiimote, "Error allocating error message"); 293 296 ret = -1; 294 297 goto SKIP_QUEUE_MESG; 295 298 } 296 error_mesg->type = WIIMOTE_MESG_ERROR;299 error_mesg->type = CWIID_MESG_ERROR; 297 300 if (len == 0) { 298 error_mesg->error = WIIMOTE_ERROR_DISCONNECT;301 error_mesg->error = CWIID_ERROR_DISCONNECT; 299 302 } 300 303 else { 301 error_mesg->error = WIIMOTE_ERROR_COMM;302 } 303 mesg_array->mesg[0] = (union wiimote_mesg *)error_mesg;304 error_mesg->error = CWIID_ERROR_COMM; 305 } 306 mesg_array->mesg[0] = (union cwiid_mesg *)error_mesg; 304 307 if (queue_flush(wiimote->dispatch_queue, (free_func_t *)free_mesg_array)) { 305 wiimote_err(wiimote, "error flushing dispatch queue");308 cwiid_err(wiimote, "error flushing dispatch queue"); 306 309 ret = -1; 307 310 } 308 311 if (queue_queue(wiimote->dispatch_queue, mesg_array)) { 309 312 free_mesg_array(mesg_array); 310 wiimote_err(wiimote, "error dispatching mesg array");313 cwiid_err(wiimote, "error dispatching mesg array"); 311 314 ret = -1; 312 315 } … … 317 320 wiimote->rw_error = 1; 318 321 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 319 wiimote_err(wiimote, "Error locking rw_cond_mutex: deadlock warning");322 cwiid_err(wiimote, "Error locking rw_cond_mutex: deadlock warning"); 320 323 ret = -1; 321 324 } 322 325 else { 323 326 if (pthread_cond_signal(&wiimote->rw_cond)) { 324 wiimote_err(wiimote, "Error signaling rw_cond: deadlock warning");327 cwiid_err(wiimote, "Error signaling rw_cond: deadlock warning"); 325 328 ret = -1; 326 329 } 327 330 if (pthread_mutex_unlock( 328 331 &wiimote->rw_cond_mutex)) { 329 wiimote_err(wiimote, "Error unlocking rw_cond_mutex: "330 "deadlock warning");332 cwiid_err(wiimote, "Error unlocking rw_cond_mutex: " 333 "deadlock warning"); 331 334 ret = -1; 332 335 } … … 339 342 struct mesg_array *mesg_array) 340 343 { 341 struct wiimote_status_mesg *mesg;344 struct cwiid_status_mesg *mesg; 342 345 343 346 if ((mesg = malloc(sizeof *mesg)) == NULL) { 344 wiimote_err(wiimote, "Error allocating status mesg");347 cwiid_err(wiimote, "Error allocating status mesg"); 345 348 return -1; 346 349 } 347 350 348 mesg->type = WIIMOTE_MESG_STATUS;351 mesg->type = CWIID_MESG_STATUS; 349 352 mesg->battery = data[5]; 350 353 if (data[2] & 0x02) { 351 354 /* dispatch will figure out what it is */ 352 mesg->extension = WIIMOTE_EXT_UNKNOWN;355 mesg->extension = CWIID_EXT_UNKNOWN; 353 356 } 354 357 else { 355 mesg->extension = WIIMOTE_EXT_NONE;356 } 357 358 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg;358 mesg->extension = CWIID_EXT_NONE; 359 } 360 361 mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 359 362 mesg_array->count++; 360 363 … … 365 368 struct mesg_array *mesg_array) 366 369 { 367 struct wiimote_btn_mesg *mesg;370 struct cwiid_btn_mesg *mesg; 368 371 uint16_t buttons; 369 372 … … 373 376 wiimote->buttons = buttons; 374 377 375 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_BTN) {378 if (wiimote->rpt_mode_flags & CWIID_RPT_BTN) { 376 379 if ((mesg = malloc(sizeof *mesg)) == NULL) { 377 wiimote_err(wiimote, "Error allocating btn mesg");380 cwiid_err(wiimote, "Error allocating btn mesg"); 378 381 return -1; 379 382 } 380 mesg->type = WIIMOTE_MESG_BTN;383 mesg->type = CWIID_MESG_BTN; 381 384 mesg->buttons = buttons; 382 385 383 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg;386 mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 384 387 mesg_array->count++; 385 388 } … … 392 395 struct mesg_array *mesg_array) 393 396 { 394 struct wiimote_acc_mesg *mesg;395 396 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_ACC) {397 struct cwiid_acc_mesg *mesg; 398 399 if (wiimote->rpt_mode_flags & CWIID_RPT_ACC) { 397 400 if ((mesg = malloc(sizeof *mesg)) == NULL) { 398 wiimote_err(wiimote, "Error allocating acc mesg");401 cwiid_err(wiimote, "Error allocating acc mesg"); 399 402 return -1; 400 403 } 401 mesg->type = WIIMOTE_MESG_ACC;404 mesg->type = CWIID_MESG_ACC; 402 405 mesg->x = data[0]; 403 406 mesg->y = data[1]; 404 407 mesg->z = data[2]; 405 408 406 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg;409 mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 407 410 mesg_array->count++; 408 411 } … … 414 417 struct mesg_array *mesg_array) 415 418 { 416 struct wiimote_ir_mesg *mesg;419 struct cwiid_ir_mesg *mesg; 417 420 int i; 418 421 const unsigned char *block; 419 422 420 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_IR) {423 if (wiimote->rpt_mode_flags & CWIID_RPT_IR) { 421 424 if ((mesg = malloc(sizeof *mesg)) == NULL) { 422 wiimote_err(wiimote, "Error allocating ir mesg");425 cwiid_err(wiimote, "Error allocating ir mesg"); 423 426 return -1; 424 427 } 425 mesg->type = WIIMOTE_MESG_IR;426 427 for (i=0, block=data; i < WIIMOTE_IR_SRC_COUNT; i+=2, block+=5) {428 mesg->type = CWIID_MESG_IR; 429 430 for (i=0, block=data; i < CWIID_IR_SRC_COUNT; i+=2, block+=5) { 428 431 if (block[0] == 0xFF) { 429 432 mesg->src[i].valid = 0; … … 451 454 } 452 455 453 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg;456 mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 454 457 mesg_array->count++; 455 458 } … … 461 464 struct mesg_array *mesg_array) 462 465 { 463 struct wiimote_ir_mesg *mesg;466 struct cwiid_ir_mesg *mesg; 464 467 int i; 465 468 const unsigned char *block; 466 469 467 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_IR) {470 if (wiimote->rpt_mode_flags & CWIID_RPT_IR) { 468 471 if ((mesg = malloc(sizeof *mesg)) == NULL) { 469 wiimote_err(wiimote, "Error allocating ir mesg");472 cwiid_err(wiimote, "Error allocating ir mesg"); 470 473 return -1; 471 474 } 472 mesg->type = WIIMOTE_MESG_IR;473 474 for (i=0, block=data; i < WIIMOTE_IR_SRC_COUNT; i++, block+=3) {475 mesg->type = CWIID_MESG_IR; 476 477 for (i=0, block=data; i < CWIID_IR_SRC_COUNT; i++, block+=3) { 475 478 if (block[0] == 0xFF) { 476 479 mesg->src[i].valid = 0; … … 486 489 } 487 490 488 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg;491 mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 489 492 mesg_array->count++; 490 493 } … … 496 499 unsigned char len, struct mesg_array *mesg_array) 497 500 { 498 struct wiimote_nunchuk_mesg *nunchuk_mesg;499 struct wiimote_classic_mesg *classic_mesg;501 struct cwiid_nunchuk_mesg *nunchuk_mesg; 502 struct cwiid_classic_mesg *classic_mesg; 500 503 int i; 501 504 502 505 switch (wiimote->extension) { 503 case WIIMOTE_EXT_NONE:504 wiimote_err(wiimote,505 "Extension report received with no extension present");506 case CWIID_EXT_NONE: 507 cwiid_err(wiimote, 508 "Extension report received with no extension present"); 506 509 break; 507 case WIIMOTE_EXT_UNKNOWN:510 case CWIID_EXT_UNKNOWN: 508 511 break; 509 case WIIMOTE_EXT_NUNCHUK:510 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_NUNCHUK) {512 case CWIID_EXT_NUNCHUK: 513 if (wiimote->rpt_mode_flags & CWIID_RPT_NUNCHUK) { 511 514 if ((nunchuk_mesg = malloc(sizeof *nunchuk_mesg)) == NULL) { 512 wiimote_err(wiimote, "Error allocating nunchuk mesg");515 cwiid_err(wiimote, "Error allocating nunchuk mesg"); 513 516 return -1; 514 517 } 515 518 516 nunchuk_mesg->type = WIIMOTE_MESG_NUNCHUK;519 nunchuk_mesg->type = CWIID_MESG_NUNCHUK; 517 520 nunchuk_mesg->stick_x = DECODE(data[0]); 518 521 nunchuk_mesg->stick_y = DECODE(data[1]); … … 523 526 524 527 mesg_array->mesg[mesg_array->count] = 525 (union wiimote_mesg *)nunchuk_mesg;528 (union cwiid_mesg *)nunchuk_mesg; 526 529 mesg_array->count++; 527 530 } 528 531 break; 529 case WIIMOTE_EXT_CLASSIC:530 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_CLASSIC) {532 case CWIID_EXT_CLASSIC: 533 if (wiimote->rpt_mode_flags & CWIID_RPT_CLASSIC) { 531 534 if ((classic_mesg = malloc(sizeof *classic_mesg)) == NULL) { 532 wiimote_err(wiimote, "Error allocating classic mesg");535 cwiid_err(wiimote, "Error allocating classic mesg"); 533 536 return -1; 534 537 } … … 538 541 } 539 542 540 classic_mesg->type = WIIMOTE_MESG_CLASSIC;543 classic_mesg->type = CWIID_MESG_CLASSIC; 541 544 classic_mesg->l_stick_x = data[0] & 0x3F; 542 545 classic_mesg->l_stick_y = data[1] & 0x3F; … … 552 555 553 556 mesg_array->mesg[mesg_array->count] = 554 (union wiimote_mesg *)classic_mesg;557 (union cwiid_mesg *)classic_mesg; 555 558 mesg_array->count++; 556 559 } … … 574 577 if (((data_len + wiimote->read_received) > wiimote->read_len) || 575 578 error) { 576 wiimote_err(wiimote, "Error in read data");579 cwiid_err(wiimote, "Error in read data"); 577 580 wiimote->rw_error = 1; 578 581 wiimote->rw_status = RW_NONE; … … 593 596 * rw_cond_mutex */ 594 597 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 595 wiimote_err(wiimote, "Error locking rw_cond_mutex: "596 "deadlock warning");598 cwiid_err(wiimote, "Error locking rw_cond_mutex: " 599 "deadlock warning"); 597 600 wiimote->rw_error = 1; 598 601 ret = -1; … … 600 603 else { 601 604 if (pthread_cond_signal(&wiimote->rw_cond)) { 602 wiimote_err(wiimote, "Error signaling rw_cond: "603 "deadlock warning");605 cwiid_err(wiimote, "Error signaling rw_cond: " 606 "deadlock warning"); 604 607 wiimote->rw_error = 1; 605 608 ret = -1; … … 607 610 if (pthread_mutex_unlock( 608 611 &wiimote->rw_cond_mutex)) { 609 wiimote_err(wiimote, "Error unlocking rw_cond_mutex: "610 "deadlock warning");612 cwiid_err(wiimote, "Error unlocking rw_cond_mutex: " 613 "deadlock warning"); 611 614 wiimote->rw_error = 1; 612 615 ret = -1; … … 616 619 } 617 620 else { 618 wiimote_err(wiimote, "Extraneous read data received");621 cwiid_err(wiimote, "Extraneous read data received"); 619 622 ret = -1; 620 623 } … … 632 635 * write_cond_mutex */ 633 636 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 634 wiimote_err(wiimote, "Error locking rw_cond_mutex: "635 "deadlock warning");637 cwiid_err(wiimote, "Error locking rw_cond_mutex: " 638 "deadlock warning"); 636 639 wiimote->rw_error = 1; 637 640 ret = -1; … … 639 642 else { 640 643 if (pthread_cond_signal(&wiimote->rw_cond)) { 641 wiimote_err(wiimote, "Error signaling rw_cond: "642 "deadlock warning");644 cwiid_err(wiimote, "Error signaling rw_cond: " 645 "deadlock warning"); 643 646 wiimote->rw_error = 1; 644 647 ret = -1; 645 648 } 646 649 if (pthread_mutex_unlock(&wiimote->rw_cond_mutex)) { 647 wiimote_err(wiimote, "Error unlocking rw_cond_mutex: "648 "deadlock warning");650 cwiid_err(wiimote, "Error unlocking rw_cond_mutex: " 651 "deadlock warning"); 649 652 wiimote->rw_error = 1; 650 653 ret = -1; … … 653 656 } 654 657 else { 655 wiimote_err(wiimote, "Extraneous write ack received");658 cwiid_err(wiimote, "Extraneous write ack received"); 656 659 ret = -1; 657 660 } … … 665 668 if (queue_free(queue, (free_func_t *)free_mesg_array)) { 666 669 /* TODO: return proper wiimote ptr */ 667 wiimote_err(NULL, "Error freeing dispatch queue");670 cwiid_err(NULL, "Error freeing dispatch queue"); 668 671 } 669 672 } … … 674 677 struct queue *dispatch_queue = wiimote->dispatch_queue; 675 678 struct mesg_array *mesg_array; 676 union wiimote_mesg *mesg;679 union cwiid_mesg *mesg; 677 680 unsigned char buf; 678 681 … … 681 684 do { 682 685 if (queue_wait(dispatch_queue)) { 683 wiimote_err(wiimote, "Error waiting on dispatch_queue");686 cwiid_err(wiimote, "Error waiting on dispatch_queue"); 684 687 return NULL; 685 688 } … … 691 694 /* Disable cancelling while in callback */ 692 695 if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancelstate)) { 693 wiimote_err(wiimote, "Error disabling cancel state");696 cwiid_err(wiimote, "Error disabling cancel state"); 694 697 } 695 698 else { … … 698 701 * only messages in the array */ 699 702 mesg = mesg_array->mesg[0]; 700 if (mesg->type == WIIMOTE_MESG_STATUS) {701 if ((mesg->status_mesg.extension == WIIMOTE_EXT_UNKNOWN) &&702 (wiimote->extension == WIIMOTE_EXT_NONE)) {703 if (mesg->type == CWIID_MESG_STATUS) { 704 if ((mesg->status_mesg.extension == CWIID_EXT_UNKNOWN) && 705 (wiimote->extension == CWIID_EXT_NONE)) { 703 706 buf = 0x00; 704 707 /* Initialize extension register space */ 705 if ( wiimote_write(wiimote, WIIMOTE_RW_REG, 0xA40040, 1,708 if (cwiid_write(wiimote, CWIID_RW_REG, 0xA40040, 1, 706 709 &buf)) { 707 wiimote_err(wiimote, 708 "Error initializing extension"); 709 wiimote->extension = WIIMOTE_EXT_UNKNOWN; 710 cwiid_err(wiimote, "Error initializing extension"); 711 wiimote->extension = CWIID_EXT_UNKNOWN; 710 712 } 711 713 /* Read extension ID */ 712 else if ( wiimote_read(wiimote,713 WIIMOTE_RW_REG | WIIMOTE_RW_DECODE, 0xA400FE,714 else if (cwiid_read(wiimote, 715 CWIID_RW_REG | CWIID_RW_DECODE, 0xA400FE, 714 716 1, &buf)) { 715 wiimote_err(wiimote, 716 "Error reading extension type"); 717 wiimote->extension = WIIMOTE_EXT_UNKNOWN; 717 cwiid_err(wiimote, "Error reading extension type"); 718 wiimote->extension = CWIID_EXT_UNKNOWN; 718 719 } 719 720 else { … … 721 722 case EXT_NONE: 722 723 case EXT_PARTIAL: 723 wiimote->extension = WIIMOTE_EXT_NONE;724 wiimote->extension = CWIID_EXT_NONE; 724 725 break; 725 726 case EXT_NUNCHUK: 726 wiimote->extension = WIIMOTE_EXT_NUNCHUK;727 wiimote->extension = CWIID_EXT_NUNCHUK; 727 728 break; 728 729 case EXT_CLASSIC: 729 wiimote->extension = WIIMOTE_EXT_CLASSIC;730 wiimote->extension = CWIID_EXT_CLASSIC; 730 731 break; 731 732 default: 732 wiimote->extension = WIIMOTE_EXT_UNKNOWN;733 wiimote->extension = CWIID_EXT_UNKNOWN; 733 734 break; 734 735 } 735 736 } 736 737 } 737 else if (mesg->status_mesg.extension == WIIMOTE_EXT_NONE) {738 wiimote->extension = WIIMOTE_EXT_NONE;738 else if (mesg->status_mesg.extension == CWIID_EXT_NONE) { 739 wiimote->extension = CWIID_EXT_NONE; 739 740 } 740 741 741 742 if (update_rpt_mode(wiimote, -1)) { 742 wiimote_err(wiimote, "Error reseting report mode");743 cwiid_err(wiimote, "Error reseting report mode"); 743 744 } 744 745 745 746 /* Invoke Callback (for Status Messages) */ 746 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_STATUS) {747 if (wiimote->rpt_mode_flags & CWIID_RPT_STATUS) { 747 748 mesg->status_mesg.extension = wiimote->extension; 748 749 if (wiimote->mesg_callback) { … … 762 763 /* Reenable Thread Cancel */ 763 764 if (pthread_setcancelstate(cancelstate, &cancelstate)) { 764 wiimote_err(wiimote, "Error enabling cancel state");765 cwiid_err(wiimote, "Error enabling cancel state"); 765 766 } 766 767 } … … 770 771 771 772 /* This code should never execute */ 772 wiimote_err(wiimote, "Exiting dispatch thread");773 cwiid_err(wiimote, "Exiting dispatch thread"); 773 774 774 775 /* Just in case, free the dispatch queue */ -
libcwiid/queue.h
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-04 L. Donnie Smith >cwiid@abstrakraft.org>18 * 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 19 19 * * Added queue_flush prototype 20 20 * -
libcwiid/rw.c
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated wiimote_read and wiimote_write to trigger and detect rw_error22 * * updated cwiid_read and cwiid_write to trigger and detect rw_error 20 23 * 21 24 * 2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> 22 * * wiimote_read - changed to obey decode flag only for register read25 * * cwiid_read - changed to obey decode flag only for register read 23 26 * 24 27 * 2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 25 * * added wiimote parameter to wiimote_err calls28 * * added wiimote parameter to cwiid_err calls 26 29 * 27 30 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 34 37 #include <pthread.h> 35 38 #include <unistd.h> 36 #include " wiimote_internal.h"39 #include "cwiid_internal.h" 37 40 38 41 struct write_seq speaker_enable_seq[] = { 39 42 {WRITE_SEQ_RPT, RPT_SPEAKER_ENABLE, (const void *)"\x04", 1, 0}, 40 43 {WRITE_SEQ_RPT, RPT_SPEAKER_MUTE, (const void *)"\x04", 1, 0}, 41 {WRITE_SEQ_MEM, 0xA20009, (const void *)"\x01", 1, WIIMOTE_RW_REG},42 {WRITE_SEQ_MEM, 0xA20001, (const void *)"\x08", 1, WIIMOTE_RW_REG},44 {WRITE_SEQ_MEM, 0xA20009, (const void *)"\x01", 1, CWIID_RW_REG}, 45 {WRITE_SEQ_MEM, 0xA20001, (const void *)"\x08", 1, CWIID_RW_REG}, 43 46 {WRITE_SEQ_MEM, 0xA20001, (const void *)"\x00\x00\x00\x0C\x40\x00\x00", 44 7, WIIMOTE_RW_REG},45 {WRITE_SEQ_MEM, 0xA20008, (const void *)"\x01", 1, WIIMOTE_RW_REG},47 7, CWIID_RW_REG}, 48 {WRITE_SEQ_MEM, 0xA20008, (const void *)"\x01", 1, CWIID_RW_REG}, 46 49 {WRITE_SEQ_RPT, RPT_SPEAKER_MUTE, (const void *)"\x00", 1, 0} 47 50 }; … … 54 57 55 58 #define RPT_READ_REQ_LEN 6 56 int wiimote_read(struct wiimote *wiimote, uint8_t flags, uint32_t offset,59 int cwiid_read(struct wiimote *wiimote, uint8_t flags, uint32_t offset, 57 60 uint16_t len, void *data) 58 61 { … … 70 73 71 74 /* Compose read request packet */ 72 buf[0]=flags & ( WIIMOTE_RW_EEPROM | WIIMOTE_RW_REG);75 buf[0]=flags & (CWIID_RW_EEPROM | CWIID_RW_REG); 73 76 buf[1]=(unsigned char)((offset>>16) & 0xFF); 74 77 buf[2]=(unsigned char)((offset>>8) & 0xFF); … … 80 83 /* Lock wiimote rw access */ 81 84 if (pthread_mutex_lock(&wiimote->rw_mutex)) { 82 wiimote_err(wiimote, "Error locking rw_mutex");85 cwiid_err(wiimote, "Error locking rw_mutex"); 83 86 return -1; 84 87 } … … 98 101 /* Send read request packet */ 99 102 if (send_report(wiimote, 0, RPT_READ_REQ, RPT_READ_REQ_LEN, buf)) { 100 wiimote_err(wiimote, "Error sending read request");103 cwiid_err(wiimote, "Error sending read request"); 101 104 ret = -1; 102 105 goto CODA; … … 105 108 /* Lock rw_cond_mutex */ 106 109 if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 107 wiimote_err(wiimote, "Error locking rw_cond_mutex");110 cwiid_err(wiimote, "Error locking rw_cond_mutex"); 108 111 ret = -1; 109 112 goto CODA; … … 113 116 if (pthread_cond_wait(&wiimote->rw_cond, 114 117 &wiimote->rw_cond_mutex)) { 115 wiimote_err(wiimote, "Error waiting on rw_cond");118 cwiid_err(wiimote, "Error waiting on rw_cond"); 116 119 ret = -1; 117 120 /* can't goto CODA from here - unlock rw_cond_mutex first */ … … 120 123 /* Unlock rw_cond_mutex */ 121 124 if (pthread_mutex_unlock(&wiimote->rw_cond_mutex)) { 122 wiimote_err(wiimote, "Error unlocking rw_cond_mutex");125 cwiid_err(wiimote, "Error unlocking rw_cond_mutex"); 123 126 wiimote->rw_error = 1; 124 127 ret = -1; … … 137 140 /* Unlock rw_mutex */ 138 141 if (pthread_mutex_unlock(&wiimote->rw_mutex)) { 139 wiimote_err(wiimote, "Error unlocking rw_mutex: deadlock warning");142 cwiid_err(wiimote, "Error unlocking rw_mutex: deadlock warning"); 140 143 wiimote->rw_error = 1; 141 144 } 142 145 143 146 /* Decode (only for register reads) */ 144 if ((ret == 0) && (flags & WIIMOTE_RW_DECODE) &&145 (flags & WIIMOTE_RW_REG)) {147 if ((ret == 0) && (flags & CWIID_RW_DECODE) && 148 (flags & CWIID_RW_REG)) { 146 149 for (i=0; i < len; i++) { 147 150 ((unsigned char *)data)[i] = DECODE(((unsigned char *)data)[i]); … … 153 156 154 157 #define RPT_WRITE_LEN 21 155 int wiimote_write(struct wiimote *wiimote, uint8_t flags, uint32_t offset,158 int cwiid_write(struct wiimote *wiimote, uint8_t flags, uint32_t offset, 156 159 uint16_t len, const void *data) 157 160 { … … 173 176 /* Lock wiimote rw access */ 174 177 if (pthread_mutex_lock(&wiimote->rw_mutex)) { 175 wiimote_err(wiimote, "Error locking rw_mutex");178 cwiid_err(wiimote, "Error locking rw_mutex"); 176 179 return -1; 177 180 } … … 195 198 196 199 if (send_report(wiimote, 0, RPT_WRITE, RPT_WRITE_LEN, buf)) { 197 wiimote_err(wiimote, "Error sending write");200 cwiid_err(wiimote, "Error sending write"); 198 201 ret = -1; 199 202 goto CODA; … … 201 204 /* Lock rw_cond_mutex */ 202 205 else if (pthread_mutex_lock(&wiimote->rw_cond_mutex)) { 203 wiimote_err(wiimote, "Error locking rw_cond_mutex");206 cwiid_err(wiimote, "Error locking rw_cond_mutex"); 204 207 ret = -1; 205 208 goto CODA; 206 209 } 207 210 else { 208 /* Wait on condition, signalled by wiimote_int_listen */211 /* Wait on condition, signalled by cwiid_int_listen */ 209 212 while (!wiimote->rw_error && !ret && 210 213 (wiimote->rw_status == RW_PENDING)) { 211 214 if (pthread_cond_wait(&wiimote->rw_cond, 212 215 &wiimote->rw_cond_mutex)) { 213 wiimote_err(wiimote, "Error waiting on rw_cond");216 cwiid_err(wiimote, "Error waiting on rw_cond"); 214 217 ret = -1; 215 218 /* can't goto CODA from here - … … 219 222 /* Unlock rw_cond_mutex */ 220 223 if (pthread_mutex_unlock(&wiimote->rw_cond_mutex)) { 221 wiimote_err(wiimote, "Error unlocking rw_cond_mutex");224 cwiid_err(wiimote, "Error unlocking rw_cond_mutex"); 222 225 wiimote->rw_error = 1; 223 226 ret = -1; … … 245 248 /* Unlock rw_mutex */ 246 249 if (pthread_mutex_unlock(&wiimote->rw_mutex)) { 247 wiimote_err(wiimote, "Error unlocking rw_mutex: deadlock warning");250 cwiid_err(wiimote, "Error unlocking rw_mutex: deadlock warning"); 248 251 wiimote->rw_error = 1; 249 252 } … … 253 256 254 257 #define SOUND_BUF_LEN 21 255 int wiimote_beep(wiimote_t *wiimote)258 int cwiid_beep(cwiid_wiimote_t *wiimote) 256 259 { 257 260 /* unsigned char buf[SOUND_BUF_LEN] = { 0xA0, 0xCC, 0x33, 0xCC, 0x33, … … 269 272 if (exec_write_seq(wiimote, SEQ_LEN(speaker_enable_seq), 270 273 speaker_enable_seq)) { 271 wiimote_err(wiimote, "Error on speaker enable");274 cwiid_err(wiimote, "Error on speaker enable"); 272 275 ret = -1; 273 276 } … … 281 284 if (send_report(wiimote, 0, RPT_SPEAKER_DATA, SOUND_BUF_LEN, buf)) { 282 285 printf("%d\n", i); 283 wiimote_err(wiimote, "Error on speaker data");286 cwiid_err(wiimote, "Error on speaker data"); 284 287 ret = -1; 285 288 break; … … 294 297 if (exec_write_seq(wiimote, SEQ_LEN(speaker_disable_seq), 295 298 speaker_disable_seq)) { 296 wiimote_err(wiimote, "Error on speaker disable");299 cwiid_err(wiimote, "Error on speaker disable"); 297 300 ret = -1; 298 301 } -
libcwiid/util.c
r2547e8f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * renamed wiimote to libcwiid, renamed structures accordingly 20 * 18 21 * 2007-04-08 Petter Reinholdtsen <pere@hungry.com> 19 22 * * fixed signed/unsigned comparison warning in send_report and … … 21 24 * 22 25 * 2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> 23 * * removed wiimote_findfirst (moved to bluetooth.c)26 * * removed cwiid_findfirst (moved to bluetooth.c) 24 27 * 25 28 * 2007-03-27 L. Donnie Smith <cwiid@abstrakraft.org> 26 * * moved wiimote_findfirst to bluetooth.c29 * * moved cwiid_findfirst to bluetooth.c 27 30 * 28 31 * 2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> … … 30 33 * 31 34 * 2007-03-05 L. Donnie Smith <cwiid@abstrakraft.org> 32 * * created wiimote_err_func variable33 * * created wiimote_err_default34 * * added wiimote parameter to wiimote_err definition and calls35 * * created cwiid_err_func variable 36 * * created cwiid_err_default 37 * * added wiimote parameter to cwiid_err definition and calls 35 38 * 36 39 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 45 48 #include <string.h> 46 49 #include <unistd.h> 47 #include " wiimote_internal.h"50 #include "cwiid_internal.h" 48 51 49 static wiimote_err_t wiimote_err_default;52 static cwiid_err_t cwiid_err_default; 50 53 51 static wiimote_err_t *wiimote_err_func = &wiimote_err_default;54 static cwiid_err_t *cwiid_err_func = &cwiid_err_default; 52 55 53 int wiimote_set_err(wiimote_err_t *err)56 int cwiid_set_err(cwiid_err_t *err) 54 57 { 55 58 /* TODO: assuming pointer assignment is atomic operation */ 56 59 /* if it is, and the user doesn't care about race conditions, we don't 57 60 * either */ 58 wiimote_err_func = err;61 cwiid_err_func = err; 59 62 return 0; 60 63 } 61 64 62 static void wiimote_err_default(int id, const char *str, ...)65 static void cwiid_err_default(int id, const char *str, ...) 63 66 { 64 67 va_list ap; … … 70 73 } 71 74 72 void wiimote_err(struct wiimote *wiimote, const char *str, ...)75 void cwiid_err(struct wiimote *wiimote, const char *str, ...) 73 76 { 74 77 va_list ap; 75 78 76 if ( wiimote_err_func) {79 if (cwiid_err_func) { 77 80 va_start(ap, str); 78 81 if (wiimote) { 79 (* wiimote_err_func)(wiimote->id, str, ap);82 (*cwiid_err_func)(wiimote->id, str, ap); 80 83 } 81 84 else { 82 (* wiimote_err_func)(-1, str, ap);85 (*cwiid_err_func)(-1, str, ap); 83 86 } 84 87 va_end(ap); … … 90 93 unsigned char handshake; 91 94 if (read(wiimote->ctl_socket, &handshake, 1) != 1) { 92 wiimote_err(wiimote, "Error on read handshake");95 cwiid_err(wiimote, "Error on read handshake"); 93 96 return -1; 94 97 } 95 98 else if ((handshake & BT_TRANS_MASK) != BT_TRANS_HANDSHAKE) { 96 wiimote_err(wiimote, "Handshake expected, non-handshake received");99 cwiid_err(wiimote, "Handshake expected, non-handshake received"); 97 100 return -1; 98 101 } 99 102 else if ((handshake & BT_PARAM_MASK) != BT_PARAM_SUCCESSFUL) { 100 wiimote_err(wiimote, "Non-successful handshake");103 cwiid_err(wiimote, "Non-successful handshake"); 101 104 return -1; 102 105 } … … 146 149 break; 147 150 case WRITE_SEQ_MEM: 148 if ( wiimote_write(wiimote, seq[i].flags, seq[i].report_offset,151 if (cwiid_write(wiimote, seq[i].flags, seq[i].report_offset, 149 152 seq[i].len, seq[i].data)) { 150 153 return -1; -
lswm/Makefile.in
rbdb6c21 r805477a 7 7 SOURCES = lswm.c 8 8 9 CFLAGS += -I@top_builddir@/ wiimote10 LDFLAGS += -L@top_builddir@/ wiimote11 LDLIBS += -l wiimote9 CFLAGS += -I@top_builddir@/libcwiid 10 LDFLAGS += -L@top_builddir@/libcwiid 11 LDLIBS += -lcwiid 12 12 INST_DIR = @bindir@ 13 13 -
lswm/lswm.c
rd37162f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-07 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * changed wiimote_info.class to btclass22 * * changed cwiid_info.class to btclass 20 23 * 21 24 * 2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 28 31 #include <unistd.h> 29 32 #include <bluetooth/bluetooth.h> 30 #include < wiimote.h>33 #include <cwiid.h> 31 34 32 35 #define OPTSTRING "ahlq" … … 45 48 char long_format = 0; 46 49 char quiet = 0; 47 struct wiimote_info *wm;48 int wm_count;50 struct cwiid_bdinfo *bdinfo; 51 int bdinfo_count; 49 52 int i; 50 53 char ba_str[18]; … … 78 81 /* Handle quiet mode */ 79 82 if (quiet) { 80 wiimote_set_err(NULL);83 cwiid_set_err(NULL); 81 84 } 82 85 /* Print discoverable mode message */ … … 90 93 91 94 /* Get device info */ 92 if ((wm_count = wiimote_get_info_array(-1, 2, -1, &wm, flags)) == -1) { 95 if ((bdinfo_count = cwiid_get_bdinfo_array(-1, 2, -1, &bdinfo, flags)) 96 == -1) { 93 97 return -1; 94 98 } 95 99 96 100 /* Print info */ 97 for (i=0; i < wm_count; i++) {98 ba2str(& wm[i].bdaddr, ba_str);101 for (i=0; i < bdinfo_count; i++) { 102 ba2str(&bdinfo[i].bdaddr, ba_str); 99 103 if (long_format) { 100 printf("%s 0x%.2X%.2X%.2X %s\n", ba_str, wm[i].btclass[2],101 wm[i].btclass[1], wm[i].btclass[0], wm[i].name);104 printf("%s 0x%.2X%.2X%.2X %s\n", ba_str, bdinfo[i].btclass[2], 105 bdinfo[i].btclass[1], bdinfo[i].btclass[0], bdinfo[i].name); 102 106 } 103 107 else { -
wmdemo/Makefile.in
rbdb6c21 r805477a 7 7 SOURCES = wmdemo.c 8 8 9 CFLAGS += -I@top_builddir@/ wiimote10 LDFLAGS += -L@top_builddir@/ wiimote11 LDLIBS += -l wiimote9 CFLAGS += -I@top_builddir@/libcwiid 10 LDFLAGS += -L@top_builddir@/libcwiid 11 LDLIBS += -lcwiid 12 12 INST_DIR = @bindir@ 13 13 -
wmdemo/wmdemo.c
r09bfa38 r805477a 3 3 #include <stdlib.h> 4 4 5 #include < wiimote.h>5 #include <cwiid.h> 6 6 7 7 /* This is a sample program written to demonstrate basic CWiid libwiimote … … 15 15 * interface, and it shows. */ 16 16 17 wiimote_mesg_callback_t wiimote_callback;17 cwiid_mesg_callback_t cwiid_callback; 18 18 19 19 #define toggle_bit(bf,b) \ … … 22 22 : ((bf) | (b)) 23 23 24 void set_led_state( wiimote_t *wiimote, unsigned char led_state);25 void set_rpt_mode( wiimote_t *wiimote, unsigned char rpt_mode);26 27 wiimote_err_t err;24 void set_led_state(cwiid_wiimote_t *wiimote, unsigned char led_state); 25 void set_rpt_mode(cwiid_wiimote_t *wiimote, unsigned char rpt_mode); 26 27 cwiid_err_t err; 28 28 void err(int id, const char *s, ...) 29 29 { … … 38 38 39 39 /* wiimote handle */ 40 wiimote_t *wiimote;40 cwiid_wiimote_t *wiimote; 41 41 42 42 int main(int argc, char *argv[]) 43 43 { 44 44 bdaddr_t bdaddr; /* bluetooth device address */ 45 int wiimote_id; /* wiimote id: useful for handling multiple wiimotes45 int cwiid_id; /* wiimote id: useful for handling multiple wiimotes 46 46 with a single callback */ 47 47 unsigned char led_state = 0; … … 50 50 int exit = 0; 51 51 52 wiimote_set_err(err);52 cwiid_set_err(err); 53 53 54 54 /* Connect to any wiimote */ 55 55 bdaddr = *BDADDR_ANY; 56 /* Connect to address in string WIIMOTE_BDADDR */57 /* str2ba( WIIMOTE_BDADDR, &bdaddr); */56 /* Connect to address in string CWIID_BDADDR */ 57 /* str2ba(CWIID_BDADDR, &bdaddr); */ 58 58 59 59 /* Connect to the wiimote */ 60 60 printf("Put Wiimote in discoverable mode now (press 1+2)...\n"); 61 if (!(wiimote = wiimote_connect(&bdaddr, wiimote_callback, &wiimote_id))) {61 if (!(wiimote = cwiid_connect(&bdaddr, cwiid_callback, &cwiid_id))) { 62 62 fprintf(stderr, "Unable to connect to wiimote\n"); 63 63 return -1; … … 81 81 switch (getchar()) { 82 82 case '1': 83 toggle_bit(led_state, WIIMOTE_LED1_ON);83 toggle_bit(led_state, CWIID_LED1_ON); 84 84 set_led_state(wiimote, led_state); 85 85 break; 86 86 case '2': 87 toggle_bit(led_state, WIIMOTE_LED2_ON);87 toggle_bit(led_state, CWIID_LED2_ON); 88 88 set_led_state(wiimote, led_state); 89 89 break; 90 90 case '3': 91 toggle_bit(led_state, WIIMOTE_LED3_ON);91 toggle_bit(led_state, CWIID_LED3_ON); 92 92 set_led_state(wiimote, led_state); 93 93 break; 94 94 case '4': 95 toggle_bit(led_state, WIIMOTE_LED4_ON);95 toggle_bit(led_state, CWIID_LED4_ON); 96 96 set_led_state(wiimote, led_state); 97 97 break; 98 98 case 'a': 99 toggle_bit(rpt_mode, WIIMOTE_RPT_ACC);99 toggle_bit(rpt_mode, CWIID_RPT_ACC); 100 100 set_rpt_mode(wiimote, rpt_mode); 101 101 break; 102 102 case 'b': 103 toggle_bit(rpt_mode, WIIMOTE_RPT_BTN);103 toggle_bit(rpt_mode, CWIID_RPT_BTN); 104 104 set_rpt_mode(wiimote, rpt_mode); 105 105 break; 106 106 case 'e': 107 /* WIIMOTE_RPT_EXT is actually108 * WIIMOTE_RPT_NUNCHUK | WIIMOTE_RPT_CLASSIC */109 toggle_bit(rpt_mode, WIIMOTE_RPT_EXT);107 /* CWIID_RPT_EXT is actually 108 * CWIID_RPT_NUNCHUK | CWIID_RPT_CLASSIC */ 109 toggle_bit(rpt_mode, CWIID_RPT_EXT); 110 110 set_rpt_mode(wiimote, rpt_mode); 111 111 break; … … 114 114 * other options selected (not including as-yet-undeciphered 115 115 * interleaved mode */ 116 toggle_bit(rpt_mode, WIIMOTE_RPT_IR);116 toggle_bit(rpt_mode, CWIID_RPT_IR); 117 117 set_rpt_mode(wiimote, rpt_mode); 118 118 break; 119 119 case 'r': 120 120 toggle_bit(rumble, 1); 121 if ( wiimote_command(wiimote, WIIMOTE_CMD_RUMBLE, rumble)) {121 if (cwiid_command(wiimote, CWIID_CMD_RUMBLE, rumble)) { 122 122 fprintf(stderr, "Error setting rumble\n"); 123 123 } 124 124 break; 125 125 case 's': 126 if ( wiimote_command(wiimote, WIIMOTE_CMD_STATUS, 0)) {126 if (cwiid_command(wiimote, CWIID_CMD_STATUS, 0)) { 127 127 fprintf(stderr, "Error requesting status message\n"); 128 128 } 129 129 break; 130 130 case 't': 131 toggle_bit(rpt_mode, WIIMOTE_RPT_STATUS);131 toggle_bit(rpt_mode, CWIID_RPT_STATUS); 132 132 set_rpt_mode(wiimote, rpt_mode); 133 133 break; … … 142 142 } 143 143 144 if ( wiimote_disconnect(wiimote)) {144 if (cwiid_disconnect(wiimote)) { 145 145 fprintf(stderr, "Error on wiimote disconnect\n"); 146 146 return -1; … … 150 150 } 151 151 152 void set_led_state( wiimote_t *wiimote, unsigned char led_state)153 { 154 if ( wiimote_command(wiimote, WIIMOTE_CMD_LED, led_state)) {152 void set_led_state(cwiid_wiimote_t *wiimote, unsigned char led_state) 153 { 154 if (cwiid_command(wiimote, CWIID_CMD_LED, led_state)) { 155 155 fprintf(stderr, "Error setting LEDs \n"); 156 156 } 157 157 } 158 158 159 void set_rpt_mode( wiimote_t *wiimote, unsigned char rpt_mode)160 { 161 if ( wiimote_command(wiimote, WIIMOTE_CMD_RPT_MODE, rpt_mode)) {159 void set_rpt_mode(cwiid_wiimote_t *wiimote, unsigned char rpt_mode) 160 { 161 if (cwiid_command(wiimote, CWIID_CMD_RPT_MODE, rpt_mode)) { 162 162 fprintf(stderr, "Error setting report mode\n"); 163 163 } 164 164 } 165 165 166 /* Prototype wiimote_callback with wiimote_callback_t, define it with the actual166 /* Prototype cwiid_callback with cwiid_callback_t, define it with the actual 167 167 * type - this will cause a compile error (rather than some undefined bizarre 168 * behavior) if wiimote_callback_t changes */169 /* wiimote_mesg_callback_t has undergone a few changes lately, hopefully this168 * behavior) if cwiid_callback_t changes */ 169 /* cwiid_mesg_callback_t has undergone a few changes lately, hopefully this 170 170 * will be the last. Some programs need to know which messages were received 171 * simultaneously (e.g. for correlating acce perometer and IR data), and the171 * simultaneously (e.g. for correlating accelerometer and IR data), and the 172 172 * sequence number mechanism used previously proved cumbersome, so we just 173 173 * pass an array of messages, all of which were received at the same time. 174 174 * The id is to distinguish between multiple wiimotes using the same callback. 175 175 * */ 176 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg[])176 void cwiid_callback(int id, int mesg_count, union cwiid_mesg *mesg[]) 177 177 { 178 178 int i, j; … … 182 182 { 183 183 switch (mesg[i]->type) { 184 case WIIMOTE_MESG_STATUS:184 case CWIID_MESG_STATUS: 185 185 printf("Status Report: battery=%d extension=", 186 186 mesg[i]->status_mesg.battery); 187 187 switch (mesg[i]->status_mesg.extension) { 188 case WIIMOTE_EXT_NONE:188 case CWIID_EXT_NONE: 189 189 printf("none"); 190 190 break; 191 case WIIMOTE_EXT_NUNCHUK:191 case CWIID_EXT_NUNCHUK: 192 192 printf("Nunchuk"); 193 193 break; 194 case WIIMOTE_EXT_CLASSIC:194 case CWIID_EXT_CLASSIC: 195 195 printf("Classic Controller"); 196 196 break; … … 201 201 printf("\n"); 202 202 break; 203 case WIIMOTE_MESG_BTN:203 case CWIID_MESG_BTN: 204 204 printf("Button Report: %.4X\n", mesg[i]->btn_mesg.buttons); 205 205 break; 206 case WIIMOTE_MESG_ACC:206 case CWIID_MESG_ACC: 207 207 printf("Acc Report: x=%d, y=%d, z=%d\n", mesg[i]->acc_mesg.x, 208 208 mesg[i]->acc_mesg.y, 209 209 mesg[i]->acc_mesg.z); 210 210 break; 211 case WIIMOTE_MESG_IR:211 case CWIID_MESG_IR: 212 212 printf("IR Report: "); 213 213 valid_source = 0; 214 for (j = 0; j < WIIMOTE_IR_SRC_COUNT; j++) {214 for (j = 0; j < CWIID_IR_SRC_COUNT; j++) { 215 215 if (mesg[i]->ir_mesg.src[j].valid) { 216 216 valid_source = 1; … … 224 224 printf("\n"); 225 225 break; 226 case WIIMOTE_MESG_NUNCHUK:226 case CWIID_MESG_NUNCHUK: 227 227 printf("Nunchuk Report: btns=%.2X stick=(%d,%d) acc.x=%d acc.y=%d " 228 228 "acc.z=%d\n", mesg[i]->nunchuk_mesg.buttons, … … 231 231 mesg[i]->nunchuk_mesg.acc_y, mesg[i]->nunchuk_mesg.acc_z); 232 232 break; 233 case WIIMOTE_MESG_CLASSIC:233 case CWIID_MESG_CLASSIC: 234 234 printf("Classic Report: btns=%.4X l_stick=(%d,%d) r_stick=(%d,%d) " 235 235 "l=%d r=%d\n", mesg[i]->classic_mesg.buttons, … … 240 240 mesg[i]->classic_mesg.l, mesg[i]->classic_mesg.r); 241 241 break; 242 case WIIMOTE_MESG_ERROR:243 if ( wiimote_disconnect(wiimote)) {242 case CWIID_MESG_ERROR: 243 if (cwiid_disconnect(wiimote)) { 244 244 fprintf(stderr, "Error on wiimote disconnect\n"); 245 245 exit(-1); -
wmgui/Makefile.in
rbdb6c21 r805477a 7 7 SOURCES = main.c interface.c support.c 8 8 9 CFLAGS += @GTK_CFLAGS@ -I@top_builddir@/ wiimote\9 CFLAGS += @GTK_CFLAGS@ -I@top_builddir@/libcwiid \ 10 10 -DCWIID_VERSION=\"${PACKAGE_VERSION}\" 11 LDFLAGS += -L@top_builddir@/ wiimote12 LDLIBS += @GTK_LIBS@ -lm -l wiimote11 LDFLAGS += -L@top_builddir@/libcwiid 12 LDLIBS += @GTK_LIBS@ -lm -lcwiid 13 13 INST_DIR = @bindir@ 14 14 -
wmgui/main.c
re39b37a r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@anstrakraft.org> 19 22 * * fixed signed/unsigned comparison warning in btnRead_clicked 20 23 * 21 24 * 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 22 * * disconnect on wiimote_mesg_error25 * * disconnect on cwiid_mesg_error 23 26 * 24 27 * 2007-04-03 L. Donnie Smith <cwiid@abstrakraft.org> 25 * * commented custom wiimote_err (causing Xlib errors)28 * * commented custom cwiid_err (causing Xlib errors) 26 29 * 27 30 * 2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> … … 51 54 52 55 #include <bluetooth/bluetooth.h> 53 #include " wiimote.h"56 #include "cwiid.h" 54 57 55 58 #define PI 3.14159265358979323 … … 69 72 70 73 /* Globals */ 71 wiimote_t *wiimote = NULL;74 cwiid_wiimote_t *wiimote = NULL; 72 75 bdaddr_t bdaddr; 73 76 struct acc acc_zero, acc_one; 74 struct wiimote_ir_mesg ir_data;77 struct cwiid_ir_mesg ir_data; 75 78 struct acc nc_acc_zero, nc_acc_one; 76 79 struct stick nc_stick; … … 163 166 164 167 /* Wiimote Callback */ 165 wiimote_mesg_callback_t wiimote_callback;168 cwiid_mesg_callback_t cwiid_callback; 166 169 167 170 /* Wiimote Handler Functions */ 168 void wiimote_btn(struct wiimote_btn_mesg *);169 void wiimote_acc(struct wiimote_acc_mesg *);170 void wiimote_ir(struct wiimote_ir_mesg *);171 void wiimote_nunchuk(struct wiimote_nunchuk_mesg *);172 void wiimote_classic(struct wiimote_classic_mesg *);171 void cwiid_btn(struct cwiid_btn_mesg *); 172 void cwiid_acc(struct cwiid_acc_mesg *); 173 void cwiid_ir(struct cwiid_ir_mesg *); 174 void cwiid_nunchuk(struct cwiid_nunchuk_mesg *); 175 void cwiid_classic(struct cwiid_classic_mesg *); 173 176 174 177 /* GetOpt */ … … 180 183 181 184 /* 182 wiimote_err_t err;185 cwiid_err_t err; 183 186 184 187 void err(int id, const char *s, ...) … … 202 205 gdk_threads_enter(); 203 206 204 /* wiimote_set_err(err); */207 /* cwiid_set_err(err); */ 205 208 206 209 /* Parse Options */ … … 233 236 } 234 237 } 235 else if ((str_addr = getenv( WIIMOTE_BDADDR)) != NULL) {238 else if ((str_addr = getenv(CWIID_BDADDR)) != NULL) { 236 239 if (str2ba(str_addr, &bdaddr)) { 237 printf("invalid address in %s\n", WIIMOTE_BDADDR);240 printf("invalid address in %s\n", CWIID_BDADDR); 238 241 bdaddr = *BDADDR_ANY; 239 242 } … … 418 421 419 422 nc_stick.max = 0xFF; 420 cc_l_stick.max = WIIMOTE_CLASSIC_L_STICK_MAX;421 cc_r_stick.max = WIIMOTE_CLASSIC_R_STICK_MAX;423 cc_l_stick.max = CWIID_CLASSIC_L_STICK_MAX; 424 cc_r_stick.max = CWIID_CLASSIC_R_STICK_MAX; 422 425 423 426 set_gui_state(); … … 573 576 int i; 574 577 575 for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) {578 for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 576 579 ir_data.src[i].x = -1; 577 580 ir_data.src[i].y = -1; … … 633 636 "Put Wiimote in discoverable mode (press 1+2) and press OK", 634 637 GTK_WINDOW(winMain)); 635 if ((wiimote = wiimote_connect(&bdaddr, &wiimote_callback, NULL)) == NULL) {638 if ((wiimote = cwiid_connect(&bdaddr, &cwiid_callback, NULL)) == NULL) { 636 639 message(GTK_MESSAGE_ERROR, "Unable to connect", GTK_WINDOW(winMain)); 637 640 status("No connection"); … … 639 642 else { 640 643 status("Connected"); 641 if ( wiimote_read(wiimote, WIIMOTE_RW_EEPROM, 0x16, 7, buf)) {644 if (cwiid_read(wiimote, CWIID_RW_EEPROM, 0x16, 7, buf)) { 642 645 message(GTK_MESSAGE_ERROR, "Unable to retrieve accelerometer " 643 646 "calibration", GTK_WINDOW(winMain)); … … 653 656 set_gui_state(); 654 657 set_report_mode(); 655 wiimote_command(wiimote, WIIMOTE_CMD_STATUS, 0);658 cwiid_command(wiimote, CWIID_CMD_STATUS, 0); 656 659 } 657 660 … … 663 666 void menuDisconnect_activate(void) 664 667 { 665 if ( wiimote_disconnect(wiimote)) {668 if (cwiid_disconnect(wiimote)) { 666 669 message(GTK_MESSAGE_ERROR, "Error on disconnect", GTK_WINDOW(winMain)); 667 670 } … … 736 739 LED_state = 737 740 (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED1)) 738 ? WIIMOTE_LED1_ON : 0) |741 ? CWIID_LED1_ON : 0) | 739 742 (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED2)) 740 ? WIIMOTE_LED2_ON : 0) |743 ? CWIID_LED2_ON : 0) | 741 744 (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED3)) 742 ? WIIMOTE_LED3_ON : 0) |745 ? CWIID_LED3_ON : 0) | 743 746 (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED4)) 744 ? WIIMOTE_LED4_ON : 0);745 if ( wiimote_command(wiimote, WIIMOTE_CMD_LED, LED_state)) {747 ? CWIID_LED4_ON : 0); 748 if (cwiid_command(wiimote, CWIID_CMD_LED, LED_state)) { 746 749 message(GTK_MESSAGE_ERROR, "error setting LEDs", 747 750 GTK_WINDOW(winMain)); … … 753 756 { 754 757 if (wiimote) { 755 if ( wiimote_command(wiimote, WIIMOTE_CMD_RUMBLE,758 if (cwiid_command(wiimote, CWIID_CMD_RUMBLE, 756 759 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkRumble)))) { 757 760 message(GTK_MESSAGE_ERROR, "error setting rumble", … … 769 772 gdk_window_get_geometry(drawIR->window, NULL, NULL, &width, &height, NULL); 770 773 771 for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) {774 for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 772 775 if (ir_data.src[i].valid) { 773 776 if (ir_data.src[i].size == -1) { … … 780 783 drawIR->style->fg_gc[GTK_WIDGET_STATE(drawIR)], 781 784 TRUE, 782 ir_data.src[i].x*width/ WIIMOTE_IR_X_MAX,783 height - ir_data.src[i].y*height/ WIIMOTE_IR_Y_MAX,785 ir_data.src[i].x*width/CWIID_IR_X_MAX, 786 height - ir_data.src[i].y*height/CWIID_IR_Y_MAX, 784 787 size, size, 785 788 0, 64 * 360); … … 811 814 void btnRead_clicked(void) 812 815 { 813 static unsigned char buf[ WIIMOTE_MAX_READ_LEN];814 static char txt[ WIIMOTE_MAX_READ_LEN*4+50]; /* 3 chars per byte, with816 static unsigned char buf[CWIID_MAX_READ_LEN]; 817 static char txt[CWIID_MAX_READ_LEN*4+50]; /* 3 chars per byte, with 815 818 * plenty extra */ 816 819 GtkTextIter text_iter; … … 832 835 } 833 836 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radReadReg))) { 834 flags = WIIMOTE_RW_REG;837 flags = CWIID_RW_REG; 835 838 } 836 839 else { 837 flags = WIIMOTE_RW_EEPROM;840 flags = CWIID_RW_EEPROM; 838 841 } 839 842 840 843 /* Make the call */ 841 if ( wiimote_read(wiimote, flags, offset, len, buf)) {844 if (cwiid_read(wiimote, flags, offset, len, buf)) { 842 845 message(GTK_MESSAGE_ERROR, "Wiimote read error", GTK_WINDOW(winRW)); 843 846 } … … 906 909 907 910 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radWriteReg))) { 908 flags = WIIMOTE_RW_REG;911 flags = CWIID_RW_REG; 909 912 } 910 913 else { 911 flags = WIIMOTE_RW_EEPROM;914 flags = CWIID_RW_EEPROM; 912 915 } 913 916 … … 956 959 957 960 /* Make the call */ 958 if ( wiimote_write(wiimote, flags, offset, len, buf)) {961 if (cwiid_write(wiimote, flags, offset, len, buf)) { 959 962 message(GTK_MESSAGE_ERROR, "Wiimote write error", GTK_WINDOW(winRW)); 960 963 } … … 972 975 void btnBeep_clicked(void) 973 976 { 974 /*if ( wiimote_beep(wiimote)) {977 /*if (cwiid_beep(wiimote)) { 975 978 message(GTK_MESSAGE_ERROR, "Wiimote sound error", GTK_WINDOW(winMain)); 976 979 }*/ … … 981 984 uint8_t rpt_mode; 982 985 983 rpt_mode = WIIMOTE_RPT_STATUS | WIIMOTE_RPT_BTN;986 rpt_mode = CWIID_RPT_STATUS | CWIID_RPT_BTN; 984 987 985 988 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkIR))) { 986 rpt_mode |= WIIMOTE_RPT_IR;989 rpt_mode |= CWIID_RPT_IR; 987 990 } 988 991 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkAcc))) { 989 rpt_mode |= WIIMOTE_RPT_ACC;992 rpt_mode |= CWIID_RPT_ACC; 990 993 } 991 994 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkExt))) { 992 rpt_mode |= WIIMOTE_RPT_EXT;993 } 994 if ( wiimote_command(wiimote, WIIMOTE_CMD_RPT_MODE, rpt_mode)) {995 rpt_mode |= CWIID_RPT_EXT; 996 } 997 if (cwiid_command(wiimote, CWIID_CMD_RPT_MODE, rpt_mode)) { 995 998 message(GTK_MESSAGE_ERROR, "error setting report mode", 996 999 GTK_WINDOW(winMain)); … … 999 1002 1000 1003 #define BATTERY_STR_LEN 14 /* "Battery: 100%" + '\0' */ 1001 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg_array[])1004 void cwiid_callback(int id, int mesg_count, union cwiid_mesg *mesg_array[]) 1002 1005 { 1003 1006 int i; … … 1005 1008 char *ext_str; 1006 1009 unsigned char buf[7]; 1007 static enum wiimote_ext_type ext_type = WIIMOTE_EXT_NONE;1010 static enum cwiid_ext_type ext_type = CWIID_EXT_NONE; 1008 1011 1009 1012 gdk_threads_enter(); 1010 1013 for (i=0; i < mesg_count; i++) { 1011 1014 switch (mesg_array[i]->type) { 1012 case WIIMOTE_MESG_STATUS:1015 case CWIID_MESG_STATUS: 1013 1016 snprintf(battery, BATTERY_STR_LEN,"Battery:%d%%", 1014 1017 (int) (100.0 * mesg_array[i]->status_mesg.battery / 1015 WIIMOTE_BATTERY_MAX));1018 CWIID_BATTERY_MAX)); 1016 1019 gtk_statusbar_push(GTK_STATUSBAR(statBattery), 0, battery); 1017 1020 switch (mesg_array[i]->status_mesg.extension) { 1018 case WIIMOTE_EXT_NONE:1021 case CWIID_EXT_NONE: 1019 1022 ext_str = "No extension"; 1020 1023 break; 1021 case WIIMOTE_EXT_NUNCHUK:1024 case CWIID_EXT_NUNCHUK: 1022 1025 ext_str = "Nunchuk"; 1023 if (ext_type != WIIMOTE_EXT_NUNCHUK) {1024 if ( wiimote_read(wiimote,1025 WIIMOTE_RW_REG | WIIMOTE_RW_DECODE,1026 if (ext_type != CWIID_EXT_NUNCHUK) { 1027 if (cwiid_read(wiimote, 1028 CWIID_RW_REG | CWIID_RW_DECODE, 1026 1029 0xA40020, 7, buf)) { 1027 1030 message(GTK_MESSAGE_ERROR, "Unable to retrieve " … … 1038 1041 } 1039 1042 break; 1040 case WIIMOTE_EXT_CLASSIC:1043 case CWIID_EXT_CLASSIC: 1041 1044 ext_str = "Classic controller"; 1042 1045 break; 1043 case WIIMOTE_EXT_UNKNOWN:1046 case CWIID_EXT_UNKNOWN: 1044 1047 ext_str = "Unknown extension"; 1045 1048 break; … … 1050 1053 ext_type = mesg_array[i]->status_mesg.extension; 1051 1054 break; 1052 case WIIMOTE_MESG_BTN:1053 wiimote_btn(&mesg_array[i]->btn_mesg);1055 case CWIID_MESG_BTN: 1056 cwiid_btn(&mesg_array[i]->btn_mesg); 1054 1057 break; 1055 case WIIMOTE_MESG_ACC:1056 wiimote_acc(&mesg_array[i]->acc_mesg);1058 case CWIID_MESG_ACC: 1059 cwiid_acc(&mesg_array[i]->acc_mesg); 1057 1060 break; 1058 case WIIMOTE_MESG_IR:1059 wiimote_ir(&mesg_array[i]->ir_mesg);1061 case CWIID_MESG_IR: 1062 cwiid_ir(&mesg_array[i]->ir_mesg); 1060 1063 break; 1061 case WIIMOTE_MESG_NUNCHUK:1062 wiimote_nunchuk(&mesg_array[i]->nunchuk_mesg);1064 case CWIID_MESG_NUNCHUK: 1065 cwiid_nunchuk(&mesg_array[i]->nunchuk_mesg); 1063 1066 break; 1064 case WIIMOTE_MESG_CLASSIC:1065 wiimote_classic(&mesg_array[i]->classic_mesg);1067 case CWIID_MESG_CLASSIC: 1068 cwiid_classic(&mesg_array[i]->classic_mesg); 1066 1069 break; 1067 case WIIMOTE_MESG_ERROR:1070 case CWIID_MESG_ERROR: 1068 1071 menuDisconnect_activate(); 1069 1072 break; … … 1076 1079 } 1077 1080 1078 void wiimote_btn(struct wiimote_btn_mesg *mesg)1081 void cwiid_btn(struct cwiid_btn_mesg *mesg) 1079 1082 { 1080 1083 gtk_widget_modify_bg(evUp, GTK_STATE_NORMAL, 1081 (mesg->buttons & WIIMOTE_BTN_UP) ? &btn_on : &btn_off);1084 (mesg->buttons & CWIID_BTN_UP) ? &btn_on : &btn_off); 1082 1085 gtk_widget_modify_bg(evDown, GTK_STATE_NORMAL, 1083 (mesg->buttons & WIIMOTE_BTN_DOWN) ? &btn_on : &btn_off);1086 (mesg->buttons & CWIID_BTN_DOWN) ? &btn_on : &btn_off); 1084 1087 gtk_widget_modify_bg(evLeft, GTK_STATE_NORMAL, 1085 (mesg->buttons & WIIMOTE_BTN_LEFT) ? &btn_on : &btn_off);1088 (mesg->buttons & CWIID_BTN_LEFT) ? &btn_on : &btn_off); 1086 1089 gtk_widget_modify_bg(evRight, GTK_STATE_NORMAL, 1087 (mesg->buttons & WIIMOTE_BTN_RIGHT) ? &btn_on : &btn_off);1090 (mesg->buttons & CWIID_BTN_RIGHT) ? &btn_on : &btn_off); 1088 1091 gtk_widget_modify_bg(evA, GTK_STATE_NORMAL, 1089 (mesg->buttons & WIIMOTE_BTN_A) ? &btn_on : &btn_off);1092 (mesg->buttons & CWIID_BTN_A) ? &btn_on : &btn_off); 1090 1093 gtk_widget_modify_bg(evB, GTK_STATE_NORMAL, 1091 (mesg->buttons & WIIMOTE_BTN_B) ? &btn_on : &btn_off);1094 (mesg->buttons & CWIID_BTN_B) ? &btn_on : &btn_off); 1092 1095 gtk_widget_modify_bg(evMinus, GTK_STATE_NORMAL, 1093 (mesg->buttons & WIIMOTE_BTN_MINUS) ? &btn_on : &btn_off);1096 (mesg->buttons & CWIID_BTN_MINUS) ? &btn_on : &btn_off); 1094 1097 gtk_widget_modify_bg(evPlus, GTK_STATE_NORMAL, 1095 (mesg->buttons & WIIMOTE_BTN_PLUS) ? &btn_on : &btn_off);1098 (mesg->buttons & CWIID_BTN_PLUS) ? &btn_on : &btn_off); 1096 1099 gtk_widget_modify_bg(evHome, GTK_STATE_NORMAL, 1097 (mesg->buttons & WIIMOTE_BTN_HOME) ? &btn_on : &btn_off);1100 (mesg->buttons & CWIID_BTN_HOME) ? &btn_on : &btn_off); 1098 1101 gtk_widget_modify_bg(ev1, GTK_STATE_NORMAL, 1099 (mesg->buttons & WIIMOTE_BTN_1) ? &btn_on : &btn_off);1102 (mesg->buttons & CWIID_BTN_1) ? &btn_on : &btn_off); 1100 1103 gtk_widget_modify_bg(ev2, GTK_STATE_NORMAL, 1101 (mesg->buttons & WIIMOTE_BTN_2) ? &btn_on : &btn_off);1104 (mesg->buttons & CWIID_BTN_2) ? &btn_on : &btn_off); 1102 1105 } 1103 1106 1104 1107 #define LBLVAL_LEN 6 1105 void wiimote_acc(struct wiimote_acc_mesg *mesg)1108 void cwiid_acc(struct cwiid_acc_mesg *mesg) 1106 1109 { 1107 1110 static gchar str[LBLVAL_LEN]; … … 1148 1151 } 1149 1152 1150 void wiimote_ir(struct wiimote_ir_mesg *mesg)1153 void cwiid_ir(struct cwiid_ir_mesg *mesg) 1151 1154 { 1152 1155 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkIR))) { 1153 /* memcpy(&ir_data, mesg, sizeof(struct wiimote_ir_mesg)); */1156 /* memcpy(&ir_data, mesg, sizeof(struct cwiid_ir_mesg)); */ 1154 1157 ir_data = *mesg; 1155 1158 gtk_widget_queue_draw(drawIR); … … 1157 1160 } 1158 1161 1159 void wiimote_nunchuk(struct wiimote_nunchuk_mesg *mesg)1162 void cwiid_nunchuk(struct cwiid_nunchuk_mesg *mesg) 1160 1163 { 1161 1164 static gchar str[LBLVAL_LEN]; … … 1165 1168 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkExt))) { 1166 1169 gtk_widget_modify_bg(evNCC, GTK_STATE_NORMAL, 1167 (mesg->buttons & WIIMOTE_NUNCHUK_BTN_C) ? &btn_on : &btn_off);1170 (mesg->buttons & CWIID_NUNCHUK_BTN_C) ? &btn_on : &btn_off); 1168 1171 gtk_widget_modify_bg(evNCZ, GTK_STATE_NORMAL, 1169 (mesg->buttons & WIIMOTE_NUNCHUK_BTN_Z) ? &btn_on : &btn_off);1172 (mesg->buttons & CWIID_NUNCHUK_BTN_Z) ? &btn_on : &btn_off); 1170 1173 1171 1174 nc_stick.valid = 1; … … 1212 1215 } 1213 1216 1214 void wiimote_classic(struct wiimote_classic_mesg *mesg)1217 void cwiid_classic(struct cwiid_classic_mesg *mesg) 1215 1218 { 1216 1219 static gchar str[LBLVAL_LEN]; … … 1218 1221 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkExt))) { 1219 1222 gtk_widget_modify_bg(evCCUp, GTK_STATE_NORMAL, 1220 (mesg->buttons & WIIMOTE_CLASSIC_BTN_UP) ? &btn_on : &btn_off);1223 (mesg->buttons & CWIID_CLASSIC_BTN_UP) ? &btn_on : &btn_off); 1221 1224 gtk_widget_modify_bg(evCCDown, GTK_STATE_NORMAL, 1222 (mesg->buttons & WIIMOTE_CLASSIC_BTN_DOWN) ? &btn_on : &btn_off);1225 (mesg->buttons & CWIID_CLASSIC_BTN_DOWN) ? &btn_on : &btn_off); 1223 1226 gtk_widget_modify_bg(evCCLeft, GTK_STATE_NORMAL, 1224 (mesg->buttons & WIIMOTE_CLASSIC_BTN_LEFT) ? &btn_on : &btn_off);1227 (mesg->buttons & CWIID_CLASSIC_BTN_LEFT) ? &btn_on : &btn_off); 1225 1228 gtk_widget_modify_bg(evCCRight, GTK_STATE_NORMAL, 1226 (mesg->buttons & WIIMOTE_CLASSIC_BTN_RIGHT) ? &btn_on : &btn_off);1229 (mesg->buttons & CWIID_CLASSIC_BTN_RIGHT) ? &btn_on : &btn_off); 1227 1230 gtk_widget_modify_bg(evCCMinus, GTK_STATE_NORMAL, 1228 (mesg->buttons & WIIMOTE_CLASSIC_BTN_MINUS) ? &btn_on : &btn_off);1231 (mesg->buttons & CWIID_CLASSIC_BTN_MINUS) ? &btn_on : &btn_off); 1229 1232 gtk_widget_modify_bg(evCCPlus, GTK_STATE_NORMAL, 1230 (mesg->buttons & WIIMOTE_CLASSIC_BTN_PLUS) ? &btn_on : &btn_off);1233 (mesg->buttons & CWIID_CLASSIC_BTN_PLUS) ? &btn_on : &btn_off); 1231 1234 gtk_widget_modify_bg(evCCHome, GTK_STATE_NORMAL, 1232 (mesg->buttons & WIIMOTE_CLASSIC_BTN_HOME) ? &btn_on : &btn_off);1235 (mesg->buttons & CWIID_CLASSIC_BTN_HOME) ? &btn_on : &btn_off); 1233 1236 gtk_widget_modify_bg(evCCA, GTK_STATE_NORMAL, 1234 (mesg->buttons & WIIMOTE_CLASSIC_BTN_A) ? &btn_on : &btn_off);1237 (mesg->buttons & CWIID_CLASSIC_BTN_A) ? &btn_on : &btn_off); 1235 1238 gtk_widget_modify_bg(evCCB, GTK_STATE_NORMAL, 1236 (mesg->buttons & WIIMOTE_CLASSIC_BTN_B) ? &btn_on : &btn_off);1239 (mesg->buttons & CWIID_CLASSIC_BTN_B) ? &btn_on : &btn_off); 1237 1240 gtk_widget_modify_bg(evCCX, GTK_STATE_NORMAL, 1238 (mesg->buttons & WIIMOTE_CLASSIC_BTN_X) ? &btn_on : &btn_off);1241 (mesg->buttons & CWIID_CLASSIC_BTN_X) ? &btn_on : &btn_off); 1239 1242 gtk_widget_modify_bg(evCCY, GTK_STATE_NORMAL, 1240 (mesg->buttons & WIIMOTE_CLASSIC_BTN_Y) ? &btn_on : &btn_off);1243 (mesg->buttons & CWIID_CLASSIC_BTN_Y) ? &btn_on : &btn_off); 1241 1244 gtk_widget_modify_bg(evCCZL, GTK_STATE_NORMAL, 1242 (mesg->buttons & WIIMOTE_CLASSIC_BTN_ZL) ? &btn_on : &btn_off);1245 (mesg->buttons & CWIID_CLASSIC_BTN_ZL) ? &btn_on : &btn_off); 1243 1246 gtk_widget_modify_bg(evCCZR, GTK_STATE_NORMAL, 1244 (mesg->buttons & WIIMOTE_CLASSIC_BTN_ZR) ? &btn_on : &btn_off);1247 (mesg->buttons & CWIID_CLASSIC_BTN_ZR) ? &btn_on : &btn_off); 1245 1248 1246 1249 cc_l_stick.valid = 1; … … 1257 1260 gtk_label_set_text(GTK_LABEL(lblCCLVal), str); 1258 1261 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progCCL), 1259 (double)mesg->l/ WIIMOTE_CLASSIC_LR_MAX);1262 (double)mesg->l/CWIID_CLASSIC_LR_MAX); 1260 1263 gtk_widget_modify_bg(evCCL, GTK_STATE_NORMAL, 1261 (mesg->buttons & WIIMOTE_CLASSIC_BTN_L) ? &btn_on : &btn_off);1264 (mesg->buttons & CWIID_CLASSIC_BTN_L) ? &btn_on : &btn_off); 1262 1265 g_snprintf(str, LBLVAL_LEN, "%X", mesg->r); 1263 1266 gtk_label_set_text(GTK_LABEL(lblCCRVal), str); 1264 1267 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progCCR), 1265 (double)mesg->r/ WIIMOTE_CLASSIC_LR_MAX);1268 (double)mesg->r/CWIID_CLASSIC_LR_MAX); 1266 1269 gtk_widget_modify_bg(evCCR, GTK_STATE_NORMAL, 1267 (mesg->buttons & WIIMOTE_CLASSIC_BTN_R) ? &btn_on : &btn_off);1268 } 1269 } 1270 1270 (mesg->buttons & CWIID_CLASSIC_BTN_R) ? &btn_on : &btn_off); 1271 } 1272 } 1273 -
wminput/Makefile.in
r26a104c r805477a 8 8 9 9 WMINPUT_CONFIG_DIR = $(CWIID_CONFIG_DIR)/wminput 10 CFLAGS += -I@top_builddir@/ wiimote\10 CFLAGS += -I@top_builddir@/libcwiid \ 11 11 -DWMINPUT_CONFIG_DIR=\"$(WMINPUT_CONFIG_DIR)\" \ 12 12 -DCWIID_PLUGINS_DIR=\"$(CWIID_PLUGINS_DIR)\" 13 LDLIBS += -l wiimote-ldl14 LDFLAGS += -L@top_builddir@/ wiimote-rdynamic13 LDLIBS += -lcwiid -ldl 14 LDFLAGS += -L@top_builddir@/libcwiid -rdynamic 15 15 INST_DIR = @bindir@ 16 16 -
wminput/README
rf200a0f r805477a 26 26 -w: on startup, wait (without timing) out until a wiimote is found 27 27 -c config: specifies the configuration file to load. "default" is the default configuration file (on install, a symlink is created to the acc_ptr configuration. The search directories are specified below in the section on configuration files, or an absolute or relative pathname may be given. 28 bdaddr: specifies the bluetooth device address of the wiimote. If unspecified, the environment variable WIIMOTE_BDADDR is used. If this variable does not exist, a connection is made with the first wiimote found.28 bdaddr: specifies the bluetooth device address of the wiimote. If unspecified, the environment variable CWIID_BDADDR is used. If this variable does not exist, a connection is made with the first wiimote found. 29 29 30 30 -
wminput/conf.c
rf200a0f r805477a 110 110 switch (source) { 111 111 case CONF_WM: 112 conf->rpt_mode_flags |= WIIMOTE_RPT_BTN;112 conf->rpt_mode_flags |= CWIID_RPT_BTN; 113 113 conf->wiimote_bmap[button].active = 1; 114 114 conf->wiimote_bmap[button].action = action; 115 115 break; 116 116 case CONF_NC: 117 conf->rpt_mode_flags |= WIIMOTE_RPT_NUNCHUK;117 conf->rpt_mode_flags |= CWIID_RPT_NUNCHUK; 118 118 conf->nunchuk_bmap[button].active = 1; 119 119 conf->nunchuk_bmap[button].action = action; 120 120 break; 121 121 case CONF_CC: 122 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC;122 conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 123 123 conf->nunchuk_bmap[button].active = 1; 124 124 conf->classic_bmap[button].action = action; … … 147 147 case CONF_WM_AXIS_DPAD_X: 148 148 case CONF_WM_AXIS_DPAD_Y: 149 conf->rpt_mode_flags |= WIIMOTE_RPT_BTN;149 conf->rpt_mode_flags |= CWIID_RPT_BTN; 150 150 if (axis_type == EV_ABS) { 151 151 conf->dev.absmax[action] = 1; … … 157 157 case CONF_NC_AXIS_STICK_X: 158 158 case CONF_NC_AXIS_STICK_Y: 159 conf->rpt_mode_flags |= WIIMOTE_RPT_NUNCHUK;159 conf->rpt_mode_flags |= CWIID_RPT_NUNCHUK; 160 160 if (axis_type == EV_ABS) { 161 161 conf->dev.absmax[action] = 0xFF; … … 167 167 case CONF_CC_AXIS_DPAD_X: 168 168 case CONF_CC_AXIS_DPAD_Y: 169 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC;169 conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 170 170 if (axis_type == EV_ABS) { 171 171 conf->dev.absmax[action] = 1; … … 177 177 case CONF_CC_AXIS_L_STICK_X: 178 178 case CONF_CC_AXIS_L_STICK_Y: 179 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC;179 conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 180 180 if (axis_type == EV_ABS) { 181 conf->dev.absmax[action] = WIIMOTE_CLASSIC_L_STICK_MAX;181 conf->dev.absmax[action] = CWIID_CLASSIC_L_STICK_MAX; 182 182 conf->dev.absmin[action] = 0; 183 183 conf->dev.absfuzz[action] = 0; … … 187 187 case CONF_CC_AXIS_R_STICK_X: 188 188 case CONF_CC_AXIS_R_STICK_Y: 189 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC;189 conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 190 190 if (axis_type == EV_ABS) { 191 conf->dev.absmax[action] = WIIMOTE_CLASSIC_R_STICK_MAX;191 conf->dev.absmax[action] = CWIID_CLASSIC_R_STICK_MAX; 192 192 conf->dev.absmin[action] = 0; 193 193 conf->dev.absfuzz[action] = 0; … … 197 197 case CONF_CC_AXIS_L: 198 198 case CONF_CC_AXIS_R: 199 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC;199 conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 200 200 if (axis_type == EV_ABS) { 201 conf->dev.absmax[action] = WIIMOTE_CLASSIC_LR_MAX;201 conf->dev.absmax[action] = CWIID_CLASSIC_LR_MAX; 202 202 conf->dev.absmin[action] = 0; 203 203 conf->dev.absfuzz[action] = 0; … … 406 406 } 407 407 conf->ff = 0; 408 conf->wiimote_bmap[CONF_WM_BTN_UP].mask = WIIMOTE_BTN_UP;409 conf->wiimote_bmap[CONF_WM_BTN_DOWN].mask = WIIMOTE_BTN_DOWN;410 conf->wiimote_bmap[CONF_WM_BTN_LEFT].mask = WIIMOTE_BTN_LEFT;411 conf->wiimote_bmap[CONF_WM_BTN_RIGHT].mask = WIIMOTE_BTN_RIGHT;412 conf->wiimote_bmap[CONF_WM_BTN_A].mask = WIIMOTE_BTN_A;413 conf->wiimote_bmap[CONF_WM_BTN_B].mask = WIIMOTE_BTN_B;414 conf->wiimote_bmap[CONF_WM_BTN_MINUS].mask = WIIMOTE_BTN_MINUS;415 conf->wiimote_bmap[CONF_WM_BTN_PLUS].mask = WIIMOTE_BTN_PLUS;416 conf->wiimote_bmap[CONF_WM_BTN_HOME].mask = WIIMOTE_BTN_HOME;417 conf->wiimote_bmap[CONF_WM_BTN_1].mask = WIIMOTE_BTN_1;418 conf->wiimote_bmap[CONF_WM_BTN_2].mask = WIIMOTE_BTN_2;419 conf->nunchuk_bmap[CONF_NC_BTN_C].mask = WIIMOTE_NUNCHUK_BTN_C;420 conf->nunchuk_bmap[CONF_NC_BTN_Z].mask = WIIMOTE_NUNCHUK_BTN_Z;421 conf->classic_bmap[CONF_CC_BTN_UP].mask = WIIMOTE_CLASSIC_BTN_UP;422 conf->classic_bmap[CONF_CC_BTN_DOWN].mask = WIIMOTE_CLASSIC_BTN_DOWN;423 conf->classic_bmap[CONF_CC_BTN_LEFT].mask = WIIMOTE_CLASSIC_BTN_LEFT;424 conf->classic_bmap[CONF_CC_BTN_RIGHT].mask = WIIMOTE_CLASSIC_BTN_RIGHT;425 conf->classic_bmap[CONF_CC_BTN_MINUS].mask = WIIMOTE_CLASSIC_BTN_MINUS;426 conf->classic_bmap[CONF_CC_BTN_PLUS].mask = WIIMOTE_CLASSIC_BTN_PLUS;427 conf->classic_bmap[CONF_CC_BTN_HOME].mask = WIIMOTE_CLASSIC_BTN_HOME;428 conf->classic_bmap[CONF_CC_BTN_A].mask = WIIMOTE_CLASSIC_BTN_A;429 conf->classic_bmap[CONF_CC_BTN_B].mask = WIIMOTE_CLASSIC_BTN_B;430 conf->classic_bmap[CONF_CC_BTN_X].mask = WIIMOTE_CLASSIC_BTN_X;431 conf->classic_bmap[CONF_CC_BTN_Y].mask = WIIMOTE_CLASSIC_BTN_Y;432 conf->classic_bmap[CONF_CC_BTN_ZL].mask = WIIMOTE_CLASSIC_BTN_ZL;433 conf->classic_bmap[CONF_CC_BTN_ZR].mask = WIIMOTE_CLASSIC_BTN_ZR;434 conf->classic_bmap[CONF_CC_BTN_L].mask = WIIMOTE_CLASSIC_BTN_L;435 conf->classic_bmap[CONF_CC_BTN_R].mask = WIIMOTE_CLASSIC_BTN_R;408 conf->wiimote_bmap[CONF_WM_BTN_UP].mask = CWIID_BTN_UP; 409 conf->wiimote_bmap[CONF_WM_BTN_DOWN].mask = CWIID_BTN_DOWN; 410 conf->wiimote_bmap[CONF_WM_BTN_LEFT].mask = CWIID_BTN_LEFT; 411 conf->wiimote_bmap[CONF_WM_BTN_RIGHT].mask = CWIID_BTN_RIGHT; 412 conf->wiimote_bmap[CONF_WM_BTN_A].mask = CWIID_BTN_A; 413 conf->wiimote_bmap[CONF_WM_BTN_B].mask = CWIID_BTN_B; 414 conf->wiimote_bmap[CONF_WM_BTN_MINUS].mask = CWIID_BTN_MINUS; 415 conf->wiimote_bmap[CONF_WM_BTN_PLUS].mask = CWIID_BTN_PLUS; 416 conf->wiimote_bmap[CONF_WM_BTN_HOME].mask = CWIID_BTN_HOME; 417 conf->wiimote_bmap[CONF_WM_BTN_1].mask = CWIID_BTN_1; 418 conf->wiimote_bmap[CONF_WM_BTN_2].mask = CWIID_BTN_2; 419 conf->nunchuk_bmap[CONF_NC_BTN_C].mask = CWIID_NUNCHUK_BTN_C; 420 conf->nunchuk_bmap[CONF_NC_BTN_Z].mask = CWIID_NUNCHUK_BTN_Z; 421 conf->classic_bmap[CONF_CC_BTN_UP].mask = CWIID_CLASSIC_BTN_UP; 422 conf->classic_bmap[CONF_CC_BTN_DOWN].mask = CWIID_CLASSIC_BTN_DOWN; 423 conf->classic_bmap[CONF_CC_BTN_LEFT].mask = CWIID_CLASSIC_BTN_LEFT; 424 conf->classic_bmap[CONF_CC_BTN_RIGHT].mask = CWIID_CLASSIC_BTN_RIGHT; 425 conf->classic_bmap[CONF_CC_BTN_MINUS].mask = CWIID_CLASSIC_BTN_MINUS; 426 conf->classic_bmap[CONF_CC_BTN_PLUS].mask = CWIID_CLASSIC_BTN_PLUS; 427 conf->classic_bmap[CONF_CC_BTN_HOME].mask = CWIID_CLASSIC_BTN_HOME; 428 conf->classic_bmap[CONF_CC_BTN_A].mask = CWIID_CLASSIC_BTN_A; 429 conf->classic_bmap[CONF_CC_BTN_B].mask = CWIID_CLASSIC_BTN_B; 430 conf->classic_bmap[CONF_CC_BTN_X].mask = CWIID_CLASSIC_BTN_X; 431 conf->classic_bmap[CONF_CC_BTN_Y].mask = CWIID_CLASSIC_BTN_Y; 432 conf->classic_bmap[CONF_CC_BTN_ZL].mask = CWIID_CLASSIC_BTN_ZL; 433 conf->classic_bmap[CONF_CC_BTN_ZR].mask = CWIID_CLASSIC_BTN_ZR; 434 conf->classic_bmap[CONF_CC_BTN_L].mask = CWIID_CLASSIC_BTN_L; 435 conf->classic_bmap[CONF_CC_BTN_R].mask = CWIID_CLASSIC_BTN_R; 436 436 for (i=0; i < CONF_WM_BTN_COUNT; i++) { 437 437 conf->wiimote_bmap[i].active = 0; -
wminput/conf.h
rf200a0f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * added conf_plugin_param_{int,float} prototypes … … 35 38 #include <linux/uinput.h> 36 39 37 #include " wiimote.h"40 #include "cwiid.h" 38 41 #include "wmplugin.h" 39 42 #include "y.tab.h" … … 163 166 164 167 struct uinput_listen_data { 165 wiimote_t *wiimote;168 cwiid_wiimote_t *wiimote; 166 169 struct conf *conf; 167 170 }; -
wminput/main.c
r9ef2b8a r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * exit on wiimote_error22 * * exit on cwiid_error 20 23 * 21 24 * 2007-03-03 L. Donnie Smith <cwiid@abstrakraft.org> … … 33 36 #include <unistd.h> 34 37 35 #include < wiimote.h>38 #include <cwiid.h> 36 39 37 40 #include "conf.h" … … 47 50 48 51 /* Prototypes */ 49 wiimote_mesg_callback_t wiimote_callback;52 cwiid_mesg_callback_t cwiid_callback; 50 53 int wminput_set_report_mode(); 51 void process_btn_mesg(struct wiimote_btn_mesg *mesg);52 void process_nunchuk_mesg(struct wiimote_nunchuk_mesg *mesg);53 void process_classic_mesg(struct wiimote_classic_mesg *mesg);54 void process_plugin(struct plugin *, int, union wiimote_mesg * []);54 void process_btn_mesg(struct cwiid_btn_mesg *mesg); 55 void process_nunchuk_mesg(struct cwiid_nunchuk_mesg *mesg); 56 void process_classic_mesg(struct cwiid_classic_mesg *mesg); 57 void process_plugin(struct plugin *, int, union cwiid_mesg * []); 55 58 56 59 /* Globals */ 57 wiimote_t *wiimote;60 cwiid_wiimote_t *wiimote; 58 61 char init; 59 62 … … 137 140 } 138 141 } 139 else if ((str_addr = getenv( WIIMOTE_BDADDR)) != NULL) {142 else if ((str_addr = getenv(CWIID_BDADDR)) != NULL) { 140 143 if (str2ba(str_addr, &bdaddr)) { 141 wminput_err("invalid address in %s", WIIMOTE_BDADDR);144 wminput_err("invalid address in %s", CWIID_BDADDR); 142 145 bdaddr = *BDADDR_ANY; 143 146 } … … 150 153 printf("Put Wiimote in discoverable mode now (press 1+2)...\n"); 151 154 if (wait_forever) { 152 if ( wiimote_find_wiimote(&bdaddr, -1)) {155 if (cwiid_find_wiimote(&bdaddr, -1)) { 153 156 wminput_err("error finding wiimote"); 154 157 conf_unload(&conf); … … 156 159 } 157 160 } 158 if ((wiimote = wiimote_connect(&bdaddr, wiimote_callback, NULL)) == NULL) {161 if ((wiimote = cwiid_connect(&bdaddr, cwiid_callback, NULL)) == NULL) { 159 162 wminput_err("unable to connect"); 160 163 conf_unload(&conf); … … 167 170 wminput_err("error on %s init", conf.plugins[i].name); 168 171 conf_unload(&conf); 169 wiimote_disconnect(wiimote);172 cwiid_disconnect(wiimote); 170 173 return -1; 171 174 } … … 174 177 if (wminput_set_report_mode()) { 175 178 conf_unload(&conf); 176 wiimote_disconnect(wiimote);179 cwiid_disconnect(wiimote); 177 180 return -1; 178 181 } … … 185 188 wminput_err("error starting uinput listen thread"); 186 189 conf_unload(&conf); 187 wiimote_disconnect(wiimote);190 cwiid_disconnect(wiimote); 188 191 return -1; 189 192 } … … 213 216 214 217 /* disconnect */ 215 if ( wiimote_disconnect(wiimote)) {218 if (cwiid_disconnect(wiimote)) { 216 219 wminput_err("error on disconnect"); 217 220 ret = -1; … … 247 250 } 248 251 249 if ( wiimote_command(wiimote, WIIMOTE_CMD_RPT_MODE, rpt_mode_flags)) {252 if (cwiid_command(wiimote, CWIID_CMD_RPT_MODE, rpt_mode_flags)) { 250 253 wminput_err("error setting report mode"); 251 254 return -1; … … 255 258 } 256 259 257 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg[])260 void cwiid_callback(int id, int mesg_count, union cwiid_mesg *mesg[]) 258 261 { 259 262 int i; … … 261 264 for (i=0; i < mesg_count; i++) { 262 265 switch (mesg[i]->type) { 263 case WIIMOTE_MESG_BTN:264 process_btn_mesg((struct wiimote_btn_mesg *) mesg[i]);265 break; 266 case WIIMOTE_MESG_NUNCHUK:267 process_nunchuk_mesg((struct wiimote_nunchuk_mesg *) mesg[i]);268 break; 269 case WIIMOTE_MESG_CLASSIC:270 process_classic_mesg((struct wiimote_classic_mesg *) mesg[i]);271 break; 272 case WIIMOTE_MESG_ERROR:266 case CWIID_MESG_BTN: 267 process_btn_mesg((struct cwiid_btn_mesg *) mesg[i]); 268 break; 269 case CWIID_MESG_NUNCHUK: 270 process_nunchuk_mesg((struct cwiid_nunchuk_mesg *) mesg[i]); 271 break; 272 case CWIID_MESG_CLASSIC: 273 process_classic_mesg((struct cwiid_classic_mesg *) mesg[i]); 274 break; 275 case CWIID_MESG_ERROR: 273 276 if (kill(getpid(),SIGINT)) { 274 277 wminput_err("error sending SIGINT"); … … 285 288 } 286 289 287 void process_btn_mesg(struct wiimote_btn_mesg *mesg)290 void process_btn_mesg(struct cwiid_btn_mesg *mesg) 288 291 { 289 292 static uint16_t prev_buttons = 0; … … 310 313 if (conf.amap[CONF_WM_AXIS_DPAD_X].active) { 311 314 axis_value = 0; 312 if (mesg->buttons & WIIMOTE_BTN_LEFT) {315 if (mesg->buttons & CWIID_BTN_LEFT) { 313 316 axis_value = -1; 314 317 } 315 else if (mesg->buttons & WIIMOTE_BTN_RIGHT) {318 else if (mesg->buttons & CWIID_BTN_RIGHT) { 316 319 axis_value = 1; 317 320 } … … 326 329 if (conf.amap[CONF_WM_AXIS_DPAD_Y].active) { 327 330 axis_value = 0; 328 if (mesg->buttons & WIIMOTE_BTN_DOWN) {331 if (mesg->buttons & CWIID_BTN_DOWN) { 329 332 axis_value = -1; 330 333 } 331 else if (mesg->buttons & WIIMOTE_BTN_UP) {334 else if (mesg->buttons & CWIID_BTN_UP) { 332 335 axis_value = 1; 333 336 } … … 340 343 } 341 344 342 void process_nunchuk_mesg(struct wiimote_nunchuk_mesg *mesg)345 void process_nunchuk_mesg(struct cwiid_nunchuk_mesg *mesg) 343 346 { 344 347 static uint8_t prev_buttons = 0; … … 383 386 } 384 387 385 void process_classic_mesg(struct wiimote_classic_mesg *mesg)388 void process_classic_mesg(struct cwiid_classic_mesg *mesg) 386 389 { 387 390 static uint16_t prev_buttons = 0; … … 408 411 if (conf.amap[CONF_CC_AXIS_DPAD_X].active) { 409 412 axis_value = 0; 410 if (mesg->buttons & WIIMOTE_CLASSIC_BTN_LEFT) {413 if (mesg->buttons & CWIID_CLASSIC_BTN_LEFT) { 411 414 axis_value = -1; 412 415 } 413 else if (mesg->buttons & WIIMOTE_CLASSIC_BTN_RIGHT) {416 else if (mesg->buttons & CWIID_CLASSIC_BTN_RIGHT) { 414 417 axis_value = 1; 415 418 } … … 424 427 if (conf.amap[CONF_CC_AXIS_DPAD_Y].active) { 425 428 axis_value = 0; 426 if (mesg->buttons & WIIMOTE_CLASSIC_BTN_DOWN) {429 if (mesg->buttons & CWIID_CLASSIC_BTN_DOWN) { 427 430 axis_value = -1; 428 431 } 429 else if (mesg->buttons & WIIMOTE_CLASSIC_BTN_UP) {432 else if (mesg->buttons & CWIID_CLASSIC_BTN_UP) { 430 433 axis_value = 1; 431 434 } … … 441 444 axis_value = mesg->l_stick_x; 442 445 if (conf.amap[CONF_CC_AXIS_L_STICK_X].flags & CONF_INVERT) { 443 axis_value = WIIMOTE_CLASSIC_L_STICK_MAX - axis_value;446 axis_value = CWIID_CLASSIC_L_STICK_MAX - axis_value; 444 447 } 445 448 send_event(&conf, conf.amap[CONF_CC_AXIS_L_STICK_X].axis_type, … … 451 454 axis_value = mesg->l_stick_y; 452 455 if (conf.amap[CONF_CC_AXIS_L_STICK_Y].flags & CONF_INVERT) { 453 axis_value = WIIMOTE_CLASSIC_L_STICK_MAX - axis_value;456 axis_value = CWIID_CLASSIC_L_STICK_MAX - axis_value; 454 457 } 455 458 send_event(&conf, conf.amap[CONF_CC_AXIS_L_STICK_Y].axis_type, … … 461 464 axis_value = mesg->r_stick_x; 462 465 if (conf.amap[CONF_CC_AXIS_R_STICK_X].flags & CONF_INVERT) { 463 axis_value = WIIMOTE_CLASSIC_R_STICK_MAX - axis_value;466 axis_value = CWIID_CLASSIC_R_STICK_MAX - axis_value; 464 467 } 465 468 send_event(&conf, conf.amap[CONF_CC_AXIS_R_STICK_X].axis_type, … … 471 474 axis_value = mesg->r_stick_y; 472 475 if (conf.amap[CONF_CC_AXIS_R_STICK_Y].flags & CONF_INVERT) { 473 axis_value = WIIMOTE_CLASSIC_R_STICK_MAX - axis_value;476 axis_value = CWIID_CLASSIC_R_STICK_MAX - axis_value; 474 477 } 475 478 send_event(&conf, conf.amap[CONF_CC_AXIS_R_STICK_Y].axis_type, … … 481 484 axis_value = mesg->l; 482 485 if (conf.amap[CONF_CC_AXIS_L].flags & CONF_INVERT) { 483 axis_value = WIIMOTE_CLASSIC_LR_MAX - axis_value;486 axis_value = CWIID_CLASSIC_LR_MAX - axis_value; 484 487 } 485 488 send_event(&conf, conf.amap[CONF_CC_AXIS_L].axis_type, … … 491 494 axis_value = mesg->r; 492 495 if (conf.amap[CONF_CC_AXIS_R].flags & CONF_INVERT) { 493 axis_value = WIIMOTE_CLASSIC_LR_MAX - axis_value;496 axis_value = CWIID_CLASSIC_LR_MAX - axis_value; 494 497 } 495 498 send_event(&conf, conf.amap[CONF_CC_AXIS_R].axis_type, … … 499 502 500 503 void process_plugin(struct plugin *plugin, int mesg_count, 501 union wiimote_mesg *mesg[])502 { 503 union wiimote_mesg *plugin_mesg[WIIMOTE_MAX_MESG_COUNT];504 union cwiid_mesg *mesg[]) 505 { 506 union cwiid_mesg *plugin_mesg[CWIID_MAX_MESG_COUNT]; 504 507 int plugin_mesg_count = 0; 505 508 int i; … … 511 514 for (i=0; i < mesg_count; i++) { 512 515 switch (mesg[i]->type) { 513 case WIIMOTE_MESG_STATUS:514 flag = WIIMOTE_RPT_STATUS;515 break; 516 case WIIMOTE_MESG_BTN:517 flag = WIIMOTE_RPT_BTN;518 break; 519 case WIIMOTE_MESG_ACC:520 flag = WIIMOTE_RPT_ACC;521 break; 522 case WIIMOTE_MESG_IR:523 flag = WIIMOTE_RPT_IR;524 break; 525 case WIIMOTE_MESG_NUNCHUK:526 flag = WIIMOTE_RPT_NUNCHUK;527 break; 528 case WIIMOTE_MESG_CLASSIC:529 flag = WIIMOTE_RPT_CLASSIC;516 case CWIID_MESG_STATUS: 517 flag = CWIID_RPT_STATUS; 518 break; 519 case CWIID_MESG_BTN: 520 flag = CWIID_RPT_BTN; 521 break; 522 case CWIID_MESG_ACC: 523 flag = CWIID_RPT_ACC; 524 break; 525 case CWIID_MESG_IR: 526 flag = CWIID_RPT_IR; 527 break; 528 case CWIID_MESG_NUNCHUK: 529 flag = CWIID_RPT_NUNCHUK; 530 break; 531 case CWIID_MESG_CLASSIC: 532 flag = CWIID_RPT_CLASSIC; 530 533 break; 531 534 default: -
wminput/plugins/acc/Makefile.in
rbdb6c21 r805477a 5 5 PLUGIN_NAME = acc 6 6 SOURCES = acc.c 7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/ wiimote7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid 8 8 LDLIBS += -lm 9 9 INST_DIR = $(CWIID_PLUGINS_DIR) -
wminput/plugins/acc/acc.c
rf200a0f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * initialized params … … 54 57 wmplugin_init_t wmplugin_init; 55 58 wmplugin_exec_t wmplugin_exec; 56 static void process_acc(struct wiimote_acc_mesg *mesg);59 static void process_acc(struct cwiid_acc_mesg *mesg); 57 60 58 61 struct wmplugin_info *wmplugin_info() { … … 102 105 } 103 106 104 int wmplugin_init(int id, wiimote_t *wiimote)107 int wmplugin_init(int id, cwiid_wiimote_t *wiimote) 105 108 { 106 109 unsigned char buf[7]; … … 111 114 data.axes[0].valid = 1; 112 115 data.axes[1].valid = 1; 113 if (wmplugin_set_report_mode(id, WIIMOTE_RPT_ACC)) {116 if (wmplugin_set_report_mode(id, CWIID_RPT_ACC)) { 114 117 return -1; 115 118 } 116 119 117 if ( wiimote_read(wiimote, WIIMOTE_RW_EEPROM, 0x16, 7, buf)) {120 if (cwiid_read(wiimote, CWIID_RW_EEPROM, 0x16, 7, buf)) { 118 121 wmplugin_err(id, "unable to read wiimote info"); 119 122 return -1; … … 129 132 } 130 133 131 struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[])134 struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg *mesg[]) 132 135 { 133 136 int i; … … 136 139 for (i=0; i < mesg_count; i++) { 137 140 switch (mesg[i]->type) { 138 case WIIMOTE_MESG_ACC:141 case CWIID_MESG_ACC: 139 142 process_acc(&mesg[i]->acc_mesg); 140 143 ret = &data; … … 152 155 double a_x = 0, a_y = 0, a_z = 0; 153 156 154 static void process_acc(struct wiimote_acc_mesg *mesg)157 static void process_acc(struct cwiid_acc_mesg *mesg) 155 158 { 156 159 double a; -
wminput/plugins/ir_ptr/Makefile.in
rbdb6c21 r805477a 5 5 PLUGIN_NAME = ir_ptr 6 6 SOURCES = ir_ptr.c 7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/ wiimote7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid 8 8 INST_DIR = $(CWIID_PLUGINS_DIR) 9 9 -
wminput/plugins/ir_ptr/ir_ptr.c
rf200a0f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * initialized param array … … 32 35 #include "wmplugin.h" 33 36 34 wiimote_t *wiimote;37 cwiid_wiimote_t *wiimote; 35 38 36 39 struct cursor { … … 43 46 /* static objects are initialized to 0 by default */ 44 47 static int a_index = -1, b_index = -1; 45 static struct wiimote_ir_src a, b, prev_a, prev_b;48 static struct cwiid_ir_src a, b, prev_a, prev_b; 46 49 47 50 static unsigned char info_init = 0; … … 77 80 } 78 81 79 int wmplugin_init(int id, wiimote_t *arg_wiimote)82 int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote) 80 83 { 81 84 wiimote = arg_wiimote; … … 83 86 data.buttons = 0; 84 87 85 if (wmplugin_set_report_mode(id, WIIMOTE_RPT_IR)) {88 if (wmplugin_set_report_mode(id, CWIID_RPT_IR)) { 86 89 return -1; 87 90 } … … 90 93 } 91 94 92 struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[])95 struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg *mesg[]) 93 96 { 94 97 int i; 95 98 uint8_t flags; 96 99 static uint8_t old_flags; 97 struct wiimote_ir_mesg *ir_mesg;100 struct cwiid_ir_mesg *ir_mesg; 98 101 99 102 ir_mesg = NULL; 100 103 for (i=0; i < mesg_count; i++) { 101 if (mesg[i]->type == WIIMOTE_MESG_IR) {104 if (mesg[i]->type == CWIID_MESG_IR) { 102 105 ir_mesg = &mesg[i]->ir_mesg; 103 106 } … … 123 126 /* of not set, pick largest available source for a & b */ 124 127 if (a_index == -1) { 125 for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) {128 for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 126 129 if ((ir_mesg->src[i].valid) && (i != b_index)) { 127 130 if ((a_index == -1) || … … 134 137 /* if there is no current src_b, pick the largest valid one */ 135 138 if (b_index == -1) { 136 for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) {139 for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 137 140 if ((ir_mesg->src[i].valid) && (i != a_index)) { 138 141 if ((b_index == -1) || … … 158 161 else { 159 162 a = ir_mesg->src[a_index]; 160 a.x = WIIMOTE_IR_X_MAX - a.x;163 a.x = CWIID_IR_X_MAX - a.x; 161 164 a_debounce = 0; 162 165 } … … 172 175 else { 173 176 b = ir_mesg->src[b_index]; 174 b.x = WIIMOTE_IR_X_MAX - b.x;177 b.x = CWIID_IR_X_MAX - b.x; 175 178 b_debounce = 0; 176 179 } … … 223 226 flags = 0; 224 227 if ((a_index == 1) || (b_index == 1)) { 225 flags |= WIIMOTE_LED1_ON;228 flags |= CWIID_LED1_ON; 226 229 } 227 230 else if ((a_index == 2) || (b_index == 2)) { 228 flags |= WIIMOTE_LED2_ON;231 flags |= CWIID_LED2_ON; 229 232 } 230 233 else if ((a_index == 3) || (b_index == 3)) { 231 flags |= WIIMOTE_LED3_ON;234 flags |= CWIID_LED3_ON; 232 235 } 233 236 else if ((a_index == 4) || (b_index == 4)) { 234 flags |= WIIMOTE_LED4_ON;237 flags |= CWIID_LED4_ON; 235 238 } 236 239 if (flags != old_flags) { 237 240 /* TODO: if this message is sent every time, we get a battery meter of 238 241 * blinking lights - why? */ 239 wiimote_command(wiimote, WIIMOTE_CMD_LED, flags);242 cwiid_command(wiimote, CWIID_CMD_LED, flags); 240 243 } 241 244 old_flags = flags; -
wminput/plugins/nunchuk_acc/Makefile.in
rbdb6c21 r805477a 5 5 PLUGIN_NAME = nunchuk_acc 6 6 SOURCES = nunchuk_acc.c 7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/ wiimote7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid 8 8 LDLIBS += -lm 9 9 INST_DIR = $(CWIID_PLUGINS_DIR) -
wminput/plugins/nunchuk_acc/nunchuk_acc.c
rf200a0f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * copied low-pass filter from acc plugin … … 45 48 static struct wmplugin_data data; 46 49 47 static wiimote_t *wiimote;50 static cwiid_wiimote_t *wiimote; 48 51 49 52 static struct acc acc_zero, acc_one; … … 54 57 wmplugin_exec_t wmplugin_exec; 55 58 56 static void process_nunchuk(struct wiimote_nunchuk_mesg *mesg);59 static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg); 57 60 58 61 struct wmplugin_info *wmplugin_info() { … … 102 105 } 103 106 104 int wmplugin_init(int id, wiimote_t *wiimote_arg)107 int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote) 105 108 { 106 109 plugin_id = id; 107 wiimote = wiimote_arg;110 wiimote = arg_wiimote; 108 111 data.buttons = 0; 109 112 data.axes[0].valid = 1; 110 113 data.axes[1].valid = 1; 111 114 if (wmplugin_set_report_mode(id, 112 WIIMOTE_RPT_STATUS | WIIMOTE_RPT_NUNCHUK)) {115 CWIID_RPT_STATUS | CWIID_RPT_NUNCHUK)) { 113 116 return -1; 114 117 } … … 117 120 } 118 121 119 struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[])122 struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg *mesg[]) 120 123 { 121 124 int i; 122 enum wiimote_ext_type extension = WIIMOTE_EXT_NONE;125 enum cwiid_ext_type extension = CWIID_EXT_NONE; 123 126 unsigned char buf[7]; 124 127 struct wmplugin_data *ret = NULL; … … 126 129 for (i=0; i < mesg_count; i++) { 127 130 switch (mesg[i]->type) { 128 case WIIMOTE_MESG_STATUS:129 if ((mesg[i]->status_mesg.extension == WIIMOTE_EXT_NUNCHUK) &&130 (extension != WIIMOTE_EXT_NUNCHUK)) {131 if ( wiimote_read(wiimote, WIIMOTE_RW_REG | WIIMOTE_RW_DECODE,131 case CWIID_MESG_STATUS: 132 if ((mesg[i]->status_mesg.extension == CWIID_EXT_NUNCHUK) && 133 (extension != CWIID_EXT_NUNCHUK)) { 134 if (cwiid_read(wiimote, CWIID_RW_REG | CWIID_RW_DECODE, 132 135 0xA40020, 7, buf)) { 133 136 wmplugin_err(plugin_id, "unable to read wiimote info"); … … 142 145 extension = mesg[i]->status_mesg.extension; 143 146 break; 144 case WIIMOTE_MESG_NUNCHUK:147 case CWIID_MESG_NUNCHUK: 145 148 process_nunchuk(&mesg[i]->nunchuk_mesg); 146 149 ret = &data; … … 158 161 double a_x = 0, a_y = 0, a_z = 0; 159 162 160 static void process_nunchuk(struct wiimote_nunchuk_mesg *mesg)163 static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg) 161 164 { 162 165 double a; -
wminput/uinput.c
re39b37a r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@anstrakraft.org> 19 22 * * fixed signed/unsigned comparison warning in uinput_open … … 256 259 wminput_err("Error on ff upload begin"); 257 260 } 258 if ( wiimote_command(data->wiimote, WIIMOTE_CMD_RUMBLE, 1)) {261 if (cwiid_command(data->wiimote, CWIID_CMD_RUMBLE, 1)) { 259 262 wminput_err("Error setting rumble"); 260 263 } … … 268 271 wminput_err("Error on ff erase begin"); 269 272 } 270 if ( wiimote_command(data->wiimote, WIIMOTE_CMD_RUMBLE, 0)) {273 if (cwiid_command(data->wiimote, CWIID_CMD_RUMBLE, 0)) { 271 274 wminput_err("Error clearing rumble"); 272 275 } -
wminput/wmplugin.h
rf200a0f r805477a 16 16 * 17 17 * ChangeLog: 18 * 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 19 * * updated for libcwiid rename 20 * 18 21 * 2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 19 22 * * added param structs … … 29 32 #include <stdint.h> 30 33 #include <linux/input.h> 31 #include < wiimote.h>34 #include <cwiid.h> 32 35 33 36 #define WMPLUGIN_MAX_BUTTON_COUNT 16 … … 87 90 88 91 typedef struct wmplugin_info *wmplugin_info_t(void); 89 typedef int wmplugin_init_t(int, wiimote_t *);90 typedef struct wmplugin_data *wmplugin_exec_t(int, union wiimote_mesg * []);92 typedef int wmplugin_init_t(int, cwiid_wiimote_t *); 93 typedef struct wmplugin_data *wmplugin_exec_t(int, union cwiid_mesg * []); 91 94 92 95 int wmplugin_set_report_mode(int id, uint8_t flags);
