Browse Source

+ Added more wince api interface units by Vasil Maximov.

git-svn-id: trunk@11204 -
yury 17 years ago
parent
commit
0dbc1960bc

+ 3 - 0
.gitattributes

@@ -4502,9 +4502,12 @@ packages/winceunits/src/gpsapi.pp svneol=native#text/plain
 packages/winceunits/src/gx.pp svneol=native#text/plain
 packages/winceunits/src/htmlctrl.pp svneol=native#text/plain
 packages/winceunits/src/iphlpapi.pp svneol=native#text/plain
+packages/winceunits/src/keybd.pp svneol=native#text/plain
 packages/winceunits/src/msgqueue.pp svneol=native#text/plain
+packages/winceunits/src/nled.pp svneol=native#text/plain
 packages/winceunits/src/notify.pp svneol=native#text/plain
 packages/winceunits/src/oleauto.pp svneol=native#text/plain
+packages/winceunits/src/phone.pp svneol=native#text/plain
 packages/winceunits/src/pimstore.pp svneol=native#text/plain
 packages/winceunits/src/pm.pp svneol=native#text/plain
 packages/winceunits/src/power.pp svneol=native#text/plain

+ 2 - 2
packages/winceunits/Makefile

@@ -270,10 +270,10 @@ ifeq ($(FULL_TARGET),arm-wince)
 override TARGET_UNITS+=comobj buildwinceunits
 endif
 ifeq ($(FULL_TARGET),i386-wince)
-override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleauto power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service htmlctrl sipapi cpl bt_api bt_sdp bthapi bthutil pimstore ril sms ws2bth activex ole2 comconst
+override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleauto power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service htmlctrl sipapi cpl bt_api bt_sdp bthapi bthutil pimstore ril sms ws2bth keybd nled phone activex ole2 comconst
 endif
 ifeq ($(FULL_TARGET),arm-wince)
-override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleauto power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service htmlctrl sipapi cpl bt_api bt_sdp bthapi bthutil pimstore ril sms ws2bth activex ole2 comconst
+override TARGET_IMPLICITUNITS+=aygshell commctrl commdlg iphlpapi notify oleauto power shellapi simmgr tapi gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service htmlctrl sipapi cpl bt_api bt_sdp bthapi bthutil pimstore ril sms ws2bth keybd nled phone activex ole2 comconst
 endif
 ifeq ($(FULL_TARGET),i386-linux)
 override TARGET_RSTS+=comconst

+ 2 - 1
packages/winceunits/Makefile.fpc

@@ -10,7 +10,8 @@ version=2.2.0
 units_wince=comobj buildwinceunits
 implicitunits_wince=aygshell commctrl commdlg iphlpapi notify oleauto power shellapi simmgr tapi \
                     gpsapi todaycmn windbase cesync gx winioctl msgqueue pm service htmlctrl \
-                    sipapi cpl bt_api bt_sdp bthapi bthutil pimstore ril sms ws2bth \
+                    sipapi cpl bt_api bt_sdp bthapi bthutil pimstore ril sms ws2bth keybd nled \
+                    phone \
                     activex ole2 comconst
 
 units_win32=rapi cesync

+ 2 - 1
packages/winceunits/src/buildwinceunits.pp

@@ -23,7 +23,8 @@ interface
 uses
   aygshell,commctrl,commdlg,iphlpapi,notify,oleauto,power,shellapi,simmgr,tapi,
   gpsapi,todaycmn,windbase,cesync,gx,winioctl,msgqueue,pm,service,htmlctrl,
-  sipapi, cpl, bt_api, bt_sdp, bthapi, bthutil, pimstore, ril, sms, ws2bth;
+  sipapi, cpl, bt_api, bt_sdp, bthapi, bthutil, pimstore, ril, sms, ws2bth,
+  keybd, nled, phone;
 
 implementation
 

+ 315 - 0
packages/winceunits/src/keybd.pp

@@ -0,0 +1,315 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+//
+// Module: keybd.h
+//
+// Non Win32 defines and structs for WinCE keyboard.
+//
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit keybd;
+
+interface
+
+uses windows, WinIOCtl;
+
+// EXTERNAL DRIVERS
+// KEY_STATE_FLAGS | Flags for keyboard events and shift state.
+{
+These flags perform a number of functions:
+
+The low order bits are used to keep track of a key state.  This
+allows using 256 UINT8's for the key state array just like Windows does
+already.
+
+The upper bits keep track of shift state on a per key basis.  Since
+we are not maintaining a complete key state array for each task, this
+gives us some extra info without a big memory penalty.
+
+The KeyStateDownFlag does double duty internal to the driver to
+identify key up or key down events.
+
+KeyShiftDeadFlag is set by the <f KeybdDriverVKeyToUnicode> function
+to signify that the character generated is a dead character.
+
+KeyShiftNoCharacterFlag is set by the <f KeybdDriverVKeyToUnicode>
+function to signify that there is no valid character to generate for the
+given virtual key event.  This may be the case on a key up event or a key
+which only changes the shift state.
+
+The control, alt, shift and capital flags are set by the <f
+KeybdDriverVKeyToUnicode> function to encapsulate the shift state when the
+character was generated.
+
+KeybdDriverVKeyToUnicode
+KeybdEventCallback
+}
+
+type
+     KEY_STATE_FLAGS = UINT32;
+
+const
+      KeyStateToggledFlag			 = $0001;	//	Key is toggled.
+      KeyStateGetAsyncDownFlag = $0002;	//	Key went down since last GetAsyncKey call.
+      KeyStateReserved4			   = $0004;
+      KeyStateReserved8			   = $0008;
+      KeyStateReserved10			 = $0010;
+      KeyStateReserved20			 = $0020;
+      KeyStatePrevDownFlag		 = $0040;	//	Key was previously down.
+      KeyStateDownFlag			   = $0080;	//	Key is currently down.
+
+      KeyStateKeyEventFlag		= $80000000;	//	Internal
+      KeyShiftAnyCtrlFlag			= $40000000;  //  L or R control is down.
+      KeyShiftAnyShiftFlag		= $20000000;  //  L or R shift is down.
+      KeyShiftAnyAltFlag			= $10000000;  //  L or R alt is down.
+      KeyShiftCapitalFlag			= $08000000;  //  VK_CAPITAL is toggled.
+      KeyShiftLeftCtrlFlag		= $04000000;  //  L control is down.
+      KeyShiftLeftShiftFlag		= $02000000;  //  L shift is down.
+      KeyShiftLeftAltFlag			= $01000000;  //  L alt is down.
+      KeyShiftLeftWinFlag			= $00800000;  //  L Win key is down.
+      KeyShiftRightCtrlFlag		= $00400000;  //  R control is down.
+      KeyShiftRightShiftFlag	= $00200000;  //  R shift is down.
+      KeyShiftRightAltFlag		= $00100000;  //  R alt is down.
+      KeyShiftRightWinFlag		= $00080000;  //  R Win key is down.
+      KeyShiftReserved40000		= $00040000;  //  Reserved.
+      KeyShiftDeadFlag			  = $00020000;  //  Corresponding char is dead char.
+      KeyShiftNoCharacterFlag	= $00010000;  //  No corresponding char.
+
+			KeyShiftLanguageFlag1		= $00008000;  //  Use for language specific shifts.
+      KeyShiftKeybdEventFlag	= $00004000;	//	Not for external use.
+
+      KeyShiftUseVKNullFlag		= $00002000;  //  Not for external use.
+      KeyShiftNumLockFlag			= $00001000;  //  NumLock toggled state.
+      KeyShiftScrollLockFlag	= $00000800;  //  ScrollLock toggled state.
+      KeyShiftReserved400			= $00000400;  //  Reserved.
+      KeyShiftReserved200			= $00000200;  //  Reserved.
+      KeyShiftReserved100			= $00000100;  //  Reserved.
+
+// Japanese keyboard
+      KeyShiftKanaFlag			  = KeyShiftLanguageFlag1;  //  Kana lock is toggled.
+
+
+function KeyStateIsDown(Flags:KEY_STATE_FLAGS):BOOL;
+
+function KeyStateIsPrevDown(Flags:KEY_STATE_FLAGS):BOOL;
+
+function KeyStateIsToggled(Flags:KEY_STATE_FLAGS):BOOL;
+
+function KeyStateIsDownTransition(Flags:KEY_STATE_FLAGS):BOOL;
+
+const
+      COUNT_VKEYS     = 256;
+
+{
+		EXTERNAL DRIVERS
+		KEY_STATE       | Array of virtual key states.
+}
+type
+     KEY_STATE = array[0..COUNT_VKEYS-1] of UINT8;
+
+//
+// KeyboardDriverGetDeviceInfo query capability definitions
+//
+
+
+//	EXTERNAL DRIVERS
+//	ULONG | KBDI_VKEY_TO_UNICODE_INFO_ID |
+//  Id for KeybdDriverGetInfo to get Unicode conversion info.
+//
+// xref
+//	KeybdDriverGetInfo
+//	KBDI_VKEY_TO_UNICODE_INFO
+//	KeybdDriverVKeyToUnicode
+const
+      KBDI_VKEY_TO_UNICODE_INFO_ID	= 0;
+
+
+// EXTERNAL DRIVERS KEYBD_DRIVER
+// KBDI_VKEY_TO_UNICODE_INFO
+// Info required to set up for Unicode conversion.
+//
+// xref
+//	KeybdDriverGetInfo
+//	KBDI_VKEY_TO_UNICODE_INFO_ID
+//	KeybdDriverVKeyToUnicode
+//	TO_UNICODE_STATE
+{
+cbToUnicodeState is the number of bytes necessary to store the
+driver specific state which is required to generate characters from a
+virtual key.  For example, a French keyboard driver may need to remember
+that an accent key was previously pressed in order to decide on a specific
+Unicode character to generate for a virtual key.  This value may be 0 if
+no other state besides <t KEY_STATE> is required to generate characters,
+e.g., English keyboard drivers.
+
+cMaxToUnicodeCharacters is the maximum number of characters that may
+be generated by a call to KeybdDriverVKeyToUnicode.  For example, if a
+user presses the '^' key and then the 'b' key, a French keyboard driver
+would generate the two characters, '^' 'b', when the second key is
+pressed.  Note that this is not the count of bytes required to store the
+characters, it is just the number of characters.
+}
+type
+     KBDI_VKEY_TO_UNICODE_INFO = record
+       cbToUnicodeState:UINT32;				// @FIELD 	Count of bytes required
+											                //			for state info for Unicode
+											                //			character generation.
+       cMaxToUnicodeCharacters:UINT32;		// @FIELD	Maximum number of characters
+											                    //			generated for a single virtual key.
+     end;
+
+// EXTERNAL DRIVERS
+// ULONG | KBDI_AUTOREPEAT_INFO_ID
+// Id for KeybdDriverGetInfo to get keyboard auto-repeat info.
+//
+// xref
+//  KeybdDriverGetInfo
+//  KBDI_AUTOREPEAT_INFO
+//	KBDI_AUTOREPEAT_SELECTIONS_INFO_ID
+const
+      KBDI_AUTOREPEAT_INFO_ID	= 1;
+
+
+// Info about the keyboard autorepeat capabilities and settings.
+{
+cInitialDelaysSelectable gives the number of initial delays which
+may be set.  Query again using <c KBDI_AUTOREPEAT_SELECTIONS_INFO_ID> to
+get the actual values available.
+
+cRepeatRatesSelectable is similar to cInitialDelaysSelectable except
+that it gives the number of repeat rates available.
+}
+type
+     KBDI_AUTOREPEAT_INFO = record
+	   	 CurrentInitialDelay:INT32;		// @FIELD	Current initial delay in milliseconds.
+	     CurrentRepeatRate:INT32;			// @FIELD	Current repeat rate in keys per second.
+	     cInitialDelaysSelectable:INT32;	// @FIELD	Number of initial delays selectable.
+	     cRepeatRatesSelectable:INT32;		// @FIELD	Number of repeat rates supported.
+     end;
+
+const
+      KBD_AUTO_REPEAT_INITIAL_DELAY_DEFAULT  =   500;
+      KBD_AUTO_REPEAT_INITIAL_DELAY_MIN      =   250;
+      KBD_AUTO_REPEAT_INITIAL_DELAY_MAX      =  1000;
+
+      KBD_AUTO_REPEAT_KEYS_PER_SEC_DEFAULT   =    20;
+      KBD_AUTO_REPEAT_KEYS_PER_SEC_MIN       =     2;
+      KBD_AUTO_REPEAT_KEYS_PER_SEC_MAX       =    30;
+
+
+// Id for KeybdDriverGetInfo to get keyboard auto-repeat selections info.
+{
+When KeybdDriverGetInfo is called with this value, the lpOutput
+parameter should be a pointer to an array of INT32's to hold the selection
+info.  The initial delays will be put at the beginning of the array
+followed by the repeat rate selections.  The number of initial delay
+values is determined by calling <f KeybdDriverGetInfo> using <c
+KBDI_AUTOREPEAT_INFO_ID> and looking at the returned
+cInitialDelaysSelectable field.  If this value is -1, there will be two
+(2) values, the min and max and the initial delay may be set to any value
+in this range.  This value may be 0 if the initial delay is not settable.
+Similarly, if cRepeatRatesSelectable is 0, there will be no repeat rate
+information.  If it is -1, there will be two (2) values, the min and max.
+
+Initial delay values are in milliseconds.  Repeat rates are in keys per
+second.
+}
+const
+      KBDI_AUTOREPEAT_SELECTIONS_INFO_ID	= 2;
+
+// INTERNATIONAL
+const
+      KBDI_KEYBOARD_STATUS_ID = 3;
+
+const
+      KBDI_KEYBOARD_PRESENT	  = $0001;
+      KBDI_KEYBOARD_ENABLED	  = $0002;
+      KBDI_KEYBOARD_ENTER_ESC	= $0004;
+      KBDI_KEYBOARD_ALPHA_NUM	= $0008;
+
+
+// Reserve for SHIME_MODE.
+// Pass in the SHIME_MODE as the input parameter.
+const
+      KBDI_SHIME_MODE_ID = 4;
+
+      KBDI_SHIME_MODE_NONE                = $0000;
+      KBDI_SHIME_MODE_SPELL               = $0001;
+      KBDI_SHIME_MODE_SPELL_CAPS          = $0002;
+      KBDI_SHIME_MODE_SPELL_CAPS_LOCK     = $0003;
+      KBDI_SHIME_MODE_AMBIGUOUS           = $0004;
+      KBDI_SHIME_MODE_AMBIGUOUS_CAPS      = $0005;
+      KBDI_SHIME_MODE_AMBIGUOUS_CAPS_LOCK = $0006;
+      KBDI_SHIME_MODE_NUMBERS             = $0007;
+      KBDI_SHIME_MODE_CUSTOM              = $0008;
+
+
+// External keyboard interface
+const
+      DEVCLASS_KEYBOARD_STRING = '{CBE6DDF2-F5D4-4E16-9F61-4CCC0B6695F3}';
+      DEVCLASS_KEYBOARD_GUID:System.TGUID = (D1: $CBE6DDF2; D2: $F5D4; D3: $4E16; D4: ($9F, $61, $4C, $CC, $0B, $66, $95, $F3));
+//      DEVCLASS_KEYBOARD_GUID:System.TGUID = '{CBE6DDF2-F5D4-4E16-9F61-4CCC0B6695F3}';
+
+
+// Pass in the KEY_STATE_FLAGS as the input parameter.
+const
+      IOCTL_KBD_SET_MODIFIERS = (FILE_DEVICE_KEYBOARD shl 16) or
+                                (1 shl 2) or
+                                METHOD_BUFFERED or
+                                (FILE_ANY_ACCESS shl 14);
+
+
+      IOCTL_HID_SET_MODIFIERS = IOCTL_KBD_SET_MODIFIERS;
+
+// Pass in the KBDI_AUTOREPEAT_INFO as the input parameter.
+const
+      IOCTL_KBD_SET_AUTOREPEAT = (FILE_DEVICE_KEYBOARD shl 16) or
+                                 (2 shl 2) or
+                                 METHOD_BUFFERED or
+                                 (FILE_ANY_ACCESS shl 14);
+
+      IOCTL_HID_SET_AUTOREPEAT = IOCTL_KBD_SET_AUTOREPEAT;
+
+// Pass in the Input Language's fLocaleFlags as the input parameter.
+const
+      IOCTL_KBD_SET_LOCALE_FLAGS = (FILE_DEVICE_KEYBOARD shl 16) or
+                                   (3 shl 2) or
+                                   METHOD_BUFFERED or
+                                   (FILE_ANY_ACCESS shl 14);
+
+implementation
+
+function KeyStateIsDown(Flags:KEY_STATE_FLAGS):BOOL; inline;
+begin
+  KeyStateIsDown:=(Flags and KeyStateDownFlag)<>0;
+end;
+
+function KeyStateIsPrevDown(Flags:KEY_STATE_FLAGS):BOOL; inline;
+begin
+  KeyStateIsPrevDown:=(Flags and KeyStatePrevDownFlag)<>0;
+end;
+
+function KeyStateIsToggled(Flags:KEY_STATE_FLAGS):BOOL; inline;
+begin
+  KeyStateIsToggled:=(Flags and KeyStateToggledFlag)<>0;
+end;
+
+function KeyStateIsDownTransition(Flags:KEY_STATE_FLAGS):BOOL; inline;
+begin
+  KeyStateIsDownTransition:=KeyStateIsDown(Flags) and (not KeyStateIsPrevDown(Flags));
+end;
+
+end.

+ 244 - 0
packages/winceunits/src/nled.pp

@@ -0,0 +1,244 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+//
+//File Name:	nled.h
+//
+//Abstract:   Notification LED interface.
+//
+//Notes:
+//
+//The notification LED is distinguished from other LED's which may be on the system
+//in that it can be on or blinking even if the rest of the system is powered down.  This
+//implies a certain level of hardware support for this functionality.
+//
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit NLed;
+
+{$CALLING cdecl}
+
+interface
+
+uses Windows, WinIOCtl;
+
+// @CESYSGEN IF COREDLL_NLED
+
+//
+// NLedDriverGetDeviceInfo query definitions
+//
+
+{		@DOC	EXTERNAL DRIVERS
+		@const	ULONG | NLED_COUNT_INFO_ID |
+
+Id for <f NLedDriverGetDeviceInfo> to get count of notification LED's
+
+		@XREF
+
+			<tab><f NLedDriverGetDeviceInfo><nl>
+			<tab><t NLDI_COUNT_INFO><nl>
+
+}
+const
+      NLED_COUNT_INFO_ID	= 0;
+
+
+{      @DOC    EXTERNAL DRIVERS
+		@STRUCT	NLED_COUNT_NFO |
+
+Info about number of notification LED's.
+
+		@XREF
+
+			<tab><f NLedDriverGetDeviceInfo><nl>
+			<tab><c NLED_COUNT_INFO_ID><nl>
+
+		@COMM
+
+A device will usually have one notification LED.  Some devices may have
+none however.  It would be unusual to have more than one because of the
+power drain.
+
+
+}
+type
+     NLED_COUNT_INFO = record
+	    	 cLeds:UINT;				// @FIELD 	Count of LED's
+     end;
+
+{		@DOC	EXTERNAL DRIVERS
+		@const	ULONG | NLED_SUPPORTS_INFO_ID |
+
+Id for <f NLedDriverGetDeviceInfo> to get supported capabilities of a
+notification LED.
+
+
+		@XREF
+
+			<tab><f NLedDriverGetDeviceInfo><nl>
+			<tab><t NLDI_SUPPORTS_INFO><nl>
+
+}
+const
+      NLED_SUPPORTS_INFO_ID	= 1;
+
+
+{      @DOC    EXTERNAL DRIVERS
+		@STRUCT	NLED_SUPPORTS_NFO |
+
+Info about what a notification LED supports.
+
+		@XREF
+
+			<tab><f NLedDriverGetDeviceInfo><nl>
+			<tab><c NLED_SUPPORTS_INFO_ID><nl>
+
+		@COMM
+
+Caller should first get the number of notification LED's on the system.  
+This is usually one but may be 0 and could be greater than 1.  Caller 
+should fill in the LedNum and then call <f NLedDriverGetDeviceInfo>.  Led 
+numbering starts at 0.
+
+The lCycleAdjust field is the granularity to which cycle time adjustments 
+can be made.  E.g., if the granularity is 1/16 second, lCycleAdjust = 
+62500 microseconds.  If the LED does not support blinking, this value 
+should be 0.
+
+Values are given in microseconds only to deal with computations involving 
+fractional milliseconds.  Usually only settings in the milliseconds range 
+are meaningful.  
+
+Usually a device will report that it supports up to two of:
+
+	fAdjustTotalCycleTime
+	fAdjustOnTime
+	fAdjustOffTime
+
+since any two determine the third.  The most likely settings are:
+
+	1. The cycle time is not adjustable:
+
+		fAdjustTotalCycleTime == FALSE
+		fAdjustOnTime == FALSE
+		fAdjustOffTime == FALSE
+
+	2. Only the overall cycle time is adjustable:
+
+		fAdjustTotalCycleTime == TRUE
+		fAdjustOnTime == FALSE
+		fAdjustOffTime == FALSE
+
+	3. The on and off times are independently adjustable.
+
+		fAdjustTotalCycleTime == FALSE
+		fAdjustOnTime == TRUE
+		fAdjustOffTime == TRUE
+}
+
+type
+     NLED_SUPPORTS_INFO = record
+	    	 LedNum:UINT;						// @FIELD 	LED number, 0 is first LED
+	      lCycleAdjust:LONG;				// @FIELD	Granularity of cycle time adjustments (microseconds)
+	      fAdjustTotalCycleTime:BOOL;		// @FIELD	LED has an adjustable total cycle time
+	      fAdjustOnTime:BOOL;				// @FIELD	LED has separate on time
+	      fAdjustOffTime:BOOL;				// @FIELD	LED has separate off time
+	      fMetaCycleOn:BOOL;				// @FIELD	LED can do blink n, pause, blink n, ...
+	      fMetaCycleOff:BOOL;				// @FIELD	LED can do blink n, pause n, blink n, ...
+     end;
+
+
+{		@DOC	EXTERNAL DRIVERS
+		@const	ULONG | NLED_SETTINGS_INFO_ID |
+
+Id for <f NLedDriverGetDeviceInfo> to get current settings of a
+notification LED.
+
+
+		@XREF
+
+			<tab><f NLedDriverGetDeviceInfo><nl>
+			<tab><t NLDI_SETTINGS_INFO><nl>
+}
+const
+      NLED_SETTINGS_INFO_ID	= 2;
+
+
+{      @DOC    EXTERNAL DRIVERS
+		@STRUCT	NLED_SETTINGS_NFO |
+
+Info about the current settings of a notification LED.
+
+		@XREF
+
+			<tab><f NLedDriverGetDeviceInfo><nl>
+			<tab><c NLED_SETTINGS_INFO_ID><nl>
+
+		@COMM
+
+Caller should first get the number of notification LED's on the system.
+This is usually one but may be 0 and could be greater than 1.  Caller
+should fill in the LedNum and then call <f NLedDriverGetDeviceInfo>.  Led
+numbering starts at 0.
+
+Note that the hardware may have some minimum on or off time, so setting the OnTime or OffTime
+fields to 0 may still result in a non-zero on or off time.
+}
+type
+     NLED_SETTINGS_INFO = record
+       LedNum:UINT;                 // @FIELD   LED number, 0 is first LED
+       OffOnBlink:longint;             // @FIELD   0 == off, 1 == on, 2 == blink
+       TotalCycleTime:LONG;         // @FIELD   total cycle time of a blink in microseconds
+       OnTime:LONG;                 // @FIELD   on time of a cycle in microseconds
+       OffTime:LONG;                // @FIELD   off time of a cycle in microseconds
+       MetaCycleOn:longint;            // @FIELD   number of on blink cycles
+       MetaCycleOff:longint;           // @FIELD   number of off blink cycles
+     end;
+
+
+// NLED driver IOCTL codes
+const
+      IOCTL_NLED_GETDEVICEINFO = (FILE_DEVICE_NLED shl 16) or
+                                 (FILE_ANY_ACCESS shl 14) or
+                                 ($0100 shl 2) or
+                                 METHOD_BUFFERED;
+
+      IOCTL_NLED_SETDEVICE =(FILE_DEVICE_NLED shl 16) or
+                            (FILE_ANY_ACCESS shl 14) or
+                            ($0101 shl 2) or
+                            METHOD_BUFFERED;
+
+// Battery driver interface GUID (used with AdvertiseInterface())
+const
+      NLED_DRIVER_CLASS        = '{CBB4F234-F35F-485b-A490-ADC7804A4EF3}';
+
+// API event name for the NLED interface.  If calling OpenEvent() on this name returns a valid
+// handle, the NLED APIs exist on the platform.  The handle will be signaled when the APIs become
+// ready.
+const
+      NLED_API_EVENT_NAME     = 'SYSTEM/NLedAPIsReady';
+
+type
+     PFN_NLED_SET_DEVICE = function(nDeviceId:UINT; pInput:pointer):BOOL; cdecl;
+     PFN_NLED_GET_DEVICE_INFO = function(nInfoId:UINT; pOutput:pointer):BOOL; cdecl;
+
+function NLedGetDeviceInfo(nInfoId:UINT; pOutput:pointer):BOOL; external KernelDLL name 'NLedGetDeviceInfo'; // index 49F
+function NLedSetDevice(nDeviceId:UINT; pInput:pointer):BOOL;  external KernelDLL name 'NLedSetDevice'; // index 4A0
+
+// @CESYSGEN ENDIF COREDLL_NLED
+
+implementation
+
+end.

+ 325 - 0
packages/winceunits/src/phone.pp

@@ -0,0 +1,325 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2008 Free Pascal development team.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ ********************************************************************** }
+//
+// phone.h
+//
+// Phone API
+//
+
+//
+//  Microsoft Windows Mobile 6.0 for PocketPC SDK.
+//
+
+unit phone;
+
+{$CALLING cdecl}
+
+interface
+
+uses Windows;
+
+type
+     CALLERIDTYPE = (CALLERIDTYPE_UNAVAILABLE,
+                     CALLERIDTYPE_BLOCKED,
+                     CALLERIDTYPE_AVAILABLE);
+
+type
+     IOM = (IOM_MISSED,
+            IOM_INCOMING,
+            IOM_OUTGOING);
+
+type
+     CALLLOGSEEK = (CALLLOGSEEK_BEGINNING := 2,
+                    CALLLOGSEEK_END := 4);
+
+// Thought out by me specially for CALLLOGENTRY._flags field.
+const
+      CALLLOGENTRY_FLAG_INCOMING  = 0; // direction of call.  (Missed calls are incoming.)
+      CALLLOGENTRY_FLAG_OUTGOING  = 1; // direction of call.  (Missed calls are incoming.)
+      CALLLOGENTRY_FLAG_CONNECTED = 2; // Did the call connect? (as opposed to busy, no answer)
+      CALLLOGENTRY_FLAG_ENDED     = 4; // Was the call ended? (as opposed to dropped)
+      CALLLOGENTRY_FLAG_DROPPED   = 0; // Was the call dropped? (as opposed to ended)
+      CALLLOGENTRY_FLAG_ROAMING   = 8; // Roaming (vs. local)
+      CALLLOGENTRY_FLAG_LOCAL     = 0; // Local
+
+type
+     CALLLOGENTRY = record
+       cbSize:DWORD;  // sizeof CALLLOGENTRY
+       ftStartTime:FILETIME;
+       ftEndTime:FILETIME;
+       _iom:IOM;
+       _flags:UINT;
+{
+       BOOL fOutgoing:1;        // direction of call.  (Missed calls are incoming.)
+       BOOL fConnected:1;     // Did the call connect? (as opposed to busy, no answer)
+       BOOL fEnded:1;        // Was the call ended? (as opposed to dropped)
+       BOOL fRoam:1;        // Roaming (vs. local)
+}
+       cidt:CALLERIDTYPE;
+       pszNumber:PTSTR;
+       pszName:PTSTR;
+       pszNameType:PTSTR;    // "w" for work tel, "h" for home tel, for example
+       pszNote:PTSTR;    // filename of associated Notes file
+     end;
+     PCALLLOGENTRY = ^CALLLOGENTRY;
+
+const
+      PhoneDLL = 'phone.dll';
+
+// Open the call log and set the seek pointer to the beginning.
+function PhoneOpenCallLog(ph:LPHANDLE):HRESULT; external PhoneDLL name 'PhoneOpenCallLog';
+
+// PhoneGetCallLogEntry returns one call log entry and advances the seek
+// pointer.
+// pentry->cbSize must be set to "sizeof CALLLOGENTRY" before this function is
+// called.
+// The entries are returned in order of start time, the most recent call first.
+// It is the responsibility of the caller to LocalFree any strings
+// which are returned.
+// A return value of S_FALSE indicates there are no more entries.
+function PhoneGetCallLogEntry(h:HANDLE; pentry:PCALLLOGENTRY):HRESULT; external PhoneDLL name 'PhoneGetCallLogEntry';
+
+// PhoneSeekCallLog seeks to a record in the call log.
+// iRecord is the zero-based index of the  record, starting at the beginning
+// if seek == CALLLOGSEEK_BEGINNING, at the end if CALLLOGSEEK_END.
+// piRecord returns the zero-based index (from the beginning) of the seek
+// pointer after the seek is performed.
+// PhoneSeekCallLog(h, CALLLOGSEEK_END, 0, &count) will return the number of
+// records.
+function PhoneSeekCallLog(hdb:HANDLE;
+                          _seek:CALLLOGSEEK;
+                          iRecord:DWORD;
+                          piRecord:LPDWORD):HRESULT; external PhoneDLL name 'PhoneGetCallLogEntry';
+
+// Close the call log
+function PhoneCloseCallLog(h:HANDLE):HRESULT; external PhoneDLL name 'PhoneCloseCallLog';
+
+
+// The Call Log application supports the context menu extensibility mechanism.
+// The Context name is "Phone" and the Class name is "Log".
+// The IUnknown pointer passed to the context menu handler supports IPropertyBag,
+// and the set of properties supported is as follows:
+//
+// property name:   type:   value:
+// --------------   -----   ------
+// PropSet          BSTR    "CallLog"
+// Number           BSTR    the phone number of the other person on the call
+// NumberType       BSTR    the type of phone number (e.g. "h" for home)
+// Name             BSTR    person's name
+// Year             I2      the year of the beginning time of the call
+// Month            I2      the month of the beginning time of the call
+// Day              I2      the day of the beginning time of the call
+// Hour             I2      the hour of the beginning time of the call
+// Minute           I2      the minute of the beginning time of the call
+// Second           I2      the second of the beginning time of the call
+// DayOfWeek        I2      the day of the week of the beginning time of the call
+// Duration         UI4     the duration of the call in seconds
+// CallerIDType     UI4     a CALLERIDTYPE value (see above)
+// Connected        BOOL    Did the call connect? (as opposed to busy, no answer)
+// Ended            BOOL    Was the call ended? (as opposed to dropped)
+// Outgoing         BOOL    Was the call outgoing?  (Missed calls are incoming.)
+// Roaming          BOOL    Roaming?
+// IOM              UI4     an IOM value (see above)
+
+
+// PhoneShowCallLog
+//
+// Show the Call Log, and filter it
+type
+     CALLLOGFILTER = (CALLLOGFILTER_ALL_CALLS,
+                      CALLLOGFILTER_MISSED,
+                      CALLLOGFILTER_INCOMING,
+                      CALLLOGFILTER_OUTGOING);
+
+function PhoneShowCallLog(iCallLogFilter:CALLLOGFILTER):HRESULT; external PhoneDLL name 'PhoneShowCallLog';
+
+//++++++
+//
+//  PhoneMakeCall
+//
+//       Dials a number
+type
+     tagPHONEMAKECALLINFO = record
+       cbSize:DWORD;
+       dwFlags:DWORD;
+
+      //Params to tapiRequestMakeCall
+       pszDestAddress:PCWSTR;
+       pszAppName:PCWSTR;
+       pszCalledParty:PCWSTR;
+       pszComment:PCWSTR;
+
+      // owner window for dialog box that appears when the PMCF_EDITBEFORECALLING flag is passed into PhoneMakeCall
+       hwndOwner:HWND;
+     end;
+     PHONEMAKECALLINFO = tagPHONEMAKECALLINFO;
+     PPHONEMAKECALLINFO = ^tagPHONEMAKECALLINFO;
+
+// PhoneMakeCall flags
+const
+      PMCF_DEFAULT                = $00000001;
+      PMCF_PROMPTBEFORECALLING    = $00000002;
+      PMCF_EDITBEFORECALLING      = $00000020;
+
+function PhoneMakeCall(ppmci:PPHONEMAKECALLINFO):LONG; external PhoneDLL name 'PhoneMakeCall';
+
+//
+// End PhoneMakeCall
+//
+//------
+
+
+//++++++
+//
+//  PhoneAddSpeedDial
+//
+//       adds a speed dial entry
+//
+// dwFlags - currently unused, set to 0
+//
+// piKey - in/out: the key sequence which will invoke the speed dial.
+//           currently an entry between 2 and 99 (inclusive) is valid.
+//            the API will cause existing entries to be overwritten
+//
+// pszDisplayName - the non-empty display name for the speed dial
+//
+// pszTelNumber - the non-empty tel# to be dialed
+//
+
+function PhoneAddSpeedDial(dwFlags:DWORD;
+                           piKey:LPDWORD;
+                           pszDisplayName:PTCHAR;
+                           pszTelNumber:PTCHAR):HRESULT; external PhoneDLL name 'PhoneAddSpeedDial';
+                           
+//
+// End PhoneAddSpeedDial
+//
+//------
+
+
+
+
+//++++++
+//
+//  PhoneSendDTMFStart
+//
+//  Allows an application to begin sending a DTMF tone using the
+//  current phone call.
+//
+//  Parameters:
+//    chDTMF - DTMF character to send. Must be '0'-'9', 
+//             'A'-'D', '*', or '#'.
+//
+//  Return Value:
+//    -----------------------------------------------------------
+//    Value                        Description
+//    ------------------------------------------------------------
+//    S_OK                         The operation completed successfully.
+//    E_FAIL                       An unknown error occurred.
+//    E_INVALIDARG                 chDTMF is invalid.
+//    E_NOTIMPL                    No phone is present on the device, the 
+//                                 phone service is not running, or no 
+//                                 calls are currently active.
+//    
+//    Other custom failure codes where the facility code is
+//    FACILITY_WINDOWS_CE may be retrieved using the HRESULT_CODE
+//    macro:
+//    -----------------------------------------------------------
+//    Error Code                   Description
+//    ------------------------------------------------------------
+//    ERROR_DEVICE_NOT_CONNECTED   No phone is present on the device, 
+//                                 the phone service is not running, or 
+//                                 no calls are currently active.
+//
+//  Remarks:
+//    Caller must call PhoneSendDTMFStop to stop the DTMF tone.
+//
+//    This function will fail if no phone is present on the 
+//    device, the phone service is not running, or no calls are  
+//    currently active. If a subsequent call to this API is made 
+//    by the caller or any other application before the DTMF tone  
+//    is finished the original DTMF tone will cease and the new 
+//    DTMF will be sent.
+//
+
+function PhoneSendDTMFStart(chDTMF:TCHAR):HRESULT; external PhoneDLL name 'PhoneSendDTMFStart';
+
+//
+// End PhoneSendDTMFStart
+//
+//------
+
+
+
+//++++++
+//
+//  PhoneSendDTMFStop
+//
+//  Stops an existing DTMF tone.
+//
+//  Remarks:
+//    This function stops all DTMF tones. Applications
+//    may use PhoneSendDTMFStart to begin a DTMF tone.
+//
+
+procedure PhoneSendDTMFStop; external PhoneDLL name 'PhoneSendDTMFStop';
+
+//
+// End PhoneSendDTMFStop
+//
+//------
+
+
+//++++++
+//
+//  PhoneIsEmergencyNumber
+//
+//  Determines if a string contains an emergency phone number.
+//
+//  Parameters:
+//    fTailMatchOnly
+//        [in] If this argument is set to TRUE, the function only 
+//        attempts to match emergency numbers at the end of 
+//        pszNumber. If this value is FALSE, the function attempts 
+//        to match the emergency string with the full pszNumber 
+///       argument exactly.
+//    pszNumber
+//        [in] String to match. If this pointer is NULL or points 
+//        to an empty string, the function returns FALSE.
+//    ppszEmergencyNumber
+//        [out] On success, constant pointer to the emergency phone 
+//        number matched in pszNumber. Caller must not free. On 
+//        failure, this pointer is undefined. Optional, may be NULL.
+//
+//  Return Value:
+//    TRUE if pszNumber contains an emergency number; otherwise FALSE.
+//
+//  Remarks:
+//    The system merges the list of emergency phone numbers from 
+//    the registry and the SIM, if available. The list of emergency 
+//    numbers can vary by device.
+//
+
+function PhoneIsEmergencyNumber(fTailMatchOnly:BOOL;
+                                pszNumber:LPCTSTR;
+                                ppszEmergencyNumber:PLPWStr):BOOL;external PhoneDLL name 'PhoneIsEmergencyNumber';
+
+//
+// End PhoneIsEmergencyNumber
+//
+//------
+
+
+implementation
+
+end.