annotate rcctl.c @ 2:b16b82dbfe87

massive cleanup
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Wed, 05 Jan 2011 21:41:39 +0900
parents 05cc06e88a57
children cd846ca24ca4
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 ------------------------------------------------------*/
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
17 #define __LINUX__
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
18 #include <fcntl.h>
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
19 #include <stdio.h>
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
20 //#include <termios.h>
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
21 //#include <unistd.h>
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
22 //#include <sys/ioctl.h>
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
23
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
24 #define HID_MAX_USAGES 16
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
25 typedef unsigned int __u32;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
26 typedef unsigned int kernel_ulong_t;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
27
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
28 #include <hid.h>
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
29 #include <libusb.h>
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 #include <linux/types.h>
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
32
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
33 #define BITS_PER_LONG 32
0
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 #include <asm/types.h>
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
36 #include <errno.h>
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
37 #include <string.h>
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
38
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
39 #include "debug.h"
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
40
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
41 #ifndef S_VERS
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
42 #define S_VERS "0.50"
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
43 #endif
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
44
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
45 /* globals */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
46 HIDInterface *hidif;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
47 extern int errno;
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
48 int debug = 0;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
49
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
50 /* prototypes */
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
51 int cdcnv(int buf[], char *mak, char *cod);
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
52 extern char *cverrstr[];
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 int init_usb(void)
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
55 {
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
56 hid_return ret;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
57
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
58 /* 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
59 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
60
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
61 /* see include/debug.h for possible values */
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
62 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
63 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
64 /* passed directly to libusb */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
65 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
66
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
67 ret = hid_init();
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
68 if (ret != HID_RET_SUCCESS) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
69 fprintf(stderr, "hid_init failed with return code %d\n", ret);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
70 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
71 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
72
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
73 hidif = hid_new_HIDInterface();
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
74 if (hidif == 0) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
75 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
76 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
77 }
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
78
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
79 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
80 if (ret != HID_RET_SUCCESS) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
81 fprintf(stderr, "hid_force_open failed with return code %d\n", ret);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
82 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
83 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
84
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
85 return 0;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
86 } /* end of init_usb() */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
87
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
88
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
89 int fin_usb()
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
90 {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
91 hid_return ret;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
92
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
93 ret = hid_close(hidif);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
94 if (ret != HID_RET_SUCCESS) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
95 fprintf(stderr, "hid_close failed with return code %d\n", ret);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
96 return 1;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
97 }
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
98
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
99 hid_delete_HIDInterface(&hidif);
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
100
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
101 ret = hid_cleanup();
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
102 if (ret != HID_RET_SUCCESS) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
103 fprintf(stderr, "hid_cleanup failed with return code %d\n", ret);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
104 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
105 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
106
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
107 return 0;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
108 }
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 void usage(char *cmd)
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
111 {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
112 printf("'Oke-Con' controller, version " S_VERS ".\n");
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
113 printf("Copyright (C) 1997-2002 by Tosy / W341IG.\n");
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
114 printf("Adapted to linux by yaz / honeyplanet development\n");
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
115 printf("usage: %s <options> <vender> <song number>\n", cmd);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
116 printf("options: -d <debug level>\n");
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
117 exit(0);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
118 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
119
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
120
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
121 int main(int argc, char **argv)
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
122 {
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
123 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
124 unsigned char sbuf[8];
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
125 hid_return ret;
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
126 int opt;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
127
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
128 if(argc < 3) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
129 usage(argv[0]);
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
130 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
131
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
132 while ((opt=getopt(argc, argv, "d:h")) != -1) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
133 switch (opt) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
134 case 'd':
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
135 debug = atoi(optarg);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
136 break;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
137 case 'h':
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
138 default:
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
139 usage(argv[0]);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
140 break;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
141 }
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
142 }
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
143 argc -= optind;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
144 argv += optind;
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
145
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
146 if ((u = cdcnv(buf, *argv, *(argv+1))) < 0) {
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
147 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
148 return 1;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
149 }
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
150 debug(1, "cdcnv %d\n", u);
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
151 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
152
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
153 if (init_usb())
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
154 return 255;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
155
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
156 debug(1, " done.\n");
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
157
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
158 for(i=0; i<u; i++ ) {
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
159 debug(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
160 }
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
161 debug(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 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
164
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
165 /* u is the total length of the packet to send */
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
166 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
167 sbuf[(i-1)%8] = buf[i] & 0x00ff;
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
168 debug(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
169 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
170 ret = hid_set_output_report(hidif, PATH_IN, 2, (char *)sbuf, 8);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
171 fprintf(stderr, "**WRITE**\n");
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
172 if (ret != HID_RET_SUCCESS) {
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
173 fprintf(stderr, "hid_set_output_report failed with return code %d\n", ret);
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
174 }
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
175 }
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
176 }
2
b16b82dbfe87 massive cleanup
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 1
diff changeset
177 debug(1, "\n");
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
178
1
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
179 if(fin_usb())
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
180 return 255;
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
181
05cc06e88a57 modified to make use of libhid to access the device
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 0
diff changeset
182 return 0;
0
e1a1a181c0d7 initial import
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents:
diff changeset
183 }