Changeset 805477a3e8c4bccbd90c78e829870267c783904b

Show
Ignore:
Timestamp:
04/11/07 02:57:27 (6 years ago)
Author:
dsmith <dsmith@…>
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)
Message:

Merge libcwiid rename into trunk

git-svn-id: http://abstrakraft.org/cwiid/svn/trunk@83 918edb2d-ff29-0410-9de2-eb38e7f22bc7

Files:
1 added
1 removed
23 modified
10 moved

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rf200a0f r805477a  
     12007-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 
    1182007-04-08 Arthur Peters <amp@singingwizard.org> 
    219        wminput 
  • Makefile.in

    r416f60e r805477a  
    33include @top_builddir@/defs.mak 
    44 
    5 LIB_DIRS = wiimote 
     5LIB_DIRS = libcwiid 
    66BIN_DIRS = wmgui wminput lswm 
    77DOC_DIRS = man doc 
  • README

    r52f7c50 r805477a  
    2323------------------------------------------------------------------------------------------------ 
    2424The CWiid package contains the following parts: 
    25 1.wiimote library - API to the wiimote. 
     251.libcwiid - wiimote API. 
    26262.wmgui - GTK gui to the wiimote. 
    27273.wminput - an event/joystick/mouse driver for the wiimote. 
  • configure.ac

    r347f3c9 r805477a  
    11# ChangeLog: 
     2# 2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     3# * updated for libcwiid rename 
     4# 
    25# 2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    36# * removed --noyywrap from lex 
     
    9396        [doc/Makefile] 
    9497        [man/Makefile] 
    95         [wiimote/Makefile] 
     98        [libcwiid/Makefile] 
    9699        [wmdemo/Makefile] 
    97100        [wmgui/Makefile] 
  • libcwiid/Makefile.in

    rbdb6c21 r805477a  
    33include @top_builddir@/defs.mak 
    44 
    5 LIB_NAME = wiimote 
     5LIB_NAME = cwiid 
    66MAJOR_VER = 0 
    77MINOR_VER = 1 
  • libcwiid/bluetooth.c

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-04-07 L. Donnie Smith <cwiid@abstrakraft.org> 
    19  *  * changed wiimote_info.class to btclass 
     22 *  * changed cwiid_info.class to btclass 
    2023 * 
    2124 *  2007-04-03 L. Donnie Smith <cwiid@abstrakraft.org> 
    22  *  * fixed wiimote_find_wiimote seg fault 
     25 *  * fixed cwiid_find_wiimote seg fault 
    2326 * 
    2427 *  2007-04-02 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    3437#include <bluetooth/hci.h> 
    3538#include <bluetooth/hci_lib.h> 
    36 #include "wiimote_internal.h" 
     39#include "cwiid_internal.h" 
    3740 
    3841/* When filtering wiimotes, in order to avoid having to store the 
     
    4346#define BT_MAX_INQUIRY 256 
    4447/* 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) 
     48int cwiid_get_bdinfo_array(int dev_id, unsigned int timeout, int max_bdinfo, 
     49                           struct cwiid_bdinfo **bdinfo, uint8_t flags) 
    4750{ 
    4851        /* TODO: I suppose we'll have to sift through BlueZ source to properly 
     
    5356        int dev_count; 
    5457        int sock = -1; 
    55         int wm_count; 
     58        int bdinfo_count; 
    5659        int i, j; 
    5760        int err = 0; 
     
    5962 
    6063        /* NULLify for the benefit of error handling */ 
    61         *wm = NULL; 
     64        *bdinfo = NULL; 
    6265 
    6366        /* If not given (=-1), get the first available Bluetooth interface */ 
    6467        if (dev_id == -1) { 
    6568                if ((dev_id = hci_get_route(NULL)) == -1) { 
    66                         wiimote_err(NULL, "No Bluetooth interface found"); 
     69                        cwiid_err(NULL, "No Bluetooth interface found"); 
    6770                        return -1; 
    6871                } 
     
    7073 
    7174        /* 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; 
    7477        } 
    7578        else { 
     
    7881        if ((dev_count = hci_inquiry(dev_id, timeout, max_inquiry, NULL, 
    7982                                     &dev_list, IREQ_CACHE_FLUSH)) == -1) { 
    80                 wiimote_err(NULL, "Error on bluetooth device inquiry"); 
     83                cwiid_err(NULL, "Error on bluetooth device inquiry"); 
    8184                err = 1; 
    8285                goto CODA; 
     
    8487 
    8588        if (dev_count == 0) { 
    86                 wm_count = 0; 
     89                bdinfo_count = 0; 
    8790                goto CODA; 
    8891        } 
     
    9093        /* Open connection to Bluetooth Interface */ 
    9194        if ((sock = hci_open_dev(dev_id)) == -1) { 
    92                 wiimote_err(NULL, "Error opening Bluetooth interface"); 
     95                cwiid_err(NULL, "Error opening Bluetooth interface"); 
    9396                err = 1; 
    9497                goto CODA; 
     
    9699 
    97100        /* Allocate info list */ 
    98         if (max_wm == -1) { 
    99                 max_wm = dev_count; 
     101        if (max_bdinfo == -1) { 
     102                max_bdinfo = dev_count; 
    100103        } 
    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"); 
    103106                err = 1; 
    104107                goto CODA; 
    105108        } 
    106109 
    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++) { 
    109113                /* 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"); 
    113117                        err = 1; 
    114118                        goto CODA; 
     
    119123                   (dev_list[i].dev_class[1] != WIIMOTE_CLASS_1) || 
    120124                   (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)))) { 
    122127                        continue; 
    123128                } 
    124                 bacpy(&(*wm)[wm_count].bdaddr, &dev_list[i].bdaddr); 
     129                bacpy(&(*bdinfo)[bdinfo_count].bdaddr, &dev_list[i].bdaddr); 
    125130                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]; 
    127132                } 
    128                 wm_count++; 
     133                bdinfo_count++; 
    129134        } 
    130135 
    131         if (wm_count == 0) { 
    132                 free(*wm); 
     136        if (bdinfo_count == 0) { 
     137                free(*bdinfo); 
    133138        } 
    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"); 
    137143                        err = 1; 
    138144                        goto CODA; 
     
    144150        if (sock != -1) hci_close_dev(sock); 
    145151        if (err) { 
    146                 if (*wm) free(*wm); 
     152                if (*bdinfo) free(*bdinfo); 
    147153                ret = -1; 
    148154        } 
    149155        else { 
    150                 ret = wm_count; 
     156                ret = bdinfo_count; 
    151157        } 
    152158        return ret; 
    153159} 
    154160 
    155 int wiimote_find_wiimote(bdaddr_t *bdaddr, int timeout) 
     161int cwiid_find_wiimote(bdaddr_t *bdaddr, int timeout) 
    156162{ 
    157         struct wiimote_info *wm; 
    158         int wm_count; 
     163        struct cwiid_bdinfo *bdinfo; 
     164        int bdinfo_count; 
    159165 
    160166        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) { 
    163170                        return -1; 
    164171                } 
    165172        } 
    166173        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) { 
    169176                        return -1; 
    170177                } 
    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"); 
    173180                        return -1; 
    174181                } 
    175182        } 
    176183 
    177         bacpy(bdaddr, &wm[0].bdaddr); 
    178         free(wm); 
     184        bacpy(bdaddr, &bdinfo[0].bdaddr); 
     185        free(bdinfo); 
    179186        return 0; 
    180187} 
  • libcwiid/command.c

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * audited error checking (coda and error handler sections) 
     
    2124 * 
    2225 *  2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 
    23  *  * added wiimote parameter to wiimote_err calls 
     26 *  * added wiimote parameter to cwiid_err calls 
    2427 * 
    2528 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    3033#include <stdint.h> 
    3134#include <unistd.h> 
    32 #include "wiimote_internal.h" 
     35#include "cwiid_internal.h" 
    3336 
    3437/* IR Sensitivity Block */ 
     
    3942        {WRITE_SEQ_RPT, RPT_IR_ENABLE1, (const void *)"\x04", 1, 0}, 
    4043        {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} 
    4548}; 
    4649 
     
    4851        {WRITE_SEQ_RPT, RPT_IR_ENABLE1, (const void *)"\x04", 1, 0}, 
    4952        {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} 
    5457}; 
    5558 
     
    6063 
    6164#define CMD_BUF_LEN     21 
    62 int wiimote_command(struct wiimote *wiimote, enum wiimote_command command, 
    63                     uint8_t flags) { 
     65int cwiid_command(struct wiimote *wiimote, enum cwiid_command command, 
     66                  uint8_t flags) { 
    6467        int ret = 0; 
    6568        unsigned char buf[CMD_BUF_LEN]; 
    6669 
    6770        switch (command) { 
    68         case WIIMOTE_CMD_STATUS: 
     71        case CWIID_CMD_STATUS: 
    6972                buf[0] = 0; 
    7073                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: 
    7679                wiimote->led_rumble_state = ((flags & 0x0F)<<4) | 
    7780                                            (wiimote->led_rumble_state & 0x01); 
    7881                buf[0]=wiimote->led_rumble_state; 
    7982                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: 
    8588                wiimote->led_rumble_state = (wiimote->led_rumble_state & 0xFE) | 
    8689                                            (flags ? 1 : 0); 
    8790                buf[0]=wiimote->led_rumble_state; 
    8891                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: 
    9497                update_rpt_mode(wiimote, flags); 
    9598                break; 
    9699        default: 
    97                 wiimote_err(wiimote, "Unknown command"); 
     100                cwiid_err(wiimote, "Unknown command"); 
    98101                ret = -1; 
    99102                break; 
     
    114117        /* Lock wiimote access */ 
    115118        if (pthread_mutex_lock(&wiimote->wiimote_mutex)) { 
    116                 wiimote_err(wiimote, "Error locking rw_mutex"); 
     119                cwiid_err(wiimote, "Error locking wiimote_mutex"); 
    117120                ret = -1; 
    118121                goto CODA; 
     
    125128 
    126129        /* 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)) { 
    132135                        rpt_mode = RPT_BTN_ACC_IR10_EXT6; 
    133136                        ir_enable_seq = ir_enable10_seq; 
    134137                        seq_len = SEQ_LEN(ir_enable10_seq); 
    135138                } 
    136                 else if (flags & WIIMOTE_RPT_IR) { 
     139                else if (flags & CWIID_RPT_IR) { 
    137140                        rpt_mode = RPT_BTN_IR10_EXT9; 
    138141                        ir_enable_seq = ir_enable10_seq; 
    139142                        seq_len = SEQ_LEN(ir_enable10_seq); 
    140143                } 
    141                 else if (flags & WIIMOTE_RPT_ACC) { 
     144                else if (flags & CWIID_RPT_ACC) { 
    142145                        rpt_mode = RPT_BTN_ACC_EXT16; 
    143146                } 
    144                 else if (flags & WIIMOTE_RPT_BTN) { 
     147                else if (flags & CWIID_RPT_BTN) { 
    145148                        rpt_mode = RPT_BTN_EXT8; 
    146149                } 
     
    150153        } 
    151154        else { 
    152                 if (flags & WIIMOTE_RPT_IR) { 
     155                if (flags & CWIID_RPT_IR) { 
    153156                        rpt_mode = RPT_BTN_ACC_IR12; 
    154157                        ir_enable_seq = ir_enable12_seq; 
    155158                        seq_len = SEQ_LEN(ir_enable12_seq); 
    156159                } 
    157                 else if (flags & WIIMOTE_RPT_ACC) { 
     160                else if (flags & CWIID_RPT_ACC) { 
    158161                        rpt_mode = RPT_BTN_ACC; 
    159162                } 
     
    165168        /* Enable IR */ 
    166169        /* TODO: only do this when necessary (record old IR mode) */ 
    167         if ((flags & WIIMOTE_RPT_IR)) { 
     170        if ((flags & CWIID_RPT_IR)) { 
    168171                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"); 
    170173                        ret = -1; 
    171174                        goto CODA; 
     
    173176        } 
    174177        /* 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)) { 
    177180                if (exec_write_seq(wiimote, SEQ_LEN(ir_disable_seq), 
    178181                                   ir_disable_seq)) { 
    179                         wiimote_err(wiimote, "Error on IR enable"); 
     182                        cwiid_err(wiimote, "Error on IR enable"); 
    180183                        ret = -1; 
    181184                        goto CODA; 
     
    187190        buf[1]=rpt_mode; 
    188191        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"); 
    190193                ret = -1; 
    191194                goto CODA; 
     
    195198 
    196199CODA: 
    197         /* Unlock wiimote_mutex */ 
     200        /* Unlock cwiid_mutex */ 
    198201        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"); 
    201203        } 
    202204 
  • libcwiid/connect.c

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    19  *  * cancel rw operations from wiimote_disconnect 
     22 *  * cancel rw operations from cwiid_disconnect 
    2023 * 
    2124 *  2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> 
    22  *  * wiimote_connect now takes a pointer to bdaddr_t 
    23  *  * changed wiimote_findfirst to wiimote_find_wiimote 
     25 *  * cwiid_connect now takes a pointer to bdaddr_t 
     26 *  * changed cwiid_findfirst to cwiid_find_wiimote 
    2427 * 
    2528 *  2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    2932 * 
    3033 *  2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 
    31  *  * added wiimote parameter to wiimote_err calls 
     34 *  * added wiimote parameter to cwiid_err calls 
    3235 * 
    3336 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    4346#include <bluetooth/bluetooth.h> 
    4447#include <bluetooth/l2cap.h> 
    45 #include "wiimote_internal.h" 
     48#include "cwiid_internal.h" 
    4649#include "queue.h" 
    4750 
     
    4952static int wiimote_id = 0; 
    5053 
    51 wiimote_t *wiimote_connect(bdaddr_t *bdaddr, 
    52                            wiimote_mesg_callback_t *mesg_callback, int *id) 
     54cwiid_wiimote_t *cwiid_connect(bdaddr_t *bdaddr, 
     55                               cwiid_mesg_callback_t *mesg_callback, int *id) 
    5356{ 
    5457        struct wiimote *wiimote = NULL; 
     
    5760        /* Allocate wiimote */ 
    5861        if ((wiimote = malloc(sizeof *wiimote)) == NULL) { 
    59                 wiimote_err(NULL, "Error allocating wiimote"); 
     62                cwiid_err(NULL, "Error allocating cwiid_wiimote"); 
    6063                goto ERR_HND; 
    6164        } 
     
    6871        /* Global Lock, Store and Increment wiimote_id */ 
    6972        if (pthread_mutex_lock(&global_mutex)) { 
    70                 wiimote_err(NULL, "Error locking global lock"); 
     73                cwiid_err(NULL, "Error locking global lock"); 
    7174                goto ERR_HND; 
    7275        } 
    7376        wiimote->id = wiimote_id++; 
    7477        if (pthread_mutex_unlock(&global_mutex)) { 
    75                 wiimote_err(wiimote, "Error unlocking global lock"); 
     78                cwiid_err(wiimote, "Error unlocking global lock"); 
    7679                goto ERR_HND; 
    7780        } 
     
    8689        /* If BDADDR_ANY is given, find available wiimote */ 
    8790        if (bacmp(bdaddr, BDADDR_ANY) == 0) { 
    88                 if (wiimote_find_wiimote(bdaddr, 2)) { 
     91                if (cwiid_find_wiimote(bdaddr, 2)) { 
    8992                        goto ERR_HND; 
    9093                } 
     
    105108        if ((wiimote->ctl_socket = 
    106109          socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1) { 
    107                 wiimote_err(wiimote, "Error opening control socket"); 
     110                cwiid_err(wiimote, "Error opening control socket"); 
    108111                goto ERR_HND; 
    109112        } 
    110113        if ((wiimote->int_socket = 
    111114          socket(AF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP)) == -1) { 
    112                 wiimote_err(wiimote, "Error opening interrupt socket"); 
     115                cwiid_err(wiimote, "Error opening interrupt socket"); 
    113116                goto ERR_HND; 
    114117        } 
     
    117120        if (connect(wiimote->ctl_socket, (struct sockaddr *)&ctl_remote_addr, 
    118121                        sizeof(ctl_remote_addr))) { 
    119                 wiimote_err(wiimote, "Error opening control channel"); 
     122                cwiid_err(wiimote, "Error opening control channel"); 
    120123                goto ERR_HND; 
    121124        } 
    122125        if (connect(wiimote->int_socket, (struct sockaddr *)&int_remote_addr, 
    123126                        sizeof(int_remote_addr))) { 
    124                 wiimote_err(wiimote, "Error opening interrupt channel"); 
     127                cwiid_err(wiimote, "Error opening interrupt channel"); 
    125128                goto ERR_HND; 
    126129        } 
     
    128131        /* Create Dispatch Queue */ 
    129132        if ((wiimote->dispatch_queue = queue_new()) == NULL) { 
    130                 wiimote_err(wiimote, "Error creating dispatch queue"); 
     133                cwiid_err(wiimote, "Error creating dispatch queue"); 
    131134                goto ERR_HND; 
    132135        } 
     
    138141          pthread_cond_init(&wiimote->rw_cond, NULL) || 
    139142          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"); 
    142144                goto ERR_HND; 
    143145        } 
     
    150152        if (pthread_create(&wiimote->int_listen_thread, NULL, 
    151153                           (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"); 
    154155                goto ERR_HND; 
    155156        } 
     
    158159                pthread_cancel(wiimote->int_listen_thread); 
    159160                pthread_join(wiimote->int_listen_thread, NULL); 
    160                 wiimote_err(wiimote, "Error creating dispatch thread"); 
     161                cwiid_err(wiimote, "Error creating dispatch thread"); 
    161162                goto ERR_HND; 
    162163        } 
     
    165166        wiimote->buttons = 0; 
    166167        wiimote->rpt_mode_flags = 0; 
    167         wiimote->extension = WIIMOTE_EXT_NONE; 
     168        wiimote->extension = CWIID_EXT_NONE; 
    168169        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); 
    171172 
    172173        return wiimote; 
     
    180181                if (wiimote->int_socket != -1) { 
    181182                        if (close(wiimote->int_socket)) { 
    182                                 wiimote_err(wiimote, "Error closing interrupt channel"); 
     183                                cwiid_err(wiimote, "Error closing interrupt channel"); 
    183184                        } 
    184185                } 
    185186                if (wiimote->ctl_socket != -1) { 
    186187                        if (close(wiimote->ctl_socket)) { 
    187                                 wiimote_err(wiimote, "Error closing control channel"); 
     188                                cwiid_err(wiimote, "Error closing control channel"); 
    188189                        } 
    189190                } 
     
    193194} 
    194195 
    195 int wiimote_disconnect(struct wiimote *wiimote) 
     196int cwiid_disconnect(struct wiimote *wiimote) 
    196197{ 
    197198        void *pthread_ret; 
     
    200201        if (pthread_cancel(wiimote->int_listen_thread)) { 
    201202                /* 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"); */ 
    203204        } 
    204205        else { 
    205206                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"); 
    207208                } 
    208209                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"); 
    211211                } 
    212212        } 
     
    215215        wiimote->rw_error = 1; 
    216216        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"); 
    218218        } 
    219219        else { 
    220220                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"); 
    222222                } 
    223223                if (pthread_mutex_unlock( 
    224224                  &wiimote->rw_cond_mutex)) { 
    225                         wiimote_err(wiimote, "Error unlocking rw_cond_mutex"); 
     225                        cwiid_err(wiimote, "Error unlocking rw_cond_mutex"); 
    226226                } 
    227227        } 
    228228 
    229229        /* Cancel and detach dispatch_thread */ 
    230         /* We detach to decouple dispatch (which runs the callback) from wiimote 
     230        /* We detach to decouple dispatch (which runs the callback) from callback 
    231231         * code - specifically, a race condition exists for gtk apps */ 
    232232        if (pthread_cancel(wiimote->dispatch_thread)) { 
    233                 wiimote_err(wiimote, "Error canceling dispatch_thread"); 
     233                cwiid_err(wiimote, "Error canceling dispatch_thread"); 
    234234        } 
    235235        if (pthread_detach(wiimote->dispatch_thread)) { 
    236                 wiimote_err(wiimote, "Error detaching dispatch_thread"); 
     236                cwiid_err(wiimote, "Error detaching dispatch_thread"); 
    237237        } 
    238238 
    239239        /* Close sockets */ 
    240240        if (close(wiimote->int_socket)) { 
    241                 wiimote_err(wiimote, "Error closing interrupt channel"); 
     241                cwiid_err(wiimote, "Error closing interrupt channel"); 
    242242        } 
    243243        if (close(wiimote->ctl_socket)) { 
    244                 wiimote_err(wiimote, "Error closing control channel"); 
     244                cwiid_err(wiimote, "Error closing control channel"); 
    245245        } 
    246246 
     
    251251        /* Destroy sync variables */ 
    252252        if (pthread_mutex_destroy(&wiimote->wiimote_mutex)) { 
    253                 wiimote_err(wiimote, "Error destroying wiimote_mutex"); 
     253                cwiid_err(wiimote, "Error destroying cwiid_mutex"); 
    254254        } 
    255255        if (pthread_mutex_destroy(&wiimote->rw_mutex)) { 
    256                 wiimote_err(wiimote, "Error destroying rw_mutex"); 
     256                cwiid_err(wiimote, "Error destroying rw_mutex"); 
    257257        } 
    258258        if (pthread_cond_destroy(&wiimote->rw_cond)) { 
    259                 wiimote_err(wiimote, "Error destroying rw_cond"); 
     259                cwiid_err(wiimote, "Error destroying rw_cond"); 
    260260        } 
    261261        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"); 
    263263        } 
    264264 
  • libcwiid/cwiid_internal.h

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * moved RW error state to separate member 
    2023 * 
    2124 *  2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> 
    22  *  * removed WIIMOTE_CMP_LEN macro and wiimote_findfirst prototype 
     25 *  * removed CWIID_CMP_LEN macro and cwiid_findfirst prototype 
    2326 * 
    2427 *  2007-03-05 L. Donnie Smith <cwiid@abstrakraft.org> 
    25  *  * added wiimote parameter to wiimote_err prototype 
     28 *  * added wiimote parameter to cwiid_err prototype 
    2629 * 
    2730 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    3033 */ 
    3134 
    32 #ifndef WIIMOTE_INTERNAL_H 
    33 #define WIIMOTE_INTERNAL_H 
     35#ifndef CWIID_INTERNAL_H 
     36#define CWIID_INTERNAL_H 
    3437 
    3538#include <stdint.h> 
    3639#include <pthread.h> 
    37 #include "wiimote.h" 
     40#include "cwiid.h" 
    3841 
    3942/* Bluetooth magic numbers */ 
     
    140143struct mesg_array { 
    141144        int count; 
    142         union wiimote_mesg *mesg[WIIMOTE_MAX_MESG_COUNT]; 
     145        union cwiid_mesg *mesg[CWIID_MAX_MESG_COUNT]; 
    143146}; 
    144147 
     
    150153        uint8_t rpt_mode_flags; 
    151154        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; 
    154157        pthread_t int_listen_thread; 
    155158        pthread_t dispatch_thread; 
     
    172175int update_rpt_mode(struct wiimote *wiimote, int8_t flags); 
    173176 
    174 void wiimote_err(struct wiimote *wiimote, const char *str, ...); 
     177void cwiid_err(struct wiimote *wiimote, const char *str, ...); 
    175178int verify_handshake(struct wiimote *wiimote); 
    176179int send_report(struct wiimote *wiimote, uint8_t flags, uint8_t report, 
  • libcwiid/event.c

    r2547e8f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * fixed incompatible pointer warning in process_error 
     
    3336 * 
    3437 *  2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 
    35  *  * added wiimote parameter to wiimote_err calls 
     38 *  * added wiimote parameter to cwiid_err calls 
    3639 * 
    3740 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    6366 * GTK continues to provide an ample testbed for deadlocks.  In order to 
    6467 * 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_disconnect 
     68 * cwiid_disconnect detaches the dispatch thread rather than joins it. 
     69 * To maintain isolation, it is impossible to synchronize cwiid_disconnect 
    6770 * and the dispatch thread, so dispatch destroys it's own synchronization 
    68  * variables.  In order to be sure this doesn't happen after wiimote_disconnect 
     71 * variables.  In order to be sure this doesn't happen after cwiid_disconnect 
    6972 * has freed the memory allocated for those variables, the wiimote struct holds 
    7073 * pointers to variables, which dispatch copies on entry.  As the complexity 
     
    105108#include <pthread.h> 
    106109#include <unistd.h> 
    107 #include "wiimote_internal.h" 
     110#include "cwiid_internal.h" 
    108111#include "queue.h" 
    109112 
    110113/* process_* messages (except read and write ) allocate and fill in 
    111  * wiimote_*_mesg structs from raw wiimote data.  Messages are then 
     114 * cwiid_*_mesg structs from raw wiimote data.  Messages are then 
    112115 * placed at the end of mesg_array. */ 
    113116 
     
    127130 
    128131/* process_read and process_write handle copying data between wiimote buffers 
    129  * and r/w buffers, as well as communication between wiimote_read or 
    130  * wiimote_write */ 
     132 * and r/w buffers, as well as communication between cwiid_read or 
     133 * cwiid_write */ 
    131134static int process_read(struct wiimote *, unsigned char *); 
    132135static int process_write(struct wiimote *); 
     
    151154                        /* Verify first byte (DATA/INPUT) */ 
    152155                        if (buf[0] != (BT_TRANS_DATA | BT_PARAM_INPUT)) { 
    153                                 wiimote_err(wiimote, "Invalid packet type"); 
     156                                cwiid_err(wiimote, "Invalid packet type"); 
    154157                        } 
    155158 
     
    167170                        case RPT_EXT21: 
    168171                                if ((mesg_array = malloc(sizeof *mesg_array)) == NULL) { 
    169                                         wiimote_err(wiimote, "Error allocating mesg array"); 
     172                                        cwiid_err(wiimote, "Error allocating mesg array"); 
    170173                                        break; 
    171174                                } 
     
    243246                                        if (queue_queue(wiimote->dispatch_queue, mesg_array)) { 
    244247                                                free_mesg_array(mesg_array); 
    245                                                 wiimote_err(wiimote, "error dispatching mesg array"); 
     248                                                cwiid_err(wiimote, "error dispatching mesg array"); 
    246249                                        } 
    247250                                } 
     
    249252                        case RPT_BTN_ACC_IR36_1: 
    250253                        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)"); 
    253256                                break; 
    254257                        case RPT_READ_DATA: 
     
    260263                                break; 
    261264                        default: 
    262                                 wiimote_err(wiimote, "Unknown message type"); 
     265                                cwiid_err(wiimote, "Unknown message type"); 
    263266                                break; 
    264267                        } 
     
    272275{ 
    273276        struct mesg_array *mesg_array; 
    274         struct wiimote_error_mesg *error_mesg; 
     277        struct cwiid_error_mesg *error_mesg; 
    275278        int ret = 0; 
    276279 
    277280        /* Error message */ 
    278281        if (len == 0) { 
    279                 wiimote_err(wiimote, "Disconnect"); 
     282                cwiid_err(wiimote, "Disconnect"); 
    280283        } 
    281284        else { 
    282                 wiimote_err(wiimote, "Interrupt channel read error"); 
     285                cwiid_err(wiimote, "Interrupt channel read error"); 
    283286        } 
    284287 
    285288        if ((mesg_array = malloc(sizeof *mesg_array)) == NULL) { 
    286                 wiimote_err(wiimote, "Error allocating mesg array"); 
     289                cwiid_err(wiimote, "Error allocating mesg array"); 
    287290                ret = -1; 
    288291                goto SKIP_QUEUE_MESG; 
     
    290293        mesg_array->count = 1; 
    291294        if ((error_mesg = malloc(sizeof *error_mesg)) == NULL) { 
    292                 wiimote_err(wiimote, "Error allocating error message"); 
     295                cwiid_err(wiimote, "Error allocating error message"); 
    293296                ret = -1; 
    294297                goto SKIP_QUEUE_MESG; 
    295298        } 
    296         error_mesg->type = WIIMOTE_MESG_ERROR; 
     299        error_mesg->type = CWIID_MESG_ERROR; 
    297300        if (len == 0) { 
    298                 error_mesg->error = WIIMOTE_ERROR_DISCONNECT; 
     301                error_mesg->error = CWIID_ERROR_DISCONNECT; 
    299302        } 
    300303        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; 
    304307        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"); 
    306309                ret = -1; 
    307310        } 
    308311        if (queue_queue(wiimote->dispatch_queue, mesg_array)) { 
    309312                free_mesg_array(mesg_array); 
    310                 wiimote_err(wiimote, "error dispatching mesg array"); 
     313                cwiid_err(wiimote, "error dispatching mesg array"); 
    311314                ret = -1; 
    312315        } 
     
    317320        wiimote->rw_error = 1; 
    318321        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"); 
    320323                ret = -1; 
    321324        } 
    322325        else { 
    323326                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"); 
    325328                        ret = -1; 
    326329                } 
    327330                if (pthread_mutex_unlock( 
    328331                  &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"); 
    331334                        ret = -1; 
    332335                } 
     
    339342                          struct mesg_array *mesg_array) 
    340343{ 
    341         struct wiimote_status_mesg *mesg; 
     344        struct cwiid_status_mesg *mesg; 
    342345 
    343346        if ((mesg = malloc(sizeof *mesg)) == NULL) { 
    344                 wiimote_err(wiimote, "Error allocating status mesg"); 
     347                cwiid_err(wiimote, "Error allocating status mesg"); 
    345348                return -1; 
    346349        } 
    347350 
    348         mesg->type = WIIMOTE_MESG_STATUS; 
     351        mesg->type = CWIID_MESG_STATUS; 
    349352        mesg->battery = data[5]; 
    350353        if (data[2] & 0x02) { 
    351354                /* dispatch will figure out what it is */ 
    352                 mesg->extension = WIIMOTE_EXT_UNKNOWN; 
     355                mesg->extension = CWIID_EXT_UNKNOWN; 
    353356        } 
    354357        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; 
    359362        mesg_array->count++; 
    360363 
     
    365368                       struct mesg_array *mesg_array) 
    366369{ 
    367         struct wiimote_btn_mesg *mesg; 
     370        struct cwiid_btn_mesg *mesg; 
    368371        uint16_t buttons; 
    369372 
     
    373376                wiimote->buttons = buttons; 
    374377 
    375                 if (wiimote->rpt_mode_flags & WIIMOTE_RPT_BTN) { 
     378                if (wiimote->rpt_mode_flags & CWIID_RPT_BTN) { 
    376379                        if ((mesg = malloc(sizeof *mesg)) == NULL) { 
    377                                 wiimote_err(wiimote, "Error allocating btn mesg"); 
     380                                cwiid_err(wiimote, "Error allocating btn mesg"); 
    378381                                return -1; 
    379382                        } 
    380                         mesg->type = WIIMOTE_MESG_BTN; 
     383                        mesg->type = CWIID_MESG_BTN; 
    381384                        mesg->buttons = buttons; 
    382385 
    383                         mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg; 
     386                        mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 
    384387                        mesg_array->count++; 
    385388                } 
     
    392395                       struct mesg_array *mesg_array) 
    393396{ 
    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) { 
    397400                if ((mesg = malloc(sizeof *mesg)) == NULL) { 
    398                         wiimote_err(wiimote, "Error allocating acc mesg"); 
     401                        cwiid_err(wiimote, "Error allocating acc mesg"); 
    399402                        return -1; 
    400403                } 
    401                 mesg->type = WIIMOTE_MESG_ACC; 
     404                mesg->type = CWIID_MESG_ACC; 
    402405                mesg->x = data[0]; 
    403406                mesg->y = data[1]; 
    404407                mesg->z = data[2]; 
    405408 
    406                 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg; 
     409                mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 
    407410                mesg_array->count++; 
    408411        } 
     
    414417                        struct mesg_array *mesg_array) 
    415418{ 
    416         struct wiimote_ir_mesg *mesg; 
     419        struct cwiid_ir_mesg *mesg; 
    417420        int i; 
    418421        const unsigned char *block; 
    419422 
    420         if (wiimote->rpt_mode_flags & WIIMOTE_RPT_IR) { 
     423        if (wiimote->rpt_mode_flags & CWIID_RPT_IR) { 
    421424                if ((mesg = malloc(sizeof *mesg)) == NULL) { 
    422                         wiimote_err(wiimote, "Error allocating ir mesg"); 
     425                        cwiid_err(wiimote, "Error allocating ir mesg"); 
    423426                        return -1; 
    424427                } 
    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) { 
    428431                        if (block[0] == 0xFF) { 
    429432                                mesg->src[i].valid = 0; 
     
    451454                } 
    452455 
    453                 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg; 
     456                mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 
    454457                mesg_array->count++; 
    455458        } 
     
    461464                        struct mesg_array *mesg_array) 
    462465{ 
    463         struct wiimote_ir_mesg *mesg; 
     466        struct cwiid_ir_mesg *mesg; 
    464467        int i; 
    465468        const unsigned char *block; 
    466469 
    467         if (wiimote->rpt_mode_flags & WIIMOTE_RPT_IR) { 
     470        if (wiimote->rpt_mode_flags & CWIID_RPT_IR) { 
    468471                if ((mesg = malloc(sizeof *mesg)) == NULL) { 
    469                         wiimote_err(wiimote, "Error allocating ir mesg"); 
     472                        cwiid_err(wiimote, "Error allocating ir mesg"); 
    470473                        return -1; 
    471474                } 
    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) { 
    475478                        if (block[0] == 0xFF) { 
    476479                                mesg->src[i].valid = 0; 
     
    486489                } 
    487490 
    488                 mesg_array->mesg[mesg_array->count] = (union wiimote_mesg *)mesg; 
     491                mesg_array->mesg[mesg_array->count] = (union cwiid_mesg *)mesg; 
    489492                mesg_array->count++; 
    490493        } 
     
    496499                       unsigned char len, struct mesg_array *mesg_array) 
    497500{ 
    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; 
    500503        int i; 
    501504 
    502505        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"); 
    506509                break; 
    507         case WIIMOTE_EXT_UNKNOWN: 
     510        case CWIID_EXT_UNKNOWN: 
    508511                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) { 
    511514                        if ((nunchuk_mesg = malloc(sizeof *nunchuk_mesg)) == NULL) { 
    512                                 wiimote_err(wiimote, "Error allocating nunchuk mesg"); 
     515                                cwiid_err(wiimote, "Error allocating nunchuk mesg"); 
    513516                                return -1; 
    514517                        } 
    515518 
    516                         nunchuk_mesg->type = WIIMOTE_MESG_NUNCHUK; 
     519                        nunchuk_mesg->type = CWIID_MESG_NUNCHUK; 
    517520                        nunchuk_mesg->stick_x = DECODE(data[0]); 
    518521                        nunchuk_mesg->stick_y = DECODE(data[1]); 
     
    523526 
    524527                        mesg_array->mesg[mesg_array->count] = 
    525                           (union wiimote_mesg *)nunchuk_mesg; 
     528                          (union cwiid_mesg *)nunchuk_mesg; 
    526529                        mesg_array->count++; 
    527530                } 
    528531                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) { 
    531534                        if ((classic_mesg = malloc(sizeof *classic_mesg)) == NULL) { 
    532                                 wiimote_err(wiimote, "Error allocating classic mesg"); 
     535                                cwiid_err(wiimote, "Error allocating classic mesg"); 
    533536                                return -1; 
    534537                        } 
     
    538541                        } 
    539542 
    540                         classic_mesg->type = WIIMOTE_MESG_CLASSIC; 
     543                        classic_mesg->type = CWIID_MESG_CLASSIC; 
    541544                        classic_mesg->l_stick_x = data[0] & 0x3F; 
    542545                        classic_mesg->l_stick_y = data[1] & 0x3F; 
     
    552555 
    553556                        mesg_array->mesg[mesg_array->count] = 
    554                           (union wiimote_mesg *)classic_mesg; 
     557                          (union cwiid_mesg *)classic_mesg; 
    555558                        mesg_array->count++; 
    556559                } 
     
    574577                if (((data_len + wiimote->read_received) > wiimote->read_len) || 
    575578                  error) { 
    576                         wiimote_err(wiimote, "Error in read data"); 
     579                        cwiid_err(wiimote, "Error in read data"); 
    577580                        wiimote->rw_error = 1; 
    578581                        wiimote->rw_status = RW_NONE; 
     
    593596                         * rw_cond_mutex */ 
    594597                        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"); 
    597600                                wiimote->rw_error = 1; 
    598601                                ret = -1; 
     
    600603                        else { 
    601604                                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"); 
    604607                                        wiimote->rw_error = 1; 
    605608                                        ret = -1; 
     
    607610                                if (pthread_mutex_unlock( 
    608611                                  &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"); 
    611614                                        wiimote->rw_error = 1; 
    612615                                        ret = -1; 
     
    616619        } 
    617620        else { 
    618                 wiimote_err(wiimote, "Extraneous read data received"); 
     621                cwiid_err(wiimote, "Extraneous read data received"); 
    619622                ret = -1; 
    620623        } 
     
    632635                 * write_cond_mutex */ 
    633636                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"); 
    636639                        wiimote->rw_error = 1; 
    637640                        ret = -1; 
     
    639642                else { 
    640643                        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"); 
    643646                                wiimote->rw_error = 1; 
    644647                                ret = -1; 
    645648                        } 
    646649                        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"); 
    649652                                wiimote->rw_error = 1; 
    650653                                ret = -1; 
     
    653656        } 
    654657        else { 
    655                 wiimote_err(wiimote, "Extraneous write ack received"); 
     658                cwiid_err(wiimote, "Extraneous write ack received"); 
    656659                ret = -1; 
    657660        } 
     
    665668        if (queue_free(queue, (free_func_t *)free_mesg_array)) { 
    666669                /* TODO: return proper wiimote ptr */ 
    667                 wiimote_err(NULL, "Error freeing dispatch queue"); 
     670                cwiid_err(NULL, "Error freeing dispatch queue"); 
    668671        } 
    669672} 
     
    674677        struct queue *dispatch_queue = wiimote->dispatch_queue; 
    675678        struct mesg_array *mesg_array; 
    676         union wiimote_mesg *mesg; 
     679        union cwiid_mesg *mesg; 
    677680        unsigned char buf; 
    678681 
     
    681684        do { 
    682685                if (queue_wait(dispatch_queue)) { 
    683                         wiimote_err(wiimote, "Error waiting on dispatch_queue"); 
     686                        cwiid_err(wiimote, "Error waiting on dispatch_queue"); 
    684687                        return NULL; 
    685688                } 
     
    691694                        /* Disable cancelling while in callback */ 
    692695                        if (pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancelstate)) { 
    693                                 wiimote_err(wiimote, "Error disabling cancel state"); 
     696                                cwiid_err(wiimote, "Error disabling cancel state"); 
    694697                        } 
    695698                        else { 
     
    698701                                 * only messages in the array */ 
    699702                                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)) { 
    703706                                                buf = 0x00; 
    704707                                                /* Initialize extension register space */ 
    705                                                 if (wiimote_write(wiimote, WIIMOTE_RW_REG, 0xA40040, 1, 
     708                                                if (cwiid_write(wiimote, CWIID_RW_REG, 0xA40040, 1, 
    706709                                                                  &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; 
    710712                                                } 
    711713                                                /* 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, 
    714716                                                             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; 
    718719                                                } 
    719720                                                else { 
     
    721722                                                        case EXT_NONE: 
    722723                                                        case EXT_PARTIAL: 
    723                                                                 wiimote->extension = WIIMOTE_EXT_NONE; 
     724                                                                wiimote->extension = CWIID_EXT_NONE; 
    724725                                                                break; 
    725726                                                        case EXT_NUNCHUK: 
    726                                                                 wiimote->extension = WIIMOTE_EXT_NUNCHUK; 
     727                                                                wiimote->extension = CWIID_EXT_NUNCHUK; 
    727728                                                                break; 
    728729                                                        case EXT_CLASSIC: 
    729                                                                 wiimote->extension = WIIMOTE_EXT_CLASSIC; 
     730                                                                wiimote->extension = CWIID_EXT_CLASSIC; 
    730731                                                                break; 
    731732                                                        default: 
    732                                                                 wiimote->extension = WIIMOTE_EXT_UNKNOWN; 
     733                                                                wiimote->extension = CWIID_EXT_UNKNOWN; 
    733734                                                                break; 
    734735                                                        } 
    735736                                                } 
    736737                                        } 
    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; 
    739740                                        } 
    740741 
    741742                                        if (update_rpt_mode(wiimote, -1)) { 
    742                                                 wiimote_err(wiimote, "Error reseting report mode"); 
     743                                                cwiid_err(wiimote, "Error reseting report mode"); 
    743744                                        } 
    744745 
    745746                                        /* Invoke Callback (for Status Messages) */ 
    746                                         if (wiimote->rpt_mode_flags & WIIMOTE_RPT_STATUS) { 
     747                                        if (wiimote->rpt_mode_flags & CWIID_RPT_STATUS) { 
    747748                                                mesg->status_mesg.extension = wiimote->extension; 
    748749                                                if (wiimote->mesg_callback) { 
     
    762763                                /* Reenable Thread Cancel */ 
    763764                                if (pthread_setcancelstate(cancelstate, &cancelstate)) { 
    764                                         wiimote_err(wiimote, "Error enabling cancel state"); 
     765                                        cwiid_err(wiimote, "Error enabling cancel state"); 
    765766                                } 
    766767                        } 
     
    770771 
    771772        /* This code should never execute */ 
    772         wiimote_err(wiimote, "Exiting dispatch thread"); 
     773        cwiid_err(wiimote, "Exiting dispatch thread"); 
    773774 
    774775        /* Just in case, free the dispatch queue */ 
  • libcwiid/queue.h

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
    18  *  2007-04-04 L. Donnie Smith >cwiid@abstrakraft.org> 
     18 *  2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    1919 *  * Added queue_flush prototype 
    2020 * 
  • libcwiid/rw.c

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    19  *  * updated wiimote_read and wiimote_write to trigger and detect rw_error 
     22 *  * updated cwiid_read and cwiid_write to trigger and detect rw_error 
    2023 * 
    2124 *  2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> 
    22  *  * wiimote_read - changed to obey decode flag only for register read 
     25 *  * cwiid_read - changed to obey decode flag only for register read 
    2326 * 
    2427 *  2007-03-06 L. Donnie Smith <cwiid@abstrakraft.org> 
    25  *  * added wiimote parameter to wiimote_err calls 
     28 *  * added wiimote parameter to cwiid_err calls 
    2629 * 
    2730 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    3437#include <pthread.h> 
    3538#include <unistd.h> 
    36 #include "wiimote_internal.h" 
     39#include "cwiid_internal.h" 
    3740 
    3841struct write_seq speaker_enable_seq[] = { 
    3942        {WRITE_SEQ_RPT, RPT_SPEAKER_ENABLE, (const void *)"\x04", 1, 0}, 
    4043        {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}, 
    4346        {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}, 
    4649        {WRITE_SEQ_RPT,   RPT_SPEAKER_MUTE, (const void *)"\x00", 1, 0} 
    4750}; 
     
    5457 
    5558#define RPT_READ_REQ_LEN 6 
    56 int wiimote_read(struct wiimote *wiimote, uint8_t flags, uint32_t offset, 
     59int cwiid_read(struct wiimote *wiimote, uint8_t flags, uint32_t offset, 
    5760                 uint16_t len, void *data) 
    5861{ 
     
    7073 
    7174        /* Compose read request packet */ 
    72         buf[0]=flags & (WIIMOTE_RW_EEPROM | WIIMOTE_RW_REG); 
     75        buf[0]=flags & (CWIID_RW_EEPROM | CWIID_RW_REG); 
    7376        buf[1]=(unsigned char)((offset>>16) & 0xFF); 
    7477        buf[2]=(unsigned char)((offset>>8) & 0xFF); 
     
    8083        /* Lock wiimote rw access */ 
    8184        if (pthread_mutex_lock(&wiimote->rw_mutex)) { 
    82                 wiimote_err(wiimote, "Error locking rw_mutex"); 
     85                cwiid_err(wiimote, "Error locking rw_mutex"); 
    8386                return -1; 
    8487        } 
     
    98101        /* Send read request packet */ 
    99102        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"); 
    101104                ret = -1; 
    102105                goto CODA; 
     
    105108        /* Lock rw_cond_mutex  */ 
    106109        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"); 
    108111                ret = -1; 
    109112                goto CODA; 
     
    113116                if (pthread_cond_wait(&wiimote->rw_cond, 
    114117                                      &wiimote->rw_cond_mutex)) { 
    115                         wiimote_err(wiimote, "Error waiting on rw_cond"); 
     118                        cwiid_err(wiimote, "Error waiting on rw_cond"); 
    116119                        ret = -1; 
    117120                        /* can't goto CODA from here - unlock rw_cond_mutex first */ 
     
    120123        /* Unlock rw_cond_mutex */ 
    121124        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"); 
    123126                wiimote->rw_error = 1; 
    124127                ret = -1; 
     
    137140        /* Unlock rw_mutex */ 
    138141        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"); 
    140143                wiimote->rw_error = 1; 
    141144        } 
    142145 
    143146        /* 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)) { 
    146149                for (i=0; i < len; i++) { 
    147150                        ((unsigned char *)data)[i] = DECODE(((unsigned char *)data)[i]); 
     
    153156 
    154157#define RPT_WRITE_LEN 21 
    155 int wiimote_write(struct wiimote *wiimote, uint8_t flags, uint32_t offset, 
     158int cwiid_write(struct wiimote *wiimote, uint8_t flags, uint32_t offset, 
    156159                  uint16_t len, const void *data) 
    157160{ 
     
    173176        /* Lock wiimote rw access */ 
    174177        if (pthread_mutex_lock(&wiimote->rw_mutex)) { 
    175                 wiimote_err(wiimote, "Error locking rw_mutex"); 
     178                cwiid_err(wiimote, "Error locking rw_mutex"); 
    176179                return -1; 
    177180        } 
     
    195198 
    196199                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"); 
    198201                        ret = -1; 
    199202                        goto CODA; 
     
    201204                /* Lock rw_cond_mutex  */ 
    202205                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"); 
    204207                        ret = -1; 
    205208                        goto CODA; 
    206209                } 
    207210                else { 
    208                         /* Wait on condition, signalled by wiimote_int_listen */ 
     211                        /* Wait on condition, signalled by cwiid_int_listen */ 
    209212                        while (!wiimote->rw_error && !ret && 
    210213                          (wiimote->rw_status == RW_PENDING)) { 
    211214                                if (pthread_cond_wait(&wiimote->rw_cond, 
    212215                                                      &wiimote->rw_cond_mutex)) { 
    213                                         wiimote_err(wiimote, "Error waiting on rw_cond"); 
     216                                        cwiid_err(wiimote, "Error waiting on rw_cond"); 
    214217                                        ret = -1; 
    215218                                        /* can't goto CODA from here - 
     
    219222                        /* Unlock rw_cond_mutex */ 
    220223                        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"); 
    222225                                wiimote->rw_error = 1; 
    223226                                ret = -1; 
     
    245248        /* Unlock rw_mutex */ 
    246249        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"); 
    248251                wiimote->rw_error = 1; 
    249252        } 
     
    253256 
    254257#define SOUND_BUF_LEN   21 
    255 int wiimote_beep(wiimote_t *wiimote) 
     258int cwiid_beep(cwiid_wiimote_t *wiimote) 
    256259{ 
    257260        /* unsigned char buf[SOUND_BUF_LEN] = { 0xA0, 0xCC, 0x33, 0xCC, 0x33, 
     
    269272        if (exec_write_seq(wiimote, SEQ_LEN(speaker_enable_seq), 
    270273                           speaker_enable_seq)) { 
    271                 wiimote_err(wiimote, "Error on speaker enable"); 
     274                cwiid_err(wiimote, "Error on speaker enable"); 
    272275                ret = -1; 
    273276        } 
     
    281284                if (send_report(wiimote, 0, RPT_SPEAKER_DATA, SOUND_BUF_LEN, buf)) { 
    282285                        printf("%d\n", i); 
    283                         wiimote_err(wiimote, "Error on speaker data"); 
     286                        cwiid_err(wiimote, "Error on speaker data"); 
    284287                        ret = -1; 
    285288                        break; 
     
    294297        if (exec_write_seq(wiimote, SEQ_LEN(speaker_disable_seq), 
    295298                           speaker_disable_seq)) { 
    296                 wiimote_err(wiimote, "Error on speaker disable"); 
     299                cwiid_err(wiimote, "Error on speaker disable"); 
    297300                ret = -1; 
    298301        } 
  • libcwiid/util.c

    r2547e8f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * renamed wiimote to libcwiid, renamed structures accordingly 
     20 * 
    1821 *  2007-04-08 Petter Reinholdtsen <pere@hungry.com> 
    1922 *  * fixed signed/unsigned comparison warning in send_report and 
     
    2124 * 
    2225 *  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) 
    2427 * 
    2528 *  2007-03-27 L. Donnie Smith <cwiid@abstrakraft.org> 
    26  *  * moved wiimote_findfirst to bluetooth.c 
     29 *  * moved cwiid_findfirst to bluetooth.c 
    2730 * 
    2831 *  2007-03-14 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    3033 * 
    3134 *  2007-03-05 L. Donnie Smith <cwiid@abstrakraft.org> 
    32  *  * created wiimote_err_func variable 
    33  *  * created wiimote_err_default 
    34  *  * added wiimote parameter to wiimote_err definition and calls 
     35 *  * created cwiid_err_func variable 
     36 *  * created cwiid_err_default 
     37 *  * added wiimote parameter to cwiid_err definition and calls 
    3538 * 
    3639 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    4548#include <string.h> 
    4649#include <unistd.h> 
    47 #include "wiimote_internal.h" 
     50#include "cwiid_internal.h" 
    4851 
    49 static wiimote_err_t wiimote_err_default; 
     52static cwiid_err_t cwiid_err_default; 
    5053 
    51 static wiimote_err_t *wiimote_err_func = &wiimote_err_default; 
     54static cwiid_err_t *cwiid_err_func = &cwiid_err_default; 
    5255 
    53 int wiimote_set_err(wiimote_err_t *err) 
     56int cwiid_set_err(cwiid_err_t *err) 
    5457{ 
    5558        /* TODO: assuming pointer assignment is atomic operation */ 
    5659        /* if it is, and the user doesn't care about race conditions, we don't 
    5760         * either */ 
    58         wiimote_err_func = err; 
     61        cwiid_err_func = err; 
    5962        return 0; 
    6063} 
    6164 
    62 static void wiimote_err_default(int id, const char *str, ...) 
     65static void cwiid_err_default(int id, const char *str, ...) 
    6366{ 
    6467        va_list ap; 
     
    7073} 
    7174 
    72 void wiimote_err(struct wiimote *wiimote, const char *str, ...) 
     75void cwiid_err(struct wiimote *wiimote, const char *str, ...) 
    7376{ 
    7477        va_list ap; 
    7578 
    76         if (wiimote_err_func) { 
     79        if (cwiid_err_func) { 
    7780                va_start(ap, str); 
    7881                if (wiimote) { 
    79                         (*wiimote_err_func)(wiimote->id, str, ap); 
     82                        (*cwiid_err_func)(wiimote->id, str, ap); 
    8083                } 
    8184                else { 
    82                         (*wiimote_err_func)(-1, str, ap); 
     85                        (*cwiid_err_func)(-1, str, ap); 
    8386                } 
    8487                va_end(ap); 
     
    9093        unsigned char handshake; 
    9194        if (read(wiimote->ctl_socket, &handshake, 1) != 1) { 
    92                 wiimote_err(wiimote, "Error on read handshake"); 
     95                cwiid_err(wiimote, "Error on read handshake"); 
    9396                return -1; 
    9497        } 
    9598        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"); 
    97100                return -1; 
    98101        } 
    99102        else if ((handshake & BT_PARAM_MASK) != BT_PARAM_SUCCESSFUL) { 
    100                 wiimote_err(wiimote, "Non-successful handshake"); 
     103                cwiid_err(wiimote, "Non-successful handshake"); 
    101104                return -1; 
    102105        } 
     
    146149                        break; 
    147150                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, 
    149152                                          seq[i].len, seq[i].data)) { 
    150153                                return -1; 
  • lswm/Makefile.in

    rbdb6c21 r805477a  
    77SOURCES = lswm.c 
    88 
    9 CFLAGS += -I@top_builddir@/wiimote 
    10 LDFLAGS += -L@top_builddir@/wiimote 
    11 LDLIBS += -lwiimote 
     9CFLAGS += -I@top_builddir@/libcwiid 
     10LDFLAGS += -L@top_builddir@/libcwiid 
     11LDLIBS += -lcwiid 
    1212INST_DIR = @bindir@ 
    1313 
  • lswm/lswm.c

    rd37162f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-07 L. Donnie Smith <cwiid@abstrakraft.org> 
    19  *  * changed wiimote_info.class to btclass 
     22 *  * changed cwiid_info.class to btclass 
    2023 * 
    2124 *  2007-04-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    2831#include <unistd.h> 
    2932#include <bluetooth/bluetooth.h> 
    30 #include <wiimote.h> 
     33#include <cwiid.h> 
    3134 
    3235#define OPTSTRING       "ahlq" 
     
    4548        char long_format = 0; 
    4649        char quiet = 0; 
    47         struct wiimote_info *wm; 
    48         int wm_count; 
     50        struct cwiid_bdinfo *bdinfo; 
     51        int bdinfo_count; 
    4952        int i; 
    5053        char ba_str[18]; 
     
    7881        /* Handle quiet mode */ 
    7982        if (quiet) { 
    80                 wiimote_set_err(NULL); 
     83                cwiid_set_err(NULL); 
    8184        } 
    8285        /* Print discoverable mode message */ 
     
    9093 
    9194        /* 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) { 
    9397                return -1; 
    9498        } 
    9599 
    96100        /* 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); 
    99103                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); 
    102106                } 
    103107                else { 
  • wmdemo/Makefile.in

    rbdb6c21 r805477a  
    77SOURCES = wmdemo.c 
    88 
    9 CFLAGS += -I@top_builddir@/wiimote 
    10 LDFLAGS += -L@top_builddir@/wiimote 
    11 LDLIBS += -lwiimote 
     9CFLAGS += -I@top_builddir@/libcwiid 
     10LDFLAGS += -L@top_builddir@/libcwiid 
     11LDLIBS += -lcwiid 
    1212INST_DIR = @bindir@ 
    1313 
  • wmdemo/wmdemo.c

    r09bfa38 r805477a  
    33#include <stdlib.h> 
    44 
    5 #include <wiimote.h> 
     5#include <cwiid.h> 
    66 
    77/* This is a sample program written to demonstrate basic CWiid libwiimote 
     
    1515 * interface, and it shows. */ 
    1616 
    17 wiimote_mesg_callback_t wiimote_callback; 
     17cwiid_mesg_callback_t cwiid_callback; 
    1818 
    1919#define toggle_bit(bf,b)        \ 
     
    2222               : ((bf) | (b)) 
    2323 
    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; 
     24void set_led_state(cwiid_wiimote_t *wiimote, unsigned char led_state); 
     25void set_rpt_mode(cwiid_wiimote_t *wiimote, unsigned char rpt_mode); 
     26 
     27cwiid_err_t err; 
    2828void err(int id, const char *s, ...) 
    2929{ 
     
    3838 
    3939/* wiimote handle */ 
    40 wiimote_t *wiimote; 
     40cwiid_wiimote_t *wiimote; 
    4141 
    4242int main(int argc, char *argv[]) 
    4343{ 
    4444        bdaddr_t bdaddr;        /* bluetooth device address */ 
    45         int wiimote_id;         /* wiimote id: useful for handling multiple wiimotes 
     45        int cwiid_id;           /* wiimote id: useful for handling multiple wiimotes 
    4646                               with a single callback */ 
    4747        unsigned char led_state = 0; 
     
    5050        int exit = 0; 
    5151 
    52         wiimote_set_err(err); 
     52        cwiid_set_err(err); 
    5353 
    5454        /* Connect to any wiimote */ 
    5555        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); */ 
    5858 
    5959        /* Connect to the wiimote */ 
    6060        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))) { 
    6262                fprintf(stderr, "Unable to connect to wiimote\n"); 
    6363                return -1; 
     
    8181                switch (getchar()) { 
    8282                case '1': 
    83                         toggle_bit(led_state, WIIMOTE_LED1_ON); 
     83                        toggle_bit(led_state, CWIID_LED1_ON); 
    8484                        set_led_state(wiimote, led_state); 
    8585                        break; 
    8686                case '2': 
    87                         toggle_bit(led_state, WIIMOTE_LED2_ON); 
     87                        toggle_bit(led_state, CWIID_LED2_ON); 
    8888                        set_led_state(wiimote, led_state); 
    8989                        break; 
    9090                case '3': 
    91                         toggle_bit(led_state, WIIMOTE_LED3_ON); 
     91                        toggle_bit(led_state, CWIID_LED3_ON); 
    9292                        set_led_state(wiimote, led_state); 
    9393                        break; 
    9494                case '4': 
    95                         toggle_bit(led_state, WIIMOTE_LED4_ON); 
     95                        toggle_bit(led_state, CWIID_LED4_ON); 
    9696                        set_led_state(wiimote, led_state); 
    9797                        break; 
    9898                case 'a': 
    99                         toggle_bit(rpt_mode, WIIMOTE_RPT_ACC); 
     99                        toggle_bit(rpt_mode, CWIID_RPT_ACC); 
    100100                        set_rpt_mode(wiimote, rpt_mode); 
    101101                        break; 
    102102                case 'b': 
    103                         toggle_bit(rpt_mode, WIIMOTE_RPT_BTN); 
     103                        toggle_bit(rpt_mode, CWIID_RPT_BTN); 
    104104                        set_rpt_mode(wiimote, rpt_mode); 
    105105                        break; 
    106106                case 'e': 
    107                         /* WIIMOTE_RPT_EXT is actually 
    108                          * 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); 
    110110                        set_rpt_mode(wiimote, rpt_mode); 
    111111                        break; 
     
    114114                         * other options selected (not including as-yet-undeciphered 
    115115                         * interleaved mode */ 
    116                         toggle_bit(rpt_mode, WIIMOTE_RPT_IR); 
     116                        toggle_bit(rpt_mode, CWIID_RPT_IR); 
    117117                        set_rpt_mode(wiimote, rpt_mode); 
    118118                        break; 
    119119                case 'r': 
    120120                        toggle_bit(rumble, 1); 
    121                         if (wiimote_command(wiimote, WIIMOTE_CMD_RUMBLE, rumble)) { 
     121                        if (cwiid_command(wiimote, CWIID_CMD_RUMBLE, rumble)) { 
    122122                                fprintf(stderr, "Error setting rumble\n"); 
    123123                        } 
    124124                        break; 
    125125                case 's': 
    126                         if (wiimote_command(wiimote, WIIMOTE_CMD_STATUS, 0)) { 
     126                        if (cwiid_command(wiimote, CWIID_CMD_STATUS, 0)) { 
    127127                                fprintf(stderr, "Error requesting status message\n"); 
    128128                        } 
    129129                        break; 
    130130                case 't': 
    131                         toggle_bit(rpt_mode, WIIMOTE_RPT_STATUS); 
     131                        toggle_bit(rpt_mode, CWIID_RPT_STATUS); 
    132132                        set_rpt_mode(wiimote, rpt_mode); 
    133133                        break; 
     
    142142        } 
    143143 
    144         if (wiimote_disconnect(wiimote)) { 
     144        if (cwiid_disconnect(wiimote)) { 
    145145                fprintf(stderr, "Error on wiimote disconnect\n"); 
    146146                return -1; 
     
    150150} 
    151151 
    152 void set_led_state(wiimote_t *wiimote, unsigned char led_state) 
    153 { 
    154         if (wiimote_command(wiimote, WIIMOTE_CMD_LED, led_state)) { 
     152void set_led_state(cwiid_wiimote_t *wiimote, unsigned char led_state) 
     153{ 
     154        if (cwiid_command(wiimote, CWIID_CMD_LED, led_state)) { 
    155155                fprintf(stderr, "Error setting LEDs \n"); 
    156156        } 
    157157} 
    158158         
    159 void set_rpt_mode(wiimote_t *wiimote, unsigned char rpt_mode) 
    160 { 
    161         if (wiimote_command(wiimote, WIIMOTE_CMD_RPT_MODE, rpt_mode)) { 
     159void set_rpt_mode(cwiid_wiimote_t *wiimote, unsigned char rpt_mode) 
     160{ 
     161        if (cwiid_command(wiimote, CWIID_CMD_RPT_MODE, rpt_mode)) { 
    162162                fprintf(stderr, "Error setting report mode\n"); 
    163163        } 
    164164} 
    165165 
    166 /* Prototype wiimote_callback with wiimote_callback_t, define it with the actual 
     166/* Prototype cwiid_callback with cwiid_callback_t, define it with the actual 
    167167 * 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 this 
     168 * behavior) if cwiid_callback_t changes */ 
     169/* cwiid_mesg_callback_t has undergone a few changes lately, hopefully this 
    170170 * will be the last.  Some programs need to know which messages were received 
    171  * simultaneously (e.g. for correlating acceperometer and IR data), and the 
     171 * simultaneously (e.g. for correlating accelerometer and IR data), and the 
    172172 * sequence number mechanism used previously proved cumbersome, so we just 
    173173 * pass an array of messages, all of which were received at the same time. 
    174174 * The id is to distinguish between multiple wiimotes using the same callback. 
    175175 * */ 
    176 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg[]) 
     176void cwiid_callback(int id, int mesg_count, union cwiid_mesg *mesg[]) 
    177177{ 
    178178        int i, j; 
     
    182182        { 
    183183                switch (mesg[i]->type) { 
    184                 case WIIMOTE_MESG_STATUS: 
     184                case CWIID_MESG_STATUS: 
    185185                        printf("Status Report: battery=%d extension=", 
    186186                               mesg[i]->status_mesg.battery); 
    187187                        switch (mesg[i]->status_mesg.extension) { 
    188                         case WIIMOTE_EXT_NONE: 
     188                        case CWIID_EXT_NONE: 
    189189                                printf("none"); 
    190190                                break; 
    191                         case WIIMOTE_EXT_NUNCHUK: 
     191                        case CWIID_EXT_NUNCHUK: 
    192192                                printf("Nunchuk"); 
    193193                                break; 
    194                         case WIIMOTE_EXT_CLASSIC: 
     194                        case CWIID_EXT_CLASSIC: 
    195195                                printf("Classic Controller"); 
    196196                                break; 
     
    201201                        printf("\n"); 
    202202                        break; 
    203                 case WIIMOTE_MESG_BTN: 
     203                case CWIID_MESG_BTN: 
    204204                        printf("Button Report: %.4X\n", mesg[i]->btn_mesg.buttons); 
    205205                        break; 
    206                 case WIIMOTE_MESG_ACC: 
     206                case CWIID_MESG_ACC: 
    207207                        printf("Acc Report: x=%d, y=%d, z=%d\n", mesg[i]->acc_mesg.x, 
    208208                                                                 mesg[i]->acc_mesg.y, 
    209209                                                                 mesg[i]->acc_mesg.z); 
    210210                        break; 
    211                 case WIIMOTE_MESG_IR: 
     211                case CWIID_MESG_IR: 
    212212                        printf("IR Report: "); 
    213213                        valid_source = 0; 
    214                         for (j = 0; j < WIIMOTE_IR_SRC_COUNT; j++) { 
     214                        for (j = 0; j < CWIID_IR_SRC_COUNT; j++) { 
    215215                                if (mesg[i]->ir_mesg.src[j].valid) { 
    216216                                        valid_source = 1; 
     
    224224                        printf("\n"); 
    225225                        break; 
    226                 case WIIMOTE_MESG_NUNCHUK: 
     226                case CWIID_MESG_NUNCHUK: 
    227227                        printf("Nunchuk Report: btns=%.2X stick=(%d,%d) acc.x=%d acc.y=%d " 
    228228                               "acc.z=%d\n", mesg[i]->nunchuk_mesg.buttons, 
     
    231231                               mesg[i]->nunchuk_mesg.acc_y, mesg[i]->nunchuk_mesg.acc_z); 
    232232                        break; 
    233                 case WIIMOTE_MESG_CLASSIC: 
     233                case CWIID_MESG_CLASSIC: 
    234234                        printf("Classic Report: btns=%.4X l_stick=(%d,%d) r_stick=(%d,%d) " 
    235235                               "l=%d r=%d\n", mesg[i]->classic_mesg.buttons, 
     
    240240                               mesg[i]->classic_mesg.l, mesg[i]->classic_mesg.r); 
    241241                        break; 
    242                 case WIIMOTE_MESG_ERROR: 
    243                         if (wiimote_disconnect(wiimote)) { 
     242                case CWIID_MESG_ERROR: 
     243                        if (cwiid_disconnect(wiimote)) { 
    244244                                fprintf(stderr, "Error on wiimote disconnect\n"); 
    245245                                exit(-1); 
  • wmgui/Makefile.in

    rbdb6c21 r805477a  
    77SOURCES = main.c interface.c support.c 
    88 
    9 CFLAGS += @GTK_CFLAGS@ -I@top_builddir@/wiimote \ 
     9CFLAGS += @GTK_CFLAGS@ -I@top_builddir@/libcwiid \ 
    1010        -DCWIID_VERSION=\"${PACKAGE_VERSION}\" 
    11 LDFLAGS += -L@top_builddir@/wiimote 
    12 LDLIBS += @GTK_LIBS@ -lm -lwiimote 
     11LDFLAGS += -L@top_builddir@/libcwiid 
     12LDLIBS += @GTK_LIBS@ -lm -lcwiid 
    1313INST_DIR = @bindir@ 
    1414 
  • wmgui/main.c

    re39b37a r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@anstrakraft.org> 
    1922 *  * fixed signed/unsigned comparison warning in btnRead_clicked 
    2023 * 
    2124 *  2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    22  *  * disconnect on wiimote_mesg_error 
     25 *  * disconnect on cwiid_mesg_error 
    2326 * 
    2427 *  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) 
    2629 * 
    2730 *  2007-03-01 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    5154 
    5255#include <bluetooth/bluetooth.h> 
    53 #include "wiimote.h" 
     56#include "cwiid.h" 
    5457 
    5558#define PI      3.14159265358979323 
     
    6972 
    7073/* Globals */ 
    71 wiimote_t *wiimote = NULL; 
     74cwiid_wiimote_t *wiimote = NULL; 
    7275bdaddr_t bdaddr; 
    7376struct acc acc_zero, acc_one; 
    74 struct wiimote_ir_mesg ir_data; 
     77struct cwiid_ir_mesg ir_data; 
    7578struct acc nc_acc_zero, nc_acc_one; 
    7679struct stick nc_stick; 
     
    163166 
    164167/* Wiimote Callback */ 
    165 wiimote_mesg_callback_t wiimote_callback; 
     168cwiid_mesg_callback_t cwiid_callback; 
    166169 
    167170/* 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 *); 
     171void cwiid_btn(struct cwiid_btn_mesg *); 
     172void cwiid_acc(struct cwiid_acc_mesg *); 
     173void cwiid_ir(struct cwiid_ir_mesg *); 
     174void cwiid_nunchuk(struct cwiid_nunchuk_mesg *); 
     175void cwiid_classic(struct cwiid_classic_mesg *); 
    173176 
    174177/* GetOpt */ 
     
    180183 
    181184/* 
    182 wiimote_err_t err; 
     185cwiid_err_t err; 
    183186 
    184187void err(int id, const char *s, ...) 
     
    202205        gdk_threads_enter(); 
    203206 
    204         /* wiimote_set_err(err); */ 
     207        /* cwiid_set_err(err); */ 
    205208 
    206209        /* Parse Options */ 
     
    233236                } 
    234237        } 
    235         else if ((str_addr = getenv(WIIMOTE_BDADDR)) != NULL) { 
     238        else if ((str_addr = getenv(CWIID_BDADDR)) != NULL) { 
    236239                if (str2ba(str_addr, &bdaddr)) { 
    237                         printf("invalid address in %s\n", WIIMOTE_BDADDR); 
     240                        printf("invalid address in %s\n", CWIID_BDADDR); 
    238241                        bdaddr = *BDADDR_ANY; 
    239242                } 
     
    418421 
    419422        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; 
    422425 
    423426        set_gui_state(); 
     
    573576        int i; 
    574577 
    575         for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) { 
     578        for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 
    576579                ir_data.src[i].x = -1; 
    577580                ir_data.src[i].y = -1; 
     
    633636                "Put Wiimote in discoverable mode (press 1+2) and press OK", 
    634637                 GTK_WINDOW(winMain)); 
    635         if ((wiimote = wiimote_connect(&bdaddr, &wiimote_callback, NULL)) == NULL) { 
     638        if ((wiimote = cwiid_connect(&bdaddr, &cwiid_callback, NULL)) == NULL) { 
    636639                message(GTK_MESSAGE_ERROR, "Unable to connect", GTK_WINDOW(winMain)); 
    637640                status("No connection"); 
     
    639642        else { 
    640643                status("Connected"); 
    641                 if (wiimote_read(wiimote, WIIMOTE_RW_EEPROM, 0x16, 7, buf)) { 
     644                if (cwiid_read(wiimote, CWIID_RW_EEPROM, 0x16, 7, buf)) { 
    642645                        message(GTK_MESSAGE_ERROR, "Unable to retrieve accelerometer " 
    643646                                "calibration", GTK_WINDOW(winMain)); 
     
    653656                set_gui_state(); 
    654657                set_report_mode(); 
    655                 wiimote_command(wiimote, WIIMOTE_CMD_STATUS, 0); 
     658                cwiid_command(wiimote, CWIID_CMD_STATUS, 0); 
    656659        } 
    657660 
     
    663666void menuDisconnect_activate(void) 
    664667{ 
    665         if (wiimote_disconnect(wiimote)) { 
     668        if (cwiid_disconnect(wiimote)) { 
    666669                message(GTK_MESSAGE_ERROR, "Error on disconnect", GTK_WINDOW(winMain)); 
    667670        } 
     
    736739                LED_state = 
    737740                  (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED1)) 
    738                     ? WIIMOTE_LED1_ON : 0) | 
     741                    ? CWIID_LED1_ON : 0) | 
    739742                  (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED2)) 
    740                     ? WIIMOTE_LED2_ON : 0) | 
     743                    ? CWIID_LED2_ON : 0) | 
    741744                  (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkLED3)) 
    742                     ? WIIMOTE_LED3_ON : 0) | 
     745                    ? CWIID_LED3_ON : 0) | 
    743746                  (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)) { 
    746749                        message(GTK_MESSAGE_ERROR, "error setting LEDs", 
    747750                                GTK_WINDOW(winMain)); 
     
    753756{ 
    754757        if (wiimote) { 
    755                 if (wiimote_command(wiimote, WIIMOTE_CMD_RUMBLE, 
     758                if (cwiid_command(wiimote, CWIID_CMD_RUMBLE, 
    756759                  gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkRumble)))) { 
    757760                        message(GTK_MESSAGE_ERROR, "error setting rumble", 
     
    769772        gdk_window_get_geometry(drawIR->window, NULL, NULL, &width, &height, NULL); 
    770773 
    771         for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) { 
     774        for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 
    772775                if (ir_data.src[i].valid) { 
    773776                        if (ir_data.src[i].size == -1) { 
     
    780783                                     drawIR->style->fg_gc[GTK_WIDGET_STATE(drawIR)], 
    781784                                     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, 
    784787                                                 size, size, 
    785788                                                 0, 64 * 360); 
     
    811814void btnRead_clicked(void) 
    812815{ 
    813         static unsigned char buf[WIIMOTE_MAX_READ_LEN]; 
    814         static char txt[WIIMOTE_MAX_READ_LEN*4+50]; /* 3 chars per byte, with 
     816        static unsigned char buf[CWIID_MAX_READ_LEN]; 
     817        static char txt[CWIID_MAX_READ_LEN*4+50]; /* 3 chars per byte, with 
    815818                                                     * plenty extra */ 
    816819        GtkTextIter text_iter; 
     
    832835        } 
    833836        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radReadReg))) { 
    834                 flags = WIIMOTE_RW_REG; 
     837                flags = CWIID_RW_REG; 
    835838        } 
    836839        else { 
    837                 flags = WIIMOTE_RW_EEPROM; 
     840                flags = CWIID_RW_EEPROM; 
    838841        } 
    839842 
    840843        /* Make the call */ 
    841         if (wiimote_read(wiimote, flags, offset, len, buf)) { 
     844        if (cwiid_read(wiimote, flags, offset, len, buf)) { 
    842845                message(GTK_MESSAGE_ERROR, "Wiimote read error", GTK_WINDOW(winRW)); 
    843846        } 
     
    906909 
    907910        if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radWriteReg))) { 
    908                 flags = WIIMOTE_RW_REG; 
     911                flags = CWIID_RW_REG; 
    909912        } 
    910913        else { 
    911                 flags = WIIMOTE_RW_EEPROM; 
     914                flags = CWIID_RW_EEPROM; 
    912915        } 
    913916 
     
    956959 
    957960        /* Make the call */ 
    958         if (wiimote_write(wiimote, flags, offset, len, buf)) { 
     961        if (cwiid_write(wiimote, flags, offset, len, buf)) { 
    959962                message(GTK_MESSAGE_ERROR, "Wiimote write error", GTK_WINDOW(winRW)); 
    960963        } 
     
    972975void btnBeep_clicked(void) 
    973976{ 
    974         /*if (wiimote_beep(wiimote)) { 
     977        /*if (cwiid_beep(wiimote)) { 
    975978                message(GTK_MESSAGE_ERROR, "Wiimote sound error", GTK_WINDOW(winMain)); 
    976979        }*/ 
     
    981984        uint8_t rpt_mode; 
    982985         
    983         rpt_mode = WIIMOTE_RPT_STATUS | WIIMOTE_RPT_BTN; 
     986        rpt_mode = CWIID_RPT_STATUS | CWIID_RPT_BTN; 
    984987 
    985988        if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkIR))) { 
    986                 rpt_mode |= WIIMOTE_RPT_IR; 
     989                rpt_mode |= CWIID_RPT_IR; 
    987990        } 
    988991        if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkAcc))) { 
    989                 rpt_mode |= WIIMOTE_RPT_ACC; 
     992                rpt_mode |= CWIID_RPT_ACC; 
    990993        } 
    991994        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)) { 
    995998                message(GTK_MESSAGE_ERROR, "error setting report mode", 
    996999                        GTK_WINDOW(winMain)); 
     
    9991002 
    10001003#define BATTERY_STR_LEN 14      /* "Battery: 100%" + '\0' */ 
    1001 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg_array[]) 
     1004void cwiid_callback(int id, int mesg_count, union cwiid_mesg *mesg_array[]) 
    10021005{ 
    10031006        int i; 
     
    10051008        char *ext_str; 
    10061009        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; 
    10081011 
    10091012        gdk_threads_enter(); 
    10101013        for (i=0; i < mesg_count; i++) { 
    10111014                switch (mesg_array[i]->type) { 
    1012                 case WIIMOTE_MESG_STATUS: 
     1015                case CWIID_MESG_STATUS: 
    10131016                        snprintf(battery, BATTERY_STR_LEN,"Battery:%d%%", 
    10141017                                 (int) (100.0 * mesg_array[i]->status_mesg.battery / 
    1015                                         WIIMOTE_BATTERY_MAX)); 
     1018                                        CWIID_BATTERY_MAX)); 
    10161019                        gtk_statusbar_push(GTK_STATUSBAR(statBattery), 0, battery); 
    10171020                        switch (mesg_array[i]->status_mesg.extension) { 
    1018                         case WIIMOTE_EXT_NONE: 
     1021                        case CWIID_EXT_NONE: 
    10191022                                ext_str = "No extension"; 
    10201023                                break; 
    1021                         case WIIMOTE_EXT_NUNCHUK: 
     1024                        case CWIID_EXT_NUNCHUK: 
    10221025                                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, 
    10261029                                                     0xA40020, 7, buf)) { 
    10271030                                                message(GTK_MESSAGE_ERROR, "Unable to retrieve " 
     
    10381041                                } 
    10391042                                break; 
    1040                         case WIIMOTE_EXT_CLASSIC: 
     1043                        case CWIID_EXT_CLASSIC: 
    10411044                                ext_str = "Classic controller"; 
    10421045                                break; 
    1043                         case WIIMOTE_EXT_UNKNOWN: 
     1046                        case CWIID_EXT_UNKNOWN: 
    10441047                                ext_str = "Unknown extension"; 
    10451048                                break; 
     
    10501053                        ext_type = mesg_array[i]->status_mesg.extension; 
    10511054                        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); 
    10541057                        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); 
    10571060                        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); 
    10601063                        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); 
    10631066                        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); 
    10661069                        break; 
    1067                 case WIIMOTE_MESG_ERROR: 
     1070                case CWIID_MESG_ERROR: 
    10681071                        menuDisconnect_activate(); 
    10691072                        break; 
     
    10761079} 
    10771080 
    1078 void wiimote_btn(struct wiimote_btn_mesg *mesg) 
     1081void cwiid_btn(struct cwiid_btn_mesg *mesg) 
    10791082{ 
    10801083        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); 
    10821085        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); 
    10841087        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); 
    10861089        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); 
    10881091        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); 
    10901093        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); 
    10921095        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); 
    10941097        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); 
    10961099        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); 
    10981101        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); 
    11001103        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); 
    11021105} 
    11031106 
    11041107#define LBLVAL_LEN 6 
    1105 void wiimote_acc(struct wiimote_acc_mesg *mesg) 
     1108void cwiid_acc(struct cwiid_acc_mesg *mesg) 
    11061109{ 
    11071110        static gchar str[LBLVAL_LEN]; 
     
    11481151} 
    11491152 
    1150 void wiimote_ir(struct wiimote_ir_mesg *mesg) 
     1153void cwiid_ir(struct cwiid_ir_mesg *mesg) 
    11511154{ 
    11521155        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)); */ 
    11541157                ir_data = *mesg; 
    11551158                gtk_widget_queue_draw(drawIR); 
     
    11571160} 
    11581161 
    1159 void wiimote_nunchuk(struct wiimote_nunchuk_mesg *mesg) 
     1162void cwiid_nunchuk(struct cwiid_nunchuk_mesg *mesg) 
    11601163{ 
    11611164        static gchar str[LBLVAL_LEN]; 
     
    11651168        if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkExt))) { 
    11661169                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); 
    11681171                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); 
    11701173 
    11711174                nc_stick.valid = 1; 
     
    12121215} 
    12131216 
    1214 void wiimote_classic(struct wiimote_classic_mesg *mesg) 
     1217void cwiid_classic(struct cwiid_classic_mesg *mesg) 
    12151218{ 
    12161219        static gchar str[LBLVAL_LEN]; 
     
    12181221        if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(chkExt))) { 
    12191222                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); 
    12211224                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); 
    12231226                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); 
    12251228                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); 
    12271230                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); 
    12291232                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); 
    12311234                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); 
    12331236                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); 
    12351238                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); 
    12371240                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); 
    12391242                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); 
    12411244                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); 
    12431246                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); 
    12451248 
    12461249                cc_l_stick.valid = 1; 
     
    12571260                gtk_label_set_text(GTK_LABEL(lblCCLVal), str); 
    12581261                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); 
    12601263                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); 
    12621265                g_snprintf(str, LBLVAL_LEN, "%X", mesg->r); 
    12631266                gtk_label_set_text(GTK_LABEL(lblCCRVal), str); 
    12641267                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); 
    12661269                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  
    88 
    99WMINPUT_CONFIG_DIR = $(CWIID_CONFIG_DIR)/wminput 
    10 CFLAGS += -I@top_builddir@/wiimote \ 
     10CFLAGS += -I@top_builddir@/libcwiid \ 
    1111        -DWMINPUT_CONFIG_DIR=\"$(WMINPUT_CONFIG_DIR)\" \ 
    1212        -DCWIID_PLUGINS_DIR=\"$(CWIID_PLUGINS_DIR)\" 
    13 LDLIBS += -lwiimote -ldl 
    14 LDFLAGS += -L@top_builddir@/wiimote -rdynamic 
     13LDLIBS += -lcwiid -ldl 
     14LDFLAGS += -L@top_builddir@/libcwiid -rdynamic 
    1515INST_DIR = @bindir@ 
    1616 
  • wminput/README

    rf200a0f r805477a  
    2626-w: on startup, wait (without timing) out until a wiimote is found 
    2727-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. 
     28bdaddr: 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. 
    2929 
    3030 
  • wminput/conf.c

    rf200a0f r805477a  
    110110        switch (source) { 
    111111        case CONF_WM: 
    112                 conf->rpt_mode_flags |= WIIMOTE_RPT_BTN; 
     112                conf->rpt_mode_flags |= CWIID_RPT_BTN; 
    113113                conf->wiimote_bmap[button].active = 1; 
    114114                conf->wiimote_bmap[button].action = action; 
    115115                break; 
    116116        case CONF_NC: 
    117                 conf->rpt_mode_flags |= WIIMOTE_RPT_NUNCHUK; 
     117                conf->rpt_mode_flags |= CWIID_RPT_NUNCHUK; 
    118118                conf->nunchuk_bmap[button].active = 1; 
    119119                conf->nunchuk_bmap[button].action = action; 
    120120                break; 
    121121        case CONF_CC: 
    122                 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC; 
     122                conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 
    123123                conf->nunchuk_bmap[button].active = 1; 
    124124                conf->classic_bmap[button].action = action; 
     
    147147        case CONF_WM_AXIS_DPAD_X: 
    148148        case CONF_WM_AXIS_DPAD_Y: 
    149                 conf->rpt_mode_flags |= WIIMOTE_RPT_BTN; 
     149                conf->rpt_mode_flags |= CWIID_RPT_BTN; 
    150150                if (axis_type == EV_ABS) { 
    151151                        conf->dev.absmax[action] = 1; 
     
    157157        case CONF_NC_AXIS_STICK_X: 
    158158        case CONF_NC_AXIS_STICK_Y: 
    159                 conf->rpt_mode_flags |= WIIMOTE_RPT_NUNCHUK; 
     159                conf->rpt_mode_flags |= CWIID_RPT_NUNCHUK; 
    160160                if (axis_type == EV_ABS) { 
    161161                        conf->dev.absmax[action] = 0xFF; 
     
    167167        case CONF_CC_AXIS_DPAD_X: 
    168168        case CONF_CC_AXIS_DPAD_Y: 
    169                 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC; 
     169                conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 
    170170                if (axis_type == EV_ABS) { 
    171171                        conf->dev.absmax[action] = 1; 
     
    177177        case CONF_CC_AXIS_L_STICK_X: 
    178178        case CONF_CC_AXIS_L_STICK_Y: 
    179                 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC; 
     179                conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 
    180180                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; 
    182182                        conf->dev.absmin[action] = 0; 
    183183                        conf->dev.absfuzz[action] = 0; 
     
    187187        case CONF_CC_AXIS_R_STICK_X: 
    188188        case CONF_CC_AXIS_R_STICK_Y: 
    189                 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC; 
     189                conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 
    190190                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; 
    192192                        conf->dev.absmin[action] = 0; 
    193193                        conf->dev.absfuzz[action] = 0; 
     
    197197        case CONF_CC_AXIS_L: 
    198198        case CONF_CC_AXIS_R: 
    199                 conf->rpt_mode_flags |= WIIMOTE_RPT_CLASSIC; 
     199                conf->rpt_mode_flags |= CWIID_RPT_CLASSIC; 
    200200                if (axis_type == EV_ABS) { 
    201                         conf->dev.absmax[action] = WIIMOTE_CLASSIC_LR_MAX; 
     201                        conf->dev.absmax[action] = CWIID_CLASSIC_LR_MAX; 
    202202                        conf->dev.absmin[action] = 0; 
    203203                        conf->dev.absfuzz[action] = 0; 
     
    406406        } 
    407407        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; 
    436436        for (i=0; i < CONF_WM_BTN_COUNT; i++) { 
    437437                conf->wiimote_bmap[i].active = 0; 
  • wminput/conf.h

    rf200a0f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * added conf_plugin_param_{int,float} prototypes 
     
    3538#include <linux/uinput.h> 
    3639 
    37 #include "wiimote.h" 
     40#include "cwiid.h" 
    3841#include "wmplugin.h" 
    3942#include "y.tab.h" 
     
    163166 
    164167struct uinput_listen_data { 
    165         wiimote_t *wiimote; 
     168        cwiid_wiimote_t *wiimote; 
    166169        struct conf *conf; 
    167170}; 
  • wminput/main.c

    r9ef2b8a r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-04 L. Donnie Smith <cwiid@abstrakraft.org> 
    19  *  * exit on wiimote_error 
     22 *  * exit on cwiid_error 
    2023 * 
    2124 *  2007-03-03 L. Donnie Smith <cwiid@abstrakraft.org> 
     
    3336#include <unistd.h> 
    3437 
    35 #include <wiimote.h> 
     38#include <cwiid.h> 
    3639 
    3740#include "conf.h" 
     
    4750 
    4851/* Prototypes */ 
    49 wiimote_mesg_callback_t wiimote_callback; 
     52cwiid_mesg_callback_t cwiid_callback; 
    5053int 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 * []); 
     54void process_btn_mesg(struct cwiid_btn_mesg *mesg); 
     55void process_nunchuk_mesg(struct cwiid_nunchuk_mesg *mesg); 
     56void process_classic_mesg(struct cwiid_classic_mesg *mesg); 
     57void process_plugin(struct plugin *, int, union cwiid_mesg * []); 
    5558 
    5659/* Globals */ 
    57 wiimote_t *wiimote; 
     60cwiid_wiimote_t *wiimote; 
    5861char init; 
    5962 
     
    137140                } 
    138141        } 
    139         else if ((str_addr = getenv(WIIMOTE_BDADDR)) != NULL) { 
     142        else if ((str_addr = getenv(CWIID_BDADDR)) != NULL) { 
    140143                if (str2ba(str_addr, &bdaddr)) { 
    141                         wminput_err("invalid address in %s", WIIMOTE_BDADDR); 
     144                        wminput_err("invalid address in %s", CWIID_BDADDR); 
    142145                        bdaddr = *BDADDR_ANY; 
    143146                } 
     
    150153        printf("Put Wiimote in discoverable mode now (press 1+2)...\n"); 
    151154        if (wait_forever) { 
    152                 if (wiimote_find_wiimote(&bdaddr, -1)) { 
     155                if (cwiid_find_wiimote(&bdaddr, -1)) { 
    153156                        wminput_err("error finding wiimote"); 
    154157                        conf_unload(&conf); 
     
    156159                } 
    157160        } 
    158         if ((wiimote = wiimote_connect(&bdaddr, wiimote_callback, NULL)) == NULL) { 
     161        if ((wiimote = cwiid_connect(&bdaddr, cwiid_callback, NULL)) == NULL) { 
    159162                wminput_err("unable to connect"); 
    160163                conf_unload(&conf); 
     
    167170                        wminput_err("error on %s init", conf.plugins[i].name); 
    168171                        conf_unload(&conf); 
    169                         wiimote_disconnect(wiimote); 
     172                        cwiid_disconnect(wiimote); 
    170173                        return -1; 
    171174                } 
     
    174177        if (wminput_set_report_mode()) { 
    175178                conf_unload(&conf); 
    176                 wiimote_disconnect(wiimote); 
     179                cwiid_disconnect(wiimote); 
    177180                return -1; 
    178181        } 
     
    185188                wminput_err("error starting uinput listen thread"); 
    186189                conf_unload(&conf); 
    187                 wiimote_disconnect(wiimote); 
     190                cwiid_disconnect(wiimote); 
    188191                return -1; 
    189192        } 
     
    213216 
    214217        /* disconnect */ 
    215         if (wiimote_disconnect(wiimote)) { 
     218        if (cwiid_disconnect(wiimote)) { 
    216219                wminput_err("error on disconnect"); 
    217220                ret = -1; 
     
    247250        } 
    248251 
    249         if (wiimote_command(wiimote, WIIMOTE_CMD_RPT_MODE, rpt_mode_flags)) { 
     252        if (cwiid_command(wiimote, CWIID_CMD_RPT_MODE, rpt_mode_flags)) { 
    250253                wminput_err("error setting report mode"); 
    251254                return -1; 
     
    255258} 
    256259 
    257 void wiimote_callback(int id, int mesg_count, union wiimote_mesg *mesg[]) 
     260void cwiid_callback(int id, int mesg_count, union cwiid_mesg *mesg[]) 
    258261{ 
    259262        int i; 
     
    261264        for (i=0; i < mesg_count; i++) { 
    262265                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: 
    273276                        if (kill(getpid(),SIGINT)) { 
    274277                                wminput_err("error sending SIGINT"); 
     
    285288} 
    286289 
    287 void process_btn_mesg(struct wiimote_btn_mesg *mesg) 
     290void process_btn_mesg(struct cwiid_btn_mesg *mesg) 
    288291{ 
    289292        static uint16_t prev_buttons = 0; 
     
    310313        if (conf.amap[CONF_WM_AXIS_DPAD_X].active) { 
    311314                axis_value = 0; 
    312                 if (mesg->buttons & WIIMOTE_BTN_LEFT) { 
     315                if (mesg->buttons & CWIID_BTN_LEFT) { 
    313316                        axis_value = -1; 
    314317                } 
    315                 else if (mesg->buttons & WIIMOTE_BTN_RIGHT) { 
     318                else if (mesg->buttons & CWIID_BTN_RIGHT) { 
    316319                        axis_value = 1; 
    317320                } 
     
    326329        if (conf.amap[CONF_WM_AXIS_DPAD_Y].active) { 
    327330                axis_value = 0; 
    328                 if (mesg->buttons & WIIMOTE_BTN_DOWN) { 
     331                if (mesg->buttons & CWIID_BTN_DOWN) { 
    329332                        axis_value = -1; 
    330333                } 
    331                 else if (mesg->buttons & WIIMOTE_BTN_UP) { 
     334                else if (mesg->buttons & CWIID_BTN_UP) { 
    332335                        axis_value = 1; 
    333336                } 
     
    340343} 
    341344 
    342 void process_nunchuk_mesg(struct wiimote_nunchuk_mesg *mesg) 
     345void process_nunchuk_mesg(struct cwiid_nunchuk_mesg *mesg) 
    343346{ 
    344347        static uint8_t prev_buttons = 0; 
     
    383386} 
    384387 
    385 void process_classic_mesg(struct wiimote_classic_mesg *mesg) 
     388void process_classic_mesg(struct cwiid_classic_mesg *mesg) 
    386389{ 
    387390        static uint16_t prev_buttons = 0; 
     
    408411        if (conf.amap[CONF_CC_AXIS_DPAD_X].active) { 
    409412                axis_value = 0; 
    410                 if (mesg->buttons & WIIMOTE_CLASSIC_BTN_LEFT) { 
     413                if (mesg->buttons & CWIID_CLASSIC_BTN_LEFT) { 
    411414                        axis_value = -1; 
    412415                } 
    413                 else if (mesg->buttons & WIIMOTE_CLASSIC_BTN_RIGHT) { 
     416                else if (mesg->buttons & CWIID_CLASSIC_BTN_RIGHT) { 
    414417                        axis_value = 1; 
    415418                } 
     
    424427        if (conf.amap[CONF_CC_AXIS_DPAD_Y].active) { 
    425428                axis_value = 0; 
    426                 if (mesg->buttons & WIIMOTE_CLASSIC_BTN_DOWN) { 
     429                if (mesg->buttons & CWIID_CLASSIC_BTN_DOWN) { 
    427430                        axis_value = -1; 
    428431                } 
    429                 else if (mesg->buttons & WIIMOTE_CLASSIC_BTN_UP) { 
     432                else if (mesg->buttons & CWIID_CLASSIC_BTN_UP) { 
    430433                        axis_value = 1; 
    431434                } 
     
    441444                axis_value = mesg->l_stick_x; 
    442445                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; 
    444447                } 
    445448                send_event(&conf, conf.amap[CONF_CC_AXIS_L_STICK_X].axis_type, 
     
    451454                axis_value = mesg->l_stick_y; 
    452455                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; 
    454457                } 
    455458                send_event(&conf, conf.amap[CONF_CC_AXIS_L_STICK_Y].axis_type, 
     
    461464                axis_value = mesg->r_stick_x; 
    462465                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; 
    464467                } 
    465468                send_event(&conf, conf.amap[CONF_CC_AXIS_R_STICK_X].axis_type, 
     
    471474                axis_value = mesg->r_stick_y; 
    472475                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; 
    474477                } 
    475478                send_event(&conf, conf.amap[CONF_CC_AXIS_R_STICK_Y].axis_type, 
     
    481484                axis_value = mesg->l; 
    482485                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; 
    484487                } 
    485488                send_event(&conf, conf.amap[CONF_CC_AXIS_L].axis_type, 
     
    491494                axis_value = mesg->r; 
    492495                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; 
    494497                } 
    495498                send_event(&conf, conf.amap[CONF_CC_AXIS_R].axis_type, 
     
    499502 
    500503void 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]; 
    504507        int plugin_mesg_count = 0; 
    505508        int i; 
     
    511514        for (i=0; i < mesg_count; i++) { 
    512515                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; 
    530533                        break; 
    531534                default: 
  • wminput/plugins/acc/Makefile.in

    rbdb6c21 r805477a  
    55PLUGIN_NAME = acc 
    66SOURCES = acc.c 
    7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/wiimote 
     7CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid 
    88LDLIBS += -lm 
    99INST_DIR = $(CWIID_PLUGINS_DIR) 
  • wminput/plugins/acc/acc.c

    rf200a0f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * initialized params 
     
    5457wmplugin_init_t wmplugin_init; 
    5558wmplugin_exec_t wmplugin_exec; 
    56 static void process_acc(struct wiimote_acc_mesg *mesg); 
     59static void process_acc(struct cwiid_acc_mesg *mesg); 
    5760 
    5861struct wmplugin_info *wmplugin_info() { 
     
    102105} 
    103106 
    104 int wmplugin_init(int id, wiimote_t *wiimote) 
     107int wmplugin_init(int id, cwiid_wiimote_t *wiimote) 
    105108{ 
    106109        unsigned char buf[7]; 
     
    111114        data.axes[0].valid = 1; 
    112115        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)) { 
    114117                return -1; 
    115118        } 
    116119 
    117         if (wiimote_read(wiimote, WIIMOTE_RW_EEPROM, 0x16, 7, buf)) { 
     120        if (cwiid_read(wiimote, CWIID_RW_EEPROM, 0x16, 7, buf)) { 
    118121                wmplugin_err(id, "unable to read wiimote info"); 
    119122                return -1; 
     
    129132} 
    130133 
    131 struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[]) 
     134struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg *mesg[]) 
    132135{ 
    133136        int i; 
     
    136139        for (i=0; i < mesg_count; i++) { 
    137140                switch (mesg[i]->type) { 
    138                 case WIIMOTE_MESG_ACC: 
     141                case CWIID_MESG_ACC: 
    139142                        process_acc(&mesg[i]->acc_mesg); 
    140143                        ret = &data; 
     
    152155double a_x = 0, a_y = 0, a_z = 0; 
    153156 
    154 static void process_acc(struct wiimote_acc_mesg *mesg) 
     157static void process_acc(struct cwiid_acc_mesg *mesg) 
    155158{ 
    156159        double a; 
  • wminput/plugins/ir_ptr/Makefile.in

    rbdb6c21 r805477a  
    55PLUGIN_NAME = ir_ptr 
    66SOURCES = ir_ptr.c 
    7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/wiimote 
     7CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid 
    88INST_DIR = $(CWIID_PLUGINS_DIR) 
    99 
  • wminput/plugins/ir_ptr/ir_ptr.c

    rf200a0f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * initialized param array 
     
    3235#include "wmplugin.h" 
    3336 
    34 wiimote_t *wiimote; 
     37cwiid_wiimote_t *wiimote; 
    3538 
    3639struct cursor { 
     
    4346/* static objects are initialized to 0 by default */ 
    4447static int a_index = -1, b_index = -1; 
    45 static struct wiimote_ir_src a, b, prev_a, prev_b; 
     48static struct cwiid_ir_src a, b, prev_a, prev_b; 
    4649 
    4750static unsigned char info_init = 0; 
     
    7780} 
    7881 
    79 int wmplugin_init(int id, wiimote_t *arg_wiimote) 
     82int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote) 
    8083{ 
    8184        wiimote = arg_wiimote; 
     
    8386        data.buttons = 0; 
    8487 
    85         if (wmplugin_set_report_mode(id, WIIMOTE_RPT_IR)) { 
     88        if (wmplugin_set_report_mode(id, CWIID_RPT_IR)) { 
    8689                return -1; 
    8790        } 
     
    9093} 
    9194 
    92 struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[]) 
     95struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg *mesg[]) 
    9396{ 
    9497        int i; 
    9598        uint8_t flags; 
    9699        static uint8_t old_flags; 
    97         struct wiimote_ir_mesg *ir_mesg; 
     100        struct cwiid_ir_mesg *ir_mesg; 
    98101 
    99102        ir_mesg = NULL; 
    100103        for (i=0; i < mesg_count; i++) { 
    101                 if (mesg[i]->type == WIIMOTE_MESG_IR) { 
     104                if (mesg[i]->type == CWIID_MESG_IR) { 
    102105                        ir_mesg = &mesg[i]->ir_mesg; 
    103106                } 
     
    123126        /* of not set, pick largest available source for a & b */ 
    124127        if (a_index == -1) { 
    125                 for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) { 
     128                for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 
    126129                        if ((ir_mesg->src[i].valid) && (i != b_index)) { 
    127130                                if ((a_index == -1) || 
     
    134137        /* if there is no current src_b, pick the largest valid one */ 
    135138        if (b_index == -1) { 
    136                 for (i=0; i < WIIMOTE_IR_SRC_COUNT; i++) { 
     139                for (i=0; i < CWIID_IR_SRC_COUNT; i++) { 
    137140                        if ((ir_mesg->src[i].valid) && (i != a_index)) { 
    138141                                if ((b_index == -1) || 
     
    158161        else { 
    159162                a = ir_mesg->src[a_index]; 
    160                 a.x = WIIMOTE_IR_X_MAX - a.x; 
     163                a.x = CWIID_IR_X_MAX - a.x; 
    161164                a_debounce = 0; 
    162165        } 
     
    172175        else { 
    173176                b = ir_mesg->src[b_index]; 
    174                 b.x = WIIMOTE_IR_X_MAX - b.x; 
     177                b.x = CWIID_IR_X_MAX - b.x; 
    175178                b_debounce = 0; 
    176179        } 
     
    223226        flags = 0; 
    224227        if ((a_index == 1) || (b_index == 1)) { 
    225                 flags |= WIIMOTE_LED1_ON; 
     228                flags |= CWIID_LED1_ON; 
    226229        } 
    227230        else if ((a_index == 2) || (b_index == 2)) { 
    228                 flags |= WIIMOTE_LED2_ON; 
     231                flags |= CWIID_LED2_ON; 
    229232        } 
    230233        else if ((a_index == 3) || (b_index == 3)) { 
    231                 flags |= WIIMOTE_LED3_ON; 
     234                flags |= CWIID_LED3_ON; 
    232235        } 
    233236        else if ((a_index == 4) || (b_index == 4)) { 
    234                 flags |= WIIMOTE_LED4_ON; 
     237                flags |= CWIID_LED4_ON; 
    235238        } 
    236239        if (flags != old_flags) { 
    237240                /* TODO: if this message is sent every time, we get a battery meter of 
    238241                 * blinking lights - why? */ 
    239                 wiimote_command(wiimote, WIIMOTE_CMD_LED, flags); 
     242                cwiid_command(wiimote, CWIID_CMD_LED, flags); 
    240243        } 
    241244        old_flags = flags; 
  • wminput/plugins/nunchuk_acc/Makefile.in

    rbdb6c21 r805477a  
    55PLUGIN_NAME = nunchuk_acc 
    66SOURCES = nunchuk_acc.c 
    7 CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/wiimote 
     7CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid 
    88LDLIBS += -lm 
    99INST_DIR = $(CWIID_PLUGINS_DIR) 
  • wminput/plugins/nunchuk_acc/nunchuk_acc.c

    rf200a0f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * copied low-pass filter from acc plugin 
     
    4548static struct wmplugin_data data; 
    4649 
    47 static wiimote_t *wiimote; 
     50static cwiid_wiimote_t *wiimote; 
    4851 
    4952static struct acc acc_zero, acc_one; 
     
    5457wmplugin_exec_t wmplugin_exec; 
    5558 
    56 static void process_nunchuk(struct wiimote_nunchuk_mesg *mesg); 
     59static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg); 
    5760 
    5861struct wmplugin_info *wmplugin_info() { 
     
    102105} 
    103106 
    104 int wmplugin_init(int id, wiimote_t *wiimote_arg) 
     107int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote) 
    105108{ 
    106109        plugin_id = id; 
    107         wiimote = wiimote_arg; 
     110        wiimote = arg_wiimote; 
    108111        data.buttons = 0; 
    109112        data.axes[0].valid = 1; 
    110113        data.axes[1].valid = 1; 
    111114        if (wmplugin_set_report_mode(id, 
    112                                      WIIMOTE_RPT_STATUS | WIIMOTE_RPT_NUNCHUK)) { 
     115                                     CWIID_RPT_STATUS | CWIID_RPT_NUNCHUK)) { 
    113116                return -1; 
    114117        } 
     
    117120} 
    118121 
    119 struct wmplugin_data *wmplugin_exec(int mesg_count, union wiimote_mesg *mesg[]) 
     122struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg *mesg[]) 
    120123{ 
    121124        int i; 
    122         enum wiimote_ext_type extension = WIIMOTE_EXT_NONE; 
     125        enum cwiid_ext_type extension = CWIID_EXT_NONE; 
    123126        unsigned char buf[7]; 
    124127        struct wmplugin_data *ret = NULL; 
     
    126129        for (i=0; i < mesg_count; i++) { 
    127130                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, 
    132135                                                 0xA40020, 7, buf)) { 
    133136                                        wmplugin_err(plugin_id, "unable to read wiimote info"); 
     
    142145                        extension = mesg[i]->status_mesg.extension; 
    143146                        break; 
    144                 case WIIMOTE_MESG_NUNCHUK: 
     147                case CWIID_MESG_NUNCHUK: 
    145148                        process_nunchuk(&mesg[i]->nunchuk_mesg); 
    146149                        ret = &data; 
     
    158161double a_x = 0, a_y = 0, a_z = 0; 
    159162 
    160 static void process_nunchuk(struct wiimote_nunchuk_mesg *mesg) 
     163static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg) 
    161164{ 
    162165        double a; 
  • wminput/uinput.c

    re39b37a r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@anstrakraft.org> 
    1922 *  * fixed signed/unsigned comparison warning in uinput_open 
     
    256259                                        wminput_err("Error on ff upload begin"); 
    257260                                } 
    258                                 if (wiimote_command(data->wiimote, WIIMOTE_CMD_RUMBLE, 1)) { 
     261                                if (cwiid_command(data->wiimote, CWIID_CMD_RUMBLE, 1)) { 
    259262                                        wminput_err("Error setting rumble"); 
    260263                                } 
     
    268271                                        wminput_err("Error on ff erase begin"); 
    269272                                } 
    270                                 if (wiimote_command(data->wiimote, WIIMOTE_CMD_RUMBLE, 0)) { 
     273                                if (cwiid_command(data->wiimote, CWIID_CMD_RUMBLE, 0)) { 
    271274                                        wminput_err("Error clearing rumble"); 
    272275                                } 
  • wminput/wmplugin.h

    rf200a0f r805477a  
    1616 * 
    1717 *  ChangeLog: 
     18 *  2007-04-09 L. Donnie Smith <cwiid@abstrakraft.org> 
     19 *  * updated for libcwiid rename 
     20 * 
    1821 *  2007-04-08 L. Donnie Smith <cwiid@abstrakraft.org> 
    1922 *  * added param structs 
     
    2932#include <stdint.h> 
    3033#include <linux/input.h> 
    31 #include <wiimote.h> 
     34#include <cwiid.h> 
    3235 
    3336#define WMPLUGIN_MAX_BUTTON_COUNT       16 
     
    8790 
    8891typedef 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 * []); 
     92typedef int wmplugin_init_t(int, cwiid_wiimote_t *); 
     93typedef struct wmplugin_data *wmplugin_exec_t(int, union cwiid_mesg * []); 
    9194 
    9295int wmplugin_set_report_mode(int id, uint8_t flags);