summaryrefslogtreecommitdiff
path: root/fpcsrc/packages/libndsfpc/examples/input/Touch_Pad/touch_area/touchArea.pp
blob: bd3ee0ce2cb7ebb19cfb0b4a394b3b37edcf9999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
program touchArea;

uses
  nds9;

const
	//my experimental value for pen vs finger (higher value == lower area)
  threshold = 400;

var
	touch: touchPosition;
	area: integer = 0;

begin
	consoleDemoInit(); 

  while true do
  begin
    scanKeys();
    
    touchRead(touch);
    
    area := (touch.px * touch.z2) div (touch.z1 - touch.px);
    
    iprintf(#27'[10;0H' + 'Touch x = %04i, %04i'#10, touch.rawx, touch.px);
    
    iprintf('Touch y = %04i, %04i'#10, touch.rawy, touch.py);
    
    iprintf('Touch Area (pressure) %04i'#10, area);
    
    if (keysHeld() and KEY_TOUCH) <> 0 then
      if area > threshold then
        iprintf('Last touched by: pen')
      else
        iprintf('Last touched by: finger');

    swiWaitForVBlank();
  end;

end.