touchArea.pp 759 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. program touchArea;
  2. uses
  3. nds9;
  4. const
  5. //my experimental value for pen vs finger (higher value == lower area)
  6. threshold = 400;
  7. var
  8. touch: touchPosition;
  9. area: integer = 0;
  10. begin
  11. consoleDemoInit();
  12. while true do
  13. begin
  14. scanKeys();
  15. touchRead(touch);
  16. area := (touch.px * touch.z2) div (touch.z1 - touch.px);
  17. iprintf(#27'[10;0H' + 'Touch x = %04i, %04i'#10, touch.rawx, touch.px);
  18. iprintf('Touch y = %04i, %04i'#10, touch.rawy, touch.py);
  19. iprintf('Touch Area (pressure) %04i'#10, area);
  20. if (keysHeld() and KEY_TOUCH) <> 0 then
  21. if area > threshold then
  22. iprintf('Last touched by: pen')
  23. else
  24. iprintf('Last touched by: finger');
  25. swiWaitForVBlank();
  26. end;
  27. end.