Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

REORG Refactor pen detection

  • Loading branch information...
commit a11739481261eb40bca07967ce5ad04ae5664e0c 1 parent 8b20ce5
Luis Pedro Coelho authored August 06, 2011
10  GUIFrame.cpp
@@ -352,10 +352,10 @@ uint16_t GUIFrame::refreshDeviceState() {
352 352
         return 0x0000;
353 353
     } else {
354 354
         printf("detecting smartpen...");
355  
-        printf("smartpen idProduct: %s\n", dev->descriptor.idProduct);
356  
-        if (dev->descriptor.idProduct == LS_PULSE) {
  355
+        printf("smartpen idProduct: %d\n", dev->descriptor.idProduct);
  356
+        if (is_ls_pulse(dev->descriptor.idProduct)) {
357 357
             printf("LiveScribe Pulse(TM) Smartpen Detected!\n");
358  
-        } else if ((dev->descriptor.idProduct == LS_ECHO) || (dev->descriptor.idProduct == 0x1032)) {
  358
+        } else if (is_ls_echo(dev->descriptor.idProduct)) {
359 359
             printf("LiveScribe Echo(TM) Smartpen Detected!\n");
360 360
         } else {
361 361
             printf("Unknown LiveScribe device detected! Attempting to use this device anyways...\n");
@@ -375,10 +375,10 @@ void GUIFrame::doRefreshDeviceState() {
375 375
             statusBar->SetStatusText(_("Unable to locate a compatible Smartpen device"), 1);
376 376
         } else {
377 377
             this->mainToolbar->EnableTool(idToolbarInfo,true);
378  
-            if (dev->descriptor.idProduct == LS_PULSE) {
  378
+            if (is_ls_pulse(dev->descriptor.idProduct)) {
379 379
                 statusBar->SetStatusText(_("LiveScribe Pulse(TM) Smartpen Detected!"), 1);
380 380
                 printf("LiveScribe Pulse(TM) Smartpen Detected!\n");
381  
-            } else if (dev->descriptor.idProduct == LS_ECHO) {
  381
+            } else if (is_ls_echo(dev->descriptor.idProduct)) {
382 382
                 statusBar->SetStatusText(_("LiveScribe Echo(TM) Smartpen Detected!"), 1);
383 383
                 printf("LiveScribe Echo(TM) Smartpen Detected!\n");
384 384
             } else {
4  include/Smartpen.h
@@ -28,8 +28,8 @@ along with LibreScribe.  If not, see <http://www.gnu.org/licenses/>.
28 28
 #include <usb.h>
29 29
 
30 30
 #define LS_VENDOR_ID 0x1cfb //LiveScribe Vendor ID
31  
-#define LS_PULSE 0x1020 //LiveScribe Pulse(TM) Smartpen
32  
-#define LS_ECHO 0x1030 //LiveScribe Echo(TM) Smartpen
  31
+inline bool is_ls_pulse(unsigned int c) { return c == 0x1020; } //LiveScribe Pulse(TM) Smartpen
  32
+inline bool is_ls_echo(unsigned int c) { return c == 0x1030 || c == 0x1032; } //LiveScribe Echo(TM) Smartpen
33 33
 
34 34
 static struct usb_device *findSmartpen() {
35 35
     struct usb_bus *bus;

0 notes on commit a117394

Please sign in to comment.
Something went wrong with that request. Please try again.