Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
6.7 KiB

  1. #include "stdGSD.gsd"
  2. // script for control of HP SCL scanners
  3. function VOID DeviceAction_DeviceActionEvent()
  4. {
  5. // Handle initialization of device properties
  6. if(DeviceAction.Action == INITIALIZE_ID)
  7. {
  8. // this will call the device's specific property
  9. // initialization script function specified in the
  10. // product line file.
  11. InitializeDeviceProperties();
  12. }
  13. // Handle setting a device property
  14. else if(DeviceAction.Action == SETVALUE_ID)
  15. {
  16. if(DeviceAction.ValueID == XRESOLUTION)
  17. {
  18. LONG DataLength = 0;
  19. DataLength = (4 + LEN(STR(DeviceAction.Value)));
  20. DeviceControl.RawWrite(0,
  21. CHR(27) +
  22. "*a" +
  23. STR(DeviceAction.Value) +
  24. "R",DataLength,100)
  25. }
  26. else if(DeviceAction.ValueID == YRESOLUTION)
  27. {
  28. LONG DataLength = 0;
  29. DataLength = (4 + LEN(STR(DeviceAction.Value)));
  30. DeviceControl.RawWrite(0,
  31. CHR(27) +
  32. "*a" +
  33. STR(DeviceAction.Value) +
  34. "S",DataLength,100) }
  35. else if(DeviceAction.ValueID == XPOSITION)
  36. {
  37. LONG XresSetting = 0;
  38. DeviceProperty.GetCurrentValue(XRESOLUTION,
  39. XResSetting);
  40. LONG NewXPos = DeviceAction.Value;
  41. NewXPos = ((NewXPos * 300) / XResSetting);
  42. LONG DataLength = 0;
  43. DataLength = (4 + LEN(STR(NewXPos)));
  44. DeviceControl.RawWrite(0,CHR(27) +
  45. "*f" +
  46. STR(NewXPos) +
  47. "X",DataLength,100)
  48. }
  49. else if(DeviceAction.ValueID == YPOSITION)
  50. {
  51. LONG YResSetting = 0;
  52. DeviceProperty.GetCurrentValue(YRESOLUTION,
  53. YResSetting);
  54. LONG NewYPos = DeviceAction.Value;
  55. NewYPos = ((NewYPos * 300) / YResSetting);
  56. LONG DataLength = 0;
  57. DataLength = (4 + LEN(STR(NewYPos)));
  58. DeviceControl.RawWrite(0,CHR(27) +
  59. "*f" +
  60. STR(NewYPos) +
  61. "Y",DataLength,100)
  62. }
  63. else if(DeviceAction.ValueID == XEXTENT)
  64. {
  65. LONG XresSetting = 0;
  66. DeviceProperty.GetCurrentValue(XRESOLUTION,
  67. XResSetting);
  68. LONG NewXExt = DeviceAction.Value;
  69. NewXExt = ((NewXExt * 300) / XResSetting);
  70. LONG DataLength = 0;
  71. DataLength = (4 + LEN(STR(NewXExt)));
  72. DeviceControl.RawWrite(0,CHR(27) +
  73. "*f" +
  74. STR(NewXExt) +
  75. "P",DataLength,100)
  76. }
  77. else if(DeviceAction.ValueID == YEXTENT)
  78. {
  79. LONG YResSetting = 0;
  80. DeviceProperty.GetCurrentValue(YRESOLUTION,
  81. YResSetting);
  82. LONG NewYExt = DeviceAction.Value;
  83. NewYExt = ((NewYExt * 300) / YResSetting);
  84. LONG DataLength = 0;
  85. DataLength = (4 + LEN(STR(NewYExt)));
  86. DeviceControl.RawWrite(0,CHR(27) +
  87. "*f" +
  88. STR(NewYExt) +
  89. "Q",DataLength,100)
  90. }
  91. else if(DeviceAction.ValueID == DATATYPE)
  92. {
  93. if(DeviceAction.Value == 0)
  94. {
  95. DeviceControl.RawWrite(0,CHR(27) + "*a0T",5,100);
  96. DeviceControl.RawWrite(0,CHR(27) + "*a1G",5,100);
  97. }
  98. if(DeviceAction.Value == 2)
  99. {
  100. DeviceControl.RawWrite(0,CHR(27) + "*a4T",5,100);
  101. DeviceControl.RawWrite(0,CHR(27) + "*a8G",5,100);
  102. }
  103. if(DeviceAction.Value == 3)
  104. {
  105. DeviceControl.RawWrite(0,CHR(27) + "*a5T",5,100);
  106. DeviceControl.RawWrite(0,CHR(27) + "*a24G",6,100);
  107. }
  108. else
  109. {
  110. // unsupported data type, FAIL this call
  111. }
  112. }
  113. else if(DeviceAction.ValueID == BRIGHTNESS)
  114. {
  115. LONG DataLength = 0;
  116. DataLength = (4 + LEN(STR(DeviceAction.Value)));
  117. DeviceControl.RawWrite(0,
  118. CHR(27) +
  119. "*a" +
  120. STR(DeviceAction.Value) +
  121. "K",DataLength,100)
  122. }
  123. else if(DeviceAction.ValueID == CONTRAST)
  124. {
  125. LONG DataLength = 0;
  126. DataLength = (4 + LEN(STR(DeviceAction.Value)));
  127. DeviceControl.RawWrite(0,
  128. CHR(27) +
  129. "*a" +
  130. STR(DeviceAction.Value) +
  131. "L",DataLength,100)
  132. }
  133. else if(DeviceAction.ValueID == NEGATIVE)
  134. {
  135. DeviceControl.RawWrite(0,chr(27) + "*a1I",5,100);
  136. }
  137. }
  138. // Handle getting a device property
  139. else if(DeviceAction.Action == GETVALUE_ID)
  140. {
  141. }
  142. // Handle getting a device property
  143. else if(DeviceAction.Action == RESETDEVICE_ID)
  144. {
  145. }
  146. // Handle starting a scan
  147. else if(DeviceAction.Action == SCAN_FIRST_ID)
  148. {
  149. DeviceControl.RawWrite(0,CHR(27)+"*f0S",5,100);
  150. GetDataFromDevice(DeviceAction.Value);
  151. }
  152. // Handle scanning data
  153. else if(DeviceAction.Action == SCAN_NEXT_ID)
  154. {
  155. GetDataFromDevice(DeviceAction.Value);
  156. }
  157. // Handle finishing a scan
  158. else if(DeviceAction.Action == SCANFINISHED_ID)
  159. {
  160. DeviceControl.RawWrite(0,CHR(27) + CHR(69),2,100);
  161. }
  162. // Handle canceling a scan
  163. else if(DeviceAction.Action == SCAN_CANCEL_ID)
  164. {
  165. DeviceControl.RawWrite(0,CHR(27) + CHR(69),2,100);
  166. }
  167. // Handle default case
  168. else
  169. {
  170. // unknown action ID
  171. }
  172. }
  173. function BOOL GetDataFromDevice(LONG lBytesToRead)
  174. {
  175. LONG lBytesRead = 0;
  176. LONG lErrorCode = S_OK;
  177. DeviceControl.ScanRead(0,lBytesToRead,lBytesRead,100);
  178. lErrorCode = LastError.GetLastError();
  179. if(lErrorCode == S_OK)
  180. return TRUE;
  181. }