summaryrefslogtreecommitdiff
path: root/firmware/ada/src
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2022-07-27 11:56:29 +0200
committerMarc Poulhiès <dkm@kataplop.net>2022-08-28 08:20:53 +0200
commit4d0aa92f5533e74af2e5a4395e8c466cf0b0e5a3 (patch)
tree4969a2c74dd0bc1d639844ee339b9fc57b1e3a9b /firmware/ada/src
parent93e1c4676c9d5b58012e39e9891a6f01dbf30a95 (diff)
ada: modifiers, layers and regular keys are working
Still need to add timings as currently the processor is looping full speed, which may cause some lost events as the USB only polls at the frequency advertised in the descriptor (few ms).
Diffstat (limited to 'firmware/ada/src')
-rw-r--r--firmware/ada/src/pouetpouet.adb43
1 files changed, 26 insertions, 17 deletions
diff --git a/firmware/ada/src/pouetpouet.adb b/firmware/ada/src/pouetpouet.adb
index 78f04ed..babe362 100644
--- a/firmware/ada/src/pouetpouet.adb
+++ b/firmware/ada/src/pouetpouet.adb
@@ -4,9 +4,6 @@ with STM32.GPIO; use STM32.GPIO;
-- Not yet used.
-- with STM32.Timers; use STM32.Timers;
--- with USB.HAL.Device;
--- with USB.Device.Serial;
-
with USB; use USB;
with USB.Device.HID.Keyboard;
with USB.Device; use USB.Device;
@@ -31,7 +28,7 @@ procedure Pouetpouet is
:= [PA0, PA1, PB13, PB12, PB14, PB15, PA15, PB3, PB4, PB5, PB8, PB9];
package TestClick is new Click (5 ,ColR, RowR, GPIO_Point,
- Ct, Rt, Cols, Rows, 2);
+ Ct, Rt, Cols, Rows, 2, Logging.Log);
use TestClick;
Bepo_Layout : constant Layout :=
@@ -60,8 +57,18 @@ procedure Pouetpouet is
use type USB.Device.Init_Result;
USB_Status : USB.Device.Init_Result;
+ procedure Dump_Events (Es : Events) is
+ begin
+ for E of Es loop
+ Log (" - "
+ & (if E.Evt = Press then "P " else "R ")
+ & E.Row'Image & ":" & E.Col'Image);
+ end loop;
+ end Dump_Events;
+
begin
- Init;
+
+ Testclick.Init;
if not USB_Stack.Register_Class (HID_Class'Unchecked_Access) then
raise Fatal_Error with "Failed to register USB Serial device class";
@@ -88,7 +95,7 @@ begin
-- Enable_Interrupt (Timer_1, Timer_Update_Interrupt);
-- Enable (Timer_1);
- Log ("STARTING");
+ Log ("STARTING FW");
for Row of Keys.Rows loop
Enable_Clock (Row);
@@ -112,26 +119,28 @@ begin
USB_Stack.Poll;
declare
- Evts : constant Events := Get_Events (Get_Matrix);
+ Evts : constant Events := Get_Events;
begin
-- FIXME: dot notation possible in GCC12
- Register_Events (Bepo_Layout, Evts);
+ if Evts'Length > 0 then
+ Dump_Events(Evts);
+ Register_Events (Bepo_Layout, Evts);
+ end if;
+
Tick (Bepo_Layout);
- for KC of Key_Codes (Bepo_Layout) loop
- -- Log ("(" & Evt.Evt'Image & ", " & Evt.Col'Image & ", "
- -- & Evt.Row'Image & ") = "
- -- & Key_Code_T'Enum_Rep (Bepo_Layout (Evt.Row, Evt.Col).C)'Image);
+ for KC of Get_Key_Codes loop
+ Log ("Got 1 keycode to push : " & Key_Code_T'Enum_Rep (KC)'Image);
if HID_Class.Ready then
- -- if Evt.Evt = Press then
- -- HID_Class.Push_Key_Code
- -- (Key_Code_T'Enum_Rep (Bepo_Layout (Evt.Row, Evt.Col).C));
HID_Class.Push_Key_Code (Key_Code_T'Enum_Rep (KC));
-
- -- end if;
end if;
end loop;
+
+ for M of Get_Modifiers loop
+ HID_Class.Set_Modifier (M, True);
+ end loop;
+
HID_Class.Send_Report (UDC);
end;
-- Delay_Cycles (72);