annotate rcctl.c @ 8:a630b07450be

revised help message
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Thu, 06 Jan 2011 03:38:31 +0900
parents d2b8d45019d9
children c6f444d2272c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
1 /* rcctl.c ---------------------------------------------
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
2 $Id: rcctl.c,v 1.1 2002/12/21 01:13:28 tosy Exp $
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
3
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
4 v0.10 97.08.15 初期版(コミケット52)
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
5 v0.11 97.08.27 通信タイミング修正
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
6 v0.12 97.09.12 U-kara-2サポート
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
7 v0.12a 97.09.15 返り値設定
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
8 v0.12b 97.09.20 Bug fix (JOY:[SP])
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
9 v0.20 97.10.01 FreeBSD版
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
10 v0.20a 97.10.18 Bug fix (X2k:[SP],[ST])
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
11 v0.21 97.12.10 ALISA-3シーケンス修正
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
12 v0.30 97.12.13 コード変換部(cdcnv.c)分離
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
13 v0.40 02.12.16 USB版対応
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
14 v0.50 11.01.06 linux専用に書き直し (yaz)
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
15 【cdcnv.c の履歴も参照のこと】
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
16 ------------------------------------------------------*/
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
17
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 #include <stdio.h>
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
19 #include <hid.h>
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
20 #include <libusb.h>
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
21 #include "debug.h"
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
22
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
23 #ifndef S_VERS
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
24 #define S_VERS "0.50"
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
25 #endif
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
26
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
27 /* globals */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
28 HIDInterface *hidif;
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
29 int debug = 0;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
30
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
31 /* prototypes */
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
32 int cdcnv(int buf[], char *mak, char *cod);
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
33 extern char *cverrstr[];
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
34
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
35 int init_usb(void)
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
36 {
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
37 hid_return ret;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
38
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
39 /* vendor id and product id of okecon */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
40 HIDInterfaceMatcher matcher = { 0x0bfe, 0x2022, NULL, NULL, 0 };
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
41
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
42 /* see include/debug.h for possible values */
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
43 hid_set_debug(debug);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
44 hid_set_debug_stream(stderr);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
45 /* passed directly to libusb */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
46 hid_set_usb_debug(0);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
47
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
48 ret = hid_init();
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
49 if (ret != HID_RET_SUCCESS) {
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
50 message(0, "hid_init failed with return code %d\n", ret);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
51 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
52 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
53
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
54 hidif = hid_new_HIDInterface();
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
55 if (hidif == 0) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
56 fprintf(stderr, "hid_new_HIDInterface() failed, out of memory?\n");
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
57 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
58 }
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
59
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
60 ret = hid_force_open(hidif, 0, &matcher, 3);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
61 if (ret != HID_RET_SUCCESS) {
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
62 message(0, "hid_force_open failed with return code %d\n", ret);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
63 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
64 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
65
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
66 return 0;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
67 } /* end of init_usb() */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
68
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
69
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
70 int fin_usb()
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
71 {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
72 hid_return ret;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
73
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
74 ret = hid_close(hidif);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
75 if (ret != HID_RET_SUCCESS) {
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
76 message(0, "hid_close failed with return code %d\n", ret);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
77 return 1;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
78 }
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
79
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
80 hid_delete_HIDInterface(&hidif);
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
81
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
82 ret = hid_cleanup();
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
83 if (ret != HID_RET_SUCCESS) {
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
84 message(0, "hid_cleanup failed with return code %d\n", ret);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
85 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
86 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
87
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
88 return 0;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
89 }
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
90
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
91 void usage(char *cmd)
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
92 {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
93 printf("'Oke-Con' controller, version " S_VERS ".\n");
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
94 printf("Copyright (C) 1997-2002 by Tosy / W341IG.\n");
8
a630b07450be revised help message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
95 printf("Adapted to linux by yaz / honeyplanet development.\n");
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
96 printf("usage: %s <options> <vender> <song number>\n", cmd);
8
a630b07450be revised help message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
97 printf("options: -d <debug level> specify debug message level\n");
a630b07450be revised help message
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 7
diff changeset
98 printf(" -h show this help\n");
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
99 exit(0);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
100 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
101
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
102
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
103 int main(int argc, char **argv)
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
104 {
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
105 int i, u, buf[16];
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
106 unsigned char sbuf[8];
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
107 hid_return ret;
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
108 int opt;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
109
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
110 if(argc < 3) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
111 usage(argv[0]);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
112 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
113
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
114 while ((opt=getopt(argc, argv, "d:h")) != -1) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
115 switch (opt) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
116 case 'd':
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
117 debug = atoi(optarg);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
118 break;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
119 case 'h':
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
120 default:
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
121 usage(argv[0]);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
122 break;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
123 }
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
124 }
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
125 argc -= optind;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
126 argv += optind;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
127
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
128 if ((u = cdcnv(buf, *argv, *(argv+1))) < 0) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
129 fprintf(stderr, "%s: %s\n", *argv, cverrstr[~u]);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
130 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
131 }
7
d2b8d45019d9 minor tweak
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 6
diff changeset
132 debug(2, "cdcnv %d\n", u);
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
133 debug(1, "Initializing....\n");
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
134
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
135 if (init_usb())
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
136 return 255;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
137
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
138 debug(1, "done.\n");
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
139
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
140 debug(1, "");
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
141 for(i=0; i<u; i++ ) {
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
142 message(1, "%02x ", buf[i]);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
143 }
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
144 message(1, "\n");
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
145
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
146 const int PATH_IN[1] = { 0xffa10004 };
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
147
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
148 /* u is the total length of the packet to send */
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
149 debug(1,"");
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
150 for(i=1; i<u; i++ ) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
151 sbuf[(i-1)%8] = buf[i] & 0x00ff;
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
152 message(1, "%02x ", sbuf[(i-1)%8]);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
153 if ((i == 8)||(i == (u-1))) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
154 ret = hid_set_output_report(hidif, PATH_IN, 2, (char *)sbuf, 8);
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
155 message(1, "**WRITE** ");
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
156 if (ret != HID_RET_SUCCESS) {
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
157 message(0, "hid_set_output_report failed with return code %d\n", ret);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
158 }
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
159 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
160 }
6
cd846ca24ca4 more cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2
diff changeset
161 message(1, "\n");
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
162
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
163 if(fin_usb())
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
164 return 255;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
165
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
166 return 0;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
167 }