本文整理汇总了C++中IDriver::Scatter方法的典型用法代码示例。如果您正苦于以下问题:C++ IDriver::Scatter方法的具体用法?C++ IDriver::Scatter怎么用?C++ IDriver::Scatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDriver
的用法示例。
在下文中一共展示了IDriver::Scatter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
FILE *ofile = fopen("/tmp/KeyboardDriverProxyTests.out", "w");
if (!ofile) {
Service::Panic((char *)NAME, (char *)strerror(errno), errno);
return errno;
}
IDriver *proxy = new DriverProxy();
int ret = proxy->Open("MockKeyboardDriver", 123);
fprintf(ofile, "Open returned: %d\n", ret);
ret = proxy->Close();
fprintf(ofile, "Close returned: %d\n", ret);
unsigned char buffer[BUFFER_SIZE];
ret = proxy->Read(0, BUFFER_SIZE, buffer);
fprintf(ofile, "Read returned: %d\n", ret);
fprintf(ofile, "Read data: ");
for (unsigned i = 0; i < BUFFER_SIZE; ++i) {
fprintf(ofile, "0x%X ", buffer[i]);
}
fprintf(ofile, "\n");
ret = proxy->IOControl(KEYBOARD_IOCTL_CLEAR_DATA, NULL);
fprintf(ofile, "IOControl returned: %d\n", ret);
ret = proxy->Gather(0, 0, NULL);
fprintf(ofile, "Gather returned: %d\n", ret);
ret = proxy->Scatter(0, 0, NULL);
fprintf(ofile, "Scatter returned: %d\n", ret);
ret = proxy->Cancel();
fprintf(ofile, "Cancel returned: %d\n", ret);
buffer[0] = static_cast<unsigned char>(0);
// Wait for service to be terminated.
while (1) {
// Here we will continue to ask driver to flip keyboard activity for us.
ret = proxy->Write(0, 1, buffer);
fprintf(ofile, "Write returned: %d\n", ret);
buffer[0] = !buffer[0];
if (fflush(ofile) < 0) {
Service::Panic((char *)NAME, (char *)strerror(errno), errno);
return errno;
}
sleep(900);
}
if (fclose(ofile) < 0) {
Service::Panic((char *)NAME, (char *)strerror(errno), errno);
return errno;
}
delete proxy;
return 0;
}