diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2007-02-11 00:17:41 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2007-02-11 00:17:41 +0000 |
commit | 5b1649afe025b7b3f0e620fbd4c7a21b71545fe5 (patch) | |
tree | 0e20fd150b4b573015c539b39e1e12def1c672f5 /tools | |
parent | 61f64a95d1e0e8cf4f79b799394444d4bc03b5f7 (diff) |
Add Wii-Mote HID service record
Diffstat (limited to 'tools')
-rw-r--r-- | tools/sdptool.c | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/tools/sdptool.c b/tools/sdptool.c index 6418eafb..8864dc99 100644 --- a/tools/sdptool.c +++ b/tools/sdptool.c @@ -2069,6 +2069,7 @@ end: return ret; } + static int add_hid_keyb(sdp_session_t *session, svc_info_t *si) { sdp_record_t record; @@ -2232,6 +2233,177 @@ static int add_hid_keyb(sdp_session_t *session, svc_info_t *si) return 0; } +static int add_hid_wiimote(sdp_session_t *session, svc_info_t *si) +{ + sdp_record_t record; + sdp_list_t *svclass_id, *pfseq, *apseq, *root; + uuid_t root_uuid, hid_uuid, l2cap_uuid, hidp_uuid; + sdp_profile_desc_t profile[1]; + sdp_list_t *aproto, *proto[3]; + sdp_data_t *psm, *lang_lst, *lang_lst2, *hid_spec_lst, *hid_spec_lst2; + int i; + uint8_t dtd = SDP_UINT16; + uint8_t dtd2 = SDP_UINT8; + uint8_t dtd_data = SDP_TEXT_STR8; + void *dtds[2]; + void *values[2]; + void *dtds2[2]; + void *values2[2]; + int leng[2]; + uint8_t hid_spec_type = 0x22; + uint16_t hid_attr_lang[] = { 0x409, 0x100 }; + uint16_t ctrl = 0x11, intr = 0x13; + uint16_t hid_release = 0x0100, parser_version = 0x0111; + uint8_t subclass = 0x04, country = 0x33; + uint8_t virtual_cable = 0, reconnect = 1, sdp_disable = 0; + uint8_t battery = 1, remote_wakeup = 1; + uint16_t profile_version = 0x0100, superv_timeout = 0x0c80; + uint8_t norm_connect = 0, boot_device = 0; + const uint8_t hid_spec[] = { + 0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x10, + 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95, + 0x01, 0x06, 0x00, 0xff, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x11, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x12, 0x95, 0x02, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x13, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x14, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x15, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x16, 0x95, 0x15, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x17, 0x95, 0x06, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x18, 0x95, 0x15, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x19, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x1a, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00, + 0x85, 0x20, 0x95, 0x06, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x21, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x22, 0x95, 0x04, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x30, 0x95, 0x02, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x31, 0x95, 0x05, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x32, 0x95, 0x0a, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x33, 0x95, 0x11, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x34, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x35, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x36, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x37, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x3d, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x3e, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0x85, 0x3f, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00, + 0xc0, 0x00 + }; + + memset(&record, 0, sizeof(sdp_record_t)); + record.handle = si->handle; + + sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP); + root = sdp_list_append(NULL, &root_uuid); + sdp_set_browse_groups(&record, root); + + sdp_uuid16_create(&hid_uuid, HID_SVCLASS_ID); + svclass_id = sdp_list_append(NULL, &hid_uuid); + sdp_set_service_classes(&record, svclass_id); + + sdp_uuid16_create(&profile[0].uuid, HID_PROFILE_ID); + profile[0].version = 0x0100; + pfseq = sdp_list_append(NULL, profile); + sdp_set_profile_descs(&record, pfseq); + + sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID); + proto[1] = sdp_list_append(0, &l2cap_uuid); + psm = sdp_data_alloc(SDP_UINT16, &ctrl); + proto[1] = sdp_list_append(proto[1], psm); + apseq = sdp_list_append(0, proto[1]); + + sdp_uuid16_create(&hidp_uuid, HIDP_UUID); + proto[2] = sdp_list_append(0, &hidp_uuid); + apseq = sdp_list_append(apseq, proto[2]); + + aproto = sdp_list_append(0, apseq); + sdp_set_access_protos(&record, aproto); + + proto[1] = sdp_list_append(0, &l2cap_uuid); + psm = sdp_data_alloc(SDP_UINT16, &intr); + proto[1] = sdp_list_append(proto[1], psm); + apseq = sdp_list_append(0, proto[1]); + + sdp_uuid16_create(&hidp_uuid, HIDP_UUID); + proto[2] = sdp_list_append(0, &hidp_uuid); + apseq = sdp_list_append(apseq, proto[2]); + + aproto = sdp_list_append(0, apseq); + sdp_set_add_access_protos(&record, aproto); + + add_lang_attr(&record); + + sdp_set_info_attr(&record, "Nintendo RVL-CNT-01", + "Nintendo", "Nintendo RVL-CNT-01"); + + sdp_attr_add_new(&record, SDP_ATTR_HID_DEVICE_RELEASE_NUMBER, + SDP_UINT16, &hid_release); + + sdp_attr_add_new(&record, SDP_ATTR_HID_PARSER_VERSION, + SDP_UINT16, &parser_version); + + sdp_attr_add_new(&record, SDP_ATTR_HID_DEVICE_SUBCLASS, + SDP_UINT8, &subclass); + + sdp_attr_add_new(&record, SDP_ATTR_HID_COUNTRY_CODE, + SDP_UINT8, &country); + + sdp_attr_add_new(&record, SDP_ATTR_HID_VIRTUAL_CABLE, + SDP_BOOL, &virtual_cable); + + sdp_attr_add_new(&record, SDP_ATTR_HID_RECONNECT_INITIATE, + SDP_BOOL, &reconnect); + + dtds[0] = &dtd2; + values[0] = &hid_spec_type; + dtds[1] = &dtd_data; + values[1] = (uint8_t *) hid_spec; + leng[0] = 0; + leng[1] = sizeof(hid_spec); + hid_spec_lst = sdp_seq_alloc_with_length(dtds, values, leng, 2); + hid_spec_lst2 = sdp_data_alloc(SDP_SEQ8, hid_spec_lst); + sdp_attr_add(&record, SDP_ATTR_HID_DESCRIPTOR_LIST, hid_spec_lst2); + + for (i = 0; i < sizeof(hid_attr_lang) / 2; i++) { + dtds2[i] = &dtd; + values2[i] = &hid_attr_lang[i]; + } + + lang_lst = sdp_seq_alloc(dtds2, values2, sizeof(hid_attr_lang) / 2); + lang_lst2 = sdp_data_alloc(SDP_SEQ8, lang_lst); + sdp_attr_add(&record, SDP_ATTR_HID_LANG_ID_BASE_LIST, lang_lst2); + + sdp_attr_add_new(&record, SDP_ATTR_HID_SDP_DISABLE, + SDP_BOOL, &sdp_disable); + + sdp_attr_add_new(&record, SDP_ATTR_HID_BATTERY_POWER, + SDP_BOOL, &battery); + + sdp_attr_add_new(&record, SDP_ATTR_HID_REMOTE_WAKEUP, + SDP_BOOL, &remote_wakeup); + + sdp_attr_add_new(&record, SDP_ATTR_HID_PROFILE_VERSION, + SDP_UINT16, &profile_version); + + sdp_attr_add_new(&record, SDP_ATTR_HID_SUPERVISION_TIMEOUT, + SDP_UINT16, &superv_timeout); + + sdp_attr_add_new(&record, SDP_ATTR_HID_NORMALLY_CONNECTABLE, + SDP_BOOL, &norm_connect); + + sdp_attr_add_new(&record, SDP_ATTR_HID_BOOT_DEVICE, + SDP_BOOL, &boot_device); + + if (sdp_record_register(session, &record, SDP_RECORD_PERSIST) < 0) { + printf("Service Record registration failed\n"); + return -1; + } + + printf("Wii-Mote service registered\n"); + + return 0; +} + static int add_cip(sdp_session_t *session, svc_info_t *si) { sdp_list_t *svclass_id, *pfseq, *apseq, *root; @@ -3119,6 +3291,7 @@ struct { { "HCRP", HCR_SVCLASS_ID, NULL }, { "HID", HID_SVCLASS_ID, NULL }, { "KEYB", HID_SVCLASS_ID, add_hid_keyb }, + { "WIIMOTE", HID_SVCLASS_ID, add_hid_wiimote }, { "CIP", CIP_SVCLASS_ID, add_cip }, { "CTP", CORDLESS_TELEPHONY_SVCLASS_ID, add_ctp }, |