/*****************************************************************************************
*  Copyright (c) 2004, Beijing Senselock Data Security Centre
*  All rights reserved.
*
*  Filename£ºsample_4.c
*          
*  Briefs£º  The purpose of this snippet is to demonstrate how to set SenseLock EL run
*            on USB/HID mode.
*            
*            
*  History:        
*  --------------------------------------------------------        
*            11/08/2004 v1.0.0.0 Lihua created
*            
*            
*******************************************************************************************/

#include <stdio.h>
#include <conio.h>
#include <assert.h>

#include "..\..\inc\win32\sense4.h"
#include "..\..\common\common.h"


int main(int argc, char* argv[])
{
	SENSE4_CONTEXT stS4Ctx = {0};
	unsigned long dwResult = 0;
	int ch = 0;
	int finish = 0;
	
	do
	{
		printf("1: Set SenseLock EL run on USB mode;\
			  \n2: Set SenseLock EL run on HID mode;\
			  \n3: Exit;\
			  \nYour Choice:");
		ch = getch();
		if (!(dwResult = OpenS4ByIndex(FIRST_S4_INDEX, &stS4Ctx)))
		{
			return 1;
		} 
		switch(ch) 
		{
		case '1':
			printf("Set SenseLock EL run on USB mode...\n");
			dwResult = S4Control(&stS4Ctx, S4_SET_USB_MODE, NULL, 0, NULL, 0, NULL);
			if (dwResult != S4_SUCCESS) 
			{
				printf("Set SenseLock EL running mode failed! <error code: 0x%08x>\n", dwResult);
				S4Close(&stS4Ctx);
				return 1;
			}
			printf("Success!\n");
			
		break;		
		case '2':
			printf("Set SenseLock EL run on HID mode...\n");
			dwResult = S4Control(&stS4Ctx, S4_SET_HID_MODE, NULL, 0, NULL, 0, NULL);
			if (dwResult != S4_SUCCESS) 
			{
				printf("Set SenseLock EL running mode failed! <error code: 0x%08x>\n", dwResult);
				S4Close(&stS4Ctx);
				return 1;
			}
			printf("Success!\n");		
    	break;

		case '3':
			finish = 1;
		break;
		default:
			printf("Invalid input!\n");
		}
		S4Close(&stS4Ctx);
	
	}while(!finish);

	return dwResult;
}





















